vant.js 494 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360
  1. (function(global, factory) {
  2. typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.vant = {}, global.Vue));
  3. })(this, function(exports2, vue) {
  4. "use strict";
  5. const isDef = (val) => val !== void 0 && val !== null;
  6. const isFunction = (val) => typeof val === "function";
  7. const isObject = (val) => val !== null && typeof val === "object";
  8. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  9. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  10. function isMobile(value) {
  11. value = value.replace(/[^-|\d]/g, "");
  12. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  13. }
  14. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  15. const isIOS$1 = () => inBrowser$1 ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  16. function noop() {
  17. }
  18. const extend = Object.assign;
  19. const inBrowser$1 = typeof window !== "undefined";
  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((ret, key) => {
  31. if (!ignoreUndefined || obj[key] !== void 0) {
  32. ret[key] = obj[key];
  33. }
  34. return ret;
  35. }, {});
  36. }
  37. const toArray = (item) => Array.isArray(item) ? item : [item];
  38. const unknownProp = null;
  39. const numericProp = [Number, String];
  40. const truthProp = {
  41. type: Boolean,
  42. default: true
  43. };
  44. const makeRequiredProp = (type) => ({
  45. type,
  46. required: true
  47. });
  48. const makeArrayProp = () => ({
  49. type: Array,
  50. default: () => []
  51. });
  52. const makeNumberProp = (defaultVal) => ({
  53. type: Number,
  54. default: defaultVal
  55. });
  56. const makeNumericProp = (defaultVal) => ({
  57. type: numericProp,
  58. default: defaultVal
  59. });
  60. const makeStringProp = (defaultVal) => ({
  61. type: String,
  62. default: defaultVal
  63. });
  64. var inBrowser = typeof window !== "undefined";
  65. function raf(fn) {
  66. return inBrowser ? requestAnimationFrame(fn) : -1;
  67. }
  68. function cancelRaf(id) {
  69. if (inBrowser) {
  70. cancelAnimationFrame(id);
  71. }
  72. }
  73. function doubleRaf(fn) {
  74. raf(() => raf(fn));
  75. }
  76. var isWindow = (val) => val === window;
  77. var makeDOMRect = (width2, height2) => ({
  78. top: 0,
  79. left: 0,
  80. right: width2,
  81. bottom: height2,
  82. width: width2,
  83. height: height2
  84. });
  85. var useRect = (elementOrRef) => {
  86. const element = vue.unref(elementOrRef);
  87. if (isWindow(element)) {
  88. const width2 = element.innerWidth;
  89. const height2 = element.innerHeight;
  90. return makeDOMRect(width2, height2);
  91. }
  92. if (element == null ? void 0 : element.getBoundingClientRect) {
  93. return element.getBoundingClientRect();
  94. }
  95. return makeDOMRect(0, 0);
  96. };
  97. function useToggle(defaultValue = false) {
  98. const state = vue.ref(defaultValue);
  99. const toggle = (value = !state.value) => {
  100. state.value = value;
  101. };
  102. return [state, toggle];
  103. }
  104. function useParent(key) {
  105. const parent = vue.inject(key, null);
  106. if (parent) {
  107. const instance2 = vue.getCurrentInstance();
  108. const { link, unlink, internalChildren } = parent;
  109. link(instance2);
  110. vue.onUnmounted(() => unlink(instance2));
  111. const index = vue.computed(() => internalChildren.indexOf(instance2));
  112. return {
  113. parent,
  114. index
  115. };
  116. }
  117. return {
  118. parent: null,
  119. index: vue.ref(-1)
  120. };
  121. }
  122. function flattenVNodes(children) {
  123. const result = [];
  124. const traverse = (children2) => {
  125. if (Array.isArray(children2)) {
  126. children2.forEach((child) => {
  127. var _a;
  128. if (vue.isVNode(child)) {
  129. result.push(child);
  130. if ((_a = child.component) == null ? void 0 : _a.subTree) {
  131. result.push(child.component.subTree);
  132. traverse(child.component.subTree.children);
  133. }
  134. if (child.children) {
  135. traverse(child.children);
  136. }
  137. }
  138. });
  139. }
  140. };
  141. traverse(children);
  142. return result;
  143. }
  144. function sortChildren(parent, publicChildren, internalChildren) {
  145. const vnodes = flattenVNodes(parent.subTree.children);
  146. internalChildren.sort(
  147. (a, b) => vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode)
  148. );
  149. const orderedPublicChildren = internalChildren.map((item) => item.proxy);
  150. publicChildren.sort((a, b) => {
  151. const indexA = orderedPublicChildren.indexOf(a);
  152. const indexB = orderedPublicChildren.indexOf(b);
  153. return indexA - indexB;
  154. });
  155. }
  156. function useChildren(key) {
  157. const publicChildren = vue.reactive([]);
  158. const internalChildren = vue.reactive([]);
  159. const parent = vue.getCurrentInstance();
  160. const linkChildren = (value) => {
  161. const link = (child) => {
  162. if (child.proxy) {
  163. internalChildren.push(child);
  164. publicChildren.push(child.proxy);
  165. sortChildren(parent, publicChildren, internalChildren);
  166. }
  167. };
  168. const unlink = (child) => {
  169. const index = internalChildren.indexOf(child);
  170. publicChildren.splice(index, 1);
  171. internalChildren.splice(index, 1);
  172. };
  173. vue.provide(
  174. key,
  175. Object.assign(
  176. {
  177. link,
  178. unlink,
  179. children: publicChildren,
  180. internalChildren
  181. },
  182. value
  183. )
  184. );
  185. };
  186. return {
  187. children: publicChildren,
  188. linkChildren
  189. };
  190. }
  191. var SECOND = 1e3;
  192. var MINUTE = 60 * SECOND;
  193. var HOUR = 60 * MINUTE;
  194. var DAY = 24 * HOUR;
  195. function parseTime(time) {
  196. const days = Math.floor(time / DAY);
  197. const hours = Math.floor(time % DAY / HOUR);
  198. const minutes = Math.floor(time % HOUR / MINUTE);
  199. const seconds = Math.floor(time % MINUTE / SECOND);
  200. const milliseconds = Math.floor(time % SECOND);
  201. return {
  202. total: time,
  203. days,
  204. hours,
  205. minutes,
  206. seconds,
  207. milliseconds
  208. };
  209. }
  210. function isSameSecond(time1, time2) {
  211. return Math.floor(time1 / 1e3) === Math.floor(time2 / 1e3);
  212. }
  213. function useCountDown(options) {
  214. let rafId;
  215. let endTime;
  216. let counting;
  217. let deactivated;
  218. const remain = vue.ref(options.time);
  219. const current2 = vue.computed(() => parseTime(remain.value));
  220. const pause = () => {
  221. counting = false;
  222. cancelRaf(rafId);
  223. };
  224. const getCurrentRemain = () => Math.max(endTime - Date.now(), 0);
  225. const setRemain = (value) => {
  226. var _a, _b;
  227. remain.value = value;
  228. (_a = options.onChange) == null ? void 0 : _a.call(options, current2.value);
  229. if (value === 0) {
  230. pause();
  231. (_b = options.onFinish) == null ? void 0 : _b.call(options);
  232. }
  233. };
  234. const microTick = () => {
  235. rafId = raf(() => {
  236. if (counting) {
  237. setRemain(getCurrentRemain());
  238. if (remain.value > 0) {
  239. microTick();
  240. }
  241. }
  242. });
  243. };
  244. const macroTick = () => {
  245. rafId = raf(() => {
  246. if (counting) {
  247. const remainRemain = getCurrentRemain();
  248. if (!isSameSecond(remainRemain, remain.value) || remainRemain === 0) {
  249. setRemain(remainRemain);
  250. }
  251. if (remain.value > 0) {
  252. macroTick();
  253. }
  254. }
  255. });
  256. };
  257. const tick = () => {
  258. if (!inBrowser) {
  259. return;
  260. }
  261. if (options.millisecond) {
  262. microTick();
  263. } else {
  264. macroTick();
  265. }
  266. };
  267. const start2 = () => {
  268. if (!counting) {
  269. endTime = Date.now() + remain.value;
  270. counting = true;
  271. tick();
  272. }
  273. };
  274. const reset = (totalTime = options.time) => {
  275. pause();
  276. remain.value = totalTime;
  277. };
  278. vue.onBeforeUnmount(pause);
  279. vue.onActivated(() => {
  280. if (deactivated) {
  281. counting = true;
  282. deactivated = false;
  283. tick();
  284. }
  285. });
  286. vue.onDeactivated(() => {
  287. if (counting) {
  288. pause();
  289. deactivated = true;
  290. }
  291. });
  292. return {
  293. start: start2,
  294. pause,
  295. reset,
  296. current: current2
  297. };
  298. }
  299. function onMountedOrActivated(hook) {
  300. let mounted;
  301. vue.onMounted(() => {
  302. hook();
  303. vue.nextTick(() => {
  304. mounted = true;
  305. });
  306. });
  307. vue.onActivated(() => {
  308. if (mounted) {
  309. hook();
  310. }
  311. });
  312. }
  313. function useEventListener(type, listener, options = {}) {
  314. if (!inBrowser) {
  315. return;
  316. }
  317. const { target = window, passive: passive2 = false, capture = false } = options;
  318. let attached;
  319. const add = (target2) => {
  320. const element = vue.unref(target2);
  321. if (element && !attached) {
  322. element.addEventListener(type, listener, {
  323. capture,
  324. passive: passive2
  325. });
  326. attached = true;
  327. }
  328. };
  329. const remove2 = (target2) => {
  330. const element = vue.unref(target2);
  331. if (element && attached) {
  332. element.removeEventListener(type, listener, capture);
  333. attached = false;
  334. }
  335. };
  336. vue.onUnmounted(() => remove2(target));
  337. vue.onDeactivated(() => remove2(target));
  338. onMountedOrActivated(() => add(target));
  339. if (vue.isRef(target)) {
  340. vue.watch(target, (val, oldVal) => {
  341. remove2(oldVal);
  342. add(val);
  343. });
  344. }
  345. }
  346. function useClickAway(target, listener, options = {}) {
  347. if (!inBrowser) {
  348. return;
  349. }
  350. const { eventName = "click" } = options;
  351. const onClick = (event) => {
  352. const targets = Array.isArray(target) ? target : [target];
  353. const isClickAway = targets.every((item) => {
  354. const element = vue.unref(item);
  355. return element && !element.contains(event.target);
  356. });
  357. if (isClickAway) {
  358. listener(event);
  359. }
  360. };
  361. useEventListener(eventName, onClick, { target: document });
  362. }
  363. var width;
  364. var height;
  365. function useWindowSize() {
  366. if (!width) {
  367. width = vue.ref(0);
  368. height = vue.ref(0);
  369. if (inBrowser) {
  370. const update = () => {
  371. width.value = window.innerWidth;
  372. height.value = window.innerHeight;
  373. };
  374. update();
  375. window.addEventListener("resize", update, { passive: true });
  376. window.addEventListener("orientationchange", update, { passive: true });
  377. }
  378. }
  379. return { width, height };
  380. }
  381. var overflowScrollReg = /scroll|auto|overlay/i;
  382. var defaultRoot = inBrowser ? window : void 0;
  383. function isElement$1(node) {
  384. const ELEMENT_NODE_TYPE = 1;
  385. return node.tagName !== "HTML" && node.tagName !== "BODY" && node.nodeType === ELEMENT_NODE_TYPE;
  386. }
  387. function getScrollParent$1(el, root = defaultRoot) {
  388. let node = el;
  389. while (node && node !== root && isElement$1(node)) {
  390. const { overflowY } = window.getComputedStyle(node);
  391. if (overflowScrollReg.test(overflowY)) {
  392. return node;
  393. }
  394. node = node.parentNode;
  395. }
  396. return root;
  397. }
  398. function useScrollParent(el, root = defaultRoot) {
  399. const scrollParent = vue.ref();
  400. vue.onMounted(() => {
  401. if (el.value) {
  402. scrollParent.value = getScrollParent$1(el.value, root);
  403. }
  404. });
  405. return scrollParent;
  406. }
  407. var visibility;
  408. function usePageVisibility() {
  409. if (!visibility) {
  410. visibility = vue.ref("visible");
  411. if (inBrowser) {
  412. const update = () => {
  413. visibility.value = document.hidden ? "hidden" : "visible";
  414. };
  415. update();
  416. window.addEventListener("visibilitychange", update);
  417. }
  418. }
  419. return visibility;
  420. }
  421. var CUSTOM_FIELD_INJECTION_KEY = Symbol("van-field");
  422. function useCustomFieldValue(customValue) {
  423. const field = vue.inject(CUSTOM_FIELD_INJECTION_KEY, null);
  424. if (field && !field.customValue.value) {
  425. field.customValue.value = customValue;
  426. vue.watch(customValue, () => {
  427. field.resetValidation();
  428. field.validateWithTrigger("onChange");
  429. });
  430. }
  431. }
  432. function getScrollTop(el) {
  433. const top2 = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  434. return Math.max(top2, 0);
  435. }
  436. function setScrollTop(el, value) {
  437. if ("scrollTop" in el) {
  438. el.scrollTop = value;
  439. } else {
  440. el.scrollTo(el.scrollX, value);
  441. }
  442. }
  443. function getRootScrollTop() {
  444. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  445. }
  446. function setRootScrollTop(value) {
  447. setScrollTop(window, value);
  448. setScrollTop(document.body, value);
  449. }
  450. function getElementTop(el, scroller) {
  451. if (el === window) {
  452. return 0;
  453. }
  454. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  455. return useRect(el).top + scrollTop;
  456. }
  457. const isIOS = isIOS$1();
  458. function resetScroll() {
  459. if (isIOS) {
  460. setRootScrollTop(getRootScrollTop());
  461. }
  462. }
  463. const stopPropagation = (event) => event.stopPropagation();
  464. function preventDefault(event, isStopPropagation) {
  465. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  466. event.preventDefault();
  467. }
  468. if (isStopPropagation) {
  469. stopPropagation(event);
  470. }
  471. }
  472. function isHidden(elementRef) {
  473. const el = vue.unref(elementRef);
  474. if (!el) {
  475. return false;
  476. }
  477. const style = window.getComputedStyle(el);
  478. const hidden = style.display === "none";
  479. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  480. return hidden || parentHidden;
  481. }
  482. const { width: windowWidth, height: windowHeight } = useWindowSize();
  483. function addUnit(value) {
  484. if (isDef(value)) {
  485. return isNumeric(value) ? `${value}px` : String(value);
  486. }
  487. return void 0;
  488. }
  489. function getSizeStyle(originSize) {
  490. if (isDef(originSize)) {
  491. if (Array.isArray(originSize)) {
  492. return {
  493. width: addUnit(originSize[0]),
  494. height: addUnit(originSize[1])
  495. };
  496. }
  497. const size = addUnit(originSize);
  498. return {
  499. width: size,
  500. height: size
  501. };
  502. }
  503. }
  504. function getZIndexStyle(zIndex) {
  505. const style = {};
  506. if (zIndex !== void 0) {
  507. style.zIndex = +zIndex;
  508. }
  509. return style;
  510. }
  511. let rootFontSize;
  512. function getRootFontSize() {
  513. if (!rootFontSize) {
  514. const doc = document.documentElement;
  515. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  516. rootFontSize = parseFloat(fontSize);
  517. }
  518. return rootFontSize;
  519. }
  520. function convertRem(value) {
  521. value = value.replace(/rem/g, "");
  522. return +value * getRootFontSize();
  523. }
  524. function convertVw(value) {
  525. value = value.replace(/vw/g, "");
  526. return +value * windowWidth.value / 100;
  527. }
  528. function convertVh(value) {
  529. value = value.replace(/vh/g, "");
  530. return +value * windowHeight.value / 100;
  531. }
  532. function unitToPx(value) {
  533. if (typeof value === "number") {
  534. return value;
  535. }
  536. if (inBrowser$1) {
  537. if (value.includes("rem")) {
  538. return convertRem(value);
  539. }
  540. if (value.includes("vw")) {
  541. return convertVw(value);
  542. }
  543. if (value.includes("vh")) {
  544. return convertVh(value);
  545. }
  546. }
  547. return parseFloat(value);
  548. }
  549. const camelizeRE = /-(\w)/g;
  550. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  551. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  552. function padZero(num, targetLength = 2) {
  553. let str = num + "";
  554. while (str.length < targetLength) {
  555. str = "0" + str;
  556. }
  557. return str;
  558. }
  559. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  560. function trimExtraChar(value, char, regExp) {
  561. const index = value.indexOf(char);
  562. if (index === -1) {
  563. return value;
  564. }
  565. if (char === "-" && index !== 0) {
  566. return value.slice(0, index);
  567. }
  568. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  569. }
  570. function formatNumber(value, allowDot = true, allowMinus = true) {
  571. if (allowDot) {
  572. value = trimExtraChar(value, ".", /\./g);
  573. } else {
  574. value = value.split(".")[0];
  575. }
  576. if (allowMinus) {
  577. value = trimExtraChar(value, "-", /-/g);
  578. } else {
  579. value = value.replace(/-/, "");
  580. }
  581. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  582. return value.replace(regExp, "");
  583. }
  584. function addNumber(num1, num2) {
  585. const cardinal = 10 ** 10;
  586. return Math.round((num1 + num2) * cardinal) / cardinal;
  587. }
  588. const { hasOwnProperty } = Object.prototype;
  589. function assignKey(to, from, key) {
  590. const val = from[key];
  591. if (!isDef(val)) {
  592. return;
  593. }
  594. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  595. to[key] = val;
  596. } else {
  597. to[key] = deepAssign(Object(to[key]), val);
  598. }
  599. }
  600. function deepAssign(to, from) {
  601. Object.keys(from).forEach((key) => {
  602. assignKey(to, from, key);
  603. });
  604. return to;
  605. }
  606. var stdin_default$1E = {
  607. name: "\u59D3\u540D",
  608. tel: "\u7535\u8BDD",
  609. save: "\u4FDD\u5B58",
  610. confirm: "\u786E\u8BA4",
  611. cancel: "\u53D6\u6D88",
  612. delete: "\u5220\u9664",
  613. loading: "\u52A0\u8F7D\u4E2D...",
  614. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  615. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  616. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  617. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  618. vanCalendar: {
  619. end: "\u7ED3\u675F",
  620. start: "\u5F00\u59CB",
  621. title: "\u65E5\u671F\u9009\u62E9",
  622. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  623. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  624. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  625. },
  626. vanCascader: {
  627. select: "\u8BF7\u9009\u62E9"
  628. },
  629. vanPagination: {
  630. prev: "\u4E0A\u4E00\u9875",
  631. next: "\u4E0B\u4E00\u9875"
  632. },
  633. vanPullRefresh: {
  634. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  635. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  636. },
  637. vanSubmitBar: {
  638. label: "\u5408\u8BA1:"
  639. },
  640. vanCoupon: {
  641. unlimited: "\u65E0\u95E8\u69DB",
  642. discount: (discount) => `${discount}\u6298`,
  643. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  644. },
  645. vanCouponCell: {
  646. title: "\u4F18\u60E0\u5238",
  647. count: (count) => `${count}\u5F20\u53EF\u7528`
  648. },
  649. vanCouponList: {
  650. exchange: "\u5151\u6362",
  651. close: "\u4E0D\u4F7F\u7528",
  652. enable: "\u53EF\u7528",
  653. disabled: "\u4E0D\u53EF\u7528",
  654. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  655. },
  656. vanAddressEdit: {
  657. area: "\u5730\u533A",
  658. postal: "\u90AE\u653F\u7F16\u7801",
  659. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  660. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  661. postalEmpty: "\u90AE\u653F\u7F16\u7801\u4E0D\u6B63\u786E",
  662. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  663. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  664. },
  665. vanAddressList: {
  666. add: "\u65B0\u589E\u5730\u5740"
  667. }
  668. };
  669. const lang = vue.ref("zh-CN");
  670. const messages = vue.reactive({
  671. "zh-CN": stdin_default$1E
  672. });
  673. const Locale = {
  674. messages() {
  675. return messages[lang.value];
  676. },
  677. use(newLang, newMessages) {
  678. lang.value = newLang;
  679. this.add({ [newLang]: newMessages });
  680. },
  681. add(newMessages = {}) {
  682. deepAssign(messages, newMessages);
  683. }
  684. };
  685. var stdin_default$1D = Locale;
  686. function createTranslate(name2) {
  687. const prefix = camelize(name2) + ".";
  688. return (path, ...args) => {
  689. const messages2 = stdin_default$1D.messages();
  690. const message = get(messages2, prefix + path) || get(messages2, path);
  691. return isFunction(message) ? message(...args) : message;
  692. };
  693. }
  694. function genBem(name2, mods) {
  695. if (!mods) {
  696. return "";
  697. }
  698. if (typeof mods === "string") {
  699. return ` ${name2}--${mods}`;
  700. }
  701. if (Array.isArray(mods)) {
  702. return mods.reduce(
  703. (ret, item) => ret + genBem(name2, item),
  704. ""
  705. );
  706. }
  707. return Object.keys(mods).reduce(
  708. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  709. ""
  710. );
  711. }
  712. function createBEM(name2) {
  713. return (el, mods) => {
  714. if (el && typeof el !== "string") {
  715. mods = el;
  716. el = "";
  717. }
  718. el = el ? `${name2}__${el}` : name2;
  719. return `${el}${genBem(el, mods)}`;
  720. };
  721. }
  722. function createNamespace(name2) {
  723. const prefixedName = `van-${name2}`;
  724. return [
  725. prefixedName,
  726. createBEM(prefixedName),
  727. createTranslate(prefixedName)
  728. ];
  729. }
  730. const BORDER = "van-hairline";
  731. const BORDER_TOP = `${BORDER}--top`;
  732. const BORDER_LEFT = `${BORDER}--left`;
  733. const BORDER_BOTTOM = `${BORDER}--bottom`;
  734. const BORDER_SURROUND = `${BORDER}--surround`;
  735. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  736. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  737. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  738. const FORM_KEY = Symbol("van-form");
  739. function callInterceptor(interceptor, {
  740. args = [],
  741. done,
  742. canceled
  743. }) {
  744. if (interceptor) {
  745. const returnVal = interceptor.apply(null, args);
  746. if (isPromise(returnVal)) {
  747. returnVal.then((value) => {
  748. if (value) {
  749. done();
  750. } else if (canceled) {
  751. canceled();
  752. }
  753. }).catch(noop);
  754. } else if (returnVal) {
  755. done();
  756. } else if (canceled) {
  757. canceled();
  758. }
  759. } else {
  760. done();
  761. }
  762. }
  763. function withInstall(options) {
  764. options.install = (app) => {
  765. const { name: name2 } = options;
  766. if (name2) {
  767. app.component(name2, options);
  768. app.component(camelize(`-${name2}`), options);
  769. }
  770. };
  771. return options;
  772. }
  773. const POPUP_TOGGLE_KEY = Symbol();
  774. function onPopupReopen(callback) {
  775. const popupToggleStatus = vue.inject(POPUP_TOGGLE_KEY, null);
  776. if (popupToggleStatus) {
  777. vue.watch(popupToggleStatus, (show) => {
  778. if (show) {
  779. callback();
  780. }
  781. });
  782. }
  783. }
  784. const useHeight = (element, withSafeArea) => {
  785. const height2 = vue.ref();
  786. const setHeight = () => {
  787. height2.value = useRect(element).height;
  788. };
  789. vue.onMounted(() => {
  790. vue.nextTick(setHeight);
  791. if (withSafeArea) {
  792. for (let i = 1; i <= 3; i++) {
  793. setTimeout(setHeight, 100 * i);
  794. }
  795. }
  796. });
  797. onPopupReopen(() => vue.nextTick(setHeight));
  798. return height2;
  799. };
  800. function usePlaceholder(contentRef, bem2) {
  801. const height2 = useHeight(contentRef, true);
  802. return (renderContent) => vue.createVNode("div", {
  803. "class": bem2("placeholder"),
  804. "style": {
  805. height: height2.value ? `${height2.value}px` : void 0
  806. }
  807. }, [renderContent()]);
  808. }
  809. const [name$1v, bem$1r] = createNamespace("action-bar");
  810. const ACTION_BAR_KEY = Symbol(name$1v);
  811. const actionBarProps = {
  812. placeholder: Boolean,
  813. safeAreaInsetBottom: truthProp
  814. };
  815. var stdin_default$1C = vue.defineComponent({
  816. name: name$1v,
  817. props: actionBarProps,
  818. setup(props, {
  819. slots
  820. }) {
  821. const root = vue.ref();
  822. const renderPlaceholder = usePlaceholder(root, bem$1r);
  823. const {
  824. linkChildren
  825. } = useChildren(ACTION_BAR_KEY);
  826. linkChildren();
  827. const renderActionBar = () => {
  828. var _a;
  829. return vue.createVNode("div", {
  830. "ref": root,
  831. "class": [bem$1r(), {
  832. "van-safe-area-bottom": props.safeAreaInsetBottom
  833. }]
  834. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  835. };
  836. return () => {
  837. if (props.placeholder) {
  838. return renderPlaceholder(renderActionBar);
  839. }
  840. return renderActionBar();
  841. };
  842. }
  843. });
  844. const ActionBar = withInstall(stdin_default$1C);
  845. function useExpose(apis) {
  846. const instance2 = vue.getCurrentInstance();
  847. if (instance2) {
  848. extend(instance2.proxy, apis);
  849. }
  850. }
  851. const routeProps = {
  852. to: [String, Object],
  853. url: String,
  854. replace: Boolean
  855. };
  856. function route({
  857. to,
  858. url,
  859. replace,
  860. $router: router
  861. }) {
  862. if (to && router) {
  863. router[replace ? "replace" : "push"](to);
  864. } else if (url) {
  865. replace ? location.replace(url) : location.href = url;
  866. }
  867. }
  868. function useRoute() {
  869. const vm = vue.getCurrentInstance().proxy;
  870. return () => route(vm);
  871. }
  872. const [name$1u, bem$1q] = createNamespace("badge");
  873. const badgeProps = {
  874. dot: Boolean,
  875. max: numericProp,
  876. tag: makeStringProp("div"),
  877. color: String,
  878. offset: Array,
  879. content: numericProp,
  880. showZero: truthProp,
  881. position: makeStringProp("top-right")
  882. };
  883. var stdin_default$1B = vue.defineComponent({
  884. name: name$1u,
  885. props: badgeProps,
  886. setup(props, {
  887. slots
  888. }) {
  889. const hasContent = () => {
  890. if (slots.content) {
  891. return true;
  892. }
  893. const {
  894. content,
  895. showZero
  896. } = props;
  897. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  898. };
  899. const renderContent = () => {
  900. const {
  901. dot,
  902. max,
  903. content
  904. } = props;
  905. if (!dot && hasContent()) {
  906. if (slots.content) {
  907. return slots.content();
  908. }
  909. if (isDef(max) && isNumeric(content) && +content > max) {
  910. return `${max}+`;
  911. }
  912. return content;
  913. }
  914. };
  915. const style = vue.computed(() => {
  916. const style2 = {
  917. background: props.color
  918. };
  919. if (props.offset) {
  920. const [x, y] = props.offset;
  921. if (slots.default) {
  922. style2.top = addUnit(y);
  923. if (typeof x === "number") {
  924. style2.right = addUnit(-x);
  925. } else {
  926. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  927. }
  928. } else {
  929. style2.marginTop = addUnit(y);
  930. style2.marginLeft = addUnit(x);
  931. }
  932. }
  933. return style2;
  934. });
  935. const renderBadge = () => {
  936. if (hasContent() || props.dot) {
  937. return vue.createVNode("div", {
  938. "class": bem$1q([props.position, {
  939. dot: props.dot,
  940. fixed: !!slots.default
  941. }]),
  942. "style": style.value
  943. }, [renderContent()]);
  944. }
  945. };
  946. return () => {
  947. if (slots.default) {
  948. const {
  949. tag
  950. } = props;
  951. return vue.createVNode(tag, {
  952. "class": bem$1q("wrapper")
  953. }, {
  954. default: () => [slots.default(), renderBadge()]
  955. });
  956. }
  957. return renderBadge();
  958. };
  959. }
  960. });
  961. const Badge = withInstall(stdin_default$1B);
  962. let globalZIndex = 2e3;
  963. const useGlobalZIndex = () => ++globalZIndex;
  964. const setGlobalZIndex = (val) => {
  965. globalZIndex = val;
  966. };
  967. const [name$1t, bem$1p] = createNamespace("config-provider");
  968. const CONFIG_PROVIDER_KEY = Symbol(name$1t);
  969. const configProviderProps = {
  970. tag: makeStringProp("div"),
  971. zIndex: Number,
  972. themeVars: Object,
  973. iconPrefix: String
  974. };
  975. function mapThemeVarsToCSSVars(themeVars) {
  976. const cssVars = {};
  977. Object.keys(themeVars).forEach((key) => {
  978. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  979. });
  980. return cssVars;
  981. }
  982. var stdin_default$1A = vue.defineComponent({
  983. name: name$1t,
  984. props: configProviderProps,
  985. setup(props, {
  986. slots
  987. }) {
  988. const style = vue.computed(() => {
  989. if (props.themeVars) {
  990. return mapThemeVarsToCSSVars(props.themeVars);
  991. }
  992. });
  993. vue.provide(CONFIG_PROVIDER_KEY, props);
  994. vue.watchEffect(() => {
  995. if (props.zIndex !== void 0) {
  996. setGlobalZIndex(props.zIndex);
  997. }
  998. });
  999. return () => vue.createVNode(props.tag, {
  1000. "class": bem$1p(),
  1001. "style": style.value
  1002. }, {
  1003. default: () => {
  1004. var _a;
  1005. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  1006. }
  1007. });
  1008. }
  1009. });
  1010. const [name$1s, bem$1o] = createNamespace("icon");
  1011. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  1012. const iconProps = {
  1013. dot: Boolean,
  1014. tag: makeStringProp("i"),
  1015. name: String,
  1016. size: numericProp,
  1017. badge: numericProp,
  1018. color: String,
  1019. badgeProps: Object,
  1020. classPrefix: String
  1021. };
  1022. var stdin_default$1z = vue.defineComponent({
  1023. name: name$1s,
  1024. props: iconProps,
  1025. setup(props, {
  1026. slots
  1027. }) {
  1028. const config = vue.inject(CONFIG_PROVIDER_KEY, null);
  1029. const classPrefix = vue.computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1o());
  1030. return () => {
  1031. const {
  1032. tag,
  1033. dot,
  1034. name: name2,
  1035. size,
  1036. badge,
  1037. color
  1038. } = props;
  1039. const isImageIcon = isImage(name2);
  1040. return vue.createVNode(Badge, vue.mergeProps({
  1041. "dot": dot,
  1042. "tag": tag,
  1043. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  1044. "style": {
  1045. color,
  1046. fontSize: addUnit(size)
  1047. },
  1048. "content": badge
  1049. }, props.badgeProps), {
  1050. default: () => {
  1051. var _a;
  1052. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
  1053. "class": bem$1o("image"),
  1054. "src": name2
  1055. }, null)];
  1056. }
  1057. });
  1058. };
  1059. }
  1060. });
  1061. const Icon = withInstall(stdin_default$1z);
  1062. const [name$1r, bem$1n] = createNamespace("loading");
  1063. const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
  1064. "class": bem$1n("line", String(index + 1))
  1065. }, null));
  1066. const CircularIcon = vue.createVNode("svg", {
  1067. "class": bem$1n("circular"),
  1068. "viewBox": "25 25 50 50"
  1069. }, [vue.createVNode("circle", {
  1070. "cx": "50",
  1071. "cy": "50",
  1072. "r": "20",
  1073. "fill": "none"
  1074. }, null)]);
  1075. const loadingProps = {
  1076. size: numericProp,
  1077. type: makeStringProp("circular"),
  1078. color: String,
  1079. vertical: Boolean,
  1080. textSize: numericProp,
  1081. textColor: String
  1082. };
  1083. var stdin_default$1y = vue.defineComponent({
  1084. name: name$1r,
  1085. props: loadingProps,
  1086. setup(props, {
  1087. slots
  1088. }) {
  1089. const spinnerStyle = vue.computed(() => extend({
  1090. color: props.color
  1091. }, getSizeStyle(props.size)));
  1092. const renderText = () => {
  1093. var _a;
  1094. if (slots.default) {
  1095. return vue.createVNode("span", {
  1096. "class": bem$1n("text"),
  1097. "style": {
  1098. fontSize: addUnit(props.textSize),
  1099. color: (_a = props.textColor) != null ? _a : props.color
  1100. }
  1101. }, [slots.default()]);
  1102. }
  1103. };
  1104. return () => {
  1105. const {
  1106. type,
  1107. vertical
  1108. } = props;
  1109. return vue.createVNode("div", {
  1110. "class": bem$1n([type, {
  1111. vertical
  1112. }]),
  1113. "aria-live": "polite",
  1114. "aria-busy": true
  1115. }, [vue.createVNode("span", {
  1116. "class": bem$1n("spinner", type),
  1117. "style": spinnerStyle.value
  1118. }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
  1119. };
  1120. }
  1121. });
  1122. const Loading = withInstall(stdin_default$1y);
  1123. const [name$1q, bem$1m] = createNamespace("button");
  1124. const buttonProps = extend({}, routeProps, {
  1125. tag: makeStringProp("button"),
  1126. text: String,
  1127. icon: String,
  1128. type: makeStringProp("default"),
  1129. size: makeStringProp("normal"),
  1130. color: String,
  1131. block: Boolean,
  1132. plain: Boolean,
  1133. round: Boolean,
  1134. square: Boolean,
  1135. loading: Boolean,
  1136. hairline: Boolean,
  1137. disabled: Boolean,
  1138. iconPrefix: String,
  1139. nativeType: makeStringProp("button"),
  1140. loadingSize: numericProp,
  1141. loadingText: String,
  1142. loadingType: String,
  1143. iconPosition: makeStringProp("left")
  1144. });
  1145. var stdin_default$1x = vue.defineComponent({
  1146. name: name$1q,
  1147. props: buttonProps,
  1148. emits: ["click"],
  1149. setup(props, {
  1150. emit,
  1151. slots
  1152. }) {
  1153. const route2 = useRoute();
  1154. const renderLoadingIcon = () => {
  1155. if (slots.loading) {
  1156. return slots.loading();
  1157. }
  1158. return vue.createVNode(Loading, {
  1159. "size": props.loadingSize,
  1160. "type": props.loadingType,
  1161. "class": bem$1m("loading")
  1162. }, null);
  1163. };
  1164. const renderIcon = () => {
  1165. if (props.loading) {
  1166. return renderLoadingIcon();
  1167. }
  1168. if (slots.icon) {
  1169. return vue.createVNode("div", {
  1170. "class": bem$1m("icon")
  1171. }, [slots.icon()]);
  1172. }
  1173. if (props.icon) {
  1174. return vue.createVNode(Icon, {
  1175. "name": props.icon,
  1176. "class": bem$1m("icon"),
  1177. "classPrefix": props.iconPrefix
  1178. }, null);
  1179. }
  1180. };
  1181. const renderText = () => {
  1182. let text;
  1183. if (props.loading) {
  1184. text = props.loadingText;
  1185. } else {
  1186. text = slots.default ? slots.default() : props.text;
  1187. }
  1188. if (text) {
  1189. return vue.createVNode("span", {
  1190. "class": bem$1m("text")
  1191. }, [text]);
  1192. }
  1193. };
  1194. const getStyle = () => {
  1195. const {
  1196. color,
  1197. plain
  1198. } = props;
  1199. if (color) {
  1200. const style = {
  1201. color: plain ? color : "white"
  1202. };
  1203. if (!plain) {
  1204. style.background = color;
  1205. }
  1206. if (color.includes("gradient")) {
  1207. style.border = 0;
  1208. } else {
  1209. style.borderColor = color;
  1210. }
  1211. return style;
  1212. }
  1213. };
  1214. const onClick = (event) => {
  1215. if (props.loading) {
  1216. preventDefault(event);
  1217. } else if (!props.disabled) {
  1218. emit("click", event);
  1219. route2();
  1220. }
  1221. };
  1222. return () => {
  1223. const {
  1224. tag,
  1225. type,
  1226. size,
  1227. block,
  1228. round: round2,
  1229. plain,
  1230. square,
  1231. loading,
  1232. disabled,
  1233. hairline,
  1234. nativeType,
  1235. iconPosition
  1236. } = props;
  1237. const classes = [bem$1m([type, size, {
  1238. plain,
  1239. block,
  1240. round: round2,
  1241. square,
  1242. loading,
  1243. disabled,
  1244. hairline
  1245. }]), {
  1246. [BORDER_SURROUND]: hairline
  1247. }];
  1248. return vue.createVNode(tag, {
  1249. "type": nativeType,
  1250. "class": classes,
  1251. "style": getStyle(),
  1252. "disabled": disabled,
  1253. "onClick": onClick
  1254. }, {
  1255. default: () => [vue.createVNode("div", {
  1256. "class": bem$1m("content")
  1257. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  1258. });
  1259. };
  1260. }
  1261. });
  1262. const Button = withInstall(stdin_default$1x);
  1263. const [name$1p, bem$1l] = createNamespace("action-bar-button");
  1264. const actionBarButtonProps = extend({}, routeProps, {
  1265. type: String,
  1266. text: String,
  1267. icon: String,
  1268. color: String,
  1269. loading: Boolean,
  1270. disabled: Boolean
  1271. });
  1272. var stdin_default$1w = vue.defineComponent({
  1273. name: name$1p,
  1274. props: actionBarButtonProps,
  1275. setup(props, {
  1276. slots
  1277. }) {
  1278. const route2 = useRoute();
  1279. const {
  1280. parent,
  1281. index
  1282. } = useParent(ACTION_BAR_KEY);
  1283. const isFirst = vue.computed(() => {
  1284. if (parent) {
  1285. const prev = parent.children[index.value - 1];
  1286. return !(prev && "isButton" in prev);
  1287. }
  1288. });
  1289. const isLast = vue.computed(() => {
  1290. if (parent) {
  1291. const next = parent.children[index.value + 1];
  1292. return !(next && "isButton" in next);
  1293. }
  1294. });
  1295. useExpose({
  1296. isButton: true
  1297. });
  1298. return () => {
  1299. const {
  1300. type,
  1301. icon,
  1302. text,
  1303. color,
  1304. loading,
  1305. disabled
  1306. } = props;
  1307. return vue.createVNode(Button, {
  1308. "class": bem$1l([type, {
  1309. last: isLast.value,
  1310. first: isFirst.value
  1311. }]),
  1312. "size": "large",
  1313. "type": type,
  1314. "icon": icon,
  1315. "color": color,
  1316. "loading": loading,
  1317. "disabled": disabled,
  1318. "onClick": route2
  1319. }, {
  1320. default: () => [slots.default ? slots.default() : text]
  1321. });
  1322. };
  1323. }
  1324. });
  1325. const ActionBarButton = withInstall(stdin_default$1w);
  1326. const [name$1o, bem$1k] = createNamespace("action-bar-icon");
  1327. const actionBarIconProps = extend({}, routeProps, {
  1328. dot: Boolean,
  1329. text: String,
  1330. icon: String,
  1331. color: String,
  1332. badge: numericProp,
  1333. iconClass: unknownProp,
  1334. badgeProps: Object,
  1335. iconPrefix: String
  1336. });
  1337. var stdin_default$1v = vue.defineComponent({
  1338. name: name$1o,
  1339. props: actionBarIconProps,
  1340. setup(props, {
  1341. slots
  1342. }) {
  1343. const route2 = useRoute();
  1344. useParent(ACTION_BAR_KEY);
  1345. const renderIcon = () => {
  1346. const {
  1347. dot,
  1348. badge,
  1349. icon,
  1350. color,
  1351. iconClass,
  1352. badgeProps: badgeProps2,
  1353. iconPrefix
  1354. } = props;
  1355. if (slots.icon) {
  1356. return vue.createVNode(Badge, vue.mergeProps({
  1357. "dot": dot,
  1358. "class": bem$1k("icon"),
  1359. "content": badge
  1360. }, badgeProps2), {
  1361. default: slots.icon
  1362. });
  1363. }
  1364. return vue.createVNode(Icon, {
  1365. "tag": "div",
  1366. "dot": dot,
  1367. "name": icon,
  1368. "badge": badge,
  1369. "color": color,
  1370. "class": [bem$1k("icon"), iconClass],
  1371. "badgeProps": badgeProps2,
  1372. "classPrefix": iconPrefix
  1373. }, null);
  1374. };
  1375. return () => vue.createVNode("div", {
  1376. "role": "button",
  1377. "class": bem$1k(),
  1378. "tabindex": 0,
  1379. "onClick": route2
  1380. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1381. }
  1382. });
  1383. const ActionBarIcon = withInstall(stdin_default$1v);
  1384. const popupSharedProps = {
  1385. show: Boolean,
  1386. zIndex: numericProp,
  1387. overlay: truthProp,
  1388. duration: numericProp,
  1389. teleport: [String, Object],
  1390. lockScroll: truthProp,
  1391. lazyRender: truthProp,
  1392. beforeClose: Function,
  1393. overlayStyle: Object,
  1394. overlayClass: unknownProp,
  1395. transitionAppear: Boolean,
  1396. closeOnClickOverlay: truthProp
  1397. };
  1398. const popupSharedPropKeys = Object.keys(
  1399. popupSharedProps
  1400. );
  1401. function getDirection(x, y) {
  1402. if (x > y) {
  1403. return "horizontal";
  1404. }
  1405. if (y > x) {
  1406. return "vertical";
  1407. }
  1408. return "";
  1409. }
  1410. function useTouch() {
  1411. const startX = vue.ref(0);
  1412. const startY = vue.ref(0);
  1413. const deltaX = vue.ref(0);
  1414. const deltaY = vue.ref(0);
  1415. const offsetX = vue.ref(0);
  1416. const offsetY = vue.ref(0);
  1417. const direction = vue.ref("");
  1418. const isVertical = () => direction.value === "vertical";
  1419. const isHorizontal = () => direction.value === "horizontal";
  1420. const reset = () => {
  1421. deltaX.value = 0;
  1422. deltaY.value = 0;
  1423. offsetX.value = 0;
  1424. offsetY.value = 0;
  1425. direction.value = "";
  1426. };
  1427. const start2 = (event) => {
  1428. reset();
  1429. startX.value = event.touches[0].clientX;
  1430. startY.value = event.touches[0].clientY;
  1431. };
  1432. const move = (event) => {
  1433. const touch = event.touches[0];
  1434. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1435. deltaY.value = touch.clientY - startY.value;
  1436. offsetX.value = Math.abs(deltaX.value);
  1437. offsetY.value = Math.abs(deltaY.value);
  1438. const LOCK_DIRECTION_DISTANCE = 10;
  1439. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1440. direction.value = getDirection(offsetX.value, offsetY.value);
  1441. }
  1442. };
  1443. return {
  1444. move,
  1445. start: start2,
  1446. reset,
  1447. startX,
  1448. startY,
  1449. deltaX,
  1450. deltaY,
  1451. offsetX,
  1452. offsetY,
  1453. direction,
  1454. isVertical,
  1455. isHorizontal
  1456. };
  1457. }
  1458. let totalLockCount = 0;
  1459. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1460. function useLockScroll(rootRef, shouldLock) {
  1461. const touch = useTouch();
  1462. const DIRECTION_UP = "01";
  1463. const DIRECTION_DOWN = "10";
  1464. const onTouchMove = (event) => {
  1465. touch.move(event);
  1466. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1467. const el = getScrollParent$1(
  1468. event.target,
  1469. rootRef.value
  1470. );
  1471. const { scrollHeight, offsetHeight, scrollTop } = el;
  1472. let status = "11";
  1473. if (scrollTop === 0) {
  1474. status = offsetHeight >= scrollHeight ? "00" : "01";
  1475. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1476. status = "10";
  1477. }
  1478. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1479. preventDefault(event, true);
  1480. }
  1481. };
  1482. const lock = () => {
  1483. document.addEventListener("touchstart", touch.start);
  1484. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1485. if (!totalLockCount) {
  1486. document.body.classList.add(BODY_LOCK_CLASS);
  1487. }
  1488. totalLockCount++;
  1489. };
  1490. const unlock = () => {
  1491. if (totalLockCount) {
  1492. document.removeEventListener("touchstart", touch.start);
  1493. document.removeEventListener("touchmove", onTouchMove);
  1494. totalLockCount--;
  1495. if (!totalLockCount) {
  1496. document.body.classList.remove(BODY_LOCK_CLASS);
  1497. }
  1498. }
  1499. };
  1500. const init = () => shouldLock() && lock();
  1501. const destroy = () => shouldLock() && unlock();
  1502. onMountedOrActivated(init);
  1503. vue.onDeactivated(destroy);
  1504. vue.onBeforeUnmount(destroy);
  1505. vue.watch(shouldLock, (value) => {
  1506. value ? lock() : unlock();
  1507. });
  1508. }
  1509. function useLazyRender(show) {
  1510. const inited = vue.ref(false);
  1511. vue.watch(
  1512. show,
  1513. (value) => {
  1514. if (value) {
  1515. inited.value = value;
  1516. }
  1517. },
  1518. { immediate: true }
  1519. );
  1520. return (render) => () => inited.value ? render() : null;
  1521. }
  1522. const [name$1n, bem$1j] = createNamespace("overlay");
  1523. const overlayProps = {
  1524. show: Boolean,
  1525. zIndex: numericProp,
  1526. duration: numericProp,
  1527. className: unknownProp,
  1528. lockScroll: truthProp,
  1529. lazyRender: truthProp,
  1530. customStyle: Object
  1531. };
  1532. var stdin_default$1u = vue.defineComponent({
  1533. name: name$1n,
  1534. props: overlayProps,
  1535. setup(props, {
  1536. slots
  1537. }) {
  1538. const root = vue.ref();
  1539. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1540. const onTouchMove = (event) => {
  1541. if (props.lockScroll) {
  1542. preventDefault(event, true);
  1543. }
  1544. };
  1545. const renderOverlay = lazyRender(() => {
  1546. var _a;
  1547. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1548. if (isDef(props.duration)) {
  1549. style.animationDuration = `${props.duration}s`;
  1550. }
  1551. return vue.withDirectives(vue.createVNode("div", {
  1552. "ref": root,
  1553. "style": style,
  1554. "class": [bem$1j(), props.className]
  1555. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props.show]]);
  1556. });
  1557. useEventListener("touchmove", onTouchMove, {
  1558. target: root
  1559. });
  1560. return () => vue.createVNode(vue.Transition, {
  1561. "name": "van-fade",
  1562. "appear": true
  1563. }, {
  1564. default: renderOverlay
  1565. });
  1566. }
  1567. });
  1568. const Overlay = withInstall(stdin_default$1u);
  1569. const popupProps$2 = extend({}, popupSharedProps, {
  1570. round: Boolean,
  1571. position: makeStringProp("center"),
  1572. closeIcon: makeStringProp("cross"),
  1573. closeable: Boolean,
  1574. transition: String,
  1575. iconPrefix: String,
  1576. closeOnPopstate: Boolean,
  1577. closeIconPosition: makeStringProp("top-right"),
  1578. safeAreaInsetTop: Boolean,
  1579. safeAreaInsetBottom: Boolean
  1580. });
  1581. const [name$1m, bem$1i] = createNamespace("popup");
  1582. var stdin_default$1t = vue.defineComponent({
  1583. name: name$1m,
  1584. inheritAttrs: false,
  1585. props: popupProps$2,
  1586. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "click-overlay", "click-close-icon"],
  1587. setup(props, {
  1588. emit,
  1589. attrs,
  1590. slots
  1591. }) {
  1592. let opened;
  1593. let shouldReopen;
  1594. const zIndex = vue.ref();
  1595. const popupRef = vue.ref();
  1596. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1597. const style = vue.computed(() => {
  1598. const style2 = {
  1599. zIndex: zIndex.value
  1600. };
  1601. if (isDef(props.duration)) {
  1602. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1603. style2[key] = `${props.duration}s`;
  1604. }
  1605. return style2;
  1606. });
  1607. const open = () => {
  1608. if (!opened) {
  1609. opened = true;
  1610. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1611. emit("open");
  1612. }
  1613. };
  1614. const close = () => {
  1615. if (opened) {
  1616. callInterceptor(props.beforeClose, {
  1617. done() {
  1618. opened = false;
  1619. emit("close");
  1620. emit("update:show", false);
  1621. }
  1622. });
  1623. }
  1624. };
  1625. const onClickOverlay = (event) => {
  1626. emit("click-overlay", event);
  1627. if (props.closeOnClickOverlay) {
  1628. close();
  1629. }
  1630. };
  1631. const renderOverlay = () => {
  1632. if (props.overlay) {
  1633. return vue.createVNode(Overlay, {
  1634. "show": props.show,
  1635. "class": props.overlayClass,
  1636. "zIndex": zIndex.value,
  1637. "duration": props.duration,
  1638. "customStyle": props.overlayStyle,
  1639. "role": props.closeOnClickOverlay ? "button" : void 0,
  1640. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1641. "onClick": onClickOverlay
  1642. }, {
  1643. default: slots["overlay-content"]
  1644. });
  1645. }
  1646. };
  1647. const onClickCloseIcon = (event) => {
  1648. emit("click-close-icon", event);
  1649. close();
  1650. };
  1651. const renderCloseIcon = () => {
  1652. if (props.closeable) {
  1653. return vue.createVNode(Icon, {
  1654. "role": "button",
  1655. "tabindex": 0,
  1656. "name": props.closeIcon,
  1657. "class": [bem$1i("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1658. "classPrefix": props.iconPrefix,
  1659. "onClick": onClickCloseIcon
  1660. }, null);
  1661. }
  1662. };
  1663. const onOpened = () => emit("opened");
  1664. const onClosed = () => emit("closed");
  1665. const onKeydown = (event) => emit("keydown", event);
  1666. const renderPopup = lazyRender(() => {
  1667. var _a;
  1668. const {
  1669. round: round2,
  1670. position,
  1671. safeAreaInsetTop,
  1672. safeAreaInsetBottom
  1673. } = props;
  1674. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  1675. "ref": popupRef,
  1676. "style": style.value,
  1677. "role": "dialog",
  1678. "tabindex": 0,
  1679. "class": [bem$1i({
  1680. round: round2,
  1681. [position]: position
  1682. }), {
  1683. "van-safe-area-top": safeAreaInsetTop,
  1684. "van-safe-area-bottom": safeAreaInsetBottom
  1685. }],
  1686. "onKeydown": onKeydown
  1687. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props.show]]);
  1688. });
  1689. const renderTransition = () => {
  1690. const {
  1691. position,
  1692. transition,
  1693. transitionAppear
  1694. } = props;
  1695. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1696. return vue.createVNode(vue.Transition, {
  1697. "name": transition || name2,
  1698. "appear": transitionAppear,
  1699. "onAfterEnter": onOpened,
  1700. "onAfterLeave": onClosed
  1701. }, {
  1702. default: renderPopup
  1703. });
  1704. };
  1705. vue.watch(() => props.show, (show) => {
  1706. if (show && !opened) {
  1707. open();
  1708. if (attrs.tabindex === 0) {
  1709. vue.nextTick(() => {
  1710. var _a;
  1711. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1712. });
  1713. }
  1714. }
  1715. if (!show && opened) {
  1716. opened = false;
  1717. emit("close");
  1718. }
  1719. });
  1720. useExpose({
  1721. popupRef
  1722. });
  1723. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1724. useEventListener("popstate", () => {
  1725. if (props.closeOnPopstate) {
  1726. close();
  1727. shouldReopen = false;
  1728. }
  1729. });
  1730. vue.onMounted(() => {
  1731. if (props.show) {
  1732. open();
  1733. }
  1734. });
  1735. vue.onActivated(() => {
  1736. if (shouldReopen) {
  1737. emit("update:show", true);
  1738. shouldReopen = false;
  1739. }
  1740. });
  1741. vue.onDeactivated(() => {
  1742. if (props.show && props.teleport) {
  1743. close();
  1744. shouldReopen = true;
  1745. }
  1746. });
  1747. vue.provide(POPUP_TOGGLE_KEY, () => props.show);
  1748. return () => {
  1749. if (props.teleport) {
  1750. return vue.createVNode(vue.Teleport, {
  1751. "to": props.teleport
  1752. }, {
  1753. default: () => [renderOverlay(), renderTransition()]
  1754. });
  1755. }
  1756. return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
  1757. };
  1758. }
  1759. });
  1760. const Popup = withInstall(stdin_default$1t);
  1761. const [name$1l, bem$1h] = createNamespace("action-sheet");
  1762. const actionSheetProps = extend({}, popupSharedProps, {
  1763. title: String,
  1764. round: truthProp,
  1765. actions: makeArrayProp(),
  1766. closeIcon: makeStringProp("cross"),
  1767. closeable: truthProp,
  1768. cancelText: String,
  1769. description: String,
  1770. closeOnPopstate: truthProp,
  1771. closeOnClickAction: Boolean,
  1772. safeAreaInsetBottom: truthProp
  1773. });
  1774. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1775. var stdin_default$1s = vue.defineComponent({
  1776. name: name$1l,
  1777. props: actionSheetProps,
  1778. emits: ["select", "cancel", "update:show"],
  1779. setup(props, {
  1780. slots,
  1781. emit
  1782. }) {
  1783. const updateShow = (show) => emit("update:show", show);
  1784. const onCancel = () => {
  1785. updateShow(false);
  1786. emit("cancel");
  1787. };
  1788. const renderHeader = () => {
  1789. if (props.title) {
  1790. return vue.createVNode("div", {
  1791. "class": bem$1h("header")
  1792. }, [props.title, props.closeable && vue.createVNode(Icon, {
  1793. "name": props.closeIcon,
  1794. "class": [bem$1h("close"), HAPTICS_FEEDBACK],
  1795. "onClick": onCancel
  1796. }, null)]);
  1797. }
  1798. };
  1799. const renderCancel = () => {
  1800. if (slots.cancel || props.cancelText) {
  1801. return [vue.createVNode("div", {
  1802. "class": bem$1h("gap")
  1803. }, null), vue.createVNode("button", {
  1804. "type": "button",
  1805. "class": bem$1h("cancel"),
  1806. "onClick": onCancel
  1807. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1808. }
  1809. };
  1810. const renderActionContent = (action, index) => {
  1811. if (action.loading) {
  1812. return vue.createVNode(Loading, {
  1813. "class": bem$1h("loading-icon")
  1814. }, null);
  1815. }
  1816. if (slots.action) {
  1817. return slots.action({
  1818. action,
  1819. index
  1820. });
  1821. }
  1822. return [vue.createVNode("span", {
  1823. "class": bem$1h("name")
  1824. }, [action.name]), action.subname && vue.createVNode("div", {
  1825. "class": bem$1h("subname")
  1826. }, [action.subname])];
  1827. };
  1828. const renderAction = (action, index) => {
  1829. const {
  1830. color,
  1831. loading,
  1832. callback,
  1833. disabled,
  1834. className
  1835. } = action;
  1836. const onClick = () => {
  1837. if (disabled || loading) {
  1838. return;
  1839. }
  1840. if (callback) {
  1841. callback(action);
  1842. }
  1843. if (props.closeOnClickAction) {
  1844. updateShow(false);
  1845. }
  1846. vue.nextTick(() => emit("select", action, index));
  1847. };
  1848. return vue.createVNode("button", {
  1849. "type": "button",
  1850. "style": {
  1851. color
  1852. },
  1853. "class": [bem$1h("item", {
  1854. loading,
  1855. disabled
  1856. }), className],
  1857. "onClick": onClick
  1858. }, [renderActionContent(action, index)]);
  1859. };
  1860. const renderDescription = () => {
  1861. if (props.description || slots.description) {
  1862. const content = slots.description ? slots.description() : props.description;
  1863. return vue.createVNode("div", {
  1864. "class": bem$1h("description")
  1865. }, [content]);
  1866. }
  1867. };
  1868. return () => vue.createVNode(Popup, vue.mergeProps({
  1869. "class": bem$1h(),
  1870. "position": "bottom",
  1871. "onUpdate:show": updateShow
  1872. }, pick(props, popupInheritKeys$2)), {
  1873. default: () => {
  1874. var _a;
  1875. return [renderHeader(), renderDescription(), vue.createVNode("div", {
  1876. "class": bem$1h("content")
  1877. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1878. }
  1879. });
  1880. }
  1881. });
  1882. const ActionSheet = withInstall(stdin_default$1s);
  1883. function deepClone(obj) {
  1884. if (!isDef(obj)) {
  1885. return obj;
  1886. }
  1887. if (Array.isArray(obj)) {
  1888. return obj.map((item) => deepClone(item));
  1889. }
  1890. if (isObject(obj)) {
  1891. const to = {};
  1892. Object.keys(obj).forEach((key) => {
  1893. to[key] = deepClone(obj[key]);
  1894. });
  1895. return to;
  1896. }
  1897. return obj;
  1898. }
  1899. const DEFAULT_DURATION = 200;
  1900. const MOMENTUM_LIMIT_TIME = 300;
  1901. const MOMENTUM_LIMIT_DISTANCE = 15;
  1902. const [name$1k, bem$1g] = createNamespace("picker-column");
  1903. function getElementTranslateY(element) {
  1904. const {
  1905. transform
  1906. } = window.getComputedStyle(element);
  1907. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1908. return Number(translateY);
  1909. }
  1910. const PICKER_KEY = Symbol(name$1k);
  1911. const isOptionDisabled = (option) => isObject(option) && option.disabled;
  1912. var stdin_default$1r = vue.defineComponent({
  1913. name: name$1k,
  1914. props: {
  1915. textKey: makeRequiredProp(String),
  1916. readonly: Boolean,
  1917. allowHtml: Boolean,
  1918. className: unknownProp,
  1919. itemHeight: makeRequiredProp(Number),
  1920. defaultIndex: makeNumberProp(0),
  1921. swipeDuration: makeRequiredProp(numericProp),
  1922. initialOptions: makeArrayProp(),
  1923. visibleItemCount: makeRequiredProp(numericProp)
  1924. },
  1925. emits: ["change"],
  1926. setup(props, {
  1927. emit,
  1928. slots
  1929. }) {
  1930. let moving;
  1931. let startOffset;
  1932. let touchStartTime;
  1933. let momentumOffset;
  1934. let transitionEndTrigger;
  1935. const root = vue.ref();
  1936. const wrapper = vue.ref();
  1937. const state = vue.reactive({
  1938. index: props.defaultIndex,
  1939. offset: 0,
  1940. duration: 0,
  1941. options: deepClone(props.initialOptions)
  1942. });
  1943. const touch = useTouch();
  1944. const count = () => state.options.length;
  1945. const baseOffset = () => props.itemHeight * (+props.visibleItemCount - 1) / 2;
  1946. const adjustIndex = (index) => {
  1947. index = clamp(index, 0, count());
  1948. for (let i = index; i < count(); i++) {
  1949. if (!isOptionDisabled(state.options[i]))
  1950. return i;
  1951. }
  1952. for (let i = index - 1; i >= 0; i--) {
  1953. if (!isOptionDisabled(state.options[i]))
  1954. return i;
  1955. }
  1956. };
  1957. const setIndex = (index, emitChange) => {
  1958. index = adjustIndex(index) || 0;
  1959. const offset2 = -index * props.itemHeight;
  1960. const trigger = () => {
  1961. if (index !== state.index) {
  1962. state.index = index;
  1963. if (emitChange) {
  1964. emit("change", index);
  1965. }
  1966. }
  1967. };
  1968. if (moving && offset2 !== state.offset) {
  1969. transitionEndTrigger = trigger;
  1970. } else {
  1971. trigger();
  1972. }
  1973. state.offset = offset2;
  1974. };
  1975. const setOptions = (options) => {
  1976. if (JSON.stringify(options) !== JSON.stringify(state.options)) {
  1977. state.options = deepClone(options);
  1978. setIndex(props.defaultIndex);
  1979. }
  1980. };
  1981. const onClickItem = (index) => {
  1982. if (moving || props.readonly) {
  1983. return;
  1984. }
  1985. transitionEndTrigger = null;
  1986. state.duration = DEFAULT_DURATION;
  1987. setIndex(index, true);
  1988. };
  1989. const getOptionText = (option) => {
  1990. if (isObject(option) && props.textKey in option) {
  1991. return option[props.textKey];
  1992. }
  1993. return option;
  1994. };
  1995. const getIndexByOffset = (offset2) => clamp(Math.round(-offset2 / props.itemHeight), 0, count() - 1);
  1996. const momentum = (distance, duration) => {
  1997. const speed = Math.abs(distance / duration);
  1998. distance = state.offset + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1999. const index = getIndexByOffset(distance);
  2000. state.duration = +props.swipeDuration;
  2001. setIndex(index, true);
  2002. };
  2003. const stopMomentum = () => {
  2004. moving = false;
  2005. state.duration = 0;
  2006. if (transitionEndTrigger) {
  2007. transitionEndTrigger();
  2008. transitionEndTrigger = null;
  2009. }
  2010. };
  2011. const onTouchStart = (event) => {
  2012. if (props.readonly) {
  2013. return;
  2014. }
  2015. touch.start(event);
  2016. if (moving) {
  2017. const translateY = getElementTranslateY(wrapper.value);
  2018. state.offset = Math.min(0, translateY - baseOffset());
  2019. startOffset = state.offset;
  2020. } else {
  2021. startOffset = state.offset;
  2022. }
  2023. state.duration = 0;
  2024. touchStartTime = Date.now();
  2025. momentumOffset = startOffset;
  2026. transitionEndTrigger = null;
  2027. };
  2028. const onTouchMove = (event) => {
  2029. if (props.readonly) {
  2030. return;
  2031. }
  2032. touch.move(event);
  2033. if (touch.isVertical()) {
  2034. moving = true;
  2035. preventDefault(event, true);
  2036. }
  2037. state.offset = clamp(startOffset + touch.deltaY.value, -(count() * props.itemHeight), props.itemHeight);
  2038. const now = Date.now();
  2039. if (now - touchStartTime > MOMENTUM_LIMIT_TIME) {
  2040. touchStartTime = now;
  2041. momentumOffset = state.offset;
  2042. }
  2043. };
  2044. const onTouchEnd = () => {
  2045. if (props.readonly) {
  2046. return;
  2047. }
  2048. const distance = state.offset - momentumOffset;
  2049. const duration = Date.now() - touchStartTime;
  2050. const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
  2051. if (allowMomentum) {
  2052. momentum(distance, duration);
  2053. return;
  2054. }
  2055. const index = getIndexByOffset(state.offset);
  2056. state.duration = DEFAULT_DURATION;
  2057. setIndex(index, true);
  2058. setTimeout(() => {
  2059. moving = false;
  2060. }, 0);
  2061. };
  2062. const renderOptions = () => {
  2063. const optionStyle = {
  2064. height: `${props.itemHeight}px`
  2065. };
  2066. return state.options.map((option, index) => {
  2067. const text = getOptionText(option);
  2068. const disabled = isOptionDisabled(option);
  2069. const data = {
  2070. role: "button",
  2071. style: optionStyle,
  2072. tabindex: disabled ? -1 : 0,
  2073. class: bem$1g("item", {
  2074. disabled,
  2075. selected: index === state.index
  2076. }),
  2077. onClick: () => onClickItem(index)
  2078. };
  2079. const childData = {
  2080. class: "van-ellipsis",
  2081. [props.allowHtml ? "innerHTML" : "textContent"]: text
  2082. };
  2083. return vue.createVNode("li", data, [slots.option ? slots.option(option) : vue.createVNode("div", childData, null)]);
  2084. });
  2085. };
  2086. const setValue = (value) => {
  2087. const {
  2088. options
  2089. } = state;
  2090. for (let i = 0; i < options.length; i++) {
  2091. if (getOptionText(options[i]) === value) {
  2092. return setIndex(i);
  2093. }
  2094. }
  2095. };
  2096. const getValue = () => state.options[state.index];
  2097. const hasOptions = () => state.options.length;
  2098. setIndex(state.index);
  2099. useParent(PICKER_KEY);
  2100. useExpose({
  2101. state,
  2102. setIndex,
  2103. getValue,
  2104. setValue,
  2105. setOptions,
  2106. hasOptions,
  2107. stopMomentum
  2108. });
  2109. vue.watch(() => props.initialOptions, setOptions);
  2110. vue.watch(() => props.defaultIndex, (value) => setIndex(value));
  2111. useEventListener("touchmove", onTouchMove, {
  2112. target: root
  2113. });
  2114. return () => vue.createVNode("div", {
  2115. "ref": root,
  2116. "class": [bem$1g(), props.className],
  2117. "onTouchstartPassive": onTouchStart,
  2118. "onTouchend": onTouchEnd,
  2119. "onTouchcancel": onTouchEnd
  2120. }, [vue.createVNode("ul", {
  2121. "ref": wrapper,
  2122. "style": {
  2123. transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
  2124. transitionDuration: `${state.duration}ms`,
  2125. transitionProperty: state.duration ? "all" : "none"
  2126. },
  2127. "class": bem$1g("wrapper"),
  2128. "onTransitionend": stopMomentum
  2129. }, [renderOptions()])]);
  2130. }
  2131. });
  2132. const [name$1j, bem$1f, t$j] = createNamespace("picker");
  2133. const pickerSharedProps = {
  2134. title: String,
  2135. loading: Boolean,
  2136. readonly: Boolean,
  2137. allowHtml: Boolean,
  2138. itemHeight: makeNumericProp(44),
  2139. showToolbar: truthProp,
  2140. swipeDuration: makeNumericProp(1e3),
  2141. visibleItemCount: makeNumericProp(6),
  2142. cancelButtonText: String,
  2143. confirmButtonText: String
  2144. };
  2145. const pickerProps = extend({}, pickerSharedProps, {
  2146. columns: makeArrayProp(),
  2147. valueKey: String,
  2148. defaultIndex: makeNumericProp(0),
  2149. toolbarPosition: makeStringProp("top"),
  2150. columnsFieldNames: Object
  2151. });
  2152. var stdin_default$1q = vue.defineComponent({
  2153. name: name$1j,
  2154. props: pickerProps,
  2155. emits: ["confirm", "cancel", "change"],
  2156. setup(props, {
  2157. emit,
  2158. slots
  2159. }) {
  2160. const hasOptions = vue.ref(false);
  2161. const columnsRef = vue.ref();
  2162. const formattedColumns = vue.ref([]);
  2163. const columnsFieldNames = vue.computed(() => {
  2164. const {
  2165. columnsFieldNames: columnsFieldNames2
  2166. } = props;
  2167. return {
  2168. text: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.text) || props.valueKey || "text",
  2169. values: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.values) || "values",
  2170. children: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.children) || "children"
  2171. };
  2172. });
  2173. const {
  2174. children,
  2175. linkChildren
  2176. } = useChildren(PICKER_KEY);
  2177. linkChildren();
  2178. const itemHeight = vue.computed(() => unitToPx(props.itemHeight));
  2179. const dataType = vue.computed(() => {
  2180. const firstColumn = props.columns[0];
  2181. if (typeof firstColumn === "object") {
  2182. if (columnsFieldNames.value.children in firstColumn) {
  2183. return "cascade";
  2184. }
  2185. if (columnsFieldNames.value.values in firstColumn) {
  2186. return "object";
  2187. }
  2188. }
  2189. return "plain";
  2190. });
  2191. const formatCascade = () => {
  2192. var _a;
  2193. const formatted = [];
  2194. let cursor = {
  2195. [columnsFieldNames.value.children]: props.columns
  2196. };
  2197. while (cursor && cursor[columnsFieldNames.value.children]) {
  2198. const children2 = cursor[columnsFieldNames.value.children];
  2199. let defaultIndex = (_a = cursor.defaultIndex) != null ? _a : +props.defaultIndex;
  2200. while (children2[defaultIndex] && children2[defaultIndex].disabled) {
  2201. if (defaultIndex < children2.length - 1) {
  2202. defaultIndex++;
  2203. } else {
  2204. defaultIndex = 0;
  2205. break;
  2206. }
  2207. }
  2208. formatted.push({
  2209. [columnsFieldNames.value.values]: cursor[columnsFieldNames.value.children],
  2210. className: cursor.className,
  2211. defaultIndex
  2212. });
  2213. cursor = children2[defaultIndex];
  2214. }
  2215. formattedColumns.value = formatted;
  2216. };
  2217. const format2 = () => {
  2218. const {
  2219. columns
  2220. } = props;
  2221. if (dataType.value === "plain") {
  2222. formattedColumns.value = [{
  2223. [columnsFieldNames.value.values]: columns
  2224. }];
  2225. } else if (dataType.value === "cascade") {
  2226. formatCascade();
  2227. } else {
  2228. formattedColumns.value = columns;
  2229. }
  2230. hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
  2231. };
  2232. const getIndexes = () => children.map((child) => child.state.index);
  2233. const setColumnValues = (index, options) => {
  2234. const column = children[index];
  2235. if (column) {
  2236. column.setOptions(options);
  2237. hasOptions.value = true;
  2238. }
  2239. };
  2240. const onCascadeChange = (columnIndex) => {
  2241. let cursor = {
  2242. [columnsFieldNames.value.children]: props.columns
  2243. };
  2244. const indexes = getIndexes();
  2245. for (let i = 0; i <= columnIndex; i++) {
  2246. cursor = cursor[columnsFieldNames.value.children][indexes[i]];
  2247. }
  2248. while (cursor && cursor[columnsFieldNames.value.children]) {
  2249. columnIndex++;
  2250. setColumnValues(columnIndex, cursor[columnsFieldNames.value.children]);
  2251. cursor = cursor[columnsFieldNames.value.children][cursor.defaultIndex || 0];
  2252. }
  2253. };
  2254. const getChild = (index) => children[index];
  2255. const getColumnValue = (index) => {
  2256. const column = getChild(index);
  2257. if (column) {
  2258. return column.getValue();
  2259. }
  2260. };
  2261. const setColumnValue = (index, value) => {
  2262. const column = getChild(index);
  2263. if (column) {
  2264. column.setValue(value);
  2265. if (dataType.value === "cascade") {
  2266. onCascadeChange(index);
  2267. }
  2268. }
  2269. };
  2270. const getColumnIndex = (index) => {
  2271. const column = getChild(index);
  2272. if (column) {
  2273. return column.state.index;
  2274. }
  2275. };
  2276. const setColumnIndex = (columnIndex, optionIndex) => {
  2277. const column = getChild(columnIndex);
  2278. if (column) {
  2279. column.setIndex(optionIndex);
  2280. if (dataType.value === "cascade") {
  2281. onCascadeChange(columnIndex);
  2282. }
  2283. }
  2284. };
  2285. const getColumnValues = (index) => {
  2286. const column = getChild(index);
  2287. if (column) {
  2288. return column.state.options;
  2289. }
  2290. };
  2291. const getValues = () => children.map((child) => child.getValue());
  2292. const setValues = (values) => {
  2293. values.forEach((value, index) => {
  2294. setColumnValue(index, value);
  2295. });
  2296. };
  2297. const setIndexes = (indexes) => {
  2298. indexes.forEach((optionIndex, columnIndex) => {
  2299. setColumnIndex(columnIndex, optionIndex);
  2300. });
  2301. };
  2302. const emitAction = (event) => {
  2303. if (dataType.value === "plain") {
  2304. emit(event, getColumnValue(0), getColumnIndex(0));
  2305. } else {
  2306. emit(event, getValues(), getIndexes());
  2307. }
  2308. };
  2309. const onChange = (columnIndex) => {
  2310. if (dataType.value === "cascade") {
  2311. onCascadeChange(columnIndex);
  2312. }
  2313. if (dataType.value === "plain") {
  2314. emit("change", getColumnValue(0), getColumnIndex(0));
  2315. } else {
  2316. emit("change", getValues(), columnIndex);
  2317. }
  2318. };
  2319. const confirm = () => {
  2320. children.forEach((child) => child.stopMomentum());
  2321. emitAction("confirm");
  2322. };
  2323. const cancel = () => emitAction("cancel");
  2324. const renderTitle = () => {
  2325. if (slots.title) {
  2326. return slots.title();
  2327. }
  2328. if (props.title) {
  2329. return vue.createVNode("div", {
  2330. "class": [bem$1f("title"), "van-ellipsis"]
  2331. }, [props.title]);
  2332. }
  2333. };
  2334. const renderCancel = () => {
  2335. const text = props.cancelButtonText || t$j("cancel");
  2336. return vue.createVNode("button", {
  2337. "type": "button",
  2338. "class": [bem$1f("cancel"), HAPTICS_FEEDBACK],
  2339. "onClick": cancel
  2340. }, [slots.cancel ? slots.cancel() : text]);
  2341. };
  2342. const renderConfirm = () => {
  2343. const text = props.confirmButtonText || t$j("confirm");
  2344. return vue.createVNode("button", {
  2345. "type": "button",
  2346. "class": [bem$1f("confirm"), HAPTICS_FEEDBACK],
  2347. "onClick": confirm
  2348. }, [slots.confirm ? slots.confirm() : text]);
  2349. };
  2350. const renderToolbar = () => {
  2351. if (props.showToolbar) {
  2352. const slot = slots.toolbar || slots.default;
  2353. return vue.createVNode("div", {
  2354. "class": bem$1f("toolbar")
  2355. }, [slot ? slot() : [renderCancel(), renderTitle(), renderConfirm()]]);
  2356. }
  2357. };
  2358. const renderColumnItems = () => formattedColumns.value.map((item, columnIndex) => {
  2359. var _a;
  2360. return vue.createVNode(stdin_default$1r, {
  2361. "textKey": columnsFieldNames.value.text,
  2362. "readonly": props.readonly,
  2363. "allowHtml": props.allowHtml,
  2364. "className": item.className,
  2365. "itemHeight": itemHeight.value,
  2366. "defaultIndex": (_a = item.defaultIndex) != null ? _a : +props.defaultIndex,
  2367. "swipeDuration": props.swipeDuration,
  2368. "initialOptions": item[columnsFieldNames.value.values],
  2369. "visibleItemCount": props.visibleItemCount,
  2370. "onChange": () => onChange(columnIndex)
  2371. }, {
  2372. option: slots.option
  2373. });
  2374. });
  2375. const renderMask = (wrapHeight) => {
  2376. if (hasOptions.value) {
  2377. const frameStyle = {
  2378. height: `${itemHeight.value}px`
  2379. };
  2380. const maskStyle = {
  2381. backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`
  2382. };
  2383. return [vue.createVNode("div", {
  2384. "class": bem$1f("mask"),
  2385. "style": maskStyle
  2386. }, null), vue.createVNode("div", {
  2387. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1f("frame")],
  2388. "style": frameStyle
  2389. }, null)];
  2390. }
  2391. };
  2392. const renderColumns = () => {
  2393. const wrapHeight = itemHeight.value * +props.visibleItemCount;
  2394. const columnsStyle = {
  2395. height: `${wrapHeight}px`
  2396. };
  2397. return vue.createVNode("div", {
  2398. "ref": columnsRef,
  2399. "class": bem$1f("columns"),
  2400. "style": columnsStyle
  2401. }, [renderColumnItems(), renderMask(wrapHeight)]);
  2402. };
  2403. vue.watch(() => props.columns, format2, {
  2404. immediate: true
  2405. });
  2406. useEventListener("touchmove", preventDefault, {
  2407. target: columnsRef
  2408. });
  2409. useExpose({
  2410. confirm,
  2411. getValues,
  2412. setValues,
  2413. getIndexes,
  2414. setIndexes,
  2415. getColumnIndex,
  2416. setColumnIndex,
  2417. getColumnValue,
  2418. setColumnValue,
  2419. getColumnValues,
  2420. setColumnValues
  2421. });
  2422. return () => {
  2423. var _a, _b;
  2424. return vue.createVNode("div", {
  2425. "class": bem$1f()
  2426. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? vue.createVNode(Loading, {
  2427. "class": bem$1f("loading")
  2428. }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props.toolbarPosition === "bottom" ? renderToolbar() : null]);
  2429. };
  2430. }
  2431. });
  2432. const Picker = withInstall(stdin_default$1q);
  2433. const [name$1i, bem$1e] = createNamespace("area");
  2434. const EMPTY_CODE = "000000";
  2435. const INHERIT_SLOTS = ["title", "cancel", "confirm", "toolbar", "columns-top", "columns-bottom"];
  2436. const INHERIT_PROPS = ["title", "loading", "readonly", "itemHeight", "swipeDuration", "visibleItemCount", "cancelButtonText", "confirmButtonText"];
  2437. const isOverseaCode = (code) => code[0] === "9";
  2438. const areaProps = extend({}, pickerSharedProps, {
  2439. value: String,
  2440. columnsNum: makeNumericProp(3),
  2441. columnsPlaceholder: makeArrayProp(),
  2442. areaList: {
  2443. type: Object,
  2444. default: () => ({})
  2445. },
  2446. isOverseaCode: {
  2447. type: Function,
  2448. default: isOverseaCode
  2449. }
  2450. });
  2451. var stdin_default$1p = vue.defineComponent({
  2452. name: name$1i,
  2453. props: areaProps,
  2454. emits: ["change", "confirm", "cancel"],
  2455. setup(props, {
  2456. emit,
  2457. slots
  2458. }) {
  2459. const pickerRef = vue.ref();
  2460. const state = vue.reactive({
  2461. code: props.value,
  2462. columns: [{
  2463. values: []
  2464. }, {
  2465. values: []
  2466. }, {
  2467. values: []
  2468. }]
  2469. });
  2470. const areaList = vue.computed(() => {
  2471. const {
  2472. areaList: areaList2
  2473. } = props;
  2474. return {
  2475. province: areaList2.province_list || {},
  2476. city: areaList2.city_list || {},
  2477. county: areaList2.county_list || {}
  2478. };
  2479. });
  2480. const placeholderMap = vue.computed(() => {
  2481. const {
  2482. columnsPlaceholder
  2483. } = props;
  2484. return {
  2485. province: columnsPlaceholder[0] || "",
  2486. city: columnsPlaceholder[1] || "",
  2487. county: columnsPlaceholder[2] || ""
  2488. };
  2489. });
  2490. const getDefaultCode = () => {
  2491. if (props.columnsPlaceholder.length) {
  2492. return EMPTY_CODE;
  2493. }
  2494. const {
  2495. county,
  2496. city
  2497. } = areaList.value;
  2498. const countyCodes = Object.keys(county);
  2499. if (countyCodes[0]) {
  2500. return countyCodes[0];
  2501. }
  2502. const cityCodes = Object.keys(city);
  2503. if (cityCodes[0]) {
  2504. return cityCodes[0];
  2505. }
  2506. return "";
  2507. };
  2508. const getColumnValues = (type, code) => {
  2509. let column = [];
  2510. if (type !== "province" && !code) {
  2511. return column;
  2512. }
  2513. const list = areaList.value[type];
  2514. column = Object.keys(list).map((listCode) => ({
  2515. code: listCode,
  2516. name: list[listCode]
  2517. }));
  2518. if (code) {
  2519. if (type === "city" && props.isOverseaCode(code)) {
  2520. code = "9";
  2521. }
  2522. column = column.filter((item) => item.code.indexOf(code) === 0);
  2523. }
  2524. if (placeholderMap.value[type] && column.length) {
  2525. let codeFill = "";
  2526. if (type === "city") {
  2527. codeFill = EMPTY_CODE.slice(2, 4);
  2528. } else if (type === "county") {
  2529. codeFill = EMPTY_CODE.slice(4, 6);
  2530. }
  2531. column.unshift({
  2532. code: code + codeFill,
  2533. name: placeholderMap.value[type]
  2534. });
  2535. }
  2536. return column;
  2537. };
  2538. const getIndex = (type, code) => {
  2539. let compareNum = code.length;
  2540. if (type === "province") {
  2541. compareNum = props.isOverseaCode(code) ? 1 : 2;
  2542. }
  2543. if (type === "city") {
  2544. compareNum = 4;
  2545. }
  2546. code = code.slice(0, compareNum);
  2547. const list = getColumnValues(type, compareNum > 2 ? code.slice(0, compareNum - 2) : "");
  2548. for (let i = 0; i < list.length; i++) {
  2549. if (list[i].code.slice(0, compareNum) === code) {
  2550. return i;
  2551. }
  2552. }
  2553. return 0;
  2554. };
  2555. const setValues = () => {
  2556. const picker = pickerRef.value;
  2557. if (!picker) {
  2558. return;
  2559. }
  2560. let code = state.code || getDefaultCode();
  2561. const province = getColumnValues("province");
  2562. const city = getColumnValues("city", code.slice(0, 2));
  2563. picker.setColumnValues(0, province);
  2564. picker.setColumnValues(1, city);
  2565. if (city.length && code.slice(2, 4) === "00" && !props.isOverseaCode(code)) {
  2566. [{
  2567. code
  2568. }] = city;
  2569. }
  2570. picker.setColumnValues(2, getColumnValues("county", code.slice(0, 4)));
  2571. picker.setIndexes([getIndex("province", code), getIndex("city", code), getIndex("county", code)]);
  2572. };
  2573. const parseValues = (values) => values.map((value, index) => {
  2574. if (value) {
  2575. value = deepClone(value);
  2576. if (!value.code || value.name === props.columnsPlaceholder[index]) {
  2577. value.code = "";
  2578. value.name = "";
  2579. }
  2580. }
  2581. return value;
  2582. });
  2583. const getValues = () => {
  2584. if (pickerRef.value) {
  2585. const values = pickerRef.value.getValues().filter(Boolean);
  2586. return parseValues(values);
  2587. }
  2588. return [];
  2589. };
  2590. const getArea = () => {
  2591. const values = getValues();
  2592. const area = {
  2593. code: "",
  2594. country: "",
  2595. province: "",
  2596. city: "",
  2597. county: ""
  2598. };
  2599. if (!values.length) {
  2600. return area;
  2601. }
  2602. const names = values.map((item) => item.name);
  2603. const validValues = values.filter((value) => value.code);
  2604. area.code = validValues.length ? validValues[validValues.length - 1].code : "";
  2605. if (props.isOverseaCode(area.code)) {
  2606. area.country = names[1] || "";
  2607. area.province = names[2] || "";
  2608. } else {
  2609. area.province = names[0] || "";
  2610. area.city = names[1] || "";
  2611. area.county = names[2] || "";
  2612. }
  2613. return area;
  2614. };
  2615. const reset = (newCode = "") => {
  2616. state.code = newCode;
  2617. setValues();
  2618. };
  2619. const onChange = (values, index) => {
  2620. state.code = values[index].code;
  2621. setValues();
  2622. if (pickerRef.value) {
  2623. const parsedValues = parseValues(pickerRef.value.getValues());
  2624. emit("change", parsedValues, index);
  2625. }
  2626. };
  2627. const onConfirm = (values, index) => {
  2628. setValues();
  2629. emit("confirm", parseValues(values), index);
  2630. };
  2631. const onCancel = (...args) => emit("cancel", ...args);
  2632. vue.onMounted(setValues);
  2633. vue.watch(() => props.value, (value) => {
  2634. state.code = value;
  2635. setValues();
  2636. });
  2637. vue.watch(() => props.areaList, setValues, {
  2638. deep: true
  2639. });
  2640. vue.watch(() => props.columnsNum, () => {
  2641. vue.nextTick(setValues);
  2642. });
  2643. useExpose({
  2644. reset,
  2645. getArea,
  2646. getValues
  2647. });
  2648. return () => {
  2649. const columns = state.columns.slice(0, +props.columnsNum);
  2650. return vue.createVNode(Picker, vue.mergeProps({
  2651. "ref": pickerRef,
  2652. "class": bem$1e(),
  2653. "columns": columns,
  2654. "columnsFieldNames": {
  2655. text: "name"
  2656. },
  2657. "onChange": onChange,
  2658. "onCancel": onCancel,
  2659. "onConfirm": onConfirm
  2660. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  2661. };
  2662. }
  2663. });
  2664. const Area = withInstall(stdin_default$1p);
  2665. const [name$1h, bem$1d] = createNamespace("cell");
  2666. const cellSharedProps = {
  2667. icon: String,
  2668. size: String,
  2669. title: numericProp,
  2670. value: numericProp,
  2671. label: numericProp,
  2672. center: Boolean,
  2673. isLink: Boolean,
  2674. border: truthProp,
  2675. required: Boolean,
  2676. iconPrefix: String,
  2677. valueClass: unknownProp,
  2678. labelClass: unknownProp,
  2679. titleClass: unknownProp,
  2680. titleStyle: null,
  2681. arrowDirection: String,
  2682. clickable: {
  2683. type: Boolean,
  2684. default: null
  2685. }
  2686. };
  2687. const cellProps = extend({}, cellSharedProps, routeProps);
  2688. var stdin_default$1o = vue.defineComponent({
  2689. name: name$1h,
  2690. props: cellProps,
  2691. setup(props, {
  2692. slots
  2693. }) {
  2694. const route2 = useRoute();
  2695. const renderLabel = () => {
  2696. const showLabel = slots.label || isDef(props.label);
  2697. if (showLabel) {
  2698. return vue.createVNode("div", {
  2699. "class": [bem$1d("label"), props.labelClass]
  2700. }, [slots.label ? slots.label() : props.label]);
  2701. }
  2702. };
  2703. const renderTitle = () => {
  2704. if (slots.title || isDef(props.title)) {
  2705. return vue.createVNode("div", {
  2706. "class": [bem$1d("title"), props.titleClass],
  2707. "style": props.titleStyle
  2708. }, [slots.title ? slots.title() : vue.createVNode("span", null, [props.title]), renderLabel()]);
  2709. }
  2710. };
  2711. const renderValue = () => {
  2712. const slot = slots.value || slots.default;
  2713. const hasValue = slot || isDef(props.value);
  2714. if (hasValue) {
  2715. const hasTitle = slots.title || isDef(props.title);
  2716. return vue.createVNode("div", {
  2717. "class": [bem$1d("value", {
  2718. alone: !hasTitle
  2719. }), props.valueClass]
  2720. }, [slot ? slot() : vue.createVNode("span", null, [props.value])]);
  2721. }
  2722. };
  2723. const renderLeftIcon = () => {
  2724. if (slots.icon) {
  2725. return slots.icon();
  2726. }
  2727. if (props.icon) {
  2728. return vue.createVNode(Icon, {
  2729. "name": props.icon,
  2730. "class": bem$1d("left-icon"),
  2731. "classPrefix": props.iconPrefix
  2732. }, null);
  2733. }
  2734. };
  2735. const renderRightIcon = () => {
  2736. if (slots["right-icon"]) {
  2737. return slots["right-icon"]();
  2738. }
  2739. if (props.isLink) {
  2740. const name2 = props.arrowDirection && props.arrowDirection !== "right" ? `arrow-${props.arrowDirection}` : "arrow";
  2741. return vue.createVNode(Icon, {
  2742. "name": name2,
  2743. "class": bem$1d("right-icon")
  2744. }, null);
  2745. }
  2746. };
  2747. return () => {
  2748. var _a, _b;
  2749. const {
  2750. size,
  2751. center,
  2752. border,
  2753. isLink,
  2754. required
  2755. } = props;
  2756. const clickable = (_a = props.clickable) != null ? _a : isLink;
  2757. const classes = {
  2758. center,
  2759. required,
  2760. clickable,
  2761. borderless: !border
  2762. };
  2763. if (size) {
  2764. classes[size] = !!size;
  2765. }
  2766. return vue.createVNode("div", {
  2767. "class": bem$1d(classes),
  2768. "role": clickable ? "button" : void 0,
  2769. "tabindex": clickable ? 0 : void 0,
  2770. "onClick": route2
  2771. }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
  2772. };
  2773. }
  2774. });
  2775. const Cell = withInstall(stdin_default$1o);
  2776. const [name$1g, bem$1c] = createNamespace("form");
  2777. const formProps = {
  2778. colon: Boolean,
  2779. disabled: Boolean,
  2780. readonly: Boolean,
  2781. showError: Boolean,
  2782. labelWidth: numericProp,
  2783. labelAlign: String,
  2784. inputAlign: String,
  2785. scrollToError: Boolean,
  2786. validateFirst: Boolean,
  2787. submitOnEnter: truthProp,
  2788. showErrorMessage: truthProp,
  2789. errorMessageAlign: String,
  2790. validateTrigger: {
  2791. type: [String, Array],
  2792. default: "onBlur"
  2793. }
  2794. };
  2795. var stdin_default$1n = vue.defineComponent({
  2796. name: name$1g,
  2797. props: formProps,
  2798. emits: ["submit", "failed"],
  2799. setup(props, {
  2800. emit,
  2801. slots
  2802. }) {
  2803. const {
  2804. children,
  2805. linkChildren
  2806. } = useChildren(FORM_KEY);
  2807. const getFieldsByNames = (names) => {
  2808. if (names) {
  2809. return children.filter((field) => names.includes(field.name));
  2810. }
  2811. return children;
  2812. };
  2813. const validateSeq = (names) => new Promise((resolve, reject) => {
  2814. const errors = [];
  2815. const fields = getFieldsByNames(names);
  2816. fields.reduce((promise, field) => promise.then(() => {
  2817. if (!errors.length) {
  2818. return field.validate().then((error) => {
  2819. if (error) {
  2820. errors.push(error);
  2821. }
  2822. });
  2823. }
  2824. }), Promise.resolve()).then(() => {
  2825. if (errors.length) {
  2826. reject(errors);
  2827. } else {
  2828. resolve();
  2829. }
  2830. });
  2831. });
  2832. const validateAll = (names) => new Promise((resolve, reject) => {
  2833. const fields = getFieldsByNames(names);
  2834. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  2835. errors = errors.filter(Boolean);
  2836. if (errors.length) {
  2837. reject(errors);
  2838. } else {
  2839. resolve();
  2840. }
  2841. });
  2842. });
  2843. const validateField = (name2) => {
  2844. const matched = children.find((item) => item.name === name2);
  2845. if (matched) {
  2846. return new Promise((resolve, reject) => {
  2847. matched.validate().then((error) => {
  2848. if (error) {
  2849. reject(error);
  2850. } else {
  2851. resolve();
  2852. }
  2853. });
  2854. });
  2855. }
  2856. return Promise.reject();
  2857. };
  2858. const validate = (name2) => {
  2859. if (typeof name2 === "string") {
  2860. return validateField(name2);
  2861. }
  2862. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  2863. };
  2864. const resetValidation = (name2) => {
  2865. if (typeof name2 === "string") {
  2866. name2 = [name2];
  2867. }
  2868. const fields = getFieldsByNames(name2);
  2869. fields.forEach((item) => {
  2870. item.resetValidation();
  2871. });
  2872. };
  2873. const getValidationStatus = () => children.reduce((form, field) => {
  2874. form[field.name] = field.getValidationStatus();
  2875. return form;
  2876. }, {});
  2877. const scrollToField = (name2, options) => {
  2878. children.some((item) => {
  2879. if (item.name === name2) {
  2880. item.$el.scrollIntoView(options);
  2881. return true;
  2882. }
  2883. return false;
  2884. });
  2885. };
  2886. const getValues = () => children.reduce((form, field) => {
  2887. form[field.name] = field.formValue.value;
  2888. return form;
  2889. }, {});
  2890. const submit = () => {
  2891. const values = getValues();
  2892. validate().then(() => emit("submit", values)).catch((errors) => {
  2893. emit("failed", {
  2894. values,
  2895. errors
  2896. });
  2897. if (props.scrollToError && errors[0].name) {
  2898. scrollToField(errors[0].name);
  2899. }
  2900. });
  2901. };
  2902. const onSubmit = (event) => {
  2903. preventDefault(event);
  2904. submit();
  2905. };
  2906. linkChildren({
  2907. props
  2908. });
  2909. useExpose({
  2910. submit,
  2911. validate,
  2912. getValues,
  2913. scrollToField,
  2914. resetValidation,
  2915. getValidationStatus
  2916. });
  2917. return () => {
  2918. var _a;
  2919. return vue.createVNode("form", {
  2920. "class": bem$1c(),
  2921. "onSubmit": onSubmit
  2922. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  2923. };
  2924. }
  2925. });
  2926. const Form = withInstall(stdin_default$1n);
  2927. function isEmptyValue(value) {
  2928. if (Array.isArray(value)) {
  2929. return !value.length;
  2930. }
  2931. if (value === 0) {
  2932. return false;
  2933. }
  2934. return !value;
  2935. }
  2936. function runSyncRule(value, rule) {
  2937. if (isEmptyValue(value)) {
  2938. if (rule.required) {
  2939. return false;
  2940. }
  2941. if (rule.validateEmpty === false) {
  2942. return true;
  2943. }
  2944. }
  2945. if (rule.pattern && !rule.pattern.test(String(value))) {
  2946. return false;
  2947. }
  2948. return true;
  2949. }
  2950. function runRuleValidator(value, rule) {
  2951. return new Promise((resolve) => {
  2952. const returnVal = rule.validator(value, rule);
  2953. if (isPromise(returnVal)) {
  2954. returnVal.then(resolve);
  2955. return;
  2956. }
  2957. resolve(returnVal);
  2958. });
  2959. }
  2960. function getRuleMessage(value, rule) {
  2961. const { message } = rule;
  2962. if (isFunction(message)) {
  2963. return message(value, rule);
  2964. }
  2965. return message || "";
  2966. }
  2967. function startComposing({ target }) {
  2968. target.composing = true;
  2969. }
  2970. function endComposing({ target }) {
  2971. if (target.composing) {
  2972. target.composing = false;
  2973. target.dispatchEvent(new Event("input"));
  2974. }
  2975. }
  2976. function resizeTextarea(input, autosize) {
  2977. const scrollTop = getRootScrollTop();
  2978. input.style.height = "auto";
  2979. let height2 = input.scrollHeight;
  2980. if (isObject(autosize)) {
  2981. const { maxHeight, minHeight } = autosize;
  2982. if (maxHeight !== void 0) {
  2983. height2 = Math.min(height2, maxHeight);
  2984. }
  2985. if (minHeight !== void 0) {
  2986. height2 = Math.max(height2, minHeight);
  2987. }
  2988. }
  2989. if (height2) {
  2990. input.style.height = `${height2}px`;
  2991. setRootScrollTop(scrollTop);
  2992. }
  2993. }
  2994. function mapInputType(type) {
  2995. if (type === "number") {
  2996. return {
  2997. type: "text",
  2998. inputmode: "decimal"
  2999. };
  3000. }
  3001. if (type === "digit") {
  3002. return {
  3003. type: "tel",
  3004. inputmode: "numeric"
  3005. };
  3006. }
  3007. return { type };
  3008. }
  3009. function getStringLength(str) {
  3010. return [...str].length;
  3011. }
  3012. function cutString(str, maxlength) {
  3013. return [...str].slice(0, maxlength).join("");
  3014. }
  3015. let current = 0;
  3016. function useId() {
  3017. const vm = vue.getCurrentInstance();
  3018. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  3019. return `${name2}-${++current}`;
  3020. }
  3021. const [name$1f, bem$1b] = createNamespace("field");
  3022. const fieldSharedProps = {
  3023. id: String,
  3024. name: String,
  3025. leftIcon: String,
  3026. rightIcon: String,
  3027. autofocus: Boolean,
  3028. clearable: Boolean,
  3029. maxlength: numericProp,
  3030. formatter: Function,
  3031. clearIcon: makeStringProp("clear"),
  3032. modelValue: makeNumericProp(""),
  3033. inputAlign: String,
  3034. placeholder: String,
  3035. autocomplete: String,
  3036. errorMessage: String,
  3037. enterkeyhint: String,
  3038. clearTrigger: makeStringProp("focus"),
  3039. formatTrigger: makeStringProp("onChange"),
  3040. error: {
  3041. type: Boolean,
  3042. default: null
  3043. },
  3044. disabled: {
  3045. type: Boolean,
  3046. default: null
  3047. },
  3048. readonly: {
  3049. type: Boolean,
  3050. default: null
  3051. }
  3052. };
  3053. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  3054. rows: numericProp,
  3055. type: makeStringProp("text"),
  3056. rules: Array,
  3057. autosize: [Boolean, Object],
  3058. labelWidth: numericProp,
  3059. labelClass: unknownProp,
  3060. labelAlign: String,
  3061. showWordLimit: Boolean,
  3062. errorMessageAlign: String,
  3063. colon: {
  3064. type: Boolean,
  3065. default: null
  3066. }
  3067. });
  3068. var stdin_default$1m = vue.defineComponent({
  3069. name: name$1f,
  3070. props: fieldProps,
  3071. emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
  3072. setup(props, {
  3073. emit,
  3074. slots
  3075. }) {
  3076. const id = useId();
  3077. const state = vue.reactive({
  3078. status: "unvalidated",
  3079. focused: false,
  3080. validateMessage: ""
  3081. });
  3082. const inputRef = vue.ref();
  3083. const clearIconRef = vue.ref();
  3084. const customValue = vue.ref();
  3085. const {
  3086. parent: form
  3087. } = useParent(FORM_KEY);
  3088. const getModelValue = () => {
  3089. var _a;
  3090. return String((_a = props.modelValue) != null ? _a : "");
  3091. };
  3092. const getProp = (key) => {
  3093. if (isDef(props[key])) {
  3094. return props[key];
  3095. }
  3096. if (form && isDef(form.props[key])) {
  3097. return form.props[key];
  3098. }
  3099. };
  3100. const showClear = vue.computed(() => {
  3101. const readonly = getProp("readonly");
  3102. if (props.clearable && !readonly) {
  3103. const hasValue = getModelValue() !== "";
  3104. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  3105. return hasValue && trigger;
  3106. }
  3107. return false;
  3108. });
  3109. const formValue = vue.computed(() => {
  3110. if (customValue.value && slots.input) {
  3111. return customValue.value();
  3112. }
  3113. return props.modelValue;
  3114. });
  3115. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  3116. if (state.status === "failed") {
  3117. return;
  3118. }
  3119. let {
  3120. value
  3121. } = formValue;
  3122. if (rule.formatter) {
  3123. value = rule.formatter(value, rule);
  3124. }
  3125. if (!runSyncRule(value, rule)) {
  3126. state.status = "failed";
  3127. state.validateMessage = getRuleMessage(value, rule);
  3128. return;
  3129. }
  3130. if (rule.validator) {
  3131. if (isEmptyValue(value) && rule.validateEmpty === false) {
  3132. return;
  3133. }
  3134. return runRuleValidator(value, rule).then((result) => {
  3135. if (result && typeof result === "string") {
  3136. state.status = "failed";
  3137. state.validateMessage = result;
  3138. } else if (result === false) {
  3139. state.status = "failed";
  3140. state.validateMessage = getRuleMessage(value, rule);
  3141. }
  3142. });
  3143. }
  3144. }), Promise.resolve());
  3145. const resetValidation = () => {
  3146. state.status = "unvalidated";
  3147. state.validateMessage = "";
  3148. };
  3149. const endValidate = () => emit("end-validate", {
  3150. status: state.status
  3151. });
  3152. const validate = (rules = props.rules) => new Promise((resolve) => {
  3153. resetValidation();
  3154. if (rules) {
  3155. emit("start-validate");
  3156. runRules(rules).then(() => {
  3157. if (state.status === "failed") {
  3158. resolve({
  3159. name: props.name,
  3160. message: state.validateMessage
  3161. });
  3162. endValidate();
  3163. } else {
  3164. state.status = "passed";
  3165. resolve();
  3166. endValidate();
  3167. }
  3168. });
  3169. } else {
  3170. resolve();
  3171. }
  3172. });
  3173. const validateWithTrigger = (trigger) => {
  3174. if (form && props.rules) {
  3175. const {
  3176. validateTrigger
  3177. } = form.props;
  3178. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  3179. const rules = props.rules.filter((rule) => {
  3180. if (rule.trigger) {
  3181. return toArray(rule.trigger).includes(trigger);
  3182. }
  3183. return defaultTrigger;
  3184. });
  3185. if (rules.length) {
  3186. validate(rules);
  3187. }
  3188. }
  3189. };
  3190. const limitValueLength = (value) => {
  3191. const {
  3192. maxlength
  3193. } = props;
  3194. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  3195. const modelValue = getModelValue();
  3196. if (modelValue && getStringLength(modelValue) === +maxlength) {
  3197. return modelValue;
  3198. }
  3199. return cutString(value, +maxlength);
  3200. }
  3201. return value;
  3202. };
  3203. const updateValue = (value, trigger = "onChange") => {
  3204. const originalValue = value;
  3205. value = limitValueLength(value);
  3206. const isExceedLimit = value !== originalValue;
  3207. if (props.type === "number" || props.type === "digit") {
  3208. const isNumber = props.type === "number";
  3209. value = formatNumber(value, isNumber, isNumber);
  3210. }
  3211. if (props.formatter && trigger === props.formatTrigger) {
  3212. value = props.formatter(value);
  3213. }
  3214. if (inputRef.value && inputRef.value.value !== value) {
  3215. if (state.focused && isExceedLimit) {
  3216. const {
  3217. selectionStart,
  3218. selectionEnd
  3219. } = inputRef.value;
  3220. inputRef.value.value = value;
  3221. inputRef.value.setSelectionRange(selectionStart - 1, selectionEnd - 1);
  3222. } else {
  3223. inputRef.value.value = value;
  3224. }
  3225. }
  3226. if (value !== props.modelValue) {
  3227. emit("update:modelValue", value);
  3228. }
  3229. };
  3230. const onInput = (event) => {
  3231. if (!event.target.composing) {
  3232. updateValue(event.target.value);
  3233. }
  3234. };
  3235. const blur = () => {
  3236. var _a;
  3237. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  3238. };
  3239. const focus = () => {
  3240. var _a;
  3241. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  3242. };
  3243. const adjustTextareaSize = () => {
  3244. const input = inputRef.value;
  3245. if (props.type === "textarea" && props.autosize && input) {
  3246. resizeTextarea(input, props.autosize);
  3247. }
  3248. };
  3249. const onFocus = (event) => {
  3250. state.focused = true;
  3251. emit("focus", event);
  3252. vue.nextTick(adjustTextareaSize);
  3253. if (getProp("readonly")) {
  3254. blur();
  3255. }
  3256. };
  3257. const onBlur = (event) => {
  3258. if (getProp("readonly")) {
  3259. return;
  3260. }
  3261. state.focused = false;
  3262. updateValue(getModelValue(), "onBlur");
  3263. emit("blur", event);
  3264. validateWithTrigger("onBlur");
  3265. vue.nextTick(adjustTextareaSize);
  3266. resetScroll();
  3267. };
  3268. const onClickInput = (event) => emit("click-input", event);
  3269. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  3270. const onClickRightIcon = (event) => emit("click-right-icon", event);
  3271. const onClear = (event) => {
  3272. preventDefault(event);
  3273. emit("update:modelValue", "");
  3274. emit("clear", event);
  3275. };
  3276. const showError = vue.computed(() => {
  3277. if (typeof props.error === "boolean") {
  3278. return props.error;
  3279. }
  3280. if (form && form.props.showError && state.status === "failed") {
  3281. return true;
  3282. }
  3283. });
  3284. const labelStyle = vue.computed(() => {
  3285. const labelWidth = getProp("labelWidth");
  3286. if (labelWidth) {
  3287. return {
  3288. width: addUnit(labelWidth)
  3289. };
  3290. }
  3291. });
  3292. const onKeypress = (event) => {
  3293. const ENTER_CODE = 13;
  3294. if (event.keyCode === ENTER_CODE) {
  3295. const submitOnEnter = form && form.props.submitOnEnter;
  3296. if (!submitOnEnter && props.type !== "textarea") {
  3297. preventDefault(event);
  3298. }
  3299. if (props.type === "search") {
  3300. blur();
  3301. }
  3302. }
  3303. emit("keypress", event);
  3304. };
  3305. const getInputId = () => props.id || `${id}-input`;
  3306. const getValidationStatus = () => state.status;
  3307. const renderInput = () => {
  3308. const controlClass = bem$1b("control", [getProp("inputAlign"), {
  3309. error: showError.value,
  3310. custom: !!slots.input,
  3311. "min-height": props.type === "textarea" && !props.autosize
  3312. }]);
  3313. if (slots.input) {
  3314. return vue.createVNode("div", {
  3315. "class": controlClass,
  3316. "onClick": onClickInput
  3317. }, [slots.input()]);
  3318. }
  3319. const inputAttrs = {
  3320. id: getInputId(),
  3321. ref: inputRef,
  3322. name: props.name,
  3323. rows: props.rows !== void 0 ? +props.rows : void 0,
  3324. class: controlClass,
  3325. disabled: getProp("disabled"),
  3326. readonly: getProp("readonly"),
  3327. autofocus: props.autofocus,
  3328. placeholder: props.placeholder,
  3329. autocomplete: props.autocomplete,
  3330. enterkeyhint: props.enterkeyhint,
  3331. "aria-labelledby": props.label ? `${id}-label` : void 0,
  3332. onBlur,
  3333. onFocus,
  3334. onInput,
  3335. onClick: onClickInput,
  3336. onChange: endComposing,
  3337. onKeypress,
  3338. onCompositionend: endComposing,
  3339. onCompositionstart: startComposing
  3340. };
  3341. if (props.type === "textarea") {
  3342. return vue.createVNode("textarea", inputAttrs, null);
  3343. }
  3344. return vue.createVNode("input", vue.mergeProps(mapInputType(props.type), inputAttrs), null);
  3345. };
  3346. const renderLeftIcon = () => {
  3347. const leftIconSlot = slots["left-icon"];
  3348. if (props.leftIcon || leftIconSlot) {
  3349. return vue.createVNode("div", {
  3350. "class": bem$1b("left-icon"),
  3351. "onClick": onClickLeftIcon
  3352. }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
  3353. "name": props.leftIcon,
  3354. "classPrefix": props.iconPrefix
  3355. }, null)]);
  3356. }
  3357. };
  3358. const renderRightIcon = () => {
  3359. const rightIconSlot = slots["right-icon"];
  3360. if (props.rightIcon || rightIconSlot) {
  3361. return vue.createVNode("div", {
  3362. "class": bem$1b("right-icon"),
  3363. "onClick": onClickRightIcon
  3364. }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
  3365. "name": props.rightIcon,
  3366. "classPrefix": props.iconPrefix
  3367. }, null)]);
  3368. }
  3369. };
  3370. const renderWordLimit = () => {
  3371. if (props.showWordLimit && props.maxlength) {
  3372. const count = getStringLength(getModelValue());
  3373. return vue.createVNode("div", {
  3374. "class": bem$1b("word-limit")
  3375. }, [vue.createVNode("span", {
  3376. "class": bem$1b("word-num")
  3377. }, [count]), vue.createTextVNode("/"), props.maxlength]);
  3378. }
  3379. };
  3380. const renderMessage = () => {
  3381. if (form && form.props.showErrorMessage === false) {
  3382. return;
  3383. }
  3384. const message = props.errorMessage || state.validateMessage;
  3385. if (message) {
  3386. const slot = slots["error-message"];
  3387. const errorMessageAlign = getProp("errorMessageAlign");
  3388. return vue.createVNode("div", {
  3389. "class": bem$1b("error-message", errorMessageAlign)
  3390. }, [slot ? slot({
  3391. message
  3392. }) : message]);
  3393. }
  3394. };
  3395. const renderLabel = () => {
  3396. const colon = getProp("colon") ? ":" : "";
  3397. if (slots.label) {
  3398. return [slots.label(), colon];
  3399. }
  3400. if (props.label) {
  3401. return vue.createVNode("label", {
  3402. "id": `${id}-label`,
  3403. "for": getInputId()
  3404. }, [props.label + colon]);
  3405. }
  3406. };
  3407. const renderFieldBody = () => [vue.createVNode("div", {
  3408. "class": bem$1b("body")
  3409. }, [renderInput(), showClear.value && vue.createVNode(Icon, {
  3410. "ref": clearIconRef,
  3411. "name": props.clearIcon,
  3412. "class": bem$1b("clear")
  3413. }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
  3414. "class": bem$1b("button")
  3415. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  3416. useExpose({
  3417. blur,
  3418. focus,
  3419. validate,
  3420. formValue,
  3421. resetValidation,
  3422. getValidationStatus
  3423. });
  3424. vue.provide(CUSTOM_FIELD_INJECTION_KEY, {
  3425. customValue,
  3426. resetValidation,
  3427. validateWithTrigger
  3428. });
  3429. vue.watch(() => props.modelValue, () => {
  3430. updateValue(getModelValue());
  3431. resetValidation();
  3432. validateWithTrigger("onChange");
  3433. vue.nextTick(adjustTextareaSize);
  3434. });
  3435. vue.onMounted(() => {
  3436. updateValue(getModelValue(), props.formatTrigger);
  3437. vue.nextTick(adjustTextareaSize);
  3438. });
  3439. useEventListener("touchstart", onClear, {
  3440. target: vue.computed(() => {
  3441. var _a;
  3442. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  3443. })
  3444. });
  3445. return () => {
  3446. const disabled = getProp("disabled");
  3447. const labelAlign = getProp("labelAlign");
  3448. const Label = renderLabel();
  3449. const LeftIcon = renderLeftIcon();
  3450. return vue.createVNode(Cell, {
  3451. "size": props.size,
  3452. "icon": props.leftIcon,
  3453. "class": bem$1b({
  3454. error: showError.value,
  3455. disabled,
  3456. [`label-${labelAlign}`]: labelAlign
  3457. }),
  3458. "center": props.center,
  3459. "border": props.border,
  3460. "isLink": props.isLink,
  3461. "clickable": props.clickable,
  3462. "titleStyle": labelStyle.value,
  3463. "valueClass": bem$1b("value"),
  3464. "titleClass": [bem$1b("label", [labelAlign, {
  3465. required: props.required
  3466. }]), props.labelClass],
  3467. "arrowDirection": props.arrowDirection
  3468. }, {
  3469. icon: LeftIcon ? () => LeftIcon : null,
  3470. title: Label ? () => Label : null,
  3471. value: renderFieldBody,
  3472. extra: slots.extra
  3473. });
  3474. };
  3475. }
  3476. });
  3477. const Field = withInstall(stdin_default$1m);
  3478. function usePopupState() {
  3479. const state = vue.reactive({
  3480. show: false
  3481. });
  3482. const toggle = (show) => {
  3483. state.show = show;
  3484. };
  3485. const open = (props) => {
  3486. extend(state, props, { transitionAppear: true });
  3487. toggle(true);
  3488. };
  3489. const close = () => toggle(false);
  3490. useExpose({ open, close, toggle });
  3491. return {
  3492. open,
  3493. close,
  3494. state,
  3495. toggle
  3496. };
  3497. }
  3498. function mountComponent(RootComponent) {
  3499. const app = vue.createApp(RootComponent);
  3500. const root = document.createElement("div");
  3501. document.body.appendChild(root);
  3502. return {
  3503. instance: app.mount(root),
  3504. unmount() {
  3505. app.unmount();
  3506. document.body.removeChild(root);
  3507. }
  3508. };
  3509. }
  3510. let lockCount = 0;
  3511. function lockClick(lock) {
  3512. if (lock) {
  3513. if (!lockCount) {
  3514. document.body.classList.add("van-toast--unclickable");
  3515. }
  3516. lockCount++;
  3517. } else if (lockCount) {
  3518. lockCount--;
  3519. if (!lockCount) {
  3520. document.body.classList.remove("van-toast--unclickable");
  3521. }
  3522. }
  3523. }
  3524. const [name$1e, bem$1a] = createNamespace("toast");
  3525. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  3526. const toastProps = {
  3527. icon: String,
  3528. show: Boolean,
  3529. type: makeStringProp("text"),
  3530. overlay: Boolean,
  3531. message: numericProp,
  3532. iconSize: numericProp,
  3533. duration: makeNumberProp(2e3),
  3534. position: makeStringProp("middle"),
  3535. teleport: [String, Object],
  3536. className: unknownProp,
  3537. iconPrefix: String,
  3538. transition: makeStringProp("van-fade"),
  3539. loadingType: String,
  3540. forbidClick: Boolean,
  3541. overlayClass: unknownProp,
  3542. overlayStyle: Object,
  3543. closeOnClick: Boolean,
  3544. closeOnClickOverlay: Boolean
  3545. };
  3546. var stdin_default$1l = vue.defineComponent({
  3547. name: name$1e,
  3548. props: toastProps,
  3549. emits: ["update:show"],
  3550. setup(props, {
  3551. emit
  3552. }) {
  3553. let timer2;
  3554. let clickable = false;
  3555. const toggleClickable = () => {
  3556. const newValue = props.show && props.forbidClick;
  3557. if (clickable !== newValue) {
  3558. clickable = newValue;
  3559. lockClick(clickable);
  3560. }
  3561. };
  3562. const updateShow = (show) => emit("update:show", show);
  3563. const onClick = () => {
  3564. if (props.closeOnClick) {
  3565. updateShow(false);
  3566. }
  3567. };
  3568. const clearTimer = () => clearTimeout(timer2);
  3569. const renderIcon = () => {
  3570. const {
  3571. icon,
  3572. type,
  3573. iconSize,
  3574. iconPrefix,
  3575. loadingType
  3576. } = props;
  3577. const hasIcon = icon || type === "success" || type === "fail";
  3578. if (hasIcon) {
  3579. return vue.createVNode(Icon, {
  3580. "name": icon || type,
  3581. "size": iconSize,
  3582. "class": bem$1a("icon"),
  3583. "classPrefix": iconPrefix
  3584. }, null);
  3585. }
  3586. if (type === "loading") {
  3587. return vue.createVNode(Loading, {
  3588. "class": bem$1a("loading"),
  3589. "size": iconSize,
  3590. "type": loadingType
  3591. }, null);
  3592. }
  3593. };
  3594. const renderMessage = () => {
  3595. const {
  3596. type,
  3597. message
  3598. } = props;
  3599. if (isDef(message) && message !== "") {
  3600. return type === "html" ? vue.createVNode("div", {
  3601. "key": 0,
  3602. "class": bem$1a("text"),
  3603. "innerHTML": String(message)
  3604. }, null) : vue.createVNode("div", {
  3605. "class": bem$1a("text")
  3606. }, [message]);
  3607. }
  3608. };
  3609. vue.watch(() => [props.show, props.forbidClick], toggleClickable);
  3610. vue.watch(() => [props.show, props.type, props.message, props.duration], () => {
  3611. clearTimer();
  3612. if (props.show && props.duration > 0) {
  3613. timer2 = setTimeout(() => {
  3614. updateShow(false);
  3615. }, props.duration);
  3616. }
  3617. });
  3618. vue.onMounted(toggleClickable);
  3619. vue.onUnmounted(toggleClickable);
  3620. return () => vue.createVNode(Popup, vue.mergeProps({
  3621. "class": [bem$1a([props.position, {
  3622. [props.type]: !props.icon
  3623. }]), props.className],
  3624. "lockScroll": false,
  3625. "onClick": onClick,
  3626. "onClosed": clearTimer,
  3627. "onUpdate:show": updateShow
  3628. }, pick(props, popupInheritProps)), {
  3629. default: () => [renderIcon(), renderMessage()]
  3630. });
  3631. }
  3632. });
  3633. const defaultOptions$1 = {
  3634. icon: "",
  3635. type: "text",
  3636. message: "",
  3637. className: "",
  3638. overlay: false,
  3639. onClose: void 0,
  3640. onOpened: void 0,
  3641. duration: 2e3,
  3642. teleport: "body",
  3643. iconSize: void 0,
  3644. iconPrefix: void 0,
  3645. position: "middle",
  3646. transition: "van-fade",
  3647. forbidClick: false,
  3648. loadingType: void 0,
  3649. overlayClass: "",
  3650. overlayStyle: void 0,
  3651. closeOnClick: false,
  3652. closeOnClickOverlay: false
  3653. };
  3654. let queue = [];
  3655. let allowMultiple = false;
  3656. let currentOptions = extend({}, defaultOptions$1);
  3657. const defaultOptionsMap = /* @__PURE__ */ new Map();
  3658. function parseOptions$1(message) {
  3659. if (isObject(message)) {
  3660. return message;
  3661. }
  3662. return {
  3663. message
  3664. };
  3665. }
  3666. function createInstance() {
  3667. const {
  3668. instance: instance2,
  3669. unmount
  3670. } = mountComponent({
  3671. setup() {
  3672. const message = vue.ref("");
  3673. const {
  3674. open,
  3675. state,
  3676. close,
  3677. toggle
  3678. } = usePopupState();
  3679. const onClosed = () => {
  3680. if (allowMultiple) {
  3681. queue = queue.filter((item) => item !== instance2);
  3682. unmount();
  3683. }
  3684. };
  3685. const render = () => {
  3686. const attrs = {
  3687. onClosed,
  3688. "onUpdate:show": toggle
  3689. };
  3690. return vue.createVNode(stdin_default$1l, vue.mergeProps(state, attrs), null);
  3691. };
  3692. vue.watch(message, (val) => {
  3693. state.message = val;
  3694. });
  3695. vue.getCurrentInstance().render = render;
  3696. return {
  3697. open,
  3698. clear: close,
  3699. message
  3700. };
  3701. }
  3702. });
  3703. return instance2;
  3704. }
  3705. function getInstance() {
  3706. if (!queue.length || allowMultiple) {
  3707. const instance2 = createInstance();
  3708. queue.push(instance2);
  3709. }
  3710. return queue[queue.length - 1];
  3711. }
  3712. function Toast(options = {}) {
  3713. if (!inBrowser$1) {
  3714. return {};
  3715. }
  3716. const toast = getInstance();
  3717. const parsedOptions = parseOptions$1(options);
  3718. toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
  3719. return toast;
  3720. }
  3721. const createMethod = (type) => (options) => Toast(extend({
  3722. type
  3723. }, parseOptions$1(options)));
  3724. Toast.loading = createMethod("loading");
  3725. Toast.success = createMethod("success");
  3726. Toast.fail = createMethod("fail");
  3727. Toast.clear = (all) => {
  3728. var _a;
  3729. if (queue.length) {
  3730. if (all) {
  3731. queue.forEach((toast) => {
  3732. toast.clear();
  3733. });
  3734. queue = [];
  3735. } else if (!allowMultiple) {
  3736. queue[0].clear();
  3737. } else {
  3738. (_a = queue.shift()) == null ? void 0 : _a.clear();
  3739. }
  3740. }
  3741. };
  3742. function setDefaultOptions(type, options) {
  3743. if (typeof type === "string") {
  3744. defaultOptionsMap.set(type, options);
  3745. } else {
  3746. extend(currentOptions, type);
  3747. }
  3748. }
  3749. Toast.setDefaultOptions = setDefaultOptions;
  3750. Toast.resetDefaultOptions = (type) => {
  3751. if (typeof type === "string") {
  3752. defaultOptionsMap.delete(type);
  3753. } else {
  3754. currentOptions = extend({}, defaultOptions$1);
  3755. defaultOptionsMap.clear();
  3756. }
  3757. };
  3758. Toast.allowMultiple = (value = true) => {
  3759. allowMultiple = value;
  3760. };
  3761. Toast.install = (app) => {
  3762. app.use(withInstall(stdin_default$1l));
  3763. app.config.globalProperties.$toast = Toast;
  3764. };
  3765. const [name$1d, bem$19] = createNamespace("switch");
  3766. const switchProps = {
  3767. size: numericProp,
  3768. loading: Boolean,
  3769. disabled: Boolean,
  3770. modelValue: unknownProp,
  3771. activeColor: String,
  3772. inactiveColor: String,
  3773. activeValue: {
  3774. type: unknownProp,
  3775. default: true
  3776. },
  3777. inactiveValue: {
  3778. type: unknownProp,
  3779. default: false
  3780. }
  3781. };
  3782. var stdin_default$1k = vue.defineComponent({
  3783. name: name$1d,
  3784. props: switchProps,
  3785. emits: ["change", "update:modelValue"],
  3786. setup(props, {
  3787. emit,
  3788. slots
  3789. }) {
  3790. const isChecked = () => props.modelValue === props.activeValue;
  3791. const onClick = () => {
  3792. if (!props.disabled && !props.loading) {
  3793. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  3794. emit("update:modelValue", newValue);
  3795. emit("change", newValue);
  3796. }
  3797. };
  3798. const renderLoading = () => {
  3799. if (props.loading) {
  3800. const color = isChecked() ? props.activeColor : props.inactiveColor;
  3801. return vue.createVNode(Loading, {
  3802. "class": bem$19("loading"),
  3803. "color": color
  3804. }, null);
  3805. }
  3806. if (slots.node) {
  3807. return slots.node();
  3808. }
  3809. };
  3810. useCustomFieldValue(() => props.modelValue);
  3811. return () => {
  3812. var _a;
  3813. const {
  3814. size,
  3815. loading,
  3816. disabled,
  3817. activeColor,
  3818. inactiveColor
  3819. } = props;
  3820. const checked = isChecked();
  3821. const style = {
  3822. fontSize: addUnit(size),
  3823. backgroundColor: checked ? activeColor : inactiveColor
  3824. };
  3825. return vue.createVNode("div", {
  3826. "role": "switch",
  3827. "class": bem$19({
  3828. on: checked,
  3829. loading,
  3830. disabled
  3831. }),
  3832. "style": style,
  3833. "tabindex": disabled ? void 0 : 0,
  3834. "aria-checked": checked,
  3835. "onClick": onClick
  3836. }, [vue.createVNode("div", {
  3837. "class": bem$19("node")
  3838. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  3839. };
  3840. }
  3841. });
  3842. const Switch = withInstall(stdin_default$1k);
  3843. const [name$1c, bem$18] = createNamespace("address-edit-detail");
  3844. const t$i = createNamespace("address-edit")[2];
  3845. var stdin_default$1j = vue.defineComponent({
  3846. name: name$1c,
  3847. props: {
  3848. show: Boolean,
  3849. rows: numericProp,
  3850. value: String,
  3851. rules: Array,
  3852. focused: Boolean,
  3853. maxlength: numericProp,
  3854. searchResult: Array,
  3855. showSearchResult: Boolean
  3856. },
  3857. emits: ["blur", "focus", "input", "select-search"],
  3858. setup(props, {
  3859. emit
  3860. }) {
  3861. const field = vue.ref();
  3862. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  3863. const onSelect = (express) => {
  3864. emit("select-search", express);
  3865. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  3866. };
  3867. const renderSearchTitle = (express) => {
  3868. if (express.name) {
  3869. const text = express.name.replace(props.value, `<span class=${bem$18("keyword")}>${props.value}</span>`);
  3870. return vue.createVNode("div", {
  3871. "innerHTML": text
  3872. }, null);
  3873. }
  3874. };
  3875. const renderSearchResult = () => {
  3876. if (!showSearchResult()) {
  3877. return;
  3878. }
  3879. const {
  3880. searchResult
  3881. } = props;
  3882. return searchResult.map((express) => vue.createVNode(Cell, {
  3883. "clickable": true,
  3884. "key": express.name + express.address,
  3885. "icon": "location-o",
  3886. "label": express.address,
  3887. "class": bem$18("search-item"),
  3888. "border": false,
  3889. "onClick": () => onSelect(express)
  3890. }, {
  3891. title: () => renderSearchTitle(express)
  3892. }));
  3893. };
  3894. const onBlur = (event) => emit("blur", event);
  3895. const onFocus = (event) => emit("focus", event);
  3896. const onInput = (value) => emit("input", value);
  3897. return () => {
  3898. if (props.show) {
  3899. return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
  3900. "autosize": true,
  3901. "clearable": true,
  3902. "ref": field,
  3903. "class": bem$18(),
  3904. "rows": props.rows,
  3905. "type": "textarea",
  3906. "rules": props.rules,
  3907. "label": t$i("addressDetail"),
  3908. "border": !showSearchResult(),
  3909. "maxlength": props.maxlength,
  3910. "modelValue": props.value,
  3911. "placeholder": t$i("addressDetail"),
  3912. "onBlur": onBlur,
  3913. "onFocus": onFocus,
  3914. "onUpdate:modelValue": onInput
  3915. }, null), renderSearchResult()]);
  3916. }
  3917. };
  3918. }
  3919. });
  3920. const [name$1b, bem$17, t$h] = createNamespace("address-edit");
  3921. const DEFAULT_DATA = {
  3922. name: "",
  3923. tel: "",
  3924. city: "",
  3925. county: "",
  3926. country: "",
  3927. province: "",
  3928. areaCode: "",
  3929. isDefault: false,
  3930. postalCode: "",
  3931. addressDetail: ""
  3932. };
  3933. const isPostal = (value) => /^\d{6}$/.test(value);
  3934. const addressEditProps = {
  3935. areaList: Object,
  3936. isSaving: Boolean,
  3937. isDeleting: Boolean,
  3938. validator: Function,
  3939. showArea: truthProp,
  3940. showDetail: truthProp,
  3941. showDelete: Boolean,
  3942. showPostal: Boolean,
  3943. disableArea: Boolean,
  3944. searchResult: Array,
  3945. telMaxlength: numericProp,
  3946. showSetDefault: Boolean,
  3947. saveButtonText: String,
  3948. areaPlaceholder: String,
  3949. deleteButtonText: String,
  3950. showSearchResult: Boolean,
  3951. detailRows: makeNumericProp(1),
  3952. detailMaxlength: makeNumericProp(200),
  3953. areaColumnsPlaceholder: makeArrayProp(),
  3954. addressInfo: {
  3955. type: Object,
  3956. default: () => extend({}, DEFAULT_DATA)
  3957. },
  3958. telValidator: {
  3959. type: Function,
  3960. default: isMobile
  3961. },
  3962. postalValidator: {
  3963. type: Function,
  3964. default: isPostal
  3965. }
  3966. };
  3967. var stdin_default$1i = vue.defineComponent({
  3968. name: name$1b,
  3969. props: addressEditProps,
  3970. emits: ["save", "focus", "delete", "click-area", "change-area", "change-detail", "select-search", "change-default"],
  3971. setup(props, {
  3972. emit,
  3973. slots
  3974. }) {
  3975. const areaRef = vue.ref();
  3976. const data = vue.reactive({});
  3977. const showAreaPopup = vue.ref(false);
  3978. const detailFocused = vue.ref(false);
  3979. const areaListLoaded = vue.computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  3980. const areaText = vue.computed(() => {
  3981. const {
  3982. country,
  3983. province,
  3984. city,
  3985. county,
  3986. areaCode
  3987. } = data;
  3988. if (areaCode) {
  3989. const arr = [country, province, city, county];
  3990. if (province && province === city) {
  3991. arr.splice(1, 1);
  3992. }
  3993. return arr.filter(Boolean).join("/");
  3994. }
  3995. return "";
  3996. });
  3997. const hideBottomFields = vue.computed(() => {
  3998. var _a;
  3999. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  4000. });
  4001. const assignAreaValues = () => {
  4002. if (areaRef.value) {
  4003. const detail = areaRef.value.getArea();
  4004. detail.areaCode = detail.code;
  4005. delete detail.code;
  4006. extend(data, detail);
  4007. }
  4008. };
  4009. const onFocus = (key) => {
  4010. detailFocused.value = key === "addressDetail";
  4011. emit("focus", key);
  4012. };
  4013. const rules = vue.computed(() => {
  4014. const {
  4015. validator,
  4016. telValidator,
  4017. postalValidator
  4018. } = props;
  4019. const makeRule = (name2, emptyMessage) => ({
  4020. validator: (value) => {
  4021. if (validator) {
  4022. const message = validator(name2, value);
  4023. if (message) {
  4024. return message;
  4025. }
  4026. }
  4027. if (!value) {
  4028. return emptyMessage;
  4029. }
  4030. return true;
  4031. }
  4032. });
  4033. return {
  4034. name: [makeRule("name", t$h("nameEmpty"))],
  4035. tel: [makeRule("tel", t$h("telInvalid")), {
  4036. validator: telValidator,
  4037. message: t$h("telInvalid")
  4038. }],
  4039. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  4040. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))],
  4041. postalCode: [makeRule("addressDetail", t$h("postalEmpty")), {
  4042. validator: postalValidator,
  4043. message: t$h("postalEmpty")
  4044. }]
  4045. };
  4046. });
  4047. const onSave = () => emit("save", data);
  4048. const onChangeDetail = (val) => {
  4049. data.addressDetail = val;
  4050. emit("change-detail", val);
  4051. };
  4052. const onAreaConfirm = (values) => {
  4053. values = values.filter(Boolean);
  4054. if (values.some((value) => !value.code)) {
  4055. Toast(t$h("areaEmpty"));
  4056. } else {
  4057. showAreaPopup.value = false;
  4058. assignAreaValues();
  4059. emit("change-area", values);
  4060. }
  4061. };
  4062. const onDelete = () => emit("delete", data);
  4063. const getArea = () => {
  4064. var _a;
  4065. return ((_a = areaRef.value) == null ? void 0 : _a.getValues()) || [];
  4066. };
  4067. const setAreaCode = (code) => {
  4068. data.areaCode = code || "";
  4069. if (code) {
  4070. vue.nextTick(assignAreaValues);
  4071. }
  4072. };
  4073. const onDetailBlur = () => {
  4074. setTimeout(() => {
  4075. detailFocused.value = false;
  4076. });
  4077. };
  4078. const setAddressDetail = (value) => {
  4079. data.addressDetail = value;
  4080. };
  4081. const renderSetDefaultCell = () => {
  4082. if (props.showSetDefault) {
  4083. const slots2 = {
  4084. "right-icon": () => vue.createVNode(Switch, {
  4085. "modelValue": data.isDefault,
  4086. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  4087. "size": "24",
  4088. "onChange": (event) => emit("change-default", event)
  4089. }, null)
  4090. };
  4091. return vue.withDirectives(vue.createVNode(Cell, {
  4092. "center": true,
  4093. "title": t$h("defaultAddress"),
  4094. "class": bem$17("default")
  4095. }, slots2), [[vue.vShow, !hideBottomFields.value]]);
  4096. }
  4097. };
  4098. useExpose({
  4099. getArea,
  4100. setAreaCode,
  4101. setAddressDetail
  4102. });
  4103. vue.watch(() => props.areaList, () => setAreaCode(data.areaCode));
  4104. vue.watch(() => props.addressInfo, (value) => {
  4105. extend(data, DEFAULT_DATA, value);
  4106. setAreaCode(value.areaCode);
  4107. }, {
  4108. deep: true,
  4109. immediate: true
  4110. });
  4111. return () => {
  4112. const {
  4113. disableArea
  4114. } = props;
  4115. return vue.createVNode(Form, {
  4116. "class": bem$17(),
  4117. "onSubmit": onSave
  4118. }, {
  4119. default: () => {
  4120. var _a;
  4121. return [vue.createVNode("div", {
  4122. "class": bem$17("fields")
  4123. }, [vue.createVNode(Field, {
  4124. "modelValue": data.name,
  4125. "onUpdate:modelValue": ($event) => data.name = $event,
  4126. "clearable": true,
  4127. "label": t$h("name"),
  4128. "rules": rules.value.name,
  4129. "placeholder": t$h("name"),
  4130. "onFocus": () => onFocus("name")
  4131. }, null), vue.createVNode(Field, {
  4132. "modelValue": data.tel,
  4133. "onUpdate:modelValue": ($event) => data.tel = $event,
  4134. "clearable": true,
  4135. "type": "tel",
  4136. "label": t$h("tel"),
  4137. "rules": rules.value.tel,
  4138. "maxlength": props.telMaxlength,
  4139. "placeholder": t$h("tel"),
  4140. "onFocus": () => onFocus("tel")
  4141. }, null), vue.withDirectives(vue.createVNode(Field, {
  4142. "readonly": true,
  4143. "label": t$h("area"),
  4144. "is-link": !disableArea,
  4145. "modelValue": areaText.value,
  4146. "rules": rules.value.areaCode,
  4147. "placeholder": props.areaPlaceholder || t$h("area"),
  4148. "onFocus": () => onFocus("areaCode"),
  4149. "onClick": () => {
  4150. emit("click-area");
  4151. showAreaPopup.value = !disableArea;
  4152. }
  4153. }, null), [[vue.vShow, props.showArea]]), vue.createVNode(stdin_default$1j, {
  4154. "show": props.showDetail,
  4155. "rows": props.detailRows,
  4156. "rules": rules.value.addressDetail,
  4157. "value": data.addressDetail,
  4158. "focused": detailFocused.value,
  4159. "maxlength": props.detailMaxlength,
  4160. "searchResult": props.searchResult,
  4161. "showSearchResult": props.showSearchResult,
  4162. "onBlur": onDetailBlur,
  4163. "onFocus": () => onFocus("addressDetail"),
  4164. "onInput": onChangeDetail,
  4165. "onSelect-search": (event) => emit("select-search", event)
  4166. }, null), props.showPostal && vue.withDirectives(vue.createVNode(Field, {
  4167. "modelValue": data.postalCode,
  4168. "onUpdate:modelValue": ($event) => data.postalCode = $event,
  4169. "type": "tel",
  4170. "rules": rules.value.postalCode,
  4171. "label": t$h("postal"),
  4172. "maxlength": "6",
  4173. "placeholder": t$h("postal"),
  4174. "onFocus": () => onFocus("postalCode")
  4175. }, null), [[vue.vShow, !hideBottomFields.value]]), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
  4176. "class": bem$17("buttons")
  4177. }, [vue.createVNode(Button, {
  4178. "block": true,
  4179. "round": true,
  4180. "type": "danger",
  4181. "text": props.saveButtonText || t$h("save"),
  4182. "class": bem$17("button"),
  4183. "loading": props.isSaving,
  4184. "nativeType": "submit"
  4185. }, null), props.showDelete && vue.createVNode(Button, {
  4186. "block": true,
  4187. "round": true,
  4188. "class": bem$17("button"),
  4189. "loading": props.isDeleting,
  4190. "text": props.deleteButtonText || t$h("delete"),
  4191. "onClick": onDelete
  4192. }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
  4193. "show": showAreaPopup.value,
  4194. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  4195. "round": true,
  4196. "teleport": "body",
  4197. "position": "bottom",
  4198. "lazyRender": false
  4199. }, {
  4200. default: () => [vue.createVNode(Area, {
  4201. "ref": areaRef,
  4202. "value": data.areaCode,
  4203. "loading": !areaListLoaded.value,
  4204. "areaList": props.areaList,
  4205. "columnsPlaceholder": props.areaColumnsPlaceholder,
  4206. "onConfirm": onAreaConfirm,
  4207. "onCancel": () => {
  4208. showAreaPopup.value = false;
  4209. }
  4210. }, null)]
  4211. })];
  4212. }
  4213. });
  4214. };
  4215. }
  4216. });
  4217. const AddressEdit = withInstall(stdin_default$1i);
  4218. const [name$1a, bem$16] = createNamespace("radio-group");
  4219. const radioGroupProps = {
  4220. disabled: Boolean,
  4221. iconSize: numericProp,
  4222. direction: String,
  4223. modelValue: unknownProp,
  4224. checkedColor: String
  4225. };
  4226. const RADIO_KEY = Symbol(name$1a);
  4227. var stdin_default$1h = vue.defineComponent({
  4228. name: name$1a,
  4229. props: radioGroupProps,
  4230. emits: ["change", "update:modelValue"],
  4231. setup(props, {
  4232. emit,
  4233. slots
  4234. }) {
  4235. const {
  4236. linkChildren
  4237. } = useChildren(RADIO_KEY);
  4238. const updateValue = (value) => emit("update:modelValue", value);
  4239. vue.watch(() => props.modelValue, (value) => emit("change", value));
  4240. linkChildren({
  4241. props,
  4242. updateValue
  4243. });
  4244. useCustomFieldValue(() => props.modelValue);
  4245. return () => {
  4246. var _a;
  4247. return vue.createVNode("div", {
  4248. "class": bem$16([props.direction]),
  4249. "role": "radiogroup"
  4250. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  4251. };
  4252. }
  4253. });
  4254. const RadioGroup = withInstall(stdin_default$1h);
  4255. const [name$19, bem$15] = createNamespace("tag");
  4256. const tagProps = {
  4257. size: String,
  4258. mark: Boolean,
  4259. show: truthProp,
  4260. type: makeStringProp("default"),
  4261. color: String,
  4262. plain: Boolean,
  4263. round: Boolean,
  4264. textColor: String,
  4265. closeable: Boolean
  4266. };
  4267. var stdin_default$1g = vue.defineComponent({
  4268. name: name$19,
  4269. props: tagProps,
  4270. emits: ["close"],
  4271. setup(props, {
  4272. slots,
  4273. emit
  4274. }) {
  4275. const onClose = (event) => {
  4276. event.stopPropagation();
  4277. emit("close", event);
  4278. };
  4279. const getStyle = () => {
  4280. if (props.plain) {
  4281. return {
  4282. color: props.textColor || props.color,
  4283. borderColor: props.color
  4284. };
  4285. }
  4286. return {
  4287. color: props.textColor,
  4288. background: props.color
  4289. };
  4290. };
  4291. const renderTag = () => {
  4292. var _a;
  4293. const {
  4294. type,
  4295. mark,
  4296. plain,
  4297. round: round2,
  4298. size,
  4299. closeable
  4300. } = props;
  4301. const classes = {
  4302. mark,
  4303. plain,
  4304. round: round2
  4305. };
  4306. if (size) {
  4307. classes[size] = size;
  4308. }
  4309. const CloseIcon = closeable && vue.createVNode(Icon, {
  4310. "name": "cross",
  4311. "class": [bem$15("close"), HAPTICS_FEEDBACK],
  4312. "onClick": onClose
  4313. }, null);
  4314. return vue.createVNode("span", {
  4315. "style": getStyle(),
  4316. "class": bem$15([classes, type])
  4317. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  4318. };
  4319. return () => vue.createVNode(vue.Transition, {
  4320. "name": props.closeable ? "van-fade" : void 0
  4321. }, {
  4322. default: () => [props.show ? renderTag() : null]
  4323. });
  4324. }
  4325. });
  4326. const Tag = withInstall(stdin_default$1g);
  4327. const checkerProps = {
  4328. name: unknownProp,
  4329. shape: makeStringProp("round"),
  4330. disabled: Boolean,
  4331. iconSize: numericProp,
  4332. modelValue: unknownProp,
  4333. checkedColor: String,
  4334. labelPosition: String,
  4335. labelDisabled: Boolean
  4336. };
  4337. var stdin_default$1f = vue.defineComponent({
  4338. props: extend({}, checkerProps, {
  4339. bem: makeRequiredProp(Function),
  4340. role: String,
  4341. parent: Object,
  4342. checked: Boolean,
  4343. bindGroup: truthProp
  4344. }),
  4345. emits: ["click", "toggle"],
  4346. setup(props, {
  4347. emit,
  4348. slots
  4349. }) {
  4350. const iconRef = vue.ref();
  4351. const getParentProp = (name2) => {
  4352. if (props.parent && props.bindGroup) {
  4353. return props.parent.props[name2];
  4354. }
  4355. };
  4356. const disabled = vue.computed(() => getParentProp("disabled") || props.disabled);
  4357. const direction = vue.computed(() => getParentProp("direction"));
  4358. const iconStyle = vue.computed(() => {
  4359. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  4360. if (checkedColor && props.checked && !disabled.value) {
  4361. return {
  4362. borderColor: checkedColor,
  4363. backgroundColor: checkedColor
  4364. };
  4365. }
  4366. });
  4367. const onClick = (event) => {
  4368. const {
  4369. target
  4370. } = event;
  4371. const icon = iconRef.value;
  4372. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  4373. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  4374. emit("toggle");
  4375. }
  4376. emit("click", event);
  4377. };
  4378. const renderIcon = () => {
  4379. const {
  4380. bem: bem2,
  4381. shape,
  4382. checked
  4383. } = props;
  4384. const iconSize = props.iconSize || getParentProp("iconSize");
  4385. return vue.createVNode("div", {
  4386. "ref": iconRef,
  4387. "class": bem2("icon", [shape, {
  4388. disabled: disabled.value,
  4389. checked
  4390. }]),
  4391. "style": {
  4392. fontSize: addUnit(iconSize)
  4393. }
  4394. }, [slots.icon ? slots.icon({
  4395. checked,
  4396. disabled: disabled.value
  4397. }) : vue.createVNode(Icon, {
  4398. "name": "success",
  4399. "style": iconStyle.value
  4400. }, null)]);
  4401. };
  4402. const renderLabel = () => {
  4403. if (slots.default) {
  4404. return vue.createVNode("span", {
  4405. "class": props.bem("label", [props.labelPosition, {
  4406. disabled: disabled.value
  4407. }])
  4408. }, [slots.default()]);
  4409. }
  4410. };
  4411. return () => {
  4412. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  4413. return vue.createVNode("div", {
  4414. "role": props.role,
  4415. "class": props.bem([{
  4416. disabled: disabled.value,
  4417. "label-disabled": props.labelDisabled
  4418. }, direction.value]),
  4419. "tabindex": disabled.value ? void 0 : 0,
  4420. "aria-checked": props.checked,
  4421. "onClick": onClick
  4422. }, [nodes]);
  4423. };
  4424. }
  4425. });
  4426. const [name$18, bem$14] = createNamespace("radio");
  4427. var stdin_default$1e = vue.defineComponent({
  4428. name: name$18,
  4429. props: checkerProps,
  4430. emits: ["update:modelValue"],
  4431. setup(props, {
  4432. emit,
  4433. slots
  4434. }) {
  4435. const {
  4436. parent
  4437. } = useParent(RADIO_KEY);
  4438. const checked = () => {
  4439. const value = parent ? parent.props.modelValue : props.modelValue;
  4440. return value === props.name;
  4441. };
  4442. const toggle = () => {
  4443. if (parent) {
  4444. parent.updateValue(props.name);
  4445. } else {
  4446. emit("update:modelValue", props.name);
  4447. }
  4448. };
  4449. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  4450. "bem": bem$14,
  4451. "role": "radio",
  4452. "parent": parent,
  4453. "checked": checked(),
  4454. "onToggle": toggle
  4455. }, props), pick(slots, ["default", "icon"]));
  4456. }
  4457. });
  4458. const Radio = withInstall(stdin_default$1e);
  4459. const [name$17, bem$13] = createNamespace("address-item");
  4460. var stdin_default$1d = vue.defineComponent({
  4461. name: name$17,
  4462. props: {
  4463. address: makeRequiredProp(Object),
  4464. disabled: Boolean,
  4465. switchable: Boolean,
  4466. defaultTagText: String
  4467. },
  4468. emits: ["edit", "click", "select"],
  4469. setup(props, {
  4470. slots,
  4471. emit
  4472. }) {
  4473. const onClick = () => {
  4474. if (props.switchable) {
  4475. emit("select");
  4476. }
  4477. emit("click");
  4478. };
  4479. const renderRightIcon = () => vue.createVNode(Icon, {
  4480. "name": "edit",
  4481. "class": bem$13("edit"),
  4482. "onClick": (event) => {
  4483. event.stopPropagation();
  4484. emit("edit");
  4485. emit("click");
  4486. }
  4487. }, null);
  4488. const renderTag = () => {
  4489. if (slots.tag) {
  4490. return slots.tag(props.address);
  4491. }
  4492. if (props.address.isDefault && props.defaultTagText) {
  4493. return vue.createVNode(Tag, {
  4494. "type": "danger",
  4495. "round": true,
  4496. "class": bem$13("tag")
  4497. }, {
  4498. default: () => [props.defaultTagText]
  4499. });
  4500. }
  4501. };
  4502. const renderContent = () => {
  4503. const {
  4504. address,
  4505. disabled,
  4506. switchable
  4507. } = props;
  4508. const Info = [vue.createVNode("div", {
  4509. "class": bem$13("name")
  4510. }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
  4511. "class": bem$13("address")
  4512. }, [address.address])];
  4513. if (switchable && !disabled) {
  4514. return vue.createVNode(Radio, {
  4515. "name": address.id,
  4516. "iconSize": 18
  4517. }, {
  4518. default: () => [Info]
  4519. });
  4520. }
  4521. return Info;
  4522. };
  4523. return () => {
  4524. var _a;
  4525. const {
  4526. disabled
  4527. } = props;
  4528. return vue.createVNode("div", {
  4529. "class": bem$13({
  4530. disabled
  4531. }),
  4532. "onClick": onClick
  4533. }, [vue.createVNode(Cell, {
  4534. "border": false,
  4535. "valueClass": bem$13("value")
  4536. }, {
  4537. value: renderContent,
  4538. "right-icon": renderRightIcon
  4539. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  4540. disabled
  4541. }))]);
  4542. };
  4543. }
  4544. });
  4545. const [name$16, bem$12, t$g] = createNamespace("address-list");
  4546. const addressListProps = {
  4547. list: makeArrayProp(),
  4548. modelValue: numericProp,
  4549. switchable: truthProp,
  4550. disabledText: String,
  4551. disabledList: makeArrayProp(),
  4552. addButtonText: String,
  4553. defaultTagText: String
  4554. };
  4555. var stdin_default$1c = vue.defineComponent({
  4556. name: name$16,
  4557. props: addressListProps,
  4558. emits: ["add", "edit", "select", "click-item", "edit-disabled", "select-disabled", "update:modelValue"],
  4559. setup(props, {
  4560. slots,
  4561. emit
  4562. }) {
  4563. const renderItem = (item, index, disabled) => {
  4564. const onEdit = () => emit(disabled ? "edit-disabled" : "edit", item, index);
  4565. const onClick = () => emit("click-item", item, index);
  4566. const onSelect = () => {
  4567. emit(disabled ? "select-disabled" : "select", item, index);
  4568. if (!disabled) {
  4569. emit("update:modelValue", item.id);
  4570. }
  4571. };
  4572. return vue.createVNode(stdin_default$1d, {
  4573. "key": item.id,
  4574. "address": item,
  4575. "disabled": disabled,
  4576. "switchable": props.switchable,
  4577. "defaultTagText": props.defaultTagText,
  4578. "onEdit": onEdit,
  4579. "onClick": onClick,
  4580. "onSelect": onSelect
  4581. }, {
  4582. bottom: slots["item-bottom"],
  4583. tag: slots.tag
  4584. });
  4585. };
  4586. const renderList = (list, disabled) => {
  4587. if (list) {
  4588. return list.map((item, index) => renderItem(item, index, disabled));
  4589. }
  4590. };
  4591. const renderBottom = () => vue.createVNode("div", {
  4592. "class": [bem$12("bottom"), "van-safe-area-bottom"]
  4593. }, [vue.createVNode(Button, {
  4594. "round": true,
  4595. "block": true,
  4596. "type": "danger",
  4597. "text": props.addButtonText || t$g("add"),
  4598. "class": bem$12("add"),
  4599. "onClick": () => emit("add")
  4600. }, null)]);
  4601. return () => {
  4602. var _a, _b;
  4603. const List2 = renderList(props.list);
  4604. const DisabledList = renderList(props.disabledList, true);
  4605. const DisabledText = props.disabledText && vue.createVNode("div", {
  4606. "class": bem$12("disabled-text")
  4607. }, [props.disabledText]);
  4608. return vue.createVNode("div", {
  4609. "class": bem$12()
  4610. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), vue.createVNode(RadioGroup, {
  4611. "modelValue": props.modelValue
  4612. }, {
  4613. default: () => [List2]
  4614. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  4615. };
  4616. }
  4617. });
  4618. const AddressList = withInstall(stdin_default$1c);
  4619. const [name$15, bem$11, t$f] = createNamespace("calendar");
  4620. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  4621. function compareMonth(date1, date2) {
  4622. const year1 = date1.getFullYear();
  4623. const year2 = date2.getFullYear();
  4624. if (year1 === year2) {
  4625. const month1 = date1.getMonth();
  4626. const month2 = date2.getMonth();
  4627. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  4628. }
  4629. return year1 > year2 ? 1 : -1;
  4630. }
  4631. function compareDay(day1, day2) {
  4632. const compareMonthResult = compareMonth(day1, day2);
  4633. if (compareMonthResult === 0) {
  4634. const date1 = day1.getDate();
  4635. const date2 = day2.getDate();
  4636. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  4637. }
  4638. return compareMonthResult;
  4639. }
  4640. const cloneDate = (date) => new Date(date);
  4641. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  4642. function getDayByOffset(date, offset2) {
  4643. const cloned = cloneDate(date);
  4644. cloned.setDate(cloned.getDate() + offset2);
  4645. return cloned;
  4646. }
  4647. const getPrevDay = (date) => getDayByOffset(date, -1);
  4648. const getNextDay = (date) => getDayByOffset(date, 1);
  4649. const getToday = () => {
  4650. const today = new Date();
  4651. today.setHours(0, 0, 0, 0);
  4652. return today;
  4653. };
  4654. function calcDateNum(date) {
  4655. const day1 = date[0].getTime();
  4656. const day2 = date[1].getTime();
  4657. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  4658. }
  4659. function useRefs() {
  4660. const refs = vue.ref([]);
  4661. const cache = [];
  4662. vue.onBeforeUpdate(() => {
  4663. refs.value = [];
  4664. });
  4665. const setRefs = (index) => {
  4666. if (!cache[index]) {
  4667. cache[index] = (el) => {
  4668. refs.value[index] = el;
  4669. };
  4670. }
  4671. return cache[index];
  4672. };
  4673. return [refs, setRefs];
  4674. }
  4675. const sharedProps = extend({}, pickerSharedProps, {
  4676. filter: Function,
  4677. columnsOrder: Array,
  4678. formatter: {
  4679. type: Function,
  4680. default: (type, value) => value
  4681. }
  4682. });
  4683. const pickerInheritKeys = Object.keys(pickerSharedProps);
  4684. function times(n, iteratee) {
  4685. if (n < 0) {
  4686. return [];
  4687. }
  4688. const result = Array(n);
  4689. let index = -1;
  4690. while (++index < n) {
  4691. result[index] = iteratee(index);
  4692. }
  4693. return result;
  4694. }
  4695. function getTrueValue(value) {
  4696. if (!value) {
  4697. return 0;
  4698. }
  4699. while (Number.isNaN(parseInt(value, 10))) {
  4700. if (value.length > 1) {
  4701. value = value.slice(1);
  4702. } else {
  4703. return 0;
  4704. }
  4705. }
  4706. return parseInt(value, 10);
  4707. }
  4708. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  4709. const proxyPickerMethods = (picker, callback) => {
  4710. const methods = [
  4711. "setValues",
  4712. "setIndexes",
  4713. "setColumnIndex",
  4714. "setColumnValue"
  4715. ];
  4716. return new Proxy(picker, {
  4717. get: (target, prop) => {
  4718. if (methods.includes(prop)) {
  4719. return (...args) => {
  4720. target[prop](...args);
  4721. callback();
  4722. };
  4723. }
  4724. return target[prop];
  4725. }
  4726. });
  4727. };
  4728. const [name$14] = createNamespace("calendar-day");
  4729. var stdin_default$1b = vue.defineComponent({
  4730. name: name$14,
  4731. props: {
  4732. item: makeRequiredProp(Object),
  4733. color: String,
  4734. index: Number,
  4735. offset: makeNumberProp(0),
  4736. rowHeight: String
  4737. },
  4738. emits: ["click"],
  4739. setup(props, {
  4740. emit,
  4741. slots
  4742. }) {
  4743. const style = vue.computed(() => {
  4744. var _a;
  4745. const {
  4746. item,
  4747. index,
  4748. color,
  4749. offset: offset2,
  4750. rowHeight
  4751. } = props;
  4752. const style2 = {
  4753. height: rowHeight
  4754. };
  4755. if (item.type === "placeholder") {
  4756. style2.width = "100%";
  4757. return style2;
  4758. }
  4759. if (index === 0) {
  4760. style2.marginLeft = `${100 * offset2 / 7}%`;
  4761. }
  4762. if (color) {
  4763. switch (item.type) {
  4764. case "end":
  4765. case "start":
  4766. case "start-end":
  4767. case "multiple-middle":
  4768. case "multiple-selected":
  4769. style2.background = color;
  4770. break;
  4771. case "middle":
  4772. style2.color = color;
  4773. break;
  4774. }
  4775. }
  4776. if (offset2 + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  4777. style2.marginBottom = 0;
  4778. }
  4779. return style2;
  4780. });
  4781. const onClick = () => {
  4782. if (props.item.type !== "disabled") {
  4783. emit("click", props.item);
  4784. }
  4785. };
  4786. const renderTopInfo = () => {
  4787. const {
  4788. topInfo
  4789. } = props.item;
  4790. if (topInfo || slots["top-info"]) {
  4791. return vue.createVNode("div", {
  4792. "class": bem$11("top-info")
  4793. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  4794. }
  4795. };
  4796. const renderBottomInfo = () => {
  4797. const {
  4798. bottomInfo
  4799. } = props.item;
  4800. if (bottomInfo || slots["bottom-info"]) {
  4801. return vue.createVNode("div", {
  4802. "class": bem$11("bottom-info")
  4803. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  4804. }
  4805. };
  4806. const renderContent = () => {
  4807. const {
  4808. item,
  4809. color,
  4810. rowHeight
  4811. } = props;
  4812. const {
  4813. type,
  4814. text
  4815. } = item;
  4816. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  4817. if (type === "selected") {
  4818. return vue.createVNode("div", {
  4819. "class": bem$11("selected-day"),
  4820. "style": {
  4821. width: rowHeight,
  4822. height: rowHeight,
  4823. background: color
  4824. }
  4825. }, [Nodes]);
  4826. }
  4827. return Nodes;
  4828. };
  4829. return () => {
  4830. const {
  4831. type,
  4832. className
  4833. } = props.item;
  4834. if (type === "placeholder") {
  4835. return vue.createVNode("div", {
  4836. "class": bem$11("day"),
  4837. "style": style.value
  4838. }, null);
  4839. }
  4840. return vue.createVNode("div", {
  4841. "role": "gridcell",
  4842. "style": style.value,
  4843. "class": [bem$11("day", type), className],
  4844. "tabindex": type === "disabled" ? void 0 : -1,
  4845. "onClick": onClick
  4846. }, [renderContent()]);
  4847. };
  4848. }
  4849. });
  4850. const [name$13] = createNamespace("calendar-month");
  4851. const calendarMonthProps = {
  4852. date: makeRequiredProp(Date),
  4853. type: String,
  4854. color: String,
  4855. minDate: makeRequiredProp(Date),
  4856. maxDate: makeRequiredProp(Date),
  4857. showMark: Boolean,
  4858. rowHeight: numericProp,
  4859. formatter: Function,
  4860. lazyRender: Boolean,
  4861. currentDate: [Date, Array],
  4862. allowSameDay: Boolean,
  4863. showSubtitle: Boolean,
  4864. showMonthTitle: Boolean,
  4865. firstDayOfWeek: Number
  4866. };
  4867. var stdin_default$1a = vue.defineComponent({
  4868. name: name$13,
  4869. props: calendarMonthProps,
  4870. emits: ["click", "update-height"],
  4871. setup(props, {
  4872. emit,
  4873. slots
  4874. }) {
  4875. const [visible, setVisible] = useToggle();
  4876. const daysRef = vue.ref();
  4877. const monthRef = vue.ref();
  4878. const height2 = useHeight(monthRef);
  4879. const title = vue.computed(() => formatMonthTitle(props.date));
  4880. const rowHeight = vue.computed(() => addUnit(props.rowHeight));
  4881. const offset2 = vue.computed(() => {
  4882. const realDay = props.date.getDay();
  4883. if (props.firstDayOfWeek) {
  4884. return (realDay + 7 - props.firstDayOfWeek) % 7;
  4885. }
  4886. return realDay;
  4887. });
  4888. const totalDay = vue.computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  4889. const shouldRender = vue.computed(() => visible.value || !props.lazyRender);
  4890. const getTitle = () => title.value;
  4891. const getMultipleDayType = (day) => {
  4892. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  4893. if (isSelected(day)) {
  4894. const prevDay = getPrevDay(day);
  4895. const nextDay = getNextDay(day);
  4896. const prevSelected = isSelected(prevDay);
  4897. const nextSelected = isSelected(nextDay);
  4898. if (prevSelected && nextSelected) {
  4899. return "multiple-middle";
  4900. }
  4901. if (prevSelected) {
  4902. return "end";
  4903. }
  4904. if (nextSelected) {
  4905. return "start";
  4906. }
  4907. return "multiple-selected";
  4908. }
  4909. return "";
  4910. };
  4911. const getRangeDayType = (day) => {
  4912. const [startDay, endDay] = props.currentDate;
  4913. if (!startDay) {
  4914. return "";
  4915. }
  4916. const compareToStart = compareDay(day, startDay);
  4917. if (!endDay) {
  4918. return compareToStart === 0 ? "start" : "";
  4919. }
  4920. const compareToEnd = compareDay(day, endDay);
  4921. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  4922. return "start-end";
  4923. }
  4924. if (compareToStart === 0) {
  4925. return "start";
  4926. }
  4927. if (compareToEnd === 0) {
  4928. return "end";
  4929. }
  4930. if (compareToStart > 0 && compareToEnd < 0) {
  4931. return "middle";
  4932. }
  4933. return "";
  4934. };
  4935. const getDayType = (day) => {
  4936. const {
  4937. type,
  4938. minDate,
  4939. maxDate,
  4940. currentDate
  4941. } = props;
  4942. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  4943. return "disabled";
  4944. }
  4945. if (currentDate === null) {
  4946. return "";
  4947. }
  4948. if (Array.isArray(currentDate)) {
  4949. if (type === "multiple") {
  4950. return getMultipleDayType(day);
  4951. }
  4952. if (type === "range") {
  4953. return getRangeDayType(day);
  4954. }
  4955. } else if (type === "single") {
  4956. return compareDay(day, currentDate) === 0 ? "selected" : "";
  4957. }
  4958. return "";
  4959. };
  4960. const getBottomInfo = (dayType) => {
  4961. if (props.type === "range") {
  4962. if (dayType === "start" || dayType === "end") {
  4963. return t$f(dayType);
  4964. }
  4965. if (dayType === "start-end") {
  4966. return `${t$f("start")}/${t$f("end")}`;
  4967. }
  4968. }
  4969. };
  4970. const renderTitle = () => {
  4971. if (props.showMonthTitle) {
  4972. return vue.createVNode("div", {
  4973. "class": bem$11("month-title")
  4974. }, [title.value]);
  4975. }
  4976. };
  4977. const renderMark = () => {
  4978. if (props.showMark && shouldRender.value) {
  4979. return vue.createVNode("div", {
  4980. "class": bem$11("month-mark")
  4981. }, [props.date.getMonth() + 1]);
  4982. }
  4983. };
  4984. const placeholders = vue.computed(() => {
  4985. const count = Math.ceil((totalDay.value + offset2.value) / 7);
  4986. return Array(count).fill({
  4987. type: "placeholder"
  4988. });
  4989. });
  4990. const days = vue.computed(() => {
  4991. const days2 = [];
  4992. const year = props.date.getFullYear();
  4993. const month = props.date.getMonth();
  4994. for (let day = 1; day <= totalDay.value; day++) {
  4995. const date = new Date(year, month, day);
  4996. const type = getDayType(date);
  4997. let config = {
  4998. date,
  4999. type,
  5000. text: day,
  5001. bottomInfo: getBottomInfo(type)
  5002. };
  5003. if (props.formatter) {
  5004. config = props.formatter(config);
  5005. }
  5006. days2.push(config);
  5007. }
  5008. return days2;
  5009. });
  5010. const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
  5011. const scrollToDate = (body, targetDate) => {
  5012. if (daysRef.value) {
  5013. const daysRect = useRect(daysRef.value);
  5014. const totalRows = placeholders.value.length;
  5015. const currentRow = Math.ceil((targetDate.getDate() + offset2.value) / 7);
  5016. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  5017. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
  5018. }
  5019. };
  5020. const renderDay = (item, index) => vue.createVNode(stdin_default$1b, {
  5021. "item": item,
  5022. "index": index,
  5023. "color": props.color,
  5024. "offset": offset2.value,
  5025. "rowHeight": rowHeight.value,
  5026. "onClick": (item2) => emit("click", item2)
  5027. }, pick(slots, ["top-info", "bottom-info"]));
  5028. const renderDays = () => vue.createVNode("div", {
  5029. "ref": daysRef,
  5030. "role": "grid",
  5031. "class": bem$11("days")
  5032. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  5033. useExpose({
  5034. getTitle,
  5035. getHeight: () => height2.value,
  5036. setVisible,
  5037. scrollToDate,
  5038. disabledDays
  5039. });
  5040. return () => vue.createVNode("div", {
  5041. "class": bem$11("month"),
  5042. "ref": monthRef
  5043. }, [renderTitle(), renderDays()]);
  5044. }
  5045. });
  5046. const [name$12] = createNamespace("calendar-header");
  5047. var stdin_default$19 = vue.defineComponent({
  5048. name: name$12,
  5049. props: {
  5050. title: String,
  5051. subtitle: String,
  5052. showTitle: Boolean,
  5053. showSubtitle: Boolean,
  5054. firstDayOfWeek: Number
  5055. },
  5056. emits: ["click-subtitle"],
  5057. setup(props, {
  5058. slots,
  5059. emit
  5060. }) {
  5061. const renderTitle = () => {
  5062. if (props.showTitle) {
  5063. const text = props.title || t$f("title");
  5064. const title = slots.title ? slots.title() : text;
  5065. return vue.createVNode("div", {
  5066. "class": bem$11("header-title")
  5067. }, [title]);
  5068. }
  5069. };
  5070. const onClickSubtitle = (event) => emit("click-subtitle", event);
  5071. const renderSubtitle = () => {
  5072. if (props.showSubtitle) {
  5073. const title = slots.subtitle ? slots.subtitle() : props.subtitle;
  5074. return vue.createVNode("div", {
  5075. "class": bem$11("header-subtitle"),
  5076. "onClick": onClickSubtitle
  5077. }, [title]);
  5078. }
  5079. };
  5080. const renderWeekDays = () => {
  5081. const {
  5082. firstDayOfWeek
  5083. } = props;
  5084. const weekdays = t$f("weekdays");
  5085. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  5086. return vue.createVNode("div", {
  5087. "class": bem$11("weekdays")
  5088. }, [renderWeekDays2.map((text) => vue.createVNode("span", {
  5089. "class": bem$11("weekday")
  5090. }, [text]))]);
  5091. };
  5092. return () => vue.createVNode("div", {
  5093. "class": bem$11("header")
  5094. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  5095. }
  5096. });
  5097. const calendarProps = {
  5098. show: Boolean,
  5099. type: makeStringProp("single"),
  5100. title: String,
  5101. color: String,
  5102. round: truthProp,
  5103. readonly: Boolean,
  5104. poppable: truthProp,
  5105. maxRange: makeNumericProp(null),
  5106. position: makeStringProp("bottom"),
  5107. teleport: [String, Object],
  5108. showMark: truthProp,
  5109. showTitle: truthProp,
  5110. formatter: Function,
  5111. rowHeight: numericProp,
  5112. confirmText: String,
  5113. rangePrompt: String,
  5114. lazyRender: truthProp,
  5115. showConfirm: truthProp,
  5116. defaultDate: [Date, Array],
  5117. allowSameDay: Boolean,
  5118. showSubtitle: truthProp,
  5119. closeOnPopstate: truthProp,
  5120. showRangePrompt: truthProp,
  5121. confirmDisabledText: String,
  5122. closeOnClickOverlay: truthProp,
  5123. safeAreaInsetTop: Boolean,
  5124. safeAreaInsetBottom: truthProp,
  5125. minDate: {
  5126. type: Date,
  5127. validator: isDate,
  5128. default: getToday
  5129. },
  5130. maxDate: {
  5131. type: Date,
  5132. validator: isDate,
  5133. default: () => {
  5134. const now = getToday();
  5135. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  5136. }
  5137. },
  5138. firstDayOfWeek: {
  5139. type: numericProp,
  5140. default: 0,
  5141. validator: (val) => val >= 0 && val <= 6
  5142. }
  5143. };
  5144. var stdin_default$18 = vue.defineComponent({
  5145. name: name$15,
  5146. props: calendarProps,
  5147. emits: ["select", "confirm", "unselect", "month-show", "over-range", "update:show", "click-subtitle"],
  5148. setup(props, {
  5149. emit,
  5150. slots
  5151. }) {
  5152. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  5153. if (compareDay(date, minDate) === -1) {
  5154. return minDate;
  5155. }
  5156. if (compareDay(date, maxDate) === 1) {
  5157. return maxDate;
  5158. }
  5159. return date;
  5160. };
  5161. const getInitialDate = (defaultDate = props.defaultDate) => {
  5162. const {
  5163. type,
  5164. minDate,
  5165. maxDate,
  5166. allowSameDay
  5167. } = props;
  5168. if (defaultDate === null) {
  5169. return defaultDate;
  5170. }
  5171. const now = getToday();
  5172. if (type === "range") {
  5173. if (!Array.isArray(defaultDate)) {
  5174. defaultDate = [];
  5175. }
  5176. const start2 = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  5177. const end2 = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  5178. return [start2, end2];
  5179. }
  5180. if (type === "multiple") {
  5181. if (Array.isArray(defaultDate)) {
  5182. return defaultDate.map((date) => limitDateRange(date));
  5183. }
  5184. return [limitDateRange(now)];
  5185. }
  5186. if (!defaultDate || Array.isArray(defaultDate)) {
  5187. defaultDate = now;
  5188. }
  5189. return limitDateRange(defaultDate);
  5190. };
  5191. let bodyHeight;
  5192. const bodyRef = vue.ref();
  5193. const subtitle = vue.ref("");
  5194. const currentDate = vue.ref(getInitialDate());
  5195. const [monthRefs, setMonthRefs] = useRefs();
  5196. const dayOffset = vue.computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  5197. const months = vue.computed(() => {
  5198. const months2 = [];
  5199. const cursor = new Date(props.minDate);
  5200. cursor.setDate(1);
  5201. do {
  5202. months2.push(new Date(cursor));
  5203. cursor.setMonth(cursor.getMonth() + 1);
  5204. } while (compareMonth(cursor, props.maxDate) !== 1);
  5205. return months2;
  5206. });
  5207. const buttonDisabled = vue.computed(() => {
  5208. if (currentDate.value) {
  5209. if (props.type === "range") {
  5210. return !currentDate.value[0] || !currentDate.value[1];
  5211. }
  5212. if (props.type === "multiple") {
  5213. return !currentDate.value.length;
  5214. }
  5215. }
  5216. return !currentDate.value;
  5217. });
  5218. const getSelectedDate = () => currentDate.value;
  5219. const onScroll = () => {
  5220. const top2 = getScrollTop(bodyRef.value);
  5221. const bottom2 = top2 + bodyHeight;
  5222. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  5223. const heightSum = heights.reduce((a, b) => a + b, 0);
  5224. if (bottom2 > heightSum && top2 > 0) {
  5225. return;
  5226. }
  5227. let height2 = 0;
  5228. let currentMonth;
  5229. const visibleRange = [-1, -1];
  5230. for (let i = 0; i < months.value.length; i++) {
  5231. const month = monthRefs.value[i];
  5232. const visible = height2 <= bottom2 && height2 + heights[i] >= top2;
  5233. if (visible) {
  5234. visibleRange[1] = i;
  5235. if (!currentMonth) {
  5236. currentMonth = month;
  5237. visibleRange[0] = i;
  5238. }
  5239. if (!monthRefs.value[i].showed) {
  5240. monthRefs.value[i].showed = true;
  5241. emit("month-show", {
  5242. date: month.date,
  5243. title: month.getTitle()
  5244. });
  5245. }
  5246. }
  5247. height2 += heights[i];
  5248. }
  5249. months.value.forEach((month, index) => {
  5250. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  5251. monthRefs.value[index].setVisible(visible);
  5252. });
  5253. if (currentMonth) {
  5254. subtitle.value = currentMonth.getTitle();
  5255. }
  5256. };
  5257. const scrollToDate = (targetDate) => {
  5258. raf(() => {
  5259. months.value.some((month, index) => {
  5260. if (compareMonth(month, targetDate) === 0) {
  5261. if (bodyRef.value) {
  5262. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  5263. }
  5264. return true;
  5265. }
  5266. return false;
  5267. });
  5268. onScroll();
  5269. });
  5270. };
  5271. const scrollToCurrentDate = () => {
  5272. if (props.poppable && !props.show) {
  5273. return;
  5274. }
  5275. if (currentDate.value) {
  5276. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  5277. if (isDate(targetDate)) {
  5278. scrollToDate(targetDate);
  5279. }
  5280. } else {
  5281. raf(onScroll);
  5282. }
  5283. };
  5284. const init = () => {
  5285. if (props.poppable && !props.show) {
  5286. return;
  5287. }
  5288. raf(() => {
  5289. bodyHeight = Math.floor(useRect(bodyRef).height);
  5290. });
  5291. scrollToCurrentDate();
  5292. };
  5293. const reset = (date = getInitialDate()) => {
  5294. currentDate.value = date;
  5295. scrollToCurrentDate();
  5296. };
  5297. const checkRange = (date) => {
  5298. const {
  5299. maxRange,
  5300. rangePrompt,
  5301. showRangePrompt
  5302. } = props;
  5303. if (maxRange && calcDateNum(date) > maxRange) {
  5304. if (showRangePrompt) {
  5305. Toast(rangePrompt || t$f("rangePrompt", maxRange));
  5306. }
  5307. emit("over-range");
  5308. return false;
  5309. }
  5310. return true;
  5311. };
  5312. const onConfirm = () => {
  5313. var _a;
  5314. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  5315. };
  5316. const select = (date, complete) => {
  5317. const setCurrentDate = (date2) => {
  5318. currentDate.value = date2;
  5319. emit("select", cloneDates(date2));
  5320. };
  5321. if (complete && props.type === "range") {
  5322. const valid = checkRange(date);
  5323. if (!valid) {
  5324. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  5325. return;
  5326. }
  5327. }
  5328. setCurrentDate(date);
  5329. if (complete && !props.showConfirm) {
  5330. onConfirm();
  5331. }
  5332. };
  5333. const getDisabledDate = (disabledDays2, startDay, date) => {
  5334. var _a;
  5335. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  5336. };
  5337. const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
  5338. var _a, _b;
  5339. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  5340. return arr;
  5341. }, []));
  5342. const onClickDay = (item) => {
  5343. if (props.readonly || !item.date) {
  5344. return;
  5345. }
  5346. const {
  5347. date
  5348. } = item;
  5349. const {
  5350. type
  5351. } = props;
  5352. if (type === "range") {
  5353. if (!currentDate.value) {
  5354. select([date]);
  5355. return;
  5356. }
  5357. const [startDay, endDay] = currentDate.value;
  5358. if (startDay && !endDay) {
  5359. const compareToStart = compareDay(date, startDay);
  5360. if (compareToStart === 1) {
  5361. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  5362. if (disabledDay) {
  5363. const endDay2 = getPrevDay(disabledDay);
  5364. if (compareDay(startDay, endDay2) === -1) {
  5365. select([startDay, endDay2]);
  5366. } else {
  5367. select([date]);
  5368. }
  5369. } else {
  5370. select([startDay, date], true);
  5371. }
  5372. } else if (compareToStart === -1) {
  5373. select([date]);
  5374. } else if (props.allowSameDay) {
  5375. select([date, date], true);
  5376. }
  5377. } else {
  5378. select([date]);
  5379. }
  5380. } else if (type === "multiple") {
  5381. if (!currentDate.value) {
  5382. select([date]);
  5383. return;
  5384. }
  5385. const dates = currentDate.value;
  5386. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  5387. if (selectedIndex !== -1) {
  5388. const [unselectedDate] = dates.splice(selectedIndex, 1);
  5389. emit("unselect", cloneDate(unselectedDate));
  5390. } else if (props.maxRange && dates.length >= props.maxRange) {
  5391. Toast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  5392. } else {
  5393. select([...dates, date]);
  5394. }
  5395. } else {
  5396. select(date, true);
  5397. }
  5398. };
  5399. const updateShow = (value) => emit("update:show", value);
  5400. const renderMonth = (date, index) => {
  5401. const showMonthTitle = index !== 0 || !props.showSubtitle;
  5402. return vue.createVNode(stdin_default$1a, vue.mergeProps({
  5403. "ref": setMonthRefs(index),
  5404. "date": date,
  5405. "currentDate": currentDate.value,
  5406. "showMonthTitle": showMonthTitle,
  5407. "firstDayOfWeek": dayOffset.value
  5408. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  5409. "onClick": onClickDay
  5410. }), pick(slots, ["top-info", "bottom-info"]));
  5411. };
  5412. const renderFooterButton = () => {
  5413. if (slots.footer) {
  5414. return slots.footer();
  5415. }
  5416. if (props.showConfirm) {
  5417. const slot = slots["confirm-text"];
  5418. const disabled = buttonDisabled.value;
  5419. const text = disabled ? props.confirmDisabledText : props.confirmText;
  5420. return vue.createVNode(Button, {
  5421. "round": true,
  5422. "block": true,
  5423. "type": "danger",
  5424. "color": props.color,
  5425. "class": bem$11("confirm"),
  5426. "disabled": disabled,
  5427. "nativeType": "button",
  5428. "onClick": onConfirm
  5429. }, {
  5430. default: () => [slot ? slot({
  5431. disabled
  5432. }) : text || t$f("confirm")]
  5433. });
  5434. }
  5435. };
  5436. const renderFooter = () => vue.createVNode("div", {
  5437. "class": [bem$11("footer"), {
  5438. "van-safe-area-bottom": props.safeAreaInsetBottom
  5439. }]
  5440. }, [renderFooterButton()]);
  5441. const renderCalendar = () => vue.createVNode("div", {
  5442. "class": bem$11()
  5443. }, [vue.createVNode(stdin_default$19, {
  5444. "title": props.title,
  5445. "subtitle": subtitle.value,
  5446. "showTitle": props.showTitle,
  5447. "showSubtitle": props.showSubtitle,
  5448. "firstDayOfWeek": dayOffset.value,
  5449. "onClick-subtitle": (event) => emit("click-subtitle", event)
  5450. }, pick(slots, ["title", "subtitle"])), vue.createVNode("div", {
  5451. "ref": bodyRef,
  5452. "class": bem$11("body"),
  5453. "onScroll": onScroll
  5454. }, [months.value.map(renderMonth)]), renderFooter()]);
  5455. vue.watch(() => props.show, init);
  5456. vue.watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  5457. vue.watch(() => props.defaultDate, (value = null) => {
  5458. currentDate.value = value;
  5459. scrollToCurrentDate();
  5460. });
  5461. useExpose({
  5462. reset,
  5463. scrollToDate,
  5464. getSelectedDate
  5465. });
  5466. onMountedOrActivated(init);
  5467. return () => {
  5468. if (props.poppable) {
  5469. return vue.createVNode(Popup, {
  5470. "show": props.show,
  5471. "class": bem$11("popup"),
  5472. "round": props.round,
  5473. "position": props.position,
  5474. "closeable": props.showTitle || props.showSubtitle,
  5475. "teleport": props.teleport,
  5476. "closeOnPopstate": props.closeOnPopstate,
  5477. "safeAreaInsetTop": props.safeAreaInsetTop,
  5478. "closeOnClickOverlay": props.closeOnClickOverlay,
  5479. "onUpdate:show": updateShow
  5480. }, {
  5481. default: renderCalendar
  5482. });
  5483. }
  5484. return renderCalendar();
  5485. };
  5486. }
  5487. });
  5488. const Calendar = withInstall(stdin_default$18);
  5489. const [name$11, bem$10] = createNamespace("image");
  5490. const imageProps = {
  5491. src: String,
  5492. alt: String,
  5493. fit: String,
  5494. position: String,
  5495. round: Boolean,
  5496. block: Boolean,
  5497. width: numericProp,
  5498. height: numericProp,
  5499. radius: numericProp,
  5500. lazyLoad: Boolean,
  5501. iconSize: numericProp,
  5502. showError: truthProp,
  5503. errorIcon: makeStringProp("photo-fail"),
  5504. iconPrefix: String,
  5505. showLoading: truthProp,
  5506. loadingIcon: makeStringProp("photo")
  5507. };
  5508. var stdin_default$17 = vue.defineComponent({
  5509. name: name$11,
  5510. props: imageProps,
  5511. emits: ["load", "error"],
  5512. setup(props, {
  5513. emit,
  5514. slots
  5515. }) {
  5516. const error = vue.ref(false);
  5517. const loading = vue.ref(true);
  5518. const imageRef = vue.ref();
  5519. const {
  5520. $Lazyload
  5521. } = vue.getCurrentInstance().proxy;
  5522. const style = vue.computed(() => {
  5523. const style2 = {
  5524. width: addUnit(props.width),
  5525. height: addUnit(props.height)
  5526. };
  5527. if (isDef(props.radius)) {
  5528. style2.overflow = "hidden";
  5529. style2.borderRadius = addUnit(props.radius);
  5530. }
  5531. return style2;
  5532. });
  5533. vue.watch(() => props.src, () => {
  5534. error.value = false;
  5535. loading.value = true;
  5536. });
  5537. const onLoad = (event) => {
  5538. loading.value = false;
  5539. emit("load", event);
  5540. };
  5541. const onError = (event) => {
  5542. error.value = true;
  5543. loading.value = false;
  5544. emit("error", event);
  5545. };
  5546. const renderIcon = (name2, className, slot) => {
  5547. if (slot) {
  5548. return slot();
  5549. }
  5550. return vue.createVNode(Icon, {
  5551. "name": name2,
  5552. "size": props.iconSize,
  5553. "class": className,
  5554. "classPrefix": props.iconPrefix
  5555. }, null);
  5556. };
  5557. const renderPlaceholder = () => {
  5558. if (loading.value && props.showLoading) {
  5559. return vue.createVNode("div", {
  5560. "class": bem$10("loading")
  5561. }, [renderIcon(props.loadingIcon, bem$10("loading-icon"), slots.loading)]);
  5562. }
  5563. if (error.value && props.showError) {
  5564. return vue.createVNode("div", {
  5565. "class": bem$10("error")
  5566. }, [renderIcon(props.errorIcon, bem$10("error-icon"), slots.error)]);
  5567. }
  5568. };
  5569. const renderImage = () => {
  5570. if (error.value || !props.src) {
  5571. return;
  5572. }
  5573. const attrs = {
  5574. alt: props.alt,
  5575. class: bem$10("img"),
  5576. style: {
  5577. objectFit: props.fit,
  5578. objectPosition: props.position
  5579. }
  5580. };
  5581. if (props.lazyLoad) {
  5582. return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
  5583. "ref": imageRef
  5584. }, attrs), null), [[vue.resolveDirective("lazy"), props.src]]);
  5585. }
  5586. return vue.createVNode("img", vue.mergeProps({
  5587. "src": props.src,
  5588. "onLoad": onLoad,
  5589. "onError": onError
  5590. }, attrs), null);
  5591. };
  5592. const onLazyLoaded = ({
  5593. el
  5594. }) => {
  5595. const check = () => {
  5596. if (el === imageRef.value && loading.value) {
  5597. onLoad();
  5598. }
  5599. };
  5600. if (imageRef.value) {
  5601. check();
  5602. } else {
  5603. vue.nextTick(check);
  5604. }
  5605. };
  5606. const onLazyLoadError = ({
  5607. el
  5608. }) => {
  5609. if (el === imageRef.value && !error.value) {
  5610. onError();
  5611. }
  5612. };
  5613. if ($Lazyload && inBrowser$1) {
  5614. $Lazyload.$on("loaded", onLazyLoaded);
  5615. $Lazyload.$on("error", onLazyLoadError);
  5616. vue.onBeforeUnmount(() => {
  5617. $Lazyload.$off("loaded", onLazyLoaded);
  5618. $Lazyload.$off("error", onLazyLoadError);
  5619. });
  5620. }
  5621. return () => {
  5622. var _a;
  5623. return vue.createVNode("div", {
  5624. "class": bem$10({
  5625. round: props.round,
  5626. block: props.block
  5627. }),
  5628. "style": style.value
  5629. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5630. };
  5631. }
  5632. });
  5633. const Image$1 = withInstall(stdin_default$17);
  5634. const [name$10, bem$$] = createNamespace("card");
  5635. const cardProps = {
  5636. tag: String,
  5637. num: numericProp,
  5638. desc: String,
  5639. thumb: String,
  5640. title: String,
  5641. price: numericProp,
  5642. centered: Boolean,
  5643. lazyLoad: Boolean,
  5644. currency: makeStringProp("\xA5"),
  5645. thumbLink: String,
  5646. originPrice: numericProp
  5647. };
  5648. var stdin_default$16 = vue.defineComponent({
  5649. name: name$10,
  5650. props: cardProps,
  5651. emits: ["click-thumb"],
  5652. setup(props, {
  5653. slots,
  5654. emit
  5655. }) {
  5656. const renderTitle = () => {
  5657. if (slots.title) {
  5658. return slots.title();
  5659. }
  5660. if (props.title) {
  5661. return vue.createVNode("div", {
  5662. "class": [bem$$("title"), "van-multi-ellipsis--l2"]
  5663. }, [props.title]);
  5664. }
  5665. };
  5666. const renderThumbTag = () => {
  5667. if (slots.tag || props.tag) {
  5668. return vue.createVNode("div", {
  5669. "class": bem$$("tag")
  5670. }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
  5671. "mark": true,
  5672. "type": "danger"
  5673. }, {
  5674. default: () => [props.tag]
  5675. })]);
  5676. }
  5677. };
  5678. const renderThumbImage = () => {
  5679. if (slots.thumb) {
  5680. return slots.thumb();
  5681. }
  5682. return vue.createVNode(Image$1, {
  5683. "src": props.thumb,
  5684. "fit": "cover",
  5685. "width": "100%",
  5686. "height": "100%",
  5687. "lazyLoad": props.lazyLoad
  5688. }, null);
  5689. };
  5690. const renderThumb = () => {
  5691. if (slots.thumb || props.thumb) {
  5692. return vue.createVNode("a", {
  5693. "href": props.thumbLink,
  5694. "class": bem$$("thumb"),
  5695. "onClick": (event) => emit("click-thumb", event)
  5696. }, [renderThumbImage(), renderThumbTag()]);
  5697. }
  5698. };
  5699. const renderDesc = () => {
  5700. if (slots.desc) {
  5701. return slots.desc();
  5702. }
  5703. if (props.desc) {
  5704. return vue.createVNode("div", {
  5705. "class": [bem$$("desc"), "van-ellipsis"]
  5706. }, [props.desc]);
  5707. }
  5708. };
  5709. const renderPriceText = () => {
  5710. const priceArr = props.price.toString().split(".");
  5711. return vue.createVNode("div", null, [vue.createVNode("span", {
  5712. "class": bem$$("price-currency")
  5713. }, [props.currency]), vue.createVNode("span", {
  5714. "class": bem$$("price-integer")
  5715. }, [priceArr[0]]), vue.createTextVNode("."), vue.createVNode("span", {
  5716. "class": bem$$("price-decimal")
  5717. }, [priceArr[1]])]);
  5718. };
  5719. return () => {
  5720. var _a, _b, _c;
  5721. const showNum = slots.num || isDef(props.num);
  5722. const showPrice = slots.price || isDef(props.price);
  5723. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  5724. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  5725. const Price = showPrice && vue.createVNode("div", {
  5726. "class": bem$$("price")
  5727. }, [slots.price ? slots.price() : renderPriceText()]);
  5728. const OriginPrice = showOriginPrice && vue.createVNode("div", {
  5729. "class": bem$$("origin-price")
  5730. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  5731. const Num = showNum && vue.createVNode("div", {
  5732. "class": bem$$("num")
  5733. }, [slots.num ? slots.num() : `x${props.num}`]);
  5734. const Footer = slots.footer && vue.createVNode("div", {
  5735. "class": bem$$("footer")
  5736. }, [slots.footer()]);
  5737. const Bottom = showBottom && vue.createVNode("div", {
  5738. "class": bem$$("bottom")
  5739. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  5740. return vue.createVNode("div", {
  5741. "class": bem$$()
  5742. }, [vue.createVNode("div", {
  5743. "class": bem$$("header")
  5744. }, [renderThumb(), vue.createVNode("div", {
  5745. "class": bem$$("content", {
  5746. centered: props.centered
  5747. })
  5748. }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  5749. };
  5750. }
  5751. });
  5752. const Card = withInstall(stdin_default$16);
  5753. function scrollLeftTo(scroller, to, duration) {
  5754. let count = 0;
  5755. const from = scroller.scrollLeft;
  5756. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5757. function animate() {
  5758. scroller.scrollLeft += (to - from) / frames;
  5759. if (++count < frames) {
  5760. raf(animate);
  5761. }
  5762. }
  5763. animate();
  5764. }
  5765. function scrollTopTo(scroller, to, duration, callback) {
  5766. let current2 = getScrollTop(scroller);
  5767. const isDown = current2 < to;
  5768. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5769. const step = (to - current2) / frames;
  5770. function animate() {
  5771. current2 += step;
  5772. if (isDown && current2 > to || !isDown && current2 < to) {
  5773. current2 = to;
  5774. }
  5775. setScrollTop(scroller, current2);
  5776. if (isDown && current2 < to || !isDown && current2 > to) {
  5777. raf(animate);
  5778. } else if (callback) {
  5779. raf(callback);
  5780. }
  5781. }
  5782. animate();
  5783. }
  5784. function useVisibilityChange(target, onChange) {
  5785. if (!inBrowser$1 || !window.IntersectionObserver) {
  5786. return;
  5787. }
  5788. const observer = new IntersectionObserver(
  5789. (entries) => {
  5790. onChange(entries[0].intersectionRatio > 0);
  5791. },
  5792. { root: document.body }
  5793. );
  5794. const observe = () => {
  5795. if (target.value) {
  5796. observer.observe(target.value);
  5797. }
  5798. };
  5799. const unobserve = () => {
  5800. if (target.value) {
  5801. observer.unobserve(target.value);
  5802. }
  5803. };
  5804. vue.onDeactivated(unobserve);
  5805. vue.onBeforeUnmount(unobserve);
  5806. onMountedOrActivated(observe);
  5807. }
  5808. const [name$$, bem$_] = createNamespace("sticky");
  5809. const stickyProps = {
  5810. zIndex: numericProp,
  5811. position: makeStringProp("top"),
  5812. container: Object,
  5813. offsetTop: makeNumericProp(0),
  5814. offsetBottom: makeNumericProp(0)
  5815. };
  5816. var stdin_default$15 = vue.defineComponent({
  5817. name: name$$,
  5818. props: stickyProps,
  5819. emits: ["scroll", "change"],
  5820. setup(props, {
  5821. emit,
  5822. slots
  5823. }) {
  5824. const root = vue.ref();
  5825. const scrollParent = useScrollParent(root);
  5826. const state = vue.reactive({
  5827. fixed: false,
  5828. width: 0,
  5829. height: 0,
  5830. transform: 0
  5831. });
  5832. const offset2 = vue.computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  5833. const rootStyle = vue.computed(() => {
  5834. const {
  5835. fixed,
  5836. height: height2,
  5837. width: width2
  5838. } = state;
  5839. if (fixed) {
  5840. return {
  5841. width: `${width2}px`,
  5842. height: `${height2}px`
  5843. };
  5844. }
  5845. });
  5846. const stickyStyle = vue.computed(() => {
  5847. if (!state.fixed) {
  5848. return;
  5849. }
  5850. const style = extend(getZIndexStyle(props.zIndex), {
  5851. width: `${state.width}px`,
  5852. height: `${state.height}px`,
  5853. [props.position]: `${offset2.value}px`
  5854. });
  5855. if (state.transform) {
  5856. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  5857. }
  5858. return style;
  5859. });
  5860. const emitScroll = (scrollTop) => emit("scroll", {
  5861. scrollTop,
  5862. isFixed: state.fixed
  5863. });
  5864. const onScroll = () => {
  5865. if (!root.value || isHidden(root)) {
  5866. return;
  5867. }
  5868. const {
  5869. container,
  5870. position
  5871. } = props;
  5872. const rootRect = useRect(root);
  5873. const scrollTop = getScrollTop(window);
  5874. state.width = rootRect.width;
  5875. state.height = rootRect.height;
  5876. if (position === "top") {
  5877. if (container) {
  5878. const containerRect = useRect(container);
  5879. const difference = containerRect.bottom - offset2.value - state.height;
  5880. state.fixed = offset2.value > rootRect.top && containerRect.bottom > 0;
  5881. state.transform = difference < 0 ? difference : 0;
  5882. } else {
  5883. state.fixed = offset2.value > rootRect.top;
  5884. }
  5885. } else {
  5886. const {
  5887. clientHeight
  5888. } = document.documentElement;
  5889. if (container) {
  5890. const containerRect = useRect(container);
  5891. const difference = clientHeight - containerRect.top - offset2.value - state.height;
  5892. state.fixed = clientHeight - offset2.value < rootRect.bottom && clientHeight > containerRect.top;
  5893. state.transform = difference < 0 ? -difference : 0;
  5894. } else {
  5895. state.fixed = clientHeight - offset2.value < rootRect.bottom;
  5896. }
  5897. }
  5898. emitScroll(scrollTop);
  5899. };
  5900. vue.watch(() => state.fixed, (value) => emit("change", value));
  5901. useEventListener("scroll", onScroll, {
  5902. target: scrollParent,
  5903. passive: true
  5904. });
  5905. useVisibilityChange(root, onScroll);
  5906. return () => {
  5907. var _a;
  5908. return vue.createVNode("div", {
  5909. "ref": root,
  5910. "style": rootStyle.value
  5911. }, [vue.createVNode("div", {
  5912. "class": bem$_({
  5913. fixed: state.fixed
  5914. }),
  5915. "style": stickyStyle.value
  5916. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  5917. };
  5918. }
  5919. });
  5920. const Sticky = withInstall(stdin_default$15);
  5921. const [name$_, bem$Z] = createNamespace("tab");
  5922. var stdin_default$14 = vue.defineComponent({
  5923. name: name$_,
  5924. props: {
  5925. id: String,
  5926. dot: Boolean,
  5927. type: String,
  5928. color: String,
  5929. title: String,
  5930. badge: numericProp,
  5931. shrink: Boolean,
  5932. isActive: Boolean,
  5933. disabled: Boolean,
  5934. controls: String,
  5935. scrollable: Boolean,
  5936. activeColor: String,
  5937. inactiveColor: String,
  5938. showZeroBadge: truthProp
  5939. },
  5940. setup(props, {
  5941. slots
  5942. }) {
  5943. const style = vue.computed(() => {
  5944. const style2 = {};
  5945. const {
  5946. type,
  5947. color,
  5948. disabled,
  5949. isActive,
  5950. activeColor,
  5951. inactiveColor
  5952. } = props;
  5953. const isCard = type === "card";
  5954. if (color && isCard) {
  5955. style2.borderColor = color;
  5956. if (!disabled) {
  5957. if (isActive) {
  5958. style2.backgroundColor = color;
  5959. } else {
  5960. style2.color = color;
  5961. }
  5962. }
  5963. }
  5964. const titleColor = isActive ? activeColor : inactiveColor;
  5965. if (titleColor) {
  5966. style2.color = titleColor;
  5967. }
  5968. return style2;
  5969. });
  5970. const renderText = () => {
  5971. const Text2 = vue.createVNode("span", {
  5972. "class": bem$Z("text", {
  5973. ellipsis: !props.scrollable
  5974. })
  5975. }, [slots.title ? slots.title() : props.title]);
  5976. if (props.dot || isDef(props.badge) && props.badge !== "") {
  5977. return vue.createVNode(Badge, {
  5978. "dot": props.dot,
  5979. "content": props.badge,
  5980. "showZero": props.showZeroBadge
  5981. }, {
  5982. default: () => [Text2]
  5983. });
  5984. }
  5985. return Text2;
  5986. };
  5987. return () => vue.createVNode("div", {
  5988. "id": props.id,
  5989. "role": "tab",
  5990. "class": [bem$Z([props.type, {
  5991. grow: props.scrollable && !props.shrink,
  5992. shrink: props.shrink,
  5993. active: props.isActive,
  5994. disabled: props.disabled
  5995. }])],
  5996. "style": style.value,
  5997. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  5998. "aria-selected": props.isActive,
  5999. "aria-disabled": props.disabled || void 0,
  6000. "aria-controls": props.controls
  6001. }, [renderText()]);
  6002. }
  6003. });
  6004. const [name$Z, bem$Y] = createNamespace("swipe");
  6005. const swipeProps = {
  6006. loop: truthProp,
  6007. width: numericProp,
  6008. height: numericProp,
  6009. vertical: Boolean,
  6010. autoplay: makeNumericProp(0),
  6011. duration: makeNumericProp(500),
  6012. touchable: truthProp,
  6013. lazyRender: Boolean,
  6014. initialSwipe: makeNumericProp(0),
  6015. indicatorColor: String,
  6016. showIndicators: truthProp,
  6017. stopPropagation: truthProp
  6018. };
  6019. const SWIPE_KEY = Symbol(name$Z);
  6020. var stdin_default$13 = vue.defineComponent({
  6021. name: name$Z,
  6022. props: swipeProps,
  6023. emits: ["change"],
  6024. setup(props, {
  6025. emit,
  6026. slots
  6027. }) {
  6028. const root = vue.ref();
  6029. const track = vue.ref();
  6030. const state = vue.reactive({
  6031. rect: null,
  6032. width: 0,
  6033. height: 0,
  6034. offset: 0,
  6035. active: 0,
  6036. swiping: false
  6037. });
  6038. const touch = useTouch();
  6039. const {
  6040. children,
  6041. linkChildren
  6042. } = useChildren(SWIPE_KEY);
  6043. const count = vue.computed(() => children.length);
  6044. const size = vue.computed(() => state[props.vertical ? "height" : "width"]);
  6045. const delta = vue.computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  6046. const minOffset = vue.computed(() => {
  6047. if (state.rect) {
  6048. const base = props.vertical ? state.rect.height : state.rect.width;
  6049. return base - size.value * count.value;
  6050. }
  6051. return 0;
  6052. });
  6053. const maxCount = vue.computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
  6054. const trackSize = vue.computed(() => count.value * size.value);
  6055. const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
  6056. const isCorrectDirection = vue.computed(() => {
  6057. const expect = props.vertical ? "vertical" : "horizontal";
  6058. return touch.direction.value === expect;
  6059. });
  6060. const trackStyle = vue.computed(() => {
  6061. const style = {
  6062. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  6063. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  6064. };
  6065. if (size.value) {
  6066. const mainAxis = props.vertical ? "height" : "width";
  6067. const crossAxis = props.vertical ? "width" : "height";
  6068. style[mainAxis] = `${trackSize.value}px`;
  6069. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  6070. }
  6071. return style;
  6072. });
  6073. const getTargetActive = (pace) => {
  6074. const {
  6075. active
  6076. } = state;
  6077. if (pace) {
  6078. if (props.loop) {
  6079. return clamp(active + pace, -1, count.value);
  6080. }
  6081. return clamp(active + pace, 0, maxCount.value);
  6082. }
  6083. return active;
  6084. };
  6085. const getTargetOffset = (targetActive, offset2 = 0) => {
  6086. let currentPosition = targetActive * size.value;
  6087. if (!props.loop) {
  6088. currentPosition = Math.min(currentPosition, -minOffset.value);
  6089. }
  6090. let targetOffset = offset2 - currentPosition;
  6091. if (!props.loop) {
  6092. targetOffset = clamp(targetOffset, minOffset.value, 0);
  6093. }
  6094. return targetOffset;
  6095. };
  6096. const move = ({
  6097. pace = 0,
  6098. offset: offset2 = 0,
  6099. emitChange
  6100. }) => {
  6101. if (count.value <= 1) {
  6102. return;
  6103. }
  6104. const {
  6105. active
  6106. } = state;
  6107. const targetActive = getTargetActive(pace);
  6108. const targetOffset = getTargetOffset(targetActive, offset2);
  6109. if (props.loop) {
  6110. if (children[0] && targetOffset !== minOffset.value) {
  6111. const outRightBound = targetOffset < minOffset.value;
  6112. children[0].setOffset(outRightBound ? trackSize.value : 0);
  6113. }
  6114. if (children[count.value - 1] && targetOffset !== 0) {
  6115. const outLeftBound = targetOffset > 0;
  6116. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  6117. }
  6118. }
  6119. state.active = targetActive;
  6120. state.offset = targetOffset;
  6121. if (emitChange && targetActive !== active) {
  6122. emit("change", activeIndicator.value);
  6123. }
  6124. };
  6125. const correctPosition = () => {
  6126. state.swiping = true;
  6127. if (state.active <= -1) {
  6128. move({
  6129. pace: count.value
  6130. });
  6131. } else if (state.active >= count.value) {
  6132. move({
  6133. pace: -count.value
  6134. });
  6135. }
  6136. };
  6137. const prev = () => {
  6138. correctPosition();
  6139. touch.reset();
  6140. doubleRaf(() => {
  6141. state.swiping = false;
  6142. move({
  6143. pace: -1,
  6144. emitChange: true
  6145. });
  6146. });
  6147. };
  6148. const next = () => {
  6149. correctPosition();
  6150. touch.reset();
  6151. doubleRaf(() => {
  6152. state.swiping = false;
  6153. move({
  6154. pace: 1,
  6155. emitChange: true
  6156. });
  6157. });
  6158. };
  6159. let autoplayTimer;
  6160. const stopAutoplay = () => clearTimeout(autoplayTimer);
  6161. const autoplay = () => {
  6162. stopAutoplay();
  6163. if (props.autoplay > 0 && count.value > 1) {
  6164. autoplayTimer = setTimeout(() => {
  6165. next();
  6166. autoplay();
  6167. }, +props.autoplay);
  6168. }
  6169. };
  6170. const initialize = (active = +props.initialSwipe) => {
  6171. if (!root.value) {
  6172. return;
  6173. }
  6174. const cb = () => {
  6175. var _a, _b;
  6176. if (!isHidden(root)) {
  6177. const rect = {
  6178. width: root.value.offsetWidth,
  6179. height: root.value.offsetHeight
  6180. };
  6181. state.rect = rect;
  6182. state.width = +((_a = props.width) != null ? _a : rect.width);
  6183. state.height = +((_b = props.height) != null ? _b : rect.height);
  6184. }
  6185. if (count.value) {
  6186. active = Math.min(count.value - 1, active);
  6187. }
  6188. state.active = active;
  6189. state.swiping = true;
  6190. state.offset = getTargetOffset(active);
  6191. children.forEach((swipe) => {
  6192. swipe.setOffset(0);
  6193. });
  6194. autoplay();
  6195. };
  6196. if (isHidden(root)) {
  6197. vue.nextTick().then(cb);
  6198. } else {
  6199. cb();
  6200. }
  6201. };
  6202. const resize = () => initialize(state.active);
  6203. let touchStartTime;
  6204. const onTouchStart = (event) => {
  6205. if (!props.touchable)
  6206. return;
  6207. touch.start(event);
  6208. touchStartTime = Date.now();
  6209. stopAutoplay();
  6210. correctPosition();
  6211. };
  6212. const onTouchMove = (event) => {
  6213. if (props.touchable && state.swiping) {
  6214. touch.move(event);
  6215. if (isCorrectDirection.value) {
  6216. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  6217. if (!isEdgeTouch) {
  6218. preventDefault(event, props.stopPropagation);
  6219. move({
  6220. offset: delta.value
  6221. });
  6222. }
  6223. }
  6224. }
  6225. };
  6226. const onTouchEnd = () => {
  6227. if (!props.touchable || !state.swiping) {
  6228. return;
  6229. }
  6230. const duration = Date.now() - touchStartTime;
  6231. const speed = delta.value / duration;
  6232. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  6233. if (shouldSwipe && isCorrectDirection.value) {
  6234. const offset2 = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  6235. let pace = 0;
  6236. if (props.loop) {
  6237. pace = offset2 > 0 ? delta.value > 0 ? -1 : 1 : 0;
  6238. } else {
  6239. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  6240. }
  6241. move({
  6242. pace,
  6243. emitChange: true
  6244. });
  6245. } else if (delta.value) {
  6246. move({
  6247. pace: 0
  6248. });
  6249. }
  6250. state.swiping = false;
  6251. autoplay();
  6252. };
  6253. const swipeTo = (index, options = {}) => {
  6254. correctPosition();
  6255. touch.reset();
  6256. doubleRaf(() => {
  6257. let targetIndex;
  6258. if (props.loop && index === count.value) {
  6259. targetIndex = state.active === 0 ? 0 : index;
  6260. } else {
  6261. targetIndex = index % count.value;
  6262. }
  6263. if (options.immediate) {
  6264. doubleRaf(() => {
  6265. state.swiping = false;
  6266. });
  6267. } else {
  6268. state.swiping = false;
  6269. }
  6270. move({
  6271. pace: targetIndex - state.active,
  6272. emitChange: true
  6273. });
  6274. });
  6275. };
  6276. const renderDot = (_, index) => {
  6277. const active = index === activeIndicator.value;
  6278. const style = active ? {
  6279. backgroundColor: props.indicatorColor
  6280. } : void 0;
  6281. return vue.createVNode("i", {
  6282. "style": style,
  6283. "class": bem$Y("indicator", {
  6284. active
  6285. })
  6286. }, null);
  6287. };
  6288. const renderIndicator = () => {
  6289. if (slots.indicator) {
  6290. return slots.indicator({
  6291. active: activeIndicator.value,
  6292. total: count.value
  6293. });
  6294. }
  6295. if (props.showIndicators && count.value > 1) {
  6296. return vue.createVNode("div", {
  6297. "class": bem$Y("indicators", {
  6298. vertical: props.vertical
  6299. })
  6300. }, [Array(count.value).fill("").map(renderDot)]);
  6301. }
  6302. };
  6303. useExpose({
  6304. prev,
  6305. next,
  6306. state,
  6307. resize,
  6308. swipeTo
  6309. });
  6310. linkChildren({
  6311. size,
  6312. props,
  6313. count,
  6314. activeIndicator
  6315. });
  6316. vue.watch(() => props.initialSwipe, (value) => initialize(+value));
  6317. vue.watch(count, () => initialize(state.active));
  6318. vue.watch(() => props.autoplay, autoplay);
  6319. vue.watch([windowWidth, windowHeight], resize);
  6320. vue.watch(usePageVisibility(), (visible) => {
  6321. if (visible === "visible") {
  6322. autoplay();
  6323. } else {
  6324. stopAutoplay();
  6325. }
  6326. });
  6327. vue.onMounted(initialize);
  6328. vue.onActivated(() => initialize(state.active));
  6329. onPopupReopen(() => initialize(state.active));
  6330. vue.onDeactivated(stopAutoplay);
  6331. vue.onBeforeUnmount(stopAutoplay);
  6332. useEventListener("touchmove", onTouchMove, {
  6333. target: track
  6334. });
  6335. return () => {
  6336. var _a;
  6337. return vue.createVNode("div", {
  6338. "ref": root,
  6339. "class": bem$Y()
  6340. }, [vue.createVNode("div", {
  6341. "ref": track,
  6342. "style": trackStyle.value,
  6343. "class": bem$Y("track", {
  6344. vertical: props.vertical
  6345. }),
  6346. "onTouchstartPassive": onTouchStart,
  6347. "onTouchend": onTouchEnd,
  6348. "onTouchcancel": onTouchEnd
  6349. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  6350. };
  6351. }
  6352. });
  6353. const Swipe = withInstall(stdin_default$13);
  6354. const [name$Y, bem$X] = createNamespace("tabs");
  6355. var stdin_default$12 = vue.defineComponent({
  6356. name: name$Y,
  6357. props: {
  6358. count: makeRequiredProp(Number),
  6359. inited: Boolean,
  6360. animated: Boolean,
  6361. duration: makeRequiredProp(numericProp),
  6362. swipeable: Boolean,
  6363. lazyRender: Boolean,
  6364. currentIndex: makeRequiredProp(Number)
  6365. },
  6366. emits: ["change"],
  6367. setup(props, {
  6368. emit,
  6369. slots
  6370. }) {
  6371. const swipeRef = vue.ref();
  6372. const onChange = (index) => emit("change", index);
  6373. const renderChildren = () => {
  6374. var _a;
  6375. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  6376. if (props.animated || props.swipeable) {
  6377. return vue.createVNode(Swipe, {
  6378. "ref": swipeRef,
  6379. "loop": false,
  6380. "class": bem$X("track"),
  6381. "duration": +props.duration * 1e3,
  6382. "touchable": props.swipeable,
  6383. "lazyRender": props.lazyRender,
  6384. "showIndicators": false,
  6385. "onChange": onChange
  6386. }, {
  6387. default: () => [Content]
  6388. });
  6389. }
  6390. return Content;
  6391. };
  6392. const swipeToCurrentTab = (index) => {
  6393. const swipe = swipeRef.value;
  6394. if (swipe && swipe.state.active !== index) {
  6395. swipe.swipeTo(index, {
  6396. immediate: !props.inited
  6397. });
  6398. }
  6399. };
  6400. vue.watch(() => props.currentIndex, swipeToCurrentTab);
  6401. vue.onMounted(() => {
  6402. swipeToCurrentTab(props.currentIndex);
  6403. });
  6404. useExpose({
  6405. swipeRef
  6406. });
  6407. return () => vue.createVNode("div", {
  6408. "class": bem$X("content", {
  6409. animated: props.animated || props.swipeable
  6410. })
  6411. }, [renderChildren()]);
  6412. }
  6413. });
  6414. const [name$X, bem$W] = createNamespace("tabs");
  6415. const tabsProps = {
  6416. type: makeStringProp("line"),
  6417. color: String,
  6418. border: Boolean,
  6419. sticky: Boolean,
  6420. shrink: Boolean,
  6421. active: makeNumericProp(0),
  6422. duration: makeNumericProp(0.3),
  6423. animated: Boolean,
  6424. ellipsis: truthProp,
  6425. swipeable: Boolean,
  6426. scrollspy: Boolean,
  6427. offsetTop: makeNumericProp(0),
  6428. background: String,
  6429. lazyRender: truthProp,
  6430. lineWidth: numericProp,
  6431. lineHeight: numericProp,
  6432. beforeChange: Function,
  6433. swipeThreshold: makeNumericProp(5),
  6434. titleActiveColor: String,
  6435. titleInactiveColor: String
  6436. };
  6437. const TABS_KEY = Symbol(name$X);
  6438. var stdin_default$11 = vue.defineComponent({
  6439. name: name$X,
  6440. props: tabsProps,
  6441. emits: ["click", "change", "scroll", "disabled", "rendered", "click-tab", "update:active"],
  6442. setup(props, {
  6443. emit,
  6444. slots
  6445. }) {
  6446. let tabHeight;
  6447. let lockScroll;
  6448. let stickyFixed;
  6449. const root = vue.ref();
  6450. const navRef = vue.ref();
  6451. const wrapRef = vue.ref();
  6452. const contentRef = vue.ref();
  6453. const id = useId();
  6454. const scroller = useScrollParent(root);
  6455. const [titleRefs, setTitleRefs] = useRefs();
  6456. const {
  6457. children,
  6458. linkChildren
  6459. } = useChildren(TABS_KEY);
  6460. const state = vue.reactive({
  6461. inited: false,
  6462. position: "",
  6463. lineStyle: {},
  6464. currentIndex: -1
  6465. });
  6466. const scrollable = vue.computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  6467. const navStyle = vue.computed(() => ({
  6468. borderColor: props.color,
  6469. background: props.background
  6470. }));
  6471. const getTabName = (tab, index) => {
  6472. var _a2;
  6473. return (_a2 = tab.name) != null ? _a2 : index;
  6474. };
  6475. const currentName = vue.computed(() => {
  6476. const activeTab = children[state.currentIndex];
  6477. if (activeTab) {
  6478. return getTabName(activeTab, state.currentIndex);
  6479. }
  6480. });
  6481. const offsetTopPx = vue.computed(() => unitToPx(props.offsetTop));
  6482. const scrollOffset = vue.computed(() => {
  6483. if (props.sticky) {
  6484. return offsetTopPx.value + tabHeight;
  6485. }
  6486. return 0;
  6487. });
  6488. const scrollIntoView = (immediate) => {
  6489. const nav = navRef.value;
  6490. const titles = titleRefs.value;
  6491. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  6492. return;
  6493. }
  6494. const title = titles[state.currentIndex].$el;
  6495. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  6496. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  6497. };
  6498. const setLine = () => {
  6499. const shouldAnimate = state.inited;
  6500. vue.nextTick(() => {
  6501. const titles = titleRefs.value;
  6502. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  6503. return;
  6504. }
  6505. const title = titles[state.currentIndex].$el;
  6506. const {
  6507. lineWidth,
  6508. lineHeight
  6509. } = props;
  6510. const left2 = title.offsetLeft + title.offsetWidth / 2;
  6511. const lineStyle = {
  6512. width: addUnit(lineWidth),
  6513. backgroundColor: props.color,
  6514. transform: `translateX(${left2}px) translateX(-50%)`
  6515. };
  6516. if (shouldAnimate) {
  6517. lineStyle.transitionDuration = `${props.duration}s`;
  6518. }
  6519. if (isDef(lineHeight)) {
  6520. const height2 = addUnit(lineHeight);
  6521. lineStyle.height = height2;
  6522. lineStyle.borderRadius = height2;
  6523. }
  6524. state.lineStyle = lineStyle;
  6525. });
  6526. };
  6527. const findAvailableTab = (index) => {
  6528. const diff = index < state.currentIndex ? -1 : 1;
  6529. while (index >= 0 && index < children.length) {
  6530. if (!children[index].disabled) {
  6531. return index;
  6532. }
  6533. index += diff;
  6534. }
  6535. };
  6536. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  6537. const newIndex = findAvailableTab(currentIndex);
  6538. if (!isDef(newIndex)) {
  6539. return;
  6540. }
  6541. const newTab = children[newIndex];
  6542. const newName = getTabName(newTab, newIndex);
  6543. const shouldEmitChange = state.currentIndex !== null;
  6544. if (state.currentIndex !== newIndex) {
  6545. state.currentIndex = newIndex;
  6546. if (!skipScrollIntoView) {
  6547. scrollIntoView();
  6548. }
  6549. setLine();
  6550. }
  6551. if (newName !== props.active) {
  6552. emit("update:active", newName);
  6553. if (shouldEmitChange) {
  6554. emit("change", newName, newTab.title);
  6555. }
  6556. }
  6557. if (stickyFixed && !props.scrollspy) {
  6558. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  6559. }
  6560. };
  6561. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  6562. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  6563. const index = matched ? children.indexOf(matched) : 0;
  6564. setCurrentIndex(index, skipScrollIntoView);
  6565. };
  6566. const scrollToCurrentContent = (immediate = false) => {
  6567. if (props.scrollspy) {
  6568. const target = children[state.currentIndex].$el;
  6569. if (target && scroller.value) {
  6570. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  6571. lockScroll = true;
  6572. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  6573. lockScroll = false;
  6574. });
  6575. }
  6576. }
  6577. };
  6578. const onClickTab = (item, index, event) => {
  6579. const {
  6580. title,
  6581. disabled
  6582. } = children[index];
  6583. const name2 = getTabName(children[index], index);
  6584. if (disabled) {
  6585. emit("disabled", name2, title);
  6586. } else {
  6587. callInterceptor(props.beforeChange, {
  6588. args: [name2],
  6589. done: () => {
  6590. setCurrentIndex(index);
  6591. scrollToCurrentContent();
  6592. }
  6593. });
  6594. emit("click", name2, title);
  6595. route(item);
  6596. }
  6597. emit("click-tab", {
  6598. name: name2,
  6599. title,
  6600. event,
  6601. disabled
  6602. });
  6603. };
  6604. const onStickyScroll = (params) => {
  6605. stickyFixed = params.isFixed;
  6606. emit("scroll", params);
  6607. };
  6608. const scrollTo = (name2) => {
  6609. vue.nextTick(() => {
  6610. setCurrentIndexByName(name2);
  6611. scrollToCurrentContent(true);
  6612. });
  6613. };
  6614. const getCurrentIndexOnScroll = () => {
  6615. for (let index = 0; index < children.length; index++) {
  6616. const {
  6617. top: top2
  6618. } = useRect(children[index].$el);
  6619. if (top2 > scrollOffset.value) {
  6620. return index === 0 ? 0 : index - 1;
  6621. }
  6622. }
  6623. return children.length - 1;
  6624. };
  6625. const onScroll = () => {
  6626. if (props.scrollspy && !lockScroll) {
  6627. const index = getCurrentIndexOnScroll();
  6628. setCurrentIndex(index);
  6629. }
  6630. };
  6631. const renderNav = () => children.map((item, index) => vue.createVNode(stdin_default$14, vue.mergeProps({
  6632. "key": item.id,
  6633. "id": `${id}-${index}`,
  6634. "ref": setTitleRefs(index),
  6635. "type": props.type,
  6636. "color": props.color,
  6637. "style": item.titleStyle,
  6638. "class": item.titleClass,
  6639. "shrink": props.shrink,
  6640. "isActive": index === state.currentIndex,
  6641. "controls": item.id,
  6642. "scrollable": scrollable.value,
  6643. "activeColor": props.titleActiveColor,
  6644. "inactiveColor": props.titleInactiveColor,
  6645. "onClick": (event) => onClickTab(item, index, event)
  6646. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  6647. title: item.$slots.title
  6648. }));
  6649. const renderLine = () => {
  6650. if (props.type === "line" && children.length) {
  6651. return vue.createVNode("div", {
  6652. "class": bem$W("line"),
  6653. "style": state.lineStyle
  6654. }, null);
  6655. }
  6656. };
  6657. const renderHeader = () => {
  6658. var _a2, _b2, _c;
  6659. const {
  6660. type,
  6661. border,
  6662. sticky
  6663. } = props;
  6664. const Header = [vue.createVNode("div", {
  6665. "ref": sticky ? void 0 : wrapRef,
  6666. "class": [bem$W("wrap"), {
  6667. [BORDER_TOP_BOTTOM]: type === "line" && border
  6668. }]
  6669. }, [vue.createVNode("div", {
  6670. "ref": navRef,
  6671. "role": "tablist",
  6672. "class": bem$W("nav", [type, {
  6673. shrink: props.shrink,
  6674. complete: scrollable.value
  6675. }]),
  6676. "style": navStyle.value,
  6677. "aria-orientation": "horizontal"
  6678. }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  6679. if (sticky) {
  6680. return vue.createVNode("div", {
  6681. "ref": wrapRef
  6682. }, [Header]);
  6683. }
  6684. return Header;
  6685. };
  6686. vue.watch([() => props.color, windowWidth], setLine);
  6687. vue.watch(() => props.active, (value) => {
  6688. if (value !== currentName.value) {
  6689. setCurrentIndexByName(value);
  6690. }
  6691. });
  6692. vue.watch(() => children.length, () => {
  6693. if (state.inited) {
  6694. setCurrentIndexByName(props.active);
  6695. setLine();
  6696. vue.nextTick(() => {
  6697. scrollIntoView(true);
  6698. });
  6699. }
  6700. });
  6701. const init = () => {
  6702. setCurrentIndexByName(props.active, true);
  6703. vue.nextTick(() => {
  6704. state.inited = true;
  6705. if (wrapRef.value) {
  6706. tabHeight = useRect(wrapRef.value).height;
  6707. }
  6708. scrollIntoView(true);
  6709. });
  6710. };
  6711. const onRendered = (name2, title) => emit("rendered", name2, title);
  6712. const resize = () => {
  6713. setLine();
  6714. vue.nextTick(() => {
  6715. var _a2, _b2;
  6716. return (_b2 = (_a2 = contentRef.value) == null ? void 0 : _a2.swipeRef.value) == null ? void 0 : _b2.resize();
  6717. });
  6718. };
  6719. useExpose({
  6720. resize,
  6721. scrollTo
  6722. });
  6723. vue.onActivated(setLine);
  6724. onPopupReopen(setLine);
  6725. onMountedOrActivated(init);
  6726. useEventListener("scroll", onScroll, {
  6727. target: scroller,
  6728. passive: true
  6729. });
  6730. linkChildren({
  6731. id,
  6732. props,
  6733. setLine,
  6734. onRendered,
  6735. currentName,
  6736. scrollIntoView
  6737. });
  6738. return () => vue.createVNode("div", {
  6739. "ref": root,
  6740. "class": bem$W([props.type])
  6741. }, [props.sticky ? vue.createVNode(Sticky, {
  6742. "container": root.value,
  6743. "offsetTop": offsetTopPx.value,
  6744. "onScroll": onStickyScroll
  6745. }, {
  6746. default: () => [renderHeader()]
  6747. }) : renderHeader(), vue.createVNode(stdin_default$12, {
  6748. "ref": contentRef,
  6749. "count": children.length,
  6750. "inited": state.inited,
  6751. "animated": props.animated,
  6752. "duration": props.duration,
  6753. "swipeable": props.swipeable,
  6754. "lazyRender": props.lazyRender,
  6755. "currentIndex": state.currentIndex,
  6756. "onChange": setCurrentIndex
  6757. }, {
  6758. default: () => {
  6759. var _a2;
  6760. return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
  6761. }
  6762. })]);
  6763. }
  6764. });
  6765. const TAB_STATUS_KEY = Symbol();
  6766. const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
  6767. const [name$W, bem$V] = createNamespace("swipe-item");
  6768. var stdin_default$10 = vue.defineComponent({
  6769. name: name$W,
  6770. setup(props, {
  6771. slots
  6772. }) {
  6773. let rendered;
  6774. const state = vue.reactive({
  6775. offset: 0,
  6776. inited: false,
  6777. mounted: false
  6778. });
  6779. const {
  6780. parent,
  6781. index
  6782. } = useParent(SWIPE_KEY);
  6783. if (!parent) {
  6784. return;
  6785. }
  6786. const style = vue.computed(() => {
  6787. const style2 = {};
  6788. const {
  6789. vertical
  6790. } = parent.props;
  6791. if (parent.size.value) {
  6792. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  6793. }
  6794. if (state.offset) {
  6795. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  6796. }
  6797. return style2;
  6798. });
  6799. const shouldRender = vue.computed(() => {
  6800. const {
  6801. loop,
  6802. lazyRender
  6803. } = parent.props;
  6804. if (!lazyRender || rendered) {
  6805. return true;
  6806. }
  6807. if (!state.mounted) {
  6808. return false;
  6809. }
  6810. const active = parent.activeIndicator.value;
  6811. const maxActive = parent.count.value - 1;
  6812. const prevActive = active === 0 && loop ? maxActive : active - 1;
  6813. const nextActive = active === maxActive && loop ? 0 : active + 1;
  6814. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  6815. return rendered;
  6816. });
  6817. const setOffset = (offset2) => {
  6818. state.offset = offset2;
  6819. };
  6820. vue.onMounted(() => {
  6821. vue.nextTick(() => {
  6822. state.mounted = true;
  6823. });
  6824. });
  6825. useExpose({
  6826. setOffset
  6827. });
  6828. return () => {
  6829. var _a;
  6830. return vue.createVNode("div", {
  6831. "class": bem$V(),
  6832. "style": style.value
  6833. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  6834. };
  6835. }
  6836. });
  6837. const SwipeItem = withInstall(stdin_default$10);
  6838. const [name$V, bem$U] = createNamespace("tab");
  6839. const tabProps = extend({}, routeProps, {
  6840. dot: Boolean,
  6841. name: numericProp,
  6842. badge: numericProp,
  6843. title: String,
  6844. disabled: Boolean,
  6845. titleClass: unknownProp,
  6846. titleStyle: [String, Object],
  6847. showZeroBadge: truthProp
  6848. });
  6849. var stdin_default$$ = vue.defineComponent({
  6850. name: name$V,
  6851. props: tabProps,
  6852. setup(props, {
  6853. slots
  6854. }) {
  6855. const id = useId();
  6856. const inited = vue.ref(false);
  6857. const {
  6858. parent,
  6859. index
  6860. } = useParent(TABS_KEY);
  6861. if (!parent) {
  6862. return;
  6863. }
  6864. const getName = () => {
  6865. var _a;
  6866. return (_a = props.name) != null ? _a : index.value;
  6867. };
  6868. const init = () => {
  6869. inited.value = true;
  6870. if (parent.props.lazyRender) {
  6871. vue.nextTick(() => {
  6872. parent.onRendered(getName(), props.title);
  6873. });
  6874. }
  6875. };
  6876. const active = vue.computed(() => {
  6877. const isActive = getName() === parent.currentName.value;
  6878. if (isActive && !inited.value) {
  6879. init();
  6880. }
  6881. return isActive;
  6882. });
  6883. const hasInactiveClass = vue.ref(!active.value);
  6884. vue.watch(active, (val) => {
  6885. if (val) {
  6886. hasInactiveClass.value = false;
  6887. } else {
  6888. doubleRaf(() => {
  6889. hasInactiveClass.value = true;
  6890. });
  6891. }
  6892. });
  6893. vue.watch(() => props.title, () => {
  6894. parent.setLine();
  6895. parent.scrollIntoView();
  6896. });
  6897. vue.provide(TAB_STATUS_KEY, active);
  6898. return () => {
  6899. var _a;
  6900. const label = `${parent.id}-${index.value}`;
  6901. const {
  6902. animated,
  6903. swipeable,
  6904. scrollspy,
  6905. lazyRender
  6906. } = parent.props;
  6907. if (!slots.default && !animated) {
  6908. return;
  6909. }
  6910. const show = scrollspy || active.value;
  6911. if (animated || swipeable) {
  6912. return vue.createVNode(SwipeItem, {
  6913. "id": id,
  6914. "role": "tabpanel",
  6915. "class": bem$U("panel-wrapper", {
  6916. inactive: hasInactiveClass.value
  6917. }),
  6918. "tabindex": active.value ? 0 : -1,
  6919. "aria-hidden": !active.value,
  6920. "aria-labelledby": label
  6921. }, {
  6922. default: () => {
  6923. var _a2;
  6924. return [vue.createVNode("div", {
  6925. "class": bem$U("panel")
  6926. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  6927. }
  6928. });
  6929. }
  6930. const shouldRender = inited.value || scrollspy || !lazyRender;
  6931. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  6932. useExpose({
  6933. id
  6934. });
  6935. return vue.withDirectives(vue.createVNode("div", {
  6936. "id": id,
  6937. "role": "tabpanel",
  6938. "class": bem$U("panel"),
  6939. "tabindex": show ? 0 : -1,
  6940. "aria-labelledby": label
  6941. }, [Content]), [[vue.vShow, show]]);
  6942. };
  6943. }
  6944. });
  6945. const Tab = withInstall(stdin_default$$);
  6946. const Tabs = withInstall(stdin_default$11);
  6947. const [name$U, bem$T, t$e] = createNamespace("cascader");
  6948. const cascaderProps = {
  6949. title: String,
  6950. options: makeArrayProp(),
  6951. closeable: truthProp,
  6952. swipeable: truthProp,
  6953. closeIcon: makeStringProp("cross"),
  6954. showHeader: truthProp,
  6955. modelValue: numericProp,
  6956. fieldNames: Object,
  6957. placeholder: String,
  6958. activeColor: String
  6959. };
  6960. var stdin_default$_ = vue.defineComponent({
  6961. name: name$U,
  6962. props: cascaderProps,
  6963. emits: ["close", "change", "finish", "click-tab", "update:modelValue"],
  6964. setup(props, {
  6965. slots,
  6966. emit
  6967. }) {
  6968. const tabs = vue.ref([]);
  6969. const activeTab = vue.ref(0);
  6970. const {
  6971. text: textKey,
  6972. value: valueKey,
  6973. children: childrenKey
  6974. } = extend({
  6975. text: "text",
  6976. value: "value",
  6977. children: "children"
  6978. }, props.fieldNames);
  6979. const getSelectedOptionsByValue = (options, value) => {
  6980. for (const option of options) {
  6981. if (option[valueKey] === value) {
  6982. return [option];
  6983. }
  6984. if (option[childrenKey]) {
  6985. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6986. if (selectedOptions) {
  6987. return [option, ...selectedOptions];
  6988. }
  6989. }
  6990. }
  6991. };
  6992. const updateTabs = () => {
  6993. const {
  6994. options,
  6995. modelValue
  6996. } = props;
  6997. if (modelValue !== void 0) {
  6998. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6999. if (selectedOptions) {
  7000. let optionsCursor = options;
  7001. tabs.value = selectedOptions.map((option) => {
  7002. const tab = {
  7003. options: optionsCursor,
  7004. selected: option
  7005. };
  7006. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  7007. if (next) {
  7008. optionsCursor = next[childrenKey];
  7009. }
  7010. return tab;
  7011. });
  7012. if (optionsCursor) {
  7013. tabs.value.push({
  7014. options: optionsCursor,
  7015. selected: null
  7016. });
  7017. }
  7018. vue.nextTick(() => {
  7019. activeTab.value = tabs.value.length - 1;
  7020. });
  7021. return;
  7022. }
  7023. }
  7024. tabs.value = [{
  7025. options,
  7026. selected: null
  7027. }];
  7028. };
  7029. const onSelect = (option, tabIndex) => {
  7030. if (option.disabled) {
  7031. return;
  7032. }
  7033. tabs.value[tabIndex].selected = option;
  7034. if (tabs.value.length > tabIndex + 1) {
  7035. tabs.value = tabs.value.slice(0, tabIndex + 1);
  7036. }
  7037. if (option[childrenKey]) {
  7038. const nextTab = {
  7039. options: option[childrenKey],
  7040. selected: null
  7041. };
  7042. if (tabs.value[tabIndex + 1]) {
  7043. tabs.value[tabIndex + 1] = nextTab;
  7044. } else {
  7045. tabs.value.push(nextTab);
  7046. }
  7047. vue.nextTick(() => {
  7048. activeTab.value++;
  7049. });
  7050. }
  7051. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  7052. emit("update:modelValue", option[valueKey]);
  7053. const params = {
  7054. value: option[valueKey],
  7055. tabIndex,
  7056. selectedOptions
  7057. };
  7058. emit("change", params);
  7059. if (!option[childrenKey]) {
  7060. emit("finish", params);
  7061. }
  7062. };
  7063. const onClose = () => emit("close");
  7064. const onClickTab = ({
  7065. name: name2,
  7066. title
  7067. }) => emit("click-tab", name2, title);
  7068. const renderHeader = () => props.showHeader ? vue.createVNode("div", {
  7069. "class": bem$T("header")
  7070. }, [vue.createVNode("h2", {
  7071. "class": bem$T("title")
  7072. }, [slots.title ? slots.title() : props.title]), props.closeable ? vue.createVNode(Icon, {
  7073. "name": props.closeIcon,
  7074. "class": [bem$T("close-icon"), HAPTICS_FEEDBACK],
  7075. "onClick": onClose
  7076. }, null) : null]) : null;
  7077. const renderOption = (option, selectedOption, tabIndex) => {
  7078. const {
  7079. disabled
  7080. } = option;
  7081. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  7082. const color = option.color || (selected ? props.activeColor : void 0);
  7083. const Text2 = slots.option ? slots.option({
  7084. option,
  7085. selected
  7086. }) : vue.createVNode("span", null, [option[textKey]]);
  7087. return vue.createVNode("li", {
  7088. "role": "menuitemradio",
  7089. "class": [bem$T("option", {
  7090. selected,
  7091. disabled
  7092. }), option.className],
  7093. "style": {
  7094. color
  7095. },
  7096. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  7097. "aria-checked": selected,
  7098. "aria-disabled": disabled || void 0,
  7099. "onClick": () => onSelect(option, tabIndex)
  7100. }, [Text2, selected ? vue.createVNode(Icon, {
  7101. "name": "success",
  7102. "class": bem$T("selected-icon")
  7103. }, null) : null]);
  7104. };
  7105. const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
  7106. "role": "menu",
  7107. "class": bem$T("options")
  7108. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  7109. const renderTab = (tab, tabIndex) => {
  7110. const {
  7111. options,
  7112. selected
  7113. } = tab;
  7114. const placeholder = props.placeholder || t$e("select");
  7115. const title = selected ? selected[textKey] : placeholder;
  7116. return vue.createVNode(Tab, {
  7117. "title": title,
  7118. "titleClass": bem$T("tab", {
  7119. unselected: !selected
  7120. })
  7121. }, {
  7122. default: () => {
  7123. var _a, _b;
  7124. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  7125. tabIndex
  7126. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  7127. tabIndex
  7128. })];
  7129. }
  7130. });
  7131. };
  7132. const renderTabs = () => vue.createVNode(Tabs, {
  7133. "active": activeTab.value,
  7134. "onUpdate:active": ($event) => activeTab.value = $event,
  7135. "shrink": true,
  7136. "animated": true,
  7137. "class": bem$T("tabs"),
  7138. "color": props.activeColor,
  7139. "swipeable": props.swipeable,
  7140. "onClick-tab": onClickTab
  7141. }, {
  7142. default: () => [tabs.value.map(renderTab)]
  7143. });
  7144. updateTabs();
  7145. vue.watch(() => props.options, updateTabs, {
  7146. deep: true
  7147. });
  7148. vue.watch(() => props.modelValue, (value) => {
  7149. if (value !== void 0) {
  7150. const values = tabs.value.map((tab) => {
  7151. var _a;
  7152. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  7153. });
  7154. if (values.includes(value)) {
  7155. return;
  7156. }
  7157. }
  7158. updateTabs();
  7159. });
  7160. return () => vue.createVNode("div", {
  7161. "class": bem$T()
  7162. }, [renderHeader(), renderTabs()]);
  7163. }
  7164. });
  7165. const Cascader = withInstall(stdin_default$_);
  7166. const [name$T, bem$S] = createNamespace("cell-group");
  7167. const cellGroupProps = {
  7168. title: String,
  7169. inset: Boolean,
  7170. border: truthProp
  7171. };
  7172. var stdin_default$Z = vue.defineComponent({
  7173. name: name$T,
  7174. inheritAttrs: false,
  7175. props: cellGroupProps,
  7176. setup(props, {
  7177. slots,
  7178. attrs
  7179. }) {
  7180. const renderGroup = () => {
  7181. var _a;
  7182. return vue.createVNode("div", vue.mergeProps({
  7183. "class": [bem$S({
  7184. inset: props.inset
  7185. }), {
  7186. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  7187. }]
  7188. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7189. };
  7190. const renderTitle = () => vue.createVNode("div", {
  7191. "class": bem$S("title", {
  7192. inset: props.inset
  7193. })
  7194. }, [slots.title ? slots.title() : props.title]);
  7195. return () => {
  7196. if (props.title || slots.title) {
  7197. return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
  7198. }
  7199. return renderGroup();
  7200. };
  7201. }
  7202. });
  7203. const CellGroup = withInstall(stdin_default$Z);
  7204. const [name$S, bem$R] = createNamespace("checkbox-group");
  7205. const checkboxGroupProps = {
  7206. max: numericProp,
  7207. disabled: Boolean,
  7208. iconSize: numericProp,
  7209. direction: String,
  7210. modelValue: makeArrayProp(),
  7211. checkedColor: String
  7212. };
  7213. const CHECKBOX_GROUP_KEY = Symbol(name$S);
  7214. var stdin_default$Y = vue.defineComponent({
  7215. name: name$S,
  7216. props: checkboxGroupProps,
  7217. emits: ["change", "update:modelValue"],
  7218. setup(props, {
  7219. emit,
  7220. slots
  7221. }) {
  7222. const {
  7223. children,
  7224. linkChildren
  7225. } = useChildren(CHECKBOX_GROUP_KEY);
  7226. const updateValue = (value) => emit("update:modelValue", value);
  7227. const toggleAll = (options = {}) => {
  7228. if (typeof options === "boolean") {
  7229. options = {
  7230. checked: options
  7231. };
  7232. }
  7233. const {
  7234. checked,
  7235. skipDisabled
  7236. } = options;
  7237. const checkedChildren = children.filter((item) => {
  7238. if (!item.props.bindGroup) {
  7239. return false;
  7240. }
  7241. if (item.props.disabled && skipDisabled) {
  7242. return item.checked.value;
  7243. }
  7244. return checked != null ? checked : !item.checked.value;
  7245. });
  7246. const names = checkedChildren.map((item) => item.name);
  7247. updateValue(names);
  7248. };
  7249. vue.watch(() => props.modelValue, (value) => emit("change", value));
  7250. useExpose({
  7251. toggleAll
  7252. });
  7253. useCustomFieldValue(() => props.modelValue);
  7254. linkChildren({
  7255. props,
  7256. updateValue
  7257. });
  7258. return () => {
  7259. var _a;
  7260. return vue.createVNode("div", {
  7261. "class": bem$R([props.direction])
  7262. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7263. };
  7264. }
  7265. });
  7266. const [name$R, bem$Q] = createNamespace("checkbox");
  7267. const checkboxProps = extend({}, checkerProps, {
  7268. bindGroup: truthProp
  7269. });
  7270. var stdin_default$X = vue.defineComponent({
  7271. name: name$R,
  7272. props: checkboxProps,
  7273. emits: ["change", "update:modelValue"],
  7274. setup(props, {
  7275. emit,
  7276. slots
  7277. }) {
  7278. const {
  7279. parent
  7280. } = useParent(CHECKBOX_GROUP_KEY);
  7281. const setParentValue = (checked2) => {
  7282. const {
  7283. name: name2
  7284. } = props;
  7285. const {
  7286. max,
  7287. modelValue
  7288. } = parent.props;
  7289. const value = modelValue.slice();
  7290. if (checked2) {
  7291. const overlimit = max && value.length >= max;
  7292. if (!overlimit && !value.includes(name2)) {
  7293. value.push(name2);
  7294. if (props.bindGroup) {
  7295. parent.updateValue(value);
  7296. }
  7297. }
  7298. } else {
  7299. const index = value.indexOf(name2);
  7300. if (index !== -1) {
  7301. value.splice(index, 1);
  7302. if (props.bindGroup) {
  7303. parent.updateValue(value);
  7304. }
  7305. }
  7306. }
  7307. };
  7308. const checked = vue.computed(() => {
  7309. if (parent && props.bindGroup) {
  7310. return parent.props.modelValue.indexOf(props.name) !== -1;
  7311. }
  7312. return !!props.modelValue;
  7313. });
  7314. const toggle = (newValue = !checked.value) => {
  7315. if (parent && props.bindGroup) {
  7316. setParentValue(newValue);
  7317. } else {
  7318. emit("update:modelValue", newValue);
  7319. }
  7320. };
  7321. vue.watch(() => props.modelValue, (value) => emit("change", value));
  7322. useExpose({
  7323. toggle,
  7324. props,
  7325. checked
  7326. });
  7327. useCustomFieldValue(() => props.modelValue);
  7328. return () => vue.createVNode(stdin_default$1f, vue.mergeProps({
  7329. "bem": bem$Q,
  7330. "role": "checkbox",
  7331. "parent": parent,
  7332. "checked": checked.value,
  7333. "onToggle": toggle
  7334. }, props), pick(slots, ["default", "icon"]));
  7335. }
  7336. });
  7337. const Checkbox = withInstall(stdin_default$X);
  7338. const CheckboxGroup = withInstall(stdin_default$Y);
  7339. const [name$Q, bem$P] = createNamespace("circle");
  7340. let uid = 0;
  7341. const format$1 = (rate) => Math.min(Math.max(+rate, 0), 100);
  7342. function getPath(clockwise, viewBoxSize) {
  7343. const sweepFlag = clockwise ? 1 : 0;
  7344. 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`;
  7345. }
  7346. const circleProps = {
  7347. text: String,
  7348. size: numericProp,
  7349. fill: makeStringProp("none"),
  7350. rate: makeNumericProp(100),
  7351. speed: makeNumericProp(0),
  7352. color: [String, Object],
  7353. clockwise: truthProp,
  7354. layerColor: String,
  7355. currentRate: makeNumberProp(0),
  7356. strokeWidth: makeNumericProp(40),
  7357. strokeLinecap: String,
  7358. startPosition: makeStringProp("top")
  7359. };
  7360. var stdin_default$W = vue.defineComponent({
  7361. name: name$Q,
  7362. props: circleProps,
  7363. emits: ["update:currentRate"],
  7364. setup(props, {
  7365. emit,
  7366. slots
  7367. }) {
  7368. const id = `van-circle-${uid++}`;
  7369. const viewBoxSize = vue.computed(() => +props.strokeWidth + 1e3);
  7370. const path = vue.computed(() => getPath(props.clockwise, viewBoxSize.value));
  7371. const svgStyle = vue.computed(() => {
  7372. const ROTATE_ANGLE_MAP = {
  7373. top: 0,
  7374. right: 90,
  7375. bottom: 180,
  7376. left: 270
  7377. };
  7378. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7379. if (angleValue) {
  7380. return {
  7381. transform: `rotate(${angleValue}deg)`
  7382. };
  7383. }
  7384. });
  7385. vue.watch(() => props.rate, (rate) => {
  7386. let rafId;
  7387. const startTime = Date.now();
  7388. const startRate = props.currentRate;
  7389. const endRate = format$1(rate);
  7390. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7391. const animate = () => {
  7392. const now = Date.now();
  7393. const progress = Math.min((now - startTime) / duration, 1);
  7394. const rate2 = progress * (endRate - startRate) + startRate;
  7395. emit("update:currentRate", format$1(parseFloat(rate2.toFixed(1))));
  7396. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7397. rafId = raf(animate);
  7398. }
  7399. };
  7400. if (props.speed) {
  7401. if (rafId) {
  7402. cancelRaf(rafId);
  7403. }
  7404. rafId = raf(animate);
  7405. } else {
  7406. emit("update:currentRate", endRate);
  7407. }
  7408. }, {
  7409. immediate: true
  7410. });
  7411. const renderHover = () => {
  7412. const PERIMETER = 3140;
  7413. const {
  7414. strokeWidth,
  7415. currentRate,
  7416. strokeLinecap
  7417. } = props;
  7418. const offset2 = PERIMETER * currentRate / 100;
  7419. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7420. const style = {
  7421. stroke: color,
  7422. strokeWidth: `${+strokeWidth + 1}px`,
  7423. strokeLinecap,
  7424. strokeDasharray: `${offset2}px ${PERIMETER}px`
  7425. };
  7426. return vue.createVNode("path", {
  7427. "d": path.value,
  7428. "style": style,
  7429. "class": bem$P("hover"),
  7430. "stroke": color
  7431. }, null);
  7432. };
  7433. const renderLayer = () => {
  7434. const style = {
  7435. fill: props.fill,
  7436. stroke: props.layerColor,
  7437. strokeWidth: `${props.strokeWidth}px`
  7438. };
  7439. return vue.createVNode("path", {
  7440. "class": bem$P("layer"),
  7441. "style": style,
  7442. "d": path.value
  7443. }, null);
  7444. };
  7445. const renderGradient = () => {
  7446. const {
  7447. color
  7448. } = props;
  7449. if (!isObject(color)) {
  7450. return;
  7451. }
  7452. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
  7453. "key": index,
  7454. "offset": key,
  7455. "stop-color": color[key]
  7456. }, null));
  7457. return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7458. "id": id,
  7459. "x1": "100%",
  7460. "y1": "0%",
  7461. "x2": "0%",
  7462. "y2": "0%"
  7463. }, [Stops])]);
  7464. };
  7465. const renderText = () => {
  7466. if (slots.default) {
  7467. return slots.default();
  7468. }
  7469. if (props.text) {
  7470. return vue.createVNode("div", {
  7471. "class": bem$P("text")
  7472. }, [props.text]);
  7473. }
  7474. };
  7475. return () => vue.createVNode("div", {
  7476. "class": bem$P(),
  7477. "style": getSizeStyle(props.size)
  7478. }, [vue.createVNode("svg", {
  7479. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7480. "style": svgStyle.value
  7481. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7482. }
  7483. });
  7484. const Circle = withInstall(stdin_default$W);
  7485. const [name$P, bem$O] = createNamespace("row");
  7486. const ROW_KEY = Symbol(name$P);
  7487. const rowProps = {
  7488. tag: makeStringProp("div"),
  7489. wrap: truthProp,
  7490. align: String,
  7491. gutter: makeNumericProp(0),
  7492. justify: String
  7493. };
  7494. var stdin_default$V = vue.defineComponent({
  7495. name: name$P,
  7496. props: rowProps,
  7497. setup(props, {
  7498. slots
  7499. }) {
  7500. const {
  7501. children,
  7502. linkChildren
  7503. } = useChildren(ROW_KEY);
  7504. const groups = vue.computed(() => {
  7505. const groups2 = [[]];
  7506. let totalSpan = 0;
  7507. children.forEach((child, index) => {
  7508. totalSpan += Number(child.span);
  7509. if (totalSpan > 24) {
  7510. groups2.push([index]);
  7511. totalSpan -= 24;
  7512. } else {
  7513. groups2[groups2.length - 1].push(index);
  7514. }
  7515. });
  7516. return groups2;
  7517. });
  7518. const spaces = vue.computed(() => {
  7519. const gutter = Number(props.gutter);
  7520. const spaces2 = [];
  7521. if (!gutter) {
  7522. return spaces2;
  7523. }
  7524. groups.value.forEach((group) => {
  7525. const averagePadding = gutter * (group.length - 1) / group.length;
  7526. group.forEach((item, index) => {
  7527. if (index === 0) {
  7528. spaces2.push({
  7529. right: averagePadding
  7530. });
  7531. } else {
  7532. const left2 = gutter - spaces2[item - 1].right;
  7533. const right2 = averagePadding - left2;
  7534. spaces2.push({
  7535. left: left2,
  7536. right: right2
  7537. });
  7538. }
  7539. });
  7540. });
  7541. return spaces2;
  7542. });
  7543. linkChildren({
  7544. spaces
  7545. });
  7546. return () => {
  7547. const {
  7548. tag,
  7549. wrap,
  7550. align,
  7551. justify
  7552. } = props;
  7553. return vue.createVNode(tag, {
  7554. "class": bem$O({
  7555. [`align-${align}`]: align,
  7556. [`justify-${justify}`]: justify,
  7557. nowrap: !wrap
  7558. })
  7559. }, {
  7560. default: () => {
  7561. var _a;
  7562. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7563. }
  7564. });
  7565. };
  7566. }
  7567. });
  7568. const [name$O, bem$N] = createNamespace("col");
  7569. const colProps = {
  7570. tag: makeStringProp("div"),
  7571. span: makeNumericProp(0),
  7572. offset: numericProp
  7573. };
  7574. var stdin_default$U = vue.defineComponent({
  7575. name: name$O,
  7576. props: colProps,
  7577. setup(props, {
  7578. slots
  7579. }) {
  7580. const {
  7581. parent,
  7582. index
  7583. } = useParent(ROW_KEY);
  7584. const style = vue.computed(() => {
  7585. if (!parent) {
  7586. return;
  7587. }
  7588. const {
  7589. spaces
  7590. } = parent;
  7591. if (spaces && spaces.value && spaces.value[index.value]) {
  7592. const {
  7593. left: left2,
  7594. right: right2
  7595. } = spaces.value[index.value];
  7596. return {
  7597. paddingLeft: left2 ? `${left2}px` : null,
  7598. paddingRight: right2 ? `${right2}px` : null
  7599. };
  7600. }
  7601. });
  7602. return () => {
  7603. const {
  7604. tag,
  7605. span,
  7606. offset: offset2
  7607. } = props;
  7608. return vue.createVNode(tag, {
  7609. "style": style.value,
  7610. "class": bem$N({
  7611. [span]: span,
  7612. [`offset-${offset2}`]: offset2
  7613. })
  7614. }, {
  7615. default: () => {
  7616. var _a;
  7617. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7618. }
  7619. });
  7620. };
  7621. }
  7622. });
  7623. const Col = withInstall(stdin_default$U);
  7624. const [name$N, bem$M] = createNamespace("collapse");
  7625. const COLLAPSE_KEY = Symbol(name$N);
  7626. const collapseProps = {
  7627. border: truthProp,
  7628. accordion: Boolean,
  7629. modelValue: {
  7630. type: [String, Number, Array],
  7631. default: ""
  7632. }
  7633. };
  7634. var stdin_default$T = vue.defineComponent({
  7635. name: name$N,
  7636. props: collapseProps,
  7637. emits: ["change", "update:modelValue"],
  7638. setup(props, {
  7639. emit,
  7640. slots
  7641. }) {
  7642. const {
  7643. linkChildren,
  7644. children
  7645. } = useChildren(COLLAPSE_KEY);
  7646. const updateName = (name2) => {
  7647. emit("change", name2);
  7648. emit("update:modelValue", name2);
  7649. };
  7650. const toggle = (name2, expanded) => {
  7651. const {
  7652. accordion,
  7653. modelValue
  7654. } = props;
  7655. if (accordion) {
  7656. updateName(name2 === modelValue ? "" : name2);
  7657. } else if (expanded) {
  7658. updateName(modelValue.concat(name2));
  7659. } else {
  7660. updateName(modelValue.filter((activeName) => activeName !== name2));
  7661. }
  7662. };
  7663. const toggleAll = (options = {}) => {
  7664. if (props.accordion) {
  7665. return;
  7666. }
  7667. if (typeof options === "boolean") {
  7668. options = {
  7669. expanded: options
  7670. };
  7671. }
  7672. const {
  7673. expanded,
  7674. skipDisabled
  7675. } = options;
  7676. const expandedChildren = children.filter((item) => {
  7677. if (item.disabled && skipDisabled) {
  7678. return item.expanded.value;
  7679. }
  7680. return expanded != null ? expanded : !item.expanded.value;
  7681. });
  7682. const names = expandedChildren.map((item) => item.itemName.value);
  7683. updateName(names);
  7684. };
  7685. const isExpanded = (name2) => {
  7686. const {
  7687. accordion,
  7688. modelValue
  7689. } = props;
  7690. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7691. };
  7692. useExpose({
  7693. toggleAll
  7694. });
  7695. linkChildren({
  7696. toggle,
  7697. isExpanded
  7698. });
  7699. return () => {
  7700. var _a;
  7701. return vue.createVNode("div", {
  7702. "class": [bem$M(), {
  7703. [BORDER_TOP_BOTTOM]: props.border
  7704. }]
  7705. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7706. };
  7707. }
  7708. });
  7709. const Collapse = withInstall(stdin_default$T);
  7710. const [name$M, bem$L] = createNamespace("collapse-item");
  7711. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7712. const collapseItemProps = extend({}, cellSharedProps, {
  7713. name: numericProp,
  7714. isLink: truthProp,
  7715. disabled: Boolean,
  7716. readonly: Boolean,
  7717. lazyRender: truthProp
  7718. });
  7719. var stdin_default$S = vue.defineComponent({
  7720. name: name$M,
  7721. props: collapseItemProps,
  7722. setup(props, {
  7723. slots
  7724. }) {
  7725. const wrapperRef = vue.ref();
  7726. const contentRef = vue.ref();
  7727. const {
  7728. parent,
  7729. index
  7730. } = useParent(COLLAPSE_KEY);
  7731. if (!parent) {
  7732. return;
  7733. }
  7734. const name2 = vue.computed(() => {
  7735. var _a;
  7736. return (_a = props.name) != null ? _a : index.value;
  7737. });
  7738. const expanded = vue.computed(() => parent.isExpanded(name2.value));
  7739. const show = vue.ref(expanded.value);
  7740. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7741. const onTransitionEnd = () => {
  7742. if (!expanded.value) {
  7743. show.value = false;
  7744. } else if (wrapperRef.value) {
  7745. wrapperRef.value.style.height = "";
  7746. }
  7747. };
  7748. vue.watch(expanded, (value, oldValue) => {
  7749. if (oldValue === null) {
  7750. return;
  7751. }
  7752. if (value) {
  7753. show.value = true;
  7754. }
  7755. const tick = value ? vue.nextTick : raf;
  7756. tick(() => {
  7757. if (!contentRef.value || !wrapperRef.value) {
  7758. return;
  7759. }
  7760. const {
  7761. offsetHeight
  7762. } = contentRef.value;
  7763. if (offsetHeight) {
  7764. const contentHeight = `${offsetHeight}px`;
  7765. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7766. doubleRaf(() => {
  7767. if (wrapperRef.value) {
  7768. wrapperRef.value.style.height = value ? contentHeight : "0";
  7769. }
  7770. });
  7771. } else {
  7772. onTransitionEnd();
  7773. }
  7774. });
  7775. });
  7776. const toggle = (newValue = !expanded.value) => {
  7777. parent.toggle(name2.value, newValue);
  7778. };
  7779. const onClickTitle = () => {
  7780. if (!props.disabled && !props.readonly) {
  7781. toggle();
  7782. }
  7783. };
  7784. const renderTitle = () => {
  7785. const {
  7786. border,
  7787. disabled,
  7788. readonly
  7789. } = props;
  7790. const attrs = pick(props, Object.keys(cellSharedProps));
  7791. if (readonly) {
  7792. attrs.isLink = false;
  7793. }
  7794. if (disabled || readonly) {
  7795. attrs.clickable = false;
  7796. }
  7797. return vue.createVNode(Cell, vue.mergeProps({
  7798. "role": "button",
  7799. "class": bem$L("title", {
  7800. disabled,
  7801. expanded: expanded.value,
  7802. borderless: !border
  7803. }),
  7804. "aria-expanded": String(expanded.value),
  7805. "onClick": onClickTitle
  7806. }, attrs), pick(slots, CELL_SLOTS));
  7807. };
  7808. const renderContent = lazyRender(() => {
  7809. var _a;
  7810. return vue.withDirectives(vue.createVNode("div", {
  7811. "ref": wrapperRef,
  7812. "class": bem$L("wrapper"),
  7813. "onTransitionend": onTransitionEnd
  7814. }, [vue.createVNode("div", {
  7815. "ref": contentRef,
  7816. "class": bem$L("content")
  7817. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
  7818. });
  7819. useExpose({
  7820. toggle,
  7821. expanded,
  7822. itemName: name2
  7823. });
  7824. return () => vue.createVNode("div", {
  7825. "class": [bem$L({
  7826. border: index.value && props.border
  7827. })]
  7828. }, [renderTitle(), renderContent()]);
  7829. }
  7830. });
  7831. const CollapseItem = withInstall(stdin_default$S);
  7832. const ConfigProvider = withInstall(stdin_default$1A);
  7833. const [name$L, bem$K, t$d] = createNamespace("contact-card");
  7834. const contactCardProps = {
  7835. tel: String,
  7836. name: String,
  7837. type: makeStringProp("add"),
  7838. addText: String,
  7839. editable: truthProp
  7840. };
  7841. var stdin_default$R = vue.defineComponent({
  7842. name: name$L,
  7843. props: contactCardProps,
  7844. emits: ["click"],
  7845. setup(props, {
  7846. emit
  7847. }) {
  7848. const onClick = (event) => {
  7849. if (props.editable) {
  7850. emit("click", event);
  7851. }
  7852. };
  7853. const renderContent = () => {
  7854. if (props.type === "add") {
  7855. return props.addText || t$d("addContact");
  7856. }
  7857. return [vue.createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), vue.createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7858. };
  7859. return () => vue.createVNode(Cell, {
  7860. "center": true,
  7861. "icon": props.type === "edit" ? "contact" : "add-square",
  7862. "class": bem$K([props.type]),
  7863. "border": false,
  7864. "isLink": props.editable,
  7865. "valueClass": bem$K("value"),
  7866. "onClick": onClick
  7867. }, {
  7868. value: renderContent
  7869. });
  7870. }
  7871. });
  7872. const ContactCard = withInstall(stdin_default$R);
  7873. const [name$K, bem$J, t$c] = createNamespace("contact-edit");
  7874. const DEFAULT_CONTACT = {
  7875. tel: "",
  7876. name: ""
  7877. };
  7878. const contactEditProps = {
  7879. isEdit: Boolean,
  7880. isSaving: Boolean,
  7881. isDeleting: Boolean,
  7882. showSetDefault: Boolean,
  7883. setDefaultLabel: String,
  7884. contactInfo: {
  7885. type: Object,
  7886. default: () => extend({}, DEFAULT_CONTACT)
  7887. },
  7888. telValidator: {
  7889. type: Function,
  7890. default: isMobile
  7891. }
  7892. };
  7893. var stdin_default$Q = vue.defineComponent({
  7894. name: name$K,
  7895. props: contactEditProps,
  7896. emits: ["save", "delete", "change-default"],
  7897. setup(props, {
  7898. emit
  7899. }) {
  7900. const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7901. const onSave = () => {
  7902. if (!props.isSaving) {
  7903. emit("save", contact);
  7904. }
  7905. };
  7906. const onDelete = () => emit("delete", contact);
  7907. const renderButtons = () => vue.createVNode("div", {
  7908. "class": bem$J("buttons")
  7909. }, [vue.createVNode(Button, {
  7910. "block": true,
  7911. "round": true,
  7912. "type": "danger",
  7913. "text": t$c("save"),
  7914. "class": bem$J("button"),
  7915. "loading": props.isSaving,
  7916. "nativeType": "submit"
  7917. }, null), props.isEdit && vue.createVNode(Button, {
  7918. "block": true,
  7919. "round": true,
  7920. "text": t$c("delete"),
  7921. "class": bem$J("button"),
  7922. "loading": props.isDeleting,
  7923. "onClick": onDelete
  7924. }, null)]);
  7925. const renderSwitch = () => vue.createVNode(Switch, {
  7926. "modelValue": contact.isDefault,
  7927. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7928. "size": 24,
  7929. "onChange": (checked) => emit("change-default", checked)
  7930. }, null);
  7931. const renderSetDefault = () => {
  7932. if (props.showSetDefault) {
  7933. return vue.createVNode(Cell, {
  7934. "title": props.setDefaultLabel,
  7935. "class": bem$J("switch-cell"),
  7936. "border": false
  7937. }, {
  7938. "right-icon": renderSwitch
  7939. });
  7940. }
  7941. };
  7942. vue.watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7943. return () => vue.createVNode(Form, {
  7944. "class": bem$J(),
  7945. "onSubmit": onSave
  7946. }, {
  7947. default: () => [vue.createVNode("div", {
  7948. "class": bem$J("fields")
  7949. }, [vue.createVNode(Field, {
  7950. "modelValue": contact.name,
  7951. "onUpdate:modelValue": ($event) => contact.name = $event,
  7952. "clearable": true,
  7953. "label": t$c("name"),
  7954. "rules": [{
  7955. required: true,
  7956. message: t$c("nameEmpty")
  7957. }],
  7958. "maxlength": "30",
  7959. "placeholder": t$c("name")
  7960. }, null), vue.createVNode(Field, {
  7961. "modelValue": contact.tel,
  7962. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7963. "clearable": true,
  7964. "type": "tel",
  7965. "label": t$c("tel"),
  7966. "rules": [{
  7967. validator: props.telValidator,
  7968. message: t$c("telInvalid")
  7969. }],
  7970. "placeholder": t$c("tel")
  7971. }, null)]), renderSetDefault(), renderButtons()]
  7972. });
  7973. }
  7974. });
  7975. const ContactEdit = withInstall(stdin_default$Q);
  7976. const [name$J, bem$I, t$b] = createNamespace("contact-list");
  7977. const contactListProps = {
  7978. list: Array,
  7979. addText: String,
  7980. modelValue: unknownProp,
  7981. defaultTagText: String
  7982. };
  7983. var stdin_default$P = vue.defineComponent({
  7984. name: name$J,
  7985. props: contactListProps,
  7986. emits: ["add", "edit", "select", "update:modelValue"],
  7987. setup(props, {
  7988. emit
  7989. }) {
  7990. const renderItem = (item, index) => {
  7991. const onClick = () => {
  7992. emit("update:modelValue", item.id);
  7993. emit("select", item, index);
  7994. };
  7995. const renderRightIcon = () => vue.createVNode(Radio, {
  7996. "class": bem$I("radio"),
  7997. "name": item.id,
  7998. "iconSize": 16
  7999. }, null);
  8000. const renderEditIcon = () => vue.createVNode(Icon, {
  8001. "name": "edit",
  8002. "class": bem$I("edit"),
  8003. "onClick": (event) => {
  8004. event.stopPropagation();
  8005. emit("edit", item, index);
  8006. }
  8007. }, null);
  8008. const renderContent = () => {
  8009. const nodes = [`${item.name}\uFF0C${item.tel}`];
  8010. if (item.isDefault && props.defaultTagText) {
  8011. nodes.push(vue.createVNode(Tag, {
  8012. "type": "danger",
  8013. "round": true,
  8014. "class": bem$I("item-tag")
  8015. }, {
  8016. default: () => [props.defaultTagText]
  8017. }));
  8018. }
  8019. return nodes;
  8020. };
  8021. return vue.createVNode(Cell, {
  8022. "key": item.id,
  8023. "isLink": true,
  8024. "center": true,
  8025. "class": bem$I("item"),
  8026. "valueClass": bem$I("item-value"),
  8027. "onClick": onClick
  8028. }, {
  8029. icon: renderEditIcon,
  8030. value: renderContent,
  8031. "right-icon": renderRightIcon
  8032. });
  8033. };
  8034. return () => vue.createVNode("div", {
  8035. "class": bem$I()
  8036. }, [vue.createVNode(RadioGroup, {
  8037. "modelValue": props.modelValue,
  8038. "class": bem$I("group")
  8039. }, {
  8040. default: () => [props.list && props.list.map(renderItem)]
  8041. }), vue.createVNode("div", {
  8042. "class": [bem$I("bottom"), "van-safe-area-bottom"]
  8043. }, [vue.createVNode(Button, {
  8044. "round": true,
  8045. "block": true,
  8046. "type": "danger",
  8047. "class": bem$I("add"),
  8048. "text": props.addText || t$b("addContact"),
  8049. "onClick": () => emit("add")
  8050. }, null)])]);
  8051. }
  8052. });
  8053. const ContactList = withInstall(stdin_default$P);
  8054. function parseFormat(format2, currentTime) {
  8055. const { days } = currentTime;
  8056. let { hours, minutes, seconds, milliseconds } = currentTime;
  8057. if (format2.includes("DD")) {
  8058. format2 = format2.replace("DD", padZero(days));
  8059. } else {
  8060. hours += days * 24;
  8061. }
  8062. if (format2.includes("HH")) {
  8063. format2 = format2.replace("HH", padZero(hours));
  8064. } else {
  8065. minutes += hours * 60;
  8066. }
  8067. if (format2.includes("mm")) {
  8068. format2 = format2.replace("mm", padZero(minutes));
  8069. } else {
  8070. seconds += minutes * 60;
  8071. }
  8072. if (format2.includes("ss")) {
  8073. format2 = format2.replace("ss", padZero(seconds));
  8074. } else {
  8075. milliseconds += seconds * 1e3;
  8076. }
  8077. if (format2.includes("S")) {
  8078. const ms = padZero(milliseconds, 3);
  8079. if (format2.includes("SSS")) {
  8080. format2 = format2.replace("SSS", ms);
  8081. } else if (format2.includes("SS")) {
  8082. format2 = format2.replace("SS", ms.slice(0, 2));
  8083. } else {
  8084. format2 = format2.replace("S", ms.charAt(0));
  8085. }
  8086. }
  8087. return format2;
  8088. }
  8089. const [name$I, bem$H] = createNamespace("count-down");
  8090. const countDownProps = {
  8091. time: makeNumericProp(0),
  8092. format: makeStringProp("HH:mm:ss"),
  8093. autoStart: truthProp,
  8094. millisecond: Boolean
  8095. };
  8096. var stdin_default$O = vue.defineComponent({
  8097. name: name$I,
  8098. props: countDownProps,
  8099. emits: ["change", "finish"],
  8100. setup(props, {
  8101. emit,
  8102. slots
  8103. }) {
  8104. const {
  8105. start: start2,
  8106. pause,
  8107. reset,
  8108. current: current2
  8109. } = useCountDown({
  8110. time: +props.time,
  8111. millisecond: props.millisecond,
  8112. onChange: (current22) => emit("change", current22),
  8113. onFinish: () => emit("finish")
  8114. });
  8115. const timeText = vue.computed(() => parseFormat(props.format, current2.value));
  8116. const resetTime = () => {
  8117. reset(+props.time);
  8118. if (props.autoStart) {
  8119. start2();
  8120. }
  8121. };
  8122. vue.watch(() => props.time, resetTime, {
  8123. immediate: true
  8124. });
  8125. useExpose({
  8126. start: start2,
  8127. pause,
  8128. reset: resetTime
  8129. });
  8130. return () => vue.createVNode("div", {
  8131. "role": "timer",
  8132. "class": bem$H()
  8133. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  8134. }
  8135. });
  8136. const CountDown = withInstall(stdin_default$O);
  8137. function getDate(timeStamp) {
  8138. const date = new Date(timeStamp * 1e3);
  8139. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  8140. date.getDate()
  8141. )}`;
  8142. }
  8143. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  8144. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  8145. const [name$H, bem$G, t$a] = createNamespace("coupon");
  8146. var stdin_default$N = vue.defineComponent({
  8147. name: name$H,
  8148. props: {
  8149. chosen: Boolean,
  8150. coupon: makeRequiredProp(Object),
  8151. disabled: Boolean,
  8152. currency: makeStringProp("\xA5")
  8153. },
  8154. setup(props) {
  8155. const validPeriod = vue.computed(() => {
  8156. const {
  8157. startAt,
  8158. endAt
  8159. } = props.coupon;
  8160. return `${getDate(startAt)} - ${getDate(endAt)}`;
  8161. });
  8162. const faceAmount = vue.computed(() => {
  8163. const {
  8164. coupon,
  8165. currency
  8166. } = props;
  8167. if (coupon.valueDesc) {
  8168. return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
  8169. }
  8170. if (coupon.denominations) {
  8171. const denominations = formatAmount(coupon.denominations);
  8172. return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
  8173. }
  8174. if (coupon.discount) {
  8175. return t$a("discount", formatDiscount(coupon.discount));
  8176. }
  8177. return "";
  8178. });
  8179. const conditionMessage = vue.computed(() => {
  8180. const condition = formatAmount(props.coupon.originCondition || 0);
  8181. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  8182. });
  8183. return () => {
  8184. const {
  8185. chosen,
  8186. coupon,
  8187. disabled
  8188. } = props;
  8189. const description = disabled && coupon.reason || coupon.description;
  8190. return vue.createVNode("div", {
  8191. "class": bem$G({
  8192. disabled
  8193. })
  8194. }, [vue.createVNode("div", {
  8195. "class": bem$G("content")
  8196. }, [vue.createVNode("div", {
  8197. "class": bem$G("head")
  8198. }, [vue.createVNode("h2", {
  8199. "class": bem$G("amount")
  8200. }, [faceAmount.value]), vue.createVNode("p", {
  8201. "class": bem$G("condition")
  8202. }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
  8203. "class": bem$G("body")
  8204. }, [vue.createVNode("p", {
  8205. "class": bem$G("name")
  8206. }, [coupon.name]), vue.createVNode("p", {
  8207. "class": bem$G("valid")
  8208. }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
  8209. "class": bem$G("corner"),
  8210. "modelValue": chosen
  8211. }, null)])]), description && vue.createVNode("p", {
  8212. "class": bem$G("description")
  8213. }, [description])]);
  8214. };
  8215. }
  8216. });
  8217. const Coupon = withInstall(stdin_default$N);
  8218. const [name$G, bem$F, t$9] = createNamespace("coupon-cell");
  8219. const couponCellProps = {
  8220. title: String,
  8221. border: truthProp,
  8222. editable: truthProp,
  8223. coupons: makeArrayProp(),
  8224. currency: makeStringProp("\xA5"),
  8225. chosenCoupon: makeNumericProp(-1)
  8226. };
  8227. function formatValue({
  8228. coupons,
  8229. chosenCoupon,
  8230. currency
  8231. }) {
  8232. const coupon = coupons[+chosenCoupon];
  8233. if (coupon) {
  8234. let value = 0;
  8235. if (isDef(coupon.value)) {
  8236. ({
  8237. value
  8238. } = coupon);
  8239. } else if (isDef(coupon.denominations)) {
  8240. value = coupon.denominations;
  8241. }
  8242. return `-${currency} ${(value / 100).toFixed(2)}`;
  8243. }
  8244. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  8245. }
  8246. var stdin_default$M = vue.defineComponent({
  8247. name: name$G,
  8248. props: couponCellProps,
  8249. setup(props) {
  8250. return () => {
  8251. const selected = props.coupons[+props.chosenCoupon];
  8252. return vue.createVNode(Cell, {
  8253. "class": bem$F(),
  8254. "value": formatValue(props),
  8255. "title": props.title || t$9("title"),
  8256. "border": props.border,
  8257. "isLink": props.editable,
  8258. "valueClass": bem$F("value", {
  8259. selected
  8260. })
  8261. }, null);
  8262. };
  8263. }
  8264. });
  8265. const CouponCell = withInstall(stdin_default$M);
  8266. const [name$F, bem$E] = createNamespace("empty");
  8267. const emptyProps = {
  8268. image: makeStringProp("default"),
  8269. imageSize: [Number, String, Array],
  8270. description: String
  8271. };
  8272. var stdin_default$L = vue.defineComponent({
  8273. name: name$F,
  8274. props: emptyProps,
  8275. setup(props, {
  8276. slots
  8277. }) {
  8278. const renderDescription = () => {
  8279. const description = slots.description ? slots.description() : props.description;
  8280. if (description) {
  8281. return vue.createVNode("p", {
  8282. "class": bem$E("description")
  8283. }, [description]);
  8284. }
  8285. };
  8286. const renderBottom = () => {
  8287. if (slots.default) {
  8288. return vue.createVNode("div", {
  8289. "class": bem$E("bottom")
  8290. }, [slots.default()]);
  8291. }
  8292. };
  8293. const baseId = useId();
  8294. const getId = (num) => `${baseId}-${num}`;
  8295. const getUrlById = (num) => `url(#${getId(num)})`;
  8296. const renderStop = (color, offset2, opacity) => vue.createVNode("stop", {
  8297. "stop-color": color,
  8298. "offset": `${offset2}%`,
  8299. "stop-opacity": opacity
  8300. }, null);
  8301. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  8302. const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
  8303. "id": getId(id),
  8304. "cx": "50%",
  8305. "cy": "54%",
  8306. "fx": "50%",
  8307. "fy": "54%",
  8308. "r": "297%",
  8309. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  8310. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
  8311. "fill": getUrlById(id),
  8312. "opacity": ".8",
  8313. "cx": "80",
  8314. "cy": "140",
  8315. "rx": "46",
  8316. "ry": "8"
  8317. }, null)];
  8318. const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8319. "id": getId("a"),
  8320. "x1": "64%",
  8321. "y1": "100%",
  8322. "x2": "64%"
  8323. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8324. "opacity": ".8"
  8325. }, [vue.createVNode("path", {
  8326. "d": "M36 131V53H16v20H2v58h34z",
  8327. "fill": getUrlById("a")
  8328. }, null), vue.createVNode("path", {
  8329. "d": "M123 15h22v14h9v77h-31V15z",
  8330. "fill": getUrlById("a")
  8331. }, null)])];
  8332. const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8333. "id": getId("b"),
  8334. "x1": "64%",
  8335. "y1": "97%",
  8336. "x2": "64%",
  8337. "y2": "0%"
  8338. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8339. "opacity": ".8"
  8340. }, [vue.createVNode("path", {
  8341. "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",
  8342. "fill": getUrlById("b")
  8343. }, null), vue.createVNode("path", {
  8344. "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",
  8345. "fill": getUrlById("b")
  8346. }, null)])];
  8347. const renderNetwork = () => vue.createVNode("svg", {
  8348. "viewBox": "0 0 160 160"
  8349. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8350. "id": getId(1),
  8351. "x1": "64%",
  8352. "y1": "100%",
  8353. "x2": "64%"
  8354. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
  8355. "id": getId(2),
  8356. "x1": "50%",
  8357. "x2": "50%",
  8358. "y2": "84%"
  8359. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
  8360. "id": getId(3),
  8361. "x1": "100%",
  8362. "x2": "100%",
  8363. "y2": "100%"
  8364. }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
  8365. "id": getId(4),
  8366. "cx": "50%",
  8367. "cy": "0%",
  8368. "fx": "50%",
  8369. "fy": "0%",
  8370. "r": "100%",
  8371. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8372. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
  8373. "fill": "none"
  8374. }, [renderBuilding(), vue.createVNode("path", {
  8375. "fill": getUrlById(4),
  8376. "d": "M0 139h160v21H0z"
  8377. }, null), vue.createVNode("path", {
  8378. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8379. "fill": getUrlById(2)
  8380. }, null), vue.createVNode("g", {
  8381. "opacity": ".6",
  8382. "stroke-linecap": "round",
  8383. "stroke-width": "7"
  8384. }, [vue.createVNode("path", {
  8385. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8386. "stroke": getUrlById(3)
  8387. }, null), vue.createVNode("path", {
  8388. "d": "M53 36a34 34 0 0 0 0 48",
  8389. "stroke": getUrlById(3)
  8390. }, null), vue.createVNode("path", {
  8391. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8392. "stroke": getUrlById(3)
  8393. }, null), vue.createVNode("path", {
  8394. "d": "M106 84a34 34 0 0 0 0-48",
  8395. "stroke": getUrlById(3)
  8396. }, null)]), vue.createVNode("g", {
  8397. "transform": "translate(31 105)"
  8398. }, [vue.createVNode("rect", {
  8399. "fill": "#EBEDF0",
  8400. "width": "98",
  8401. "height": "34",
  8402. "rx": "2"
  8403. }, null), vue.createVNode("rect", {
  8404. "fill": "#FFF",
  8405. "x": "9",
  8406. "y": "8",
  8407. "width": "80",
  8408. "height": "18",
  8409. "rx": "1.1"
  8410. }, null), vue.createVNode("rect", {
  8411. "fill": "#EBEDF0",
  8412. "x": "15",
  8413. "y": "12",
  8414. "width": "18",
  8415. "height": "6",
  8416. "rx": "1.1"
  8417. }, null)])])]);
  8418. const renderMaterial = () => vue.createVNode("svg", {
  8419. "viewBox": "0 0 160 160"
  8420. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8421. "x1": "50%",
  8422. "x2": "50%",
  8423. "y2": "100%",
  8424. "id": getId(5)
  8425. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8426. "x1": "95%",
  8427. "y1": "48%",
  8428. "x2": "5.5%",
  8429. "y2": "51%",
  8430. "id": getId(6)
  8431. }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8432. "y1": "45%",
  8433. "x2": "100%",
  8434. "y2": "54%",
  8435. "id": getId(7)
  8436. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
  8437. "transform": "translate(36 50)",
  8438. "fill": "none"
  8439. }, [vue.createVNode("g", {
  8440. "transform": "translate(8)"
  8441. }, [vue.createVNode("rect", {
  8442. "fill": "#EBEDF0",
  8443. "opacity": ".6",
  8444. "x": "38",
  8445. "y": "13",
  8446. "width": "36",
  8447. "height": "53",
  8448. "rx": "2"
  8449. }, null), vue.createVNode("rect", {
  8450. "fill": getUrlById(5),
  8451. "width": "64",
  8452. "height": "66",
  8453. "rx": "2"
  8454. }, null), vue.createVNode("rect", {
  8455. "fill": "#FFF",
  8456. "x": "6",
  8457. "y": "6",
  8458. "width": "52",
  8459. "height": "55",
  8460. "rx": "1"
  8461. }, null), vue.createVNode("g", {
  8462. "transform": "translate(15 17)",
  8463. "fill": getUrlById(6)
  8464. }, [vue.createVNode("rect", {
  8465. "width": "34",
  8466. "height": "6",
  8467. "rx": "1"
  8468. }, null), vue.createVNode("path", {
  8469. "d": "M0 14h34v6H0z"
  8470. }, null), vue.createVNode("rect", {
  8471. "y": "28",
  8472. "width": "34",
  8473. "height": "6",
  8474. "rx": "1"
  8475. }, null)])]), vue.createVNode("rect", {
  8476. "fill": getUrlById(7),
  8477. "y": "61",
  8478. "width": "88",
  8479. "height": "28",
  8480. "rx": "1"
  8481. }, null), vue.createVNode("rect", {
  8482. "fill": "#F7F8FA",
  8483. "x": "29",
  8484. "y": "72",
  8485. "width": "30",
  8486. "height": "6",
  8487. "rx": "1"
  8488. }, null)])]);
  8489. const renderError = () => vue.createVNode("svg", {
  8490. "viewBox": "0 0 160 160"
  8491. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8492. "x1": "50%",
  8493. "x2": "50%",
  8494. "y2": "100%",
  8495. "id": getId(8)
  8496. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
  8497. "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",
  8498. "fill": getUrlById(8)
  8499. }, null)]);
  8500. const renderSearch = () => vue.createVNode("svg", {
  8501. "viewBox": "0 0 160 160"
  8502. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8503. "x1": "50%",
  8504. "y1": "100%",
  8505. "x2": "50%",
  8506. "id": getId(9)
  8507. }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
  8508. "x1": "100%",
  8509. "y1": "50%",
  8510. "y2": "50%",
  8511. "id": getId(10)
  8512. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8513. "x1": "50%",
  8514. "x2": "50%",
  8515. "y2": "100%",
  8516. "id": getId(11)
  8517. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  8518. "x1": "50%",
  8519. "x2": "50%",
  8520. "y2": "100%",
  8521. "id": getId(12)
  8522. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
  8523. "transform": "rotate(-45 113 -4)",
  8524. "fill": "none"
  8525. }, [vue.createVNode("rect", {
  8526. "fill": getUrlById(9),
  8527. "x": "24",
  8528. "y": "52.8",
  8529. "width": "5.8",
  8530. "height": "19",
  8531. "rx": "1"
  8532. }, null), vue.createVNode("rect", {
  8533. "fill": getUrlById(10),
  8534. "x": "22.1",
  8535. "y": "67.3",
  8536. "width": "9.9",
  8537. "height": "28",
  8538. "rx": "1"
  8539. }, null), vue.createVNode("circle", {
  8540. "stroke": getUrlById(11),
  8541. "stroke-width": "8",
  8542. "cx": "27",
  8543. "cy": "27",
  8544. "r": "27"
  8545. }, null), vue.createVNode("circle", {
  8546. "fill": getUrlById(12),
  8547. "cx": "27",
  8548. "cy": "27",
  8549. "r": "16"
  8550. }, null), vue.createVNode("path", {
  8551. "d": "M37 7c-8 0-15 5-16 12",
  8552. "stroke": getUrlById(11),
  8553. "stroke-width": "3",
  8554. "opacity": ".5",
  8555. "stroke-linecap": "round",
  8556. "transform": "rotate(45 29 13)"
  8557. }, null)])]);
  8558. const renderImage = () => {
  8559. var _a;
  8560. if (slots.image) {
  8561. return slots.image();
  8562. }
  8563. const PRESET_IMAGES = {
  8564. error: renderError,
  8565. search: renderSearch,
  8566. network: renderNetwork,
  8567. default: renderMaterial
  8568. };
  8569. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
  8570. "src": props.image
  8571. }, null);
  8572. };
  8573. return () => vue.createVNode("div", {
  8574. "class": bem$E()
  8575. }, [vue.createVNode("div", {
  8576. "class": bem$E("image"),
  8577. "style": getSizeStyle(props.imageSize)
  8578. }, [renderImage()]), renderDescription(), renderBottom()]);
  8579. }
  8580. });
  8581. const Empty = withInstall(stdin_default$L);
  8582. const [name$E, bem$D, t$8] = createNamespace("coupon-list");
  8583. const couponListProps = {
  8584. code: makeStringProp(""),
  8585. coupons: makeArrayProp(),
  8586. currency: makeStringProp("\xA5"),
  8587. showCount: truthProp,
  8588. emptyImage: String,
  8589. chosenCoupon: makeNumberProp(-1),
  8590. enabledTitle: String,
  8591. disabledTitle: String,
  8592. disabledCoupons: makeArrayProp(),
  8593. showExchangeBar: truthProp,
  8594. showCloseButton: truthProp,
  8595. closeButtonText: String,
  8596. inputPlaceholder: String,
  8597. exchangeMinLength: makeNumberProp(1),
  8598. exchangeButtonText: String,
  8599. displayedCouponIndex: makeNumberProp(-1),
  8600. exchangeButtonLoading: Boolean,
  8601. exchangeButtonDisabled: Boolean
  8602. };
  8603. var stdin_default$K = vue.defineComponent({
  8604. name: name$E,
  8605. props: couponListProps,
  8606. emits: ["change", "exchange", "update:code"],
  8607. setup(props, {
  8608. emit,
  8609. slots
  8610. }) {
  8611. const [couponRefs, setCouponRefs] = useRefs();
  8612. const root = vue.ref();
  8613. const barRef = vue.ref();
  8614. const activeTab = vue.ref(0);
  8615. const listHeight = vue.ref(0);
  8616. const currentCode = vue.ref(props.code);
  8617. const buttonDisabled = vue.computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8618. const updateListHeight = () => {
  8619. const TABS_HEIGHT = 44;
  8620. const rootHeight = useRect(root).height;
  8621. const headerHeight = useRect(barRef).height + TABS_HEIGHT;
  8622. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8623. };
  8624. const onExchange = () => {
  8625. emit("exchange", currentCode.value);
  8626. if (!props.code) {
  8627. currentCode.value = "";
  8628. }
  8629. };
  8630. const scrollToCoupon = (index) => {
  8631. vue.nextTick(() => {
  8632. var _a;
  8633. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8634. });
  8635. };
  8636. const renderEmpty = () => vue.createVNode(Empty, {
  8637. "image": props.emptyImage
  8638. }, {
  8639. default: () => [vue.createVNode("p", {
  8640. "class": bem$D("empty-tip")
  8641. }, [t$8("noCoupon")])]
  8642. });
  8643. const renderExchangeBar = () => {
  8644. if (props.showExchangeBar) {
  8645. return vue.createVNode("div", {
  8646. "ref": barRef,
  8647. "class": bem$D("exchange-bar")
  8648. }, [vue.createVNode(Field, {
  8649. "modelValue": currentCode.value,
  8650. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8651. "clearable": true,
  8652. "border": false,
  8653. "class": bem$D("field"),
  8654. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8655. "maxlength": "20"
  8656. }, null), vue.createVNode(Button, {
  8657. "plain": true,
  8658. "type": "danger",
  8659. "class": bem$D("exchange"),
  8660. "text": props.exchangeButtonText || t$8("exchange"),
  8661. "loading": props.exchangeButtonLoading,
  8662. "disabled": buttonDisabled.value,
  8663. "onClick": onExchange
  8664. }, null)]);
  8665. }
  8666. };
  8667. const renderCouponTab = () => {
  8668. const {
  8669. coupons
  8670. } = props;
  8671. const count = props.showCount ? ` (${coupons.length})` : "";
  8672. const title = (props.enabledTitle || t$8("enable")) + count;
  8673. return vue.createVNode(Tab, {
  8674. "title": title
  8675. }, {
  8676. default: () => {
  8677. var _a;
  8678. return [vue.createVNode("div", {
  8679. "class": bem$D("list", {
  8680. "with-bottom": props.showCloseButton
  8681. }),
  8682. "style": {
  8683. height: `${listHeight.value}px`
  8684. }
  8685. }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
  8686. "key": coupon.id,
  8687. "ref": setCouponRefs(index),
  8688. "coupon": coupon,
  8689. "chosen": index === props.chosenCoupon,
  8690. "currency": props.currency,
  8691. "onClick": () => emit("change", index)
  8692. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8693. }
  8694. });
  8695. };
  8696. const renderDisabledTab = () => {
  8697. const {
  8698. disabledCoupons
  8699. } = props;
  8700. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8701. const title = (props.disabledTitle || t$8("disabled")) + count;
  8702. return vue.createVNode(Tab, {
  8703. "title": title
  8704. }, {
  8705. default: () => {
  8706. var _a;
  8707. return [vue.createVNode("div", {
  8708. "class": bem$D("list", {
  8709. "with-bottom": props.showCloseButton
  8710. }),
  8711. "style": {
  8712. height: `${listHeight.value}px`
  8713. }
  8714. }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
  8715. "disabled": true,
  8716. "key": coupon.id,
  8717. "coupon": coupon,
  8718. "currency": props.currency
  8719. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8720. }
  8721. });
  8722. };
  8723. vue.watch(() => props.code, (value) => {
  8724. currentCode.value = value;
  8725. });
  8726. vue.watch(windowHeight, updateListHeight);
  8727. vue.watch(currentCode, (value) => emit("update:code", value));
  8728. vue.watch(() => props.displayedCouponIndex, scrollToCoupon);
  8729. vue.onMounted(() => {
  8730. updateListHeight();
  8731. scrollToCoupon(props.displayedCouponIndex);
  8732. });
  8733. return () => vue.createVNode("div", {
  8734. "ref": root,
  8735. "class": bem$D()
  8736. }, [renderExchangeBar(), vue.createVNode(Tabs, {
  8737. "active": activeTab.value,
  8738. "onUpdate:active": ($event) => activeTab.value = $event,
  8739. "class": bem$D("tab")
  8740. }, {
  8741. default: () => [renderCouponTab(), renderDisabledTab()]
  8742. }), vue.createVNode("div", {
  8743. "class": bem$D("bottom")
  8744. }, [vue.withDirectives(vue.createVNode(Button, {
  8745. "round": true,
  8746. "block": true,
  8747. "type": "danger",
  8748. "class": bem$D("close"),
  8749. "text": props.closeButtonText || t$8("close"),
  8750. "onClick": () => emit("change", -1)
  8751. }, null), [[vue.vShow, props.showCloseButton]])])]);
  8752. }
  8753. });
  8754. const CouponList = withInstall(stdin_default$K);
  8755. const [name$D] = createNamespace("time-picker");
  8756. var stdin_default$J = vue.defineComponent({
  8757. name: name$D,
  8758. props: extend({}, sharedProps, {
  8759. minHour: makeNumericProp(0),
  8760. maxHour: makeNumericProp(23),
  8761. minMinute: makeNumericProp(0),
  8762. maxMinute: makeNumericProp(59),
  8763. modelValue: String
  8764. }),
  8765. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8766. setup(props, {
  8767. emit,
  8768. slots
  8769. }) {
  8770. const formatValue2 = (value) => {
  8771. const {
  8772. minHour,
  8773. maxHour,
  8774. maxMinute,
  8775. minMinute
  8776. } = props;
  8777. if (!value) {
  8778. value = `${padZero(minHour)}:${padZero(minMinute)}`;
  8779. }
  8780. let [hour, minute] = value.split(":");
  8781. hour = padZero(clamp(+hour, +minHour, +maxHour));
  8782. minute = padZero(clamp(+minute, +minMinute, +maxMinute));
  8783. return `${hour}:${minute}`;
  8784. };
  8785. const picker = vue.ref();
  8786. const currentDate = vue.ref(formatValue2(props.modelValue));
  8787. const ranges = vue.computed(() => [{
  8788. type: "hour",
  8789. range: [+props.minHour, +props.maxHour]
  8790. }, {
  8791. type: "minute",
  8792. range: [+props.minMinute, +props.maxMinute]
  8793. }]);
  8794. const originColumns = vue.computed(() => ranges.value.map(({
  8795. type,
  8796. range: rangeArr
  8797. }) => {
  8798. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8799. if (props.filter) {
  8800. values = props.filter(type, values);
  8801. }
  8802. return {
  8803. type,
  8804. values
  8805. };
  8806. }));
  8807. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8808. values: column.values.map((value) => props.formatter(column.type, value))
  8809. })));
  8810. const updateColumnValue = () => {
  8811. const pair = currentDate.value.split(":");
  8812. const values = [props.formatter("hour", pair[0]), props.formatter("minute", pair[1])];
  8813. vue.nextTick(() => {
  8814. var _a;
  8815. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8816. });
  8817. };
  8818. const updateInnerValue = () => {
  8819. const [hourIndex, minuteIndex] = picker.value.getIndexes();
  8820. const [hourColumn, minuteColumn] = originColumns.value;
  8821. const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
  8822. const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
  8823. currentDate.value = formatValue2(`${hour}:${minute}`);
  8824. updateColumnValue();
  8825. };
  8826. const onConfirm = () => emit("confirm", currentDate.value);
  8827. const onCancel = () => emit("cancel");
  8828. const onChange = () => {
  8829. updateInnerValue();
  8830. vue.nextTick(() => {
  8831. vue.nextTick(() => emit("change", currentDate.value));
  8832. });
  8833. };
  8834. vue.onMounted(() => {
  8835. updateColumnValue();
  8836. vue.nextTick(updateInnerValue);
  8837. });
  8838. vue.watch(columns, updateColumnValue);
  8839. vue.watch(() => [props.filter, props.maxHour, props.minMinute, props.maxMinute], updateInnerValue);
  8840. vue.watch(() => props.minHour, () => {
  8841. vue.nextTick(updateInnerValue);
  8842. });
  8843. vue.watch(currentDate, (value) => emit("update:modelValue", value));
  8844. vue.watch(() => props.modelValue, (value) => {
  8845. value = formatValue2(value);
  8846. if (value !== currentDate.value) {
  8847. currentDate.value = value;
  8848. updateColumnValue();
  8849. }
  8850. });
  8851. useExpose({
  8852. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8853. });
  8854. return () => vue.createVNode(Picker, vue.mergeProps({
  8855. "ref": picker,
  8856. "columns": columns.value,
  8857. "onChange": onChange,
  8858. "onCancel": onCancel,
  8859. "onConfirm": onConfirm
  8860. }, pick(props, pickerInheritKeys)), slots);
  8861. }
  8862. });
  8863. const currentYear = new Date().getFullYear();
  8864. const [name$C] = createNamespace("date-picker");
  8865. var stdin_default$I = vue.defineComponent({
  8866. name: name$C,
  8867. props: extend({}, sharedProps, {
  8868. type: makeStringProp("datetime"),
  8869. modelValue: Date,
  8870. minDate: {
  8871. type: Date,
  8872. default: () => new Date(currentYear - 10, 0, 1),
  8873. validator: isDate
  8874. },
  8875. maxDate: {
  8876. type: Date,
  8877. default: () => new Date(currentYear + 10, 11, 31),
  8878. validator: isDate
  8879. }
  8880. }),
  8881. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8882. setup(props, {
  8883. emit,
  8884. slots
  8885. }) {
  8886. const formatValue2 = (value) => {
  8887. if (isDate(value)) {
  8888. const timestamp = clamp(value.getTime(), props.minDate.getTime(), props.maxDate.getTime());
  8889. return new Date(timestamp);
  8890. }
  8891. return void 0;
  8892. };
  8893. const picker = vue.ref();
  8894. const currentDate = vue.ref(formatValue2(props.modelValue));
  8895. const getBoundary = (type, value) => {
  8896. const boundary = props[`${type}Date`];
  8897. const year = boundary.getFullYear();
  8898. let month = 1;
  8899. let date = 1;
  8900. let hour = 0;
  8901. let minute = 0;
  8902. if (type === "max") {
  8903. month = 12;
  8904. date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
  8905. hour = 23;
  8906. minute = 59;
  8907. }
  8908. if (value.getFullYear() === year) {
  8909. month = boundary.getMonth() + 1;
  8910. if (value.getMonth() + 1 === month) {
  8911. date = boundary.getDate();
  8912. if (value.getDate() === date) {
  8913. hour = boundary.getHours();
  8914. if (value.getHours() === hour) {
  8915. minute = boundary.getMinutes();
  8916. }
  8917. }
  8918. }
  8919. }
  8920. return {
  8921. [`${type}Year`]: year,
  8922. [`${type}Month`]: month,
  8923. [`${type}Date`]: date,
  8924. [`${type}Hour`]: hour,
  8925. [`${type}Minute`]: minute
  8926. };
  8927. };
  8928. const ranges = vue.computed(() => {
  8929. const {
  8930. maxYear,
  8931. maxDate,
  8932. maxMonth,
  8933. maxHour,
  8934. maxMinute
  8935. } = getBoundary("max", currentDate.value || props.minDate);
  8936. const {
  8937. minYear,
  8938. minDate,
  8939. minMonth,
  8940. minHour,
  8941. minMinute
  8942. } = getBoundary("min", currentDate.value || props.minDate);
  8943. let result = [{
  8944. type: "year",
  8945. range: [minYear, maxYear]
  8946. }, {
  8947. type: "month",
  8948. range: [minMonth, maxMonth]
  8949. }, {
  8950. type: "day",
  8951. range: [minDate, maxDate]
  8952. }, {
  8953. type: "hour",
  8954. range: [minHour, maxHour]
  8955. }, {
  8956. type: "minute",
  8957. range: [minMinute, maxMinute]
  8958. }];
  8959. switch (props.type) {
  8960. case "date":
  8961. result = result.slice(0, 3);
  8962. break;
  8963. case "year-month":
  8964. result = result.slice(0, 2);
  8965. break;
  8966. case "month-day":
  8967. result = result.slice(1, 3);
  8968. break;
  8969. case "datehour":
  8970. result = result.slice(0, 4);
  8971. break;
  8972. }
  8973. if (props.columnsOrder) {
  8974. const columnsOrder = props.columnsOrder.concat(result.map((column) => column.type));
  8975. result.sort((a, b) => columnsOrder.indexOf(a.type) - columnsOrder.indexOf(b.type));
  8976. }
  8977. return result;
  8978. });
  8979. const originColumns = vue.computed(() => ranges.value.map(({
  8980. type,
  8981. range: rangeArr
  8982. }) => {
  8983. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8984. if (props.filter) {
  8985. values = props.filter(type, values);
  8986. }
  8987. return {
  8988. type,
  8989. values
  8990. };
  8991. }));
  8992. const columns = vue.computed(() => originColumns.value.map((column) => ({
  8993. values: column.values.map((value) => props.formatter(column.type, value))
  8994. })));
  8995. const updateColumnValue = () => {
  8996. const value = currentDate.value || props.minDate;
  8997. const {
  8998. formatter
  8999. } = props;
  9000. const values = originColumns.value.map((column) => {
  9001. switch (column.type) {
  9002. case "year":
  9003. return formatter("year", `${value.getFullYear()}`);
  9004. case "month":
  9005. return formatter("month", padZero(value.getMonth() + 1));
  9006. case "day":
  9007. return formatter("day", padZero(value.getDate()));
  9008. case "hour":
  9009. return formatter("hour", padZero(value.getHours()));
  9010. case "minute":
  9011. return formatter("minute", padZero(value.getMinutes()));
  9012. default:
  9013. return "";
  9014. }
  9015. });
  9016. vue.nextTick(() => {
  9017. var _a;
  9018. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  9019. });
  9020. };
  9021. const updateInnerValue = () => {
  9022. const {
  9023. type
  9024. } = props;
  9025. const indexes = picker.value.getIndexes();
  9026. const getValue = (type2) => {
  9027. let index = 0;
  9028. originColumns.value.forEach((column, columnIndex) => {
  9029. if (type2 === column.type) {
  9030. index = columnIndex;
  9031. }
  9032. });
  9033. const {
  9034. values
  9035. } = originColumns.value[index];
  9036. return getTrueValue(values[indexes[index]]);
  9037. };
  9038. let year;
  9039. let month;
  9040. let day;
  9041. if (type === "month-day") {
  9042. year = (currentDate.value || props.minDate).getFullYear();
  9043. month = getValue("month");
  9044. day = getValue("day");
  9045. } else {
  9046. year = getValue("year");
  9047. month = getValue("month");
  9048. day = type === "year-month" ? 1 : getValue("day");
  9049. }
  9050. const maxDay = getMonthEndDay(year, month);
  9051. day = day > maxDay ? maxDay : day;
  9052. let hour = 0;
  9053. let minute = 0;
  9054. if (type === "datehour") {
  9055. hour = getValue("hour");
  9056. }
  9057. if (type === "datetime") {
  9058. hour = getValue("hour");
  9059. minute = getValue("minute");
  9060. }
  9061. const value = new Date(year, month - 1, day, hour, minute);
  9062. currentDate.value = formatValue2(value);
  9063. };
  9064. const onConfirm = () => {
  9065. emit("update:modelValue", currentDate.value);
  9066. emit("confirm", currentDate.value);
  9067. };
  9068. const onCancel = () => emit("cancel");
  9069. const onChange = () => {
  9070. updateInnerValue();
  9071. vue.nextTick(() => {
  9072. updateInnerValue();
  9073. vue.nextTick(() => emit("change", currentDate.value));
  9074. });
  9075. };
  9076. vue.onMounted(() => {
  9077. updateColumnValue();
  9078. vue.nextTick(updateInnerValue);
  9079. });
  9080. vue.watch(columns, updateColumnValue);
  9081. vue.watch(currentDate, (value, oldValue) => emit("update:modelValue", oldValue ? value : null));
  9082. vue.watch(() => [props.filter, props.minDate, props.maxDate], () => {
  9083. vue.nextTick(updateInnerValue);
  9084. });
  9085. vue.watch(() => props.modelValue, (value) => {
  9086. var _a;
  9087. value = formatValue2(value);
  9088. if (value && value.valueOf() !== ((_a = currentDate.value) == null ? void 0 : _a.valueOf())) {
  9089. currentDate.value = value;
  9090. }
  9091. });
  9092. useExpose({
  9093. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  9094. });
  9095. return () => vue.createVNode(Picker, vue.mergeProps({
  9096. "ref": picker,
  9097. "columns": columns.value,
  9098. "onChange": onChange,
  9099. "onCancel": onCancel,
  9100. "onConfirm": onConfirm
  9101. }, pick(props, pickerInheritKeys)), slots);
  9102. }
  9103. });
  9104. const [name$B, bem$C] = createNamespace("datetime-picker");
  9105. const timePickerPropKeys = Object.keys(stdin_default$J.props);
  9106. const datePickerPropKeys = Object.keys(stdin_default$I.props);
  9107. const datetimePickerProps = extend({}, stdin_default$J.props, stdin_default$I.props, {
  9108. modelValue: [String, Date]
  9109. });
  9110. var stdin_default$H = vue.defineComponent({
  9111. name: name$B,
  9112. props: datetimePickerProps,
  9113. setup(props, {
  9114. attrs,
  9115. slots
  9116. }) {
  9117. const root = vue.ref();
  9118. useExpose({
  9119. getPicker: () => {
  9120. var _a;
  9121. return (_a = root.value) == null ? void 0 : _a.getPicker();
  9122. }
  9123. });
  9124. return () => {
  9125. const isTimePicker = props.type === "time";
  9126. const Component = isTimePicker ? stdin_default$J : stdin_default$I;
  9127. const inheritProps = pick(props, isTimePicker ? timePickerPropKeys : datePickerPropKeys);
  9128. return vue.createVNode(Component, vue.mergeProps({
  9129. "ref": root,
  9130. "class": bem$C()
  9131. }, inheritProps, attrs), slots);
  9132. };
  9133. }
  9134. });
  9135. const DatetimePicker = withInstall(stdin_default$H);
  9136. const [name$A, bem$B, t$7] = createNamespace("dialog");
  9137. const dialogProps = extend({}, popupSharedProps, {
  9138. title: String,
  9139. theme: String,
  9140. width: numericProp,
  9141. message: [String, Function],
  9142. callback: Function,
  9143. allowHtml: Boolean,
  9144. className: unknownProp,
  9145. transition: makeStringProp("van-dialog-bounce"),
  9146. messageAlign: String,
  9147. closeOnPopstate: truthProp,
  9148. showCancelButton: Boolean,
  9149. cancelButtonText: String,
  9150. cancelButtonColor: String,
  9151. cancelButtonDisabled: Boolean,
  9152. confirmButtonText: String,
  9153. confirmButtonColor: String,
  9154. confirmButtonDisabled: Boolean,
  9155. showConfirmButton: truthProp,
  9156. closeOnClickOverlay: Boolean
  9157. });
  9158. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  9159. var stdin_default$G = vue.defineComponent({
  9160. name: name$A,
  9161. props: dialogProps,
  9162. emits: ["confirm", "cancel", "keydown", "update:show"],
  9163. setup(props, {
  9164. emit,
  9165. slots
  9166. }) {
  9167. const root = vue.ref();
  9168. const loading = vue.reactive({
  9169. confirm: false,
  9170. cancel: false
  9171. });
  9172. const updateShow = (value) => emit("update:show", value);
  9173. const close = (action) => {
  9174. var _a;
  9175. updateShow(false);
  9176. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  9177. };
  9178. const getActionHandler = (action) => () => {
  9179. if (!props.show) {
  9180. return;
  9181. }
  9182. emit(action);
  9183. if (props.beforeClose) {
  9184. loading[action] = true;
  9185. callInterceptor(props.beforeClose, {
  9186. args: [action],
  9187. done() {
  9188. close(action);
  9189. loading[action] = false;
  9190. },
  9191. canceled() {
  9192. loading[action] = false;
  9193. }
  9194. });
  9195. } else {
  9196. close(action);
  9197. }
  9198. };
  9199. const onCancel = getActionHandler("cancel");
  9200. const onConfirm = getActionHandler("confirm");
  9201. const onKeydown = vue.withKeys((event) => {
  9202. var _a, _b;
  9203. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  9204. return;
  9205. }
  9206. const onEventType = {
  9207. Enter: props.showConfirmButton ? onConfirm : noop,
  9208. Escape: props.showCancelButton ? onCancel : noop
  9209. };
  9210. onEventType[event.key]();
  9211. emit("keydown", event);
  9212. }, ["enter", "esc"]);
  9213. const renderTitle = () => {
  9214. const title = slots.title ? slots.title() : props.title;
  9215. if (title) {
  9216. return vue.createVNode("div", {
  9217. "class": bem$B("header", {
  9218. isolated: !props.message && !slots.default
  9219. })
  9220. }, [title]);
  9221. }
  9222. };
  9223. const renderMessage = (hasTitle) => {
  9224. const {
  9225. message,
  9226. allowHtml,
  9227. messageAlign
  9228. } = props;
  9229. const classNames = bem$B("message", {
  9230. "has-title": hasTitle,
  9231. [messageAlign]: messageAlign
  9232. });
  9233. const content = isFunction(message) ? message() : message;
  9234. if (allowHtml && typeof content === "string") {
  9235. return vue.createVNode("div", {
  9236. "class": classNames,
  9237. "innerHTML": content
  9238. }, null);
  9239. }
  9240. return vue.createVNode("div", {
  9241. "class": classNames
  9242. }, [content]);
  9243. };
  9244. const renderContent = () => {
  9245. if (slots.default) {
  9246. return vue.createVNode("div", {
  9247. "class": bem$B("content")
  9248. }, [slots.default()]);
  9249. }
  9250. const {
  9251. title,
  9252. message,
  9253. allowHtml
  9254. } = props;
  9255. if (message) {
  9256. const hasTitle = !!(title || slots.title);
  9257. return vue.createVNode("div", {
  9258. "key": allowHtml ? 1 : 0,
  9259. "class": bem$B("content", {
  9260. isolated: !hasTitle
  9261. })
  9262. }, [renderMessage(hasTitle)]);
  9263. }
  9264. };
  9265. const renderButtons = () => vue.createVNode("div", {
  9266. "class": [BORDER_TOP, bem$B("footer")]
  9267. }, [props.showCancelButton && vue.createVNode(Button, {
  9268. "size": "large",
  9269. "text": props.cancelButtonText || t$7("cancel"),
  9270. "class": bem$B("cancel"),
  9271. "style": {
  9272. color: props.cancelButtonColor
  9273. },
  9274. "loading": loading.cancel,
  9275. "disabled": props.cancelButtonDisabled,
  9276. "onClick": onCancel
  9277. }, null), props.showConfirmButton && vue.createVNode(Button, {
  9278. "size": "large",
  9279. "text": props.confirmButtonText || t$7("confirm"),
  9280. "class": [bem$B("confirm"), {
  9281. [BORDER_LEFT]: props.showCancelButton
  9282. }],
  9283. "style": {
  9284. color: props.confirmButtonColor
  9285. },
  9286. "loading": loading.confirm,
  9287. "disabled": props.confirmButtonDisabled,
  9288. "onClick": onConfirm
  9289. }, null)]);
  9290. const renderRoundButtons = () => vue.createVNode(ActionBar, {
  9291. "class": bem$B("footer")
  9292. }, {
  9293. default: () => [props.showCancelButton && vue.createVNode(ActionBarButton, {
  9294. "type": "warning",
  9295. "text": props.cancelButtonText || t$7("cancel"),
  9296. "class": bem$B("cancel"),
  9297. "color": props.cancelButtonColor,
  9298. "loading": loading.cancel,
  9299. "disabled": props.cancelButtonDisabled,
  9300. "onClick": onCancel
  9301. }, null), props.showConfirmButton && vue.createVNode(ActionBarButton, {
  9302. "type": "danger",
  9303. "text": props.confirmButtonText || t$7("confirm"),
  9304. "class": bem$B("confirm"),
  9305. "color": props.confirmButtonColor,
  9306. "loading": loading.confirm,
  9307. "disabled": props.confirmButtonDisabled,
  9308. "onClick": onConfirm
  9309. }, null)]
  9310. });
  9311. const renderFooter = () => {
  9312. if (slots.footer) {
  9313. return slots.footer();
  9314. }
  9315. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  9316. };
  9317. return () => {
  9318. const {
  9319. width: width2,
  9320. title,
  9321. theme,
  9322. message,
  9323. className
  9324. } = props;
  9325. return vue.createVNode(Popup, vue.mergeProps({
  9326. "ref": root,
  9327. "role": "dialog",
  9328. "class": [bem$B([theme]), className],
  9329. "style": {
  9330. width: addUnit(width2)
  9331. },
  9332. "tabindex": 0,
  9333. "aria-labelledby": title || message,
  9334. "onKeydown": onKeydown,
  9335. "onUpdate:show": updateShow
  9336. }, pick(props, popupInheritKeys$1)), {
  9337. default: () => [renderTitle(), renderContent(), renderFooter()]
  9338. });
  9339. };
  9340. }
  9341. });
  9342. let instance$2;
  9343. function initInstance$2() {
  9344. const Wrapper = {
  9345. setup() {
  9346. const {
  9347. state,
  9348. toggle
  9349. } = usePopupState();
  9350. return () => vue.createVNode(stdin_default$G, vue.mergeProps(state, {
  9351. "onUpdate:show": toggle
  9352. }), null);
  9353. }
  9354. };
  9355. ({
  9356. instance: instance$2
  9357. } = mountComponent(Wrapper));
  9358. }
  9359. function Dialog(options) {
  9360. if (!inBrowser$1) {
  9361. return Promise.resolve();
  9362. }
  9363. return new Promise((resolve, reject) => {
  9364. if (!instance$2) {
  9365. initInstance$2();
  9366. }
  9367. instance$2.open(extend({}, Dialog.currentOptions, options, {
  9368. callback: (action) => {
  9369. (action === "confirm" ? resolve : reject)(action);
  9370. }
  9371. }));
  9372. });
  9373. }
  9374. Dialog.defaultOptions = {
  9375. title: "",
  9376. width: "",
  9377. theme: null,
  9378. message: "",
  9379. overlay: true,
  9380. callback: null,
  9381. teleport: "body",
  9382. className: "",
  9383. allowHtml: false,
  9384. lockScroll: true,
  9385. transition: void 0,
  9386. beforeClose: null,
  9387. overlayClass: "",
  9388. overlayStyle: void 0,
  9389. messageAlign: "",
  9390. cancelButtonText: "",
  9391. cancelButtonColor: null,
  9392. cancelButtonDisabled: false,
  9393. confirmButtonText: "",
  9394. confirmButtonColor: null,
  9395. confirmButtonDisabled: false,
  9396. showConfirmButton: true,
  9397. showCancelButton: false,
  9398. closeOnPopstate: true,
  9399. closeOnClickOverlay: false
  9400. };
  9401. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9402. Dialog.alert = Dialog;
  9403. Dialog.confirm = (options) => Dialog(extend({
  9404. showCancelButton: true
  9405. }, options));
  9406. Dialog.close = () => {
  9407. if (instance$2) {
  9408. instance$2.toggle(false);
  9409. }
  9410. };
  9411. Dialog.setDefaultOptions = (options) => {
  9412. extend(Dialog.currentOptions, options);
  9413. };
  9414. Dialog.resetDefaultOptions = () => {
  9415. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9416. };
  9417. Dialog.Component = withInstall(stdin_default$G);
  9418. Dialog.install = (app) => {
  9419. app.use(Dialog.Component);
  9420. app.config.globalProperties.$dialog = Dialog;
  9421. };
  9422. const [name$z, bem$A] = createNamespace("divider");
  9423. const dividerProps = {
  9424. dashed: Boolean,
  9425. hairline: truthProp,
  9426. contentPosition: makeStringProp("center")
  9427. };
  9428. var stdin_default$F = vue.defineComponent({
  9429. name: name$z,
  9430. props: dividerProps,
  9431. setup(props, {
  9432. slots
  9433. }) {
  9434. return () => {
  9435. var _a;
  9436. return vue.createVNode("div", {
  9437. "role": "separator",
  9438. "class": bem$A({
  9439. dashed: props.dashed,
  9440. hairline: props.hairline,
  9441. [`content-${props.contentPosition}`]: !!slots.default
  9442. })
  9443. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9444. };
  9445. }
  9446. });
  9447. const Divider = withInstall(stdin_default$F);
  9448. const [name$y, bem$z] = createNamespace("dropdown-menu");
  9449. const dropdownMenuProps = {
  9450. overlay: truthProp,
  9451. zIndex: numericProp,
  9452. duration: makeNumericProp(0.2),
  9453. direction: makeStringProp("down"),
  9454. activeColor: String,
  9455. closeOnClickOutside: truthProp,
  9456. closeOnClickOverlay: truthProp
  9457. };
  9458. const DROPDOWN_KEY = Symbol(name$y);
  9459. var stdin_default$E = vue.defineComponent({
  9460. name: name$y,
  9461. props: dropdownMenuProps,
  9462. setup(props, {
  9463. slots
  9464. }) {
  9465. const id = useId();
  9466. const root = vue.ref();
  9467. const barRef = vue.ref();
  9468. const offset2 = vue.ref(0);
  9469. const {
  9470. children,
  9471. linkChildren
  9472. } = useChildren(DROPDOWN_KEY);
  9473. const scrollParent = useScrollParent(root);
  9474. const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
  9475. const barStyle = vue.computed(() => {
  9476. if (opened.value && isDef(props.zIndex)) {
  9477. return {
  9478. zIndex: +props.zIndex + 1
  9479. };
  9480. }
  9481. });
  9482. const onClickAway = () => {
  9483. if (props.closeOnClickOutside) {
  9484. children.forEach((item) => {
  9485. item.toggle(false);
  9486. });
  9487. }
  9488. };
  9489. const updateOffset = () => {
  9490. if (barRef.value) {
  9491. const rect = useRect(barRef);
  9492. if (props.direction === "down") {
  9493. offset2.value = rect.bottom;
  9494. } else {
  9495. offset2.value = windowHeight.value - rect.top;
  9496. }
  9497. }
  9498. };
  9499. const onScroll = () => {
  9500. if (opened.value) {
  9501. updateOffset();
  9502. }
  9503. };
  9504. const toggleItem = (active) => {
  9505. children.forEach((item, index) => {
  9506. if (index === active) {
  9507. updateOffset();
  9508. item.toggle();
  9509. } else if (item.state.showPopup) {
  9510. item.toggle(false, {
  9511. immediate: true
  9512. });
  9513. }
  9514. });
  9515. };
  9516. const renderTitle = (item, index) => {
  9517. const {
  9518. showPopup
  9519. } = item.state;
  9520. const {
  9521. disabled,
  9522. titleClass
  9523. } = item;
  9524. return vue.createVNode("div", {
  9525. "id": `${id}-${index}`,
  9526. "role": "button",
  9527. "tabindex": disabled ? void 0 : 0,
  9528. "class": [bem$z("item", {
  9529. disabled
  9530. }), {
  9531. [HAPTICS_FEEDBACK]: !disabled
  9532. }],
  9533. "onClick": () => {
  9534. if (!disabled) {
  9535. toggleItem(index);
  9536. }
  9537. }
  9538. }, [vue.createVNode("span", {
  9539. "class": [bem$z("title", {
  9540. down: showPopup === (props.direction === "down"),
  9541. active: showPopup
  9542. }), titleClass],
  9543. "style": {
  9544. color: showPopup ? props.activeColor : ""
  9545. }
  9546. }, [vue.createVNode("div", {
  9547. "class": "van-ellipsis"
  9548. }, [item.renderTitle()])])]);
  9549. };
  9550. linkChildren({
  9551. id,
  9552. props,
  9553. offset: offset2
  9554. });
  9555. useClickAway(root, onClickAway);
  9556. useEventListener("scroll", onScroll, {
  9557. target: scrollParent,
  9558. passive: true
  9559. });
  9560. return () => {
  9561. var _a;
  9562. return vue.createVNode("div", {
  9563. "ref": root,
  9564. "class": bem$z()
  9565. }, [vue.createVNode("div", {
  9566. "ref": barRef,
  9567. "style": barStyle.value,
  9568. "class": bem$z("bar", {
  9569. opened: opened.value
  9570. })
  9571. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9572. };
  9573. }
  9574. });
  9575. const [name$x, bem$y] = createNamespace("dropdown-item");
  9576. const dropdownItemProps = {
  9577. title: String,
  9578. options: makeArrayProp(),
  9579. disabled: Boolean,
  9580. teleport: [String, Object],
  9581. lazyRender: truthProp,
  9582. modelValue: unknownProp,
  9583. titleClass: unknownProp
  9584. };
  9585. var stdin_default$D = vue.defineComponent({
  9586. name: name$x,
  9587. props: dropdownItemProps,
  9588. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9589. setup(props, {
  9590. emit,
  9591. slots
  9592. }) {
  9593. const state = vue.reactive({
  9594. showPopup: false,
  9595. transition: true,
  9596. showWrapper: false
  9597. });
  9598. const {
  9599. parent,
  9600. index
  9601. } = useParent(DROPDOWN_KEY);
  9602. if (!parent) {
  9603. return;
  9604. }
  9605. const getEmitter = (name2) => () => emit(name2);
  9606. const onOpen = getEmitter("open");
  9607. const onClose = getEmitter("close");
  9608. const onOpened = getEmitter("opened");
  9609. const onClosed = () => {
  9610. state.showWrapper = false;
  9611. emit("closed");
  9612. };
  9613. const onClickWrapper = (event) => {
  9614. if (props.teleport) {
  9615. event.stopPropagation();
  9616. }
  9617. };
  9618. const toggle = (show = !state.showPopup, options = {}) => {
  9619. if (show === state.showPopup) {
  9620. return;
  9621. }
  9622. state.showPopup = show;
  9623. state.transition = !options.immediate;
  9624. if (show) {
  9625. state.showWrapper = true;
  9626. }
  9627. };
  9628. const renderTitle = () => {
  9629. if (slots.title) {
  9630. return slots.title();
  9631. }
  9632. if (props.title) {
  9633. return props.title;
  9634. }
  9635. const match = props.options.find((option) => option.value === props.modelValue);
  9636. return match ? match.text : "";
  9637. };
  9638. const renderOption = (option) => {
  9639. const {
  9640. activeColor
  9641. } = parent.props;
  9642. const active = option.value === props.modelValue;
  9643. const onClick = () => {
  9644. state.showPopup = false;
  9645. if (option.value !== props.modelValue) {
  9646. emit("update:modelValue", option.value);
  9647. emit("change", option.value);
  9648. }
  9649. };
  9650. const renderIcon = () => {
  9651. if (active) {
  9652. return vue.createVNode(Icon, {
  9653. "class": bem$y("icon"),
  9654. "color": activeColor,
  9655. "name": "success"
  9656. }, null);
  9657. }
  9658. };
  9659. return vue.createVNode(Cell, {
  9660. "role": "menuitem",
  9661. "key": option.value,
  9662. "icon": option.icon,
  9663. "title": option.text,
  9664. "class": bem$y("option", {
  9665. active
  9666. }),
  9667. "style": {
  9668. color: active ? activeColor : ""
  9669. },
  9670. "tabindex": active ? 0 : -1,
  9671. "clickable": true,
  9672. "onClick": onClick
  9673. }, {
  9674. value: renderIcon
  9675. });
  9676. };
  9677. const renderContent = () => {
  9678. const {
  9679. offset: offset2
  9680. } = parent;
  9681. const {
  9682. zIndex,
  9683. overlay,
  9684. duration,
  9685. direction,
  9686. closeOnClickOverlay
  9687. } = parent.props;
  9688. const style = getZIndexStyle(zIndex);
  9689. if (direction === "down") {
  9690. style.top = `${offset2.value}px`;
  9691. } else {
  9692. style.bottom = `${offset2.value}px`;
  9693. }
  9694. return vue.withDirectives(vue.createVNode("div", {
  9695. "style": style,
  9696. "class": bem$y([direction]),
  9697. "onClick": onClickWrapper
  9698. }, [vue.createVNode(Popup, {
  9699. "show": state.showPopup,
  9700. "onUpdate:show": ($event) => state.showPopup = $event,
  9701. "role": "menu",
  9702. "class": bem$y("content"),
  9703. "overlay": overlay,
  9704. "position": direction === "down" ? "top" : "bottom",
  9705. "duration": state.transition ? duration : 0,
  9706. "lazyRender": props.lazyRender,
  9707. "overlayStyle": {
  9708. position: "absolute"
  9709. },
  9710. "aria-labelledby": `${parent.id}-${index.value}`,
  9711. "closeOnClickOverlay": closeOnClickOverlay,
  9712. "onOpen": onOpen,
  9713. "onClose": onClose,
  9714. "onOpened": onOpened,
  9715. "onClosed": onClosed
  9716. }, {
  9717. default: () => {
  9718. var _a;
  9719. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9720. }
  9721. })]), [[vue.vShow, state.showWrapper]]);
  9722. };
  9723. useExpose({
  9724. state,
  9725. toggle,
  9726. renderTitle
  9727. });
  9728. return () => {
  9729. if (props.teleport) {
  9730. return vue.createVNode(vue.Teleport, {
  9731. "to": props.teleport
  9732. }, {
  9733. default: () => [renderContent()]
  9734. });
  9735. }
  9736. return renderContent();
  9737. };
  9738. }
  9739. });
  9740. const DropdownItem = withInstall(stdin_default$D);
  9741. const DropdownMenu = withInstall(stdin_default$E);
  9742. const [name$w, bem$x] = createNamespace("grid");
  9743. const gridProps = {
  9744. square: Boolean,
  9745. center: truthProp,
  9746. border: truthProp,
  9747. gutter: numericProp,
  9748. reverse: Boolean,
  9749. iconSize: numericProp,
  9750. direction: String,
  9751. clickable: Boolean,
  9752. columnNum: makeNumericProp(4)
  9753. };
  9754. const GRID_KEY = Symbol(name$w);
  9755. var stdin_default$C = vue.defineComponent({
  9756. name: name$w,
  9757. props: gridProps,
  9758. setup(props, {
  9759. slots
  9760. }) {
  9761. const {
  9762. linkChildren
  9763. } = useChildren(GRID_KEY);
  9764. linkChildren({
  9765. props
  9766. });
  9767. return () => {
  9768. var _a;
  9769. return vue.createVNode("div", {
  9770. "style": {
  9771. paddingLeft: addUnit(props.gutter)
  9772. },
  9773. "class": [bem$x(), {
  9774. [BORDER_TOP]: props.border && !props.gutter
  9775. }]
  9776. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9777. };
  9778. }
  9779. });
  9780. const Grid = withInstall(stdin_default$C);
  9781. const [name$v, bem$w] = createNamespace("grid-item");
  9782. const gridItemProps = extend({}, routeProps, {
  9783. dot: Boolean,
  9784. text: String,
  9785. icon: String,
  9786. badge: numericProp,
  9787. iconColor: String,
  9788. iconPrefix: String,
  9789. badgeProps: Object
  9790. });
  9791. var stdin_default$B = vue.defineComponent({
  9792. name: name$v,
  9793. props: gridItemProps,
  9794. setup(props, {
  9795. slots
  9796. }) {
  9797. const {
  9798. parent,
  9799. index
  9800. } = useParent(GRID_KEY);
  9801. const route2 = useRoute();
  9802. if (!parent) {
  9803. return;
  9804. }
  9805. const rootStyle = vue.computed(() => {
  9806. const {
  9807. square,
  9808. gutter,
  9809. columnNum
  9810. } = parent.props;
  9811. const percent = `${100 / +columnNum}%`;
  9812. const style = {
  9813. flexBasis: percent
  9814. };
  9815. if (square) {
  9816. style.paddingTop = percent;
  9817. } else if (gutter) {
  9818. const gutterValue = addUnit(gutter);
  9819. style.paddingRight = gutterValue;
  9820. if (index.value >= columnNum) {
  9821. style.marginTop = gutterValue;
  9822. }
  9823. }
  9824. return style;
  9825. });
  9826. const contentStyle = vue.computed(() => {
  9827. const {
  9828. square,
  9829. gutter
  9830. } = parent.props;
  9831. if (square && gutter) {
  9832. const gutterValue = addUnit(gutter);
  9833. return {
  9834. right: gutterValue,
  9835. bottom: gutterValue,
  9836. height: "auto"
  9837. };
  9838. }
  9839. });
  9840. const renderIcon = () => {
  9841. if (slots.icon) {
  9842. return vue.createVNode(Badge, vue.mergeProps({
  9843. "dot": props.dot,
  9844. "content": props.badge
  9845. }, props.badgeProps), {
  9846. default: slots.icon
  9847. });
  9848. }
  9849. if (props.icon) {
  9850. return vue.createVNode(Icon, {
  9851. "dot": props.dot,
  9852. "name": props.icon,
  9853. "size": parent.props.iconSize,
  9854. "badge": props.badge,
  9855. "class": bem$w("icon"),
  9856. "color": props.iconColor,
  9857. "badgeProps": props.badgeProps,
  9858. "classPrefix": props.iconPrefix
  9859. }, null);
  9860. }
  9861. };
  9862. const renderText = () => {
  9863. if (slots.text) {
  9864. return slots.text();
  9865. }
  9866. if (props.text) {
  9867. return vue.createVNode("span", {
  9868. "class": bem$w("text")
  9869. }, [props.text]);
  9870. }
  9871. };
  9872. const renderContent = () => {
  9873. if (slots.default) {
  9874. return slots.default();
  9875. }
  9876. return [renderIcon(), renderText()];
  9877. };
  9878. return () => {
  9879. const {
  9880. center,
  9881. border,
  9882. square,
  9883. gutter,
  9884. reverse,
  9885. direction,
  9886. clickable
  9887. } = parent.props;
  9888. const classes = [bem$w("content", [direction, {
  9889. center,
  9890. square,
  9891. reverse,
  9892. clickable,
  9893. surround: border && gutter
  9894. }]), {
  9895. [BORDER]: border
  9896. }];
  9897. return vue.createVNode("div", {
  9898. "class": [bem$w({
  9899. square
  9900. })],
  9901. "style": rootStyle.value
  9902. }, [vue.createVNode("div", {
  9903. "role": clickable ? "button" : void 0,
  9904. "class": classes,
  9905. "style": contentStyle.value,
  9906. "tabindex": clickable ? 0 : void 0,
  9907. "onClick": route2
  9908. }, [renderContent()])]);
  9909. };
  9910. }
  9911. });
  9912. const GridItem = withInstall(stdin_default$B);
  9913. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9914. const bem$v = createNamespace("image-preview")[1];
  9915. var stdin_default$A = vue.defineComponent({
  9916. props: {
  9917. src: String,
  9918. show: Boolean,
  9919. active: Number,
  9920. minZoom: makeRequiredProp(numericProp),
  9921. maxZoom: makeRequiredProp(numericProp),
  9922. rootWidth: makeRequiredProp(Number),
  9923. rootHeight: makeRequiredProp(Number)
  9924. },
  9925. emits: ["scale", "close"],
  9926. setup(props, {
  9927. emit,
  9928. slots
  9929. }) {
  9930. const state = vue.reactive({
  9931. scale: 1,
  9932. moveX: 0,
  9933. moveY: 0,
  9934. moving: false,
  9935. zooming: false,
  9936. imageRatio: 0,
  9937. displayWidth: 0,
  9938. displayHeight: 0
  9939. });
  9940. const touch = useTouch();
  9941. const swipeItem = vue.ref();
  9942. const vertical = vue.computed(() => {
  9943. const {
  9944. rootWidth,
  9945. rootHeight
  9946. } = props;
  9947. const rootRatio = rootHeight / rootWidth;
  9948. return state.imageRatio > rootRatio;
  9949. });
  9950. const imageStyle = vue.computed(() => {
  9951. const {
  9952. scale,
  9953. moveX,
  9954. moveY,
  9955. moving,
  9956. zooming
  9957. } = state;
  9958. const style = {
  9959. transitionDuration: zooming || moving ? "0s" : ".3s"
  9960. };
  9961. if (scale !== 1) {
  9962. const offsetX = moveX / scale;
  9963. const offsetY = moveY / scale;
  9964. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9965. }
  9966. return style;
  9967. });
  9968. const maxMoveX = vue.computed(() => {
  9969. if (state.imageRatio) {
  9970. const {
  9971. rootWidth,
  9972. rootHeight
  9973. } = props;
  9974. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9975. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9976. }
  9977. return 0;
  9978. });
  9979. const maxMoveY = vue.computed(() => {
  9980. if (state.imageRatio) {
  9981. const {
  9982. rootWidth,
  9983. rootHeight
  9984. } = props;
  9985. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9986. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9987. }
  9988. return 0;
  9989. });
  9990. const setScale = (scale) => {
  9991. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9992. if (scale !== state.scale) {
  9993. state.scale = scale;
  9994. emit("scale", {
  9995. scale,
  9996. index: props.active
  9997. });
  9998. }
  9999. };
  10000. const resetScale = () => {
  10001. setScale(1);
  10002. state.moveX = 0;
  10003. state.moveY = 0;
  10004. };
  10005. const toggleScale = () => {
  10006. const scale = state.scale > 1 ? 1 : 2;
  10007. setScale(scale);
  10008. state.moveX = 0;
  10009. state.moveY = 0;
  10010. };
  10011. let fingerNum;
  10012. let startMoveX;
  10013. let startMoveY;
  10014. let startScale;
  10015. let startDistance;
  10016. let doubleTapTimer;
  10017. let touchStartTime;
  10018. const onTouchStart = (event) => {
  10019. const {
  10020. touches
  10021. } = event;
  10022. const {
  10023. offsetX
  10024. } = touch;
  10025. touch.start(event);
  10026. fingerNum = touches.length;
  10027. startMoveX = state.moveX;
  10028. startMoveY = state.moveY;
  10029. touchStartTime = Date.now();
  10030. state.moving = fingerNum === 1 && state.scale !== 1;
  10031. state.zooming = fingerNum === 2 && !offsetX.value;
  10032. if (state.zooming) {
  10033. startScale = state.scale;
  10034. startDistance = getDistance(event.touches);
  10035. }
  10036. };
  10037. const onTouchMove = (event) => {
  10038. const {
  10039. touches
  10040. } = event;
  10041. touch.move(event);
  10042. if (state.moving || state.zooming) {
  10043. preventDefault(event, true);
  10044. }
  10045. if (state.moving) {
  10046. const {
  10047. deltaX,
  10048. deltaY
  10049. } = touch;
  10050. const moveX = deltaX.value + startMoveX;
  10051. const moveY = deltaY.value + startMoveY;
  10052. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  10053. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  10054. }
  10055. if (state.zooming && touches.length === 2) {
  10056. const distance = getDistance(touches);
  10057. const scale = startScale * distance / startDistance;
  10058. setScale(scale);
  10059. }
  10060. };
  10061. const checkTap = () => {
  10062. if (fingerNum > 1) {
  10063. return;
  10064. }
  10065. const {
  10066. offsetX,
  10067. offsetY
  10068. } = touch;
  10069. const deltaTime = Date.now() - touchStartTime;
  10070. const TAP_TIME = 250;
  10071. const TAP_OFFSET = 5;
  10072. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
  10073. if (doubleTapTimer) {
  10074. clearTimeout(doubleTapTimer);
  10075. doubleTapTimer = null;
  10076. toggleScale();
  10077. } else {
  10078. doubleTapTimer = setTimeout(() => {
  10079. emit("close");
  10080. doubleTapTimer = null;
  10081. }, TAP_TIME);
  10082. }
  10083. }
  10084. };
  10085. const onTouchEnd = (event) => {
  10086. let stopPropagation2 = false;
  10087. if (state.moving || state.zooming) {
  10088. stopPropagation2 = true;
  10089. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  10090. stopPropagation2 = false;
  10091. }
  10092. if (!event.touches.length) {
  10093. if (state.zooming) {
  10094. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  10095. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  10096. state.zooming = false;
  10097. }
  10098. state.moving = false;
  10099. startMoveX = 0;
  10100. startMoveY = 0;
  10101. startScale = 1;
  10102. if (state.scale < 1) {
  10103. resetScale();
  10104. }
  10105. if (state.scale > props.maxZoom) {
  10106. state.scale = +props.maxZoom;
  10107. }
  10108. }
  10109. }
  10110. preventDefault(event, stopPropagation2);
  10111. checkTap();
  10112. touch.reset();
  10113. };
  10114. const onLoad = (event) => {
  10115. const {
  10116. naturalWidth,
  10117. naturalHeight
  10118. } = event.target;
  10119. state.imageRatio = naturalHeight / naturalWidth;
  10120. };
  10121. vue.watch(() => props.active, resetScale);
  10122. vue.watch(() => props.show, (value) => {
  10123. if (!value) {
  10124. resetScale();
  10125. }
  10126. });
  10127. useEventListener("touchmove", onTouchMove, {
  10128. target: vue.computed(() => {
  10129. var _a;
  10130. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  10131. })
  10132. });
  10133. return () => {
  10134. const imageSlots = {
  10135. loading: () => vue.createVNode(Loading, {
  10136. "type": "spinner"
  10137. }, null)
  10138. };
  10139. return vue.createVNode(SwipeItem, {
  10140. "ref": swipeItem,
  10141. "class": bem$v("swipe-item"),
  10142. "onTouchstartPassive": onTouchStart,
  10143. "onTouchend": onTouchEnd,
  10144. "onTouchcancel": onTouchEnd
  10145. }, {
  10146. default: () => [slots.image ? vue.createVNode("div", {
  10147. "class": bem$v("image-wrap")
  10148. }, [slots.image({
  10149. src: props.src
  10150. })]) : vue.createVNode(Image$1, {
  10151. "src": props.src,
  10152. "fit": "contain",
  10153. "class": bem$v("image", {
  10154. vertical: vertical.value
  10155. }),
  10156. "style": imageStyle.value,
  10157. "onLoad": onLoad
  10158. }, imageSlots)]
  10159. });
  10160. };
  10161. }
  10162. });
  10163. const [name$u, bem$u] = createNamespace("image-preview");
  10164. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  10165. const imagePreviewProps = {
  10166. show: Boolean,
  10167. loop: truthProp,
  10168. images: makeArrayProp(),
  10169. minZoom: makeNumericProp(1 / 3),
  10170. maxZoom: makeNumericProp(3),
  10171. overlay: truthProp,
  10172. closeable: Boolean,
  10173. showIndex: truthProp,
  10174. className: unknownProp,
  10175. closeIcon: makeStringProp("clear"),
  10176. transition: String,
  10177. beforeClose: Function,
  10178. overlayClass: unknownProp,
  10179. overlayStyle: Object,
  10180. swipeDuration: makeNumericProp(300),
  10181. startPosition: makeNumericProp(0),
  10182. showIndicators: Boolean,
  10183. closeOnPopstate: truthProp,
  10184. closeIconPosition: makeStringProp("top-right")
  10185. };
  10186. var stdin_default$z = vue.defineComponent({
  10187. name: name$u,
  10188. props: imagePreviewProps,
  10189. emits: ["scale", "close", "closed", "change", "update:show"],
  10190. setup(props, {
  10191. emit,
  10192. slots
  10193. }) {
  10194. const swipeRef = vue.ref();
  10195. const state = vue.reactive({
  10196. active: 0,
  10197. rootWidth: 0,
  10198. rootHeight: 0
  10199. });
  10200. const resize = () => {
  10201. if (swipeRef.value) {
  10202. const rect = useRect(swipeRef.value.$el);
  10203. state.rootWidth = rect.width;
  10204. state.rootHeight = rect.height;
  10205. swipeRef.value.resize();
  10206. }
  10207. };
  10208. const emitScale = (args) => emit("scale", args);
  10209. const updateShow = (show) => emit("update:show", show);
  10210. const emitClose = () => {
  10211. callInterceptor(props.beforeClose, {
  10212. args: [state.active],
  10213. done: () => updateShow(false)
  10214. });
  10215. };
  10216. const setActive = (active) => {
  10217. if (active !== state.active) {
  10218. state.active = active;
  10219. emit("change", active);
  10220. }
  10221. };
  10222. const renderIndex = () => {
  10223. if (props.showIndex) {
  10224. return vue.createVNode("div", {
  10225. "class": bem$u("index")
  10226. }, [slots.index ? slots.index({
  10227. index: state.active
  10228. }) : `${state.active + 1} / ${props.images.length}`]);
  10229. }
  10230. };
  10231. const renderCover = () => {
  10232. if (slots.cover) {
  10233. return vue.createVNode("div", {
  10234. "class": bem$u("cover")
  10235. }, [slots.cover()]);
  10236. }
  10237. };
  10238. const renderImages = () => vue.createVNode(Swipe, {
  10239. "ref": swipeRef,
  10240. "lazyRender": true,
  10241. "loop": props.loop,
  10242. "class": bem$u("swipe"),
  10243. "duration": props.swipeDuration,
  10244. "initialSwipe": props.startPosition,
  10245. "showIndicators": props.showIndicators,
  10246. "indicatorColor": "white",
  10247. "onChange": setActive
  10248. }, {
  10249. default: () => [props.images.map((image) => vue.createVNode(stdin_default$A, {
  10250. "src": image,
  10251. "show": props.show,
  10252. "active": state.active,
  10253. "maxZoom": props.maxZoom,
  10254. "minZoom": props.minZoom,
  10255. "rootWidth": state.rootWidth,
  10256. "rootHeight": state.rootHeight,
  10257. "onScale": emitScale,
  10258. "onClose": emitClose
  10259. }, {
  10260. image: slots.image
  10261. }))]
  10262. });
  10263. const renderClose = () => {
  10264. if (props.closeable) {
  10265. return vue.createVNode(Icon, {
  10266. "role": "button",
  10267. "name": props.closeIcon,
  10268. "class": [bem$u("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  10269. "onClick": emitClose
  10270. }, null);
  10271. }
  10272. };
  10273. const onClosed = () => emit("closed");
  10274. const swipeTo = (index, options) => {
  10275. var _a;
  10276. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  10277. };
  10278. useExpose({
  10279. swipeTo
  10280. });
  10281. vue.onMounted(resize);
  10282. vue.watch([windowWidth, windowHeight], resize);
  10283. vue.watch(() => props.startPosition, (value) => setActive(+value));
  10284. vue.watch(() => props.show, (value) => {
  10285. const {
  10286. images,
  10287. startPosition
  10288. } = props;
  10289. if (value) {
  10290. setActive(+startPosition);
  10291. vue.nextTick(() => {
  10292. resize();
  10293. swipeTo(+startPosition, {
  10294. immediate: true
  10295. });
  10296. });
  10297. } else {
  10298. emit("close", {
  10299. index: state.active,
  10300. url: images[state.active]
  10301. });
  10302. }
  10303. });
  10304. return () => vue.createVNode(Popup, vue.mergeProps({
  10305. "class": [bem$u(), props.className],
  10306. "overlayClass": [bem$u("overlay"), props.overlayClass],
  10307. "onClosed": onClosed,
  10308. "onUpdate:show": updateShow
  10309. }, pick(props, popupProps$1)), {
  10310. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  10311. });
  10312. }
  10313. });
  10314. let instance$1;
  10315. const defaultConfig = {
  10316. loop: true,
  10317. images: [],
  10318. maxZoom: 3,
  10319. minZoom: 1 / 3,
  10320. onScale: void 0,
  10321. onClose: void 0,
  10322. onChange: void 0,
  10323. teleport: "body",
  10324. className: "",
  10325. showIndex: true,
  10326. closeable: false,
  10327. closeIcon: "clear",
  10328. transition: void 0,
  10329. beforeClose: void 0,
  10330. overlayStyle: void 0,
  10331. overlayClass: void 0,
  10332. startPosition: 0,
  10333. swipeDuration: 300,
  10334. showIndicators: false,
  10335. closeOnPopstate: true,
  10336. closeIconPosition: "top-right"
  10337. };
  10338. function initInstance$1() {
  10339. ({
  10340. instance: instance$1
  10341. } = mountComponent({
  10342. setup() {
  10343. const {
  10344. state,
  10345. toggle
  10346. } = usePopupState();
  10347. const onClosed = () => {
  10348. state.images = [];
  10349. };
  10350. return () => vue.createVNode(stdin_default$z, vue.mergeProps(state, {
  10351. "onClosed": onClosed,
  10352. "onUpdate:show": toggle
  10353. }), null);
  10354. }
  10355. }));
  10356. }
  10357. const ImagePreview = (options, startPosition = 0) => {
  10358. if (!inBrowser$1) {
  10359. return;
  10360. }
  10361. if (!instance$1) {
  10362. initInstance$1();
  10363. }
  10364. options = Array.isArray(options) ? {
  10365. images: options,
  10366. startPosition
  10367. } : options;
  10368. instance$1.open(extend({}, defaultConfig, options));
  10369. return instance$1;
  10370. };
  10371. ImagePreview.Component = withInstall(stdin_default$z);
  10372. ImagePreview.install = (app) => {
  10373. app.use(ImagePreview.Component);
  10374. };
  10375. function genAlphabet() {
  10376. const charCodeOfA = "A".charCodeAt(0);
  10377. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  10378. return indexList;
  10379. }
  10380. const [name$t, bem$t] = createNamespace("index-bar");
  10381. const indexBarProps = {
  10382. sticky: truthProp,
  10383. zIndex: numericProp,
  10384. teleport: [String, Object],
  10385. highlightColor: String,
  10386. stickyOffsetTop: makeNumberProp(0),
  10387. indexList: {
  10388. type: Array,
  10389. default: genAlphabet
  10390. }
  10391. };
  10392. const INDEX_BAR_KEY = Symbol(name$t);
  10393. var stdin_default$y = vue.defineComponent({
  10394. name: name$t,
  10395. props: indexBarProps,
  10396. emits: ["select", "change"],
  10397. setup(props, {
  10398. emit,
  10399. slots
  10400. }) {
  10401. const root = vue.ref();
  10402. const sidebar = vue.ref();
  10403. const activeAnchor = vue.ref("");
  10404. const touch = useTouch();
  10405. const scrollParent = useScrollParent(root);
  10406. const {
  10407. children,
  10408. linkChildren
  10409. } = useChildren(INDEX_BAR_KEY);
  10410. let selectActiveIndex;
  10411. linkChildren({
  10412. props
  10413. });
  10414. const sidebarStyle = vue.computed(() => {
  10415. if (isDef(props.zIndex)) {
  10416. return {
  10417. zIndex: +props.zIndex + 1
  10418. };
  10419. }
  10420. });
  10421. const highlightStyle = vue.computed(() => {
  10422. if (props.highlightColor) {
  10423. return {
  10424. color: props.highlightColor
  10425. };
  10426. }
  10427. });
  10428. const getActiveAnchor = (scrollTop, rects) => {
  10429. for (let i = children.length - 1; i >= 0; i--) {
  10430. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10431. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10432. if (scrollTop + reachTop >= rects[i].top) {
  10433. return i;
  10434. }
  10435. }
  10436. return -1;
  10437. };
  10438. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10439. const onScroll = () => {
  10440. if (isHidden(root)) {
  10441. return;
  10442. }
  10443. const {
  10444. sticky,
  10445. indexList
  10446. } = props;
  10447. const scrollTop = getScrollTop(scrollParent.value);
  10448. const scrollParentRect = useRect(scrollParent);
  10449. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10450. let active = -1;
  10451. if (selectActiveIndex) {
  10452. const match = getMatchAnchor(selectActiveIndex);
  10453. if (match) {
  10454. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10455. active = getActiveAnchor(rect.top, rects);
  10456. }
  10457. } else {
  10458. active = getActiveAnchor(scrollTop, rects);
  10459. }
  10460. activeAnchor.value = indexList[active];
  10461. if (sticky) {
  10462. children.forEach((item, index) => {
  10463. const {
  10464. state,
  10465. $el
  10466. } = item;
  10467. if (index === active || index === active - 1) {
  10468. const rect = $el.getBoundingClientRect();
  10469. state.left = rect.left;
  10470. state.width = rect.width;
  10471. } else {
  10472. state.left = null;
  10473. state.width = null;
  10474. }
  10475. if (index === active) {
  10476. state.active = true;
  10477. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10478. } else if (index === active - 1 && selectActiveIndex === "") {
  10479. const activeItemTop = rects[active].top - scrollTop;
  10480. state.active = activeItemTop > 0;
  10481. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10482. } else {
  10483. state.active = false;
  10484. }
  10485. });
  10486. }
  10487. selectActiveIndex = "";
  10488. };
  10489. const init = () => {
  10490. vue.nextTick(onScroll);
  10491. };
  10492. useEventListener("scroll", onScroll, {
  10493. target: scrollParent,
  10494. passive: true
  10495. });
  10496. vue.onMounted(init);
  10497. vue.watch(() => props.indexList, init);
  10498. vue.watch(activeAnchor, (value) => {
  10499. if (value) {
  10500. emit("change", value);
  10501. }
  10502. });
  10503. const renderIndexes = () => props.indexList.map((index) => {
  10504. const active = index === activeAnchor.value;
  10505. return vue.createVNode("span", {
  10506. "class": bem$t("index", {
  10507. active
  10508. }),
  10509. "style": active ? highlightStyle.value : void 0,
  10510. "data-index": index
  10511. }, [index]);
  10512. });
  10513. const scrollTo = (index) => {
  10514. selectActiveIndex = String(index);
  10515. const match = getMatchAnchor(selectActiveIndex);
  10516. if (match) {
  10517. const scrollTop = getScrollTop(scrollParent.value);
  10518. const scrollParentRect = useRect(scrollParent);
  10519. const {
  10520. offsetHeight
  10521. } = document.documentElement;
  10522. match.$el.scrollIntoView();
  10523. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10524. onScroll();
  10525. return;
  10526. }
  10527. if (props.sticky && props.stickyOffsetTop) {
  10528. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10529. }
  10530. emit("select", match.index);
  10531. }
  10532. };
  10533. const scrollToElement = (element) => {
  10534. const {
  10535. index
  10536. } = element.dataset;
  10537. if (index) {
  10538. scrollTo(index);
  10539. }
  10540. };
  10541. const onClickSidebar = (event) => {
  10542. scrollToElement(event.target);
  10543. };
  10544. let touchActiveIndex;
  10545. const onTouchMove = (event) => {
  10546. touch.move(event);
  10547. if (touch.isVertical()) {
  10548. preventDefault(event);
  10549. const {
  10550. clientX,
  10551. clientY
  10552. } = event.touches[0];
  10553. const target = document.elementFromPoint(clientX, clientY);
  10554. if (target) {
  10555. const {
  10556. index
  10557. } = target.dataset;
  10558. if (index && touchActiveIndex !== index) {
  10559. touchActiveIndex = index;
  10560. scrollToElement(target);
  10561. }
  10562. }
  10563. }
  10564. };
  10565. const renderSidebar = () => vue.createVNode("div", {
  10566. "ref": sidebar,
  10567. "class": bem$t("sidebar"),
  10568. "style": sidebarStyle.value,
  10569. "onClick": onClickSidebar,
  10570. "onTouchstartPassive": touch.start
  10571. }, [renderIndexes()]);
  10572. useExpose({
  10573. scrollTo
  10574. });
  10575. useEventListener("touchmove", onTouchMove, {
  10576. target: sidebar
  10577. });
  10578. return () => {
  10579. var _a;
  10580. return vue.createVNode("div", {
  10581. "ref": root,
  10582. "class": bem$t()
  10583. }, [props.teleport ? vue.createVNode(vue.Teleport, {
  10584. "to": props.teleport
  10585. }, {
  10586. default: () => [renderSidebar()]
  10587. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10588. };
  10589. }
  10590. });
  10591. const [name$s, bem$s] = createNamespace("index-anchor");
  10592. const indexAnchorProps = {
  10593. index: numericProp
  10594. };
  10595. var stdin_default$x = vue.defineComponent({
  10596. name: name$s,
  10597. props: indexAnchorProps,
  10598. setup(props, {
  10599. slots
  10600. }) {
  10601. const state = vue.reactive({
  10602. top: 0,
  10603. left: null,
  10604. rect: {
  10605. top: 0,
  10606. height: 0
  10607. },
  10608. width: null,
  10609. active: false
  10610. });
  10611. const root = vue.ref();
  10612. const {
  10613. parent
  10614. } = useParent(INDEX_BAR_KEY);
  10615. if (!parent) {
  10616. return;
  10617. }
  10618. const isSticky = () => state.active && parent.props.sticky;
  10619. const anchorStyle = vue.computed(() => {
  10620. const {
  10621. zIndex,
  10622. highlightColor
  10623. } = parent.props;
  10624. if (isSticky()) {
  10625. return extend(getZIndexStyle(zIndex), {
  10626. left: state.left ? `${state.left}px` : void 0,
  10627. width: state.width ? `${state.width}px` : void 0,
  10628. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10629. color: highlightColor
  10630. });
  10631. }
  10632. });
  10633. const getRect = (scrollParent, scrollParentRect) => {
  10634. const rootRect = useRect(root);
  10635. state.rect.height = rootRect.height;
  10636. if (scrollParent === window || scrollParent === document.body) {
  10637. state.rect.top = rootRect.top + getRootScrollTop();
  10638. } else {
  10639. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10640. }
  10641. return state.rect;
  10642. };
  10643. useExpose({
  10644. state,
  10645. getRect
  10646. });
  10647. return () => {
  10648. const sticky = isSticky();
  10649. return vue.createVNode("div", {
  10650. "ref": root,
  10651. "style": {
  10652. height: sticky ? `${state.rect.height}px` : void 0
  10653. }
  10654. }, [vue.createVNode("div", {
  10655. "style": anchorStyle.value,
  10656. "class": [bem$s({
  10657. sticky
  10658. }), {
  10659. [BORDER_BOTTOM]: sticky
  10660. }]
  10661. }, [slots.default ? slots.default() : props.index])]);
  10662. };
  10663. }
  10664. });
  10665. const IndexAnchor = withInstall(stdin_default$x);
  10666. const IndexBar = withInstall(stdin_default$y);
  10667. const [name$r, bem$r, t$6] = createNamespace("list");
  10668. const listProps = {
  10669. error: Boolean,
  10670. offset: makeNumericProp(300),
  10671. loading: Boolean,
  10672. finished: Boolean,
  10673. errorText: String,
  10674. direction: makeStringProp("down"),
  10675. loadingText: String,
  10676. finishedText: String,
  10677. immediateCheck: truthProp
  10678. };
  10679. var stdin_default$w = vue.defineComponent({
  10680. name: name$r,
  10681. props: listProps,
  10682. emits: ["load", "update:error", "update:loading"],
  10683. setup(props, {
  10684. emit,
  10685. slots
  10686. }) {
  10687. const loading = vue.ref(props.loading);
  10688. const root = vue.ref();
  10689. const placeholder = vue.ref();
  10690. const tabStatus = useTabStatus();
  10691. const scrollParent = useScrollParent(root);
  10692. const check = () => {
  10693. vue.nextTick(() => {
  10694. if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10695. return;
  10696. }
  10697. const {
  10698. offset: offset2,
  10699. direction
  10700. } = props;
  10701. const scrollParentRect = useRect(scrollParent);
  10702. if (!scrollParentRect.height || isHidden(root)) {
  10703. return;
  10704. }
  10705. let isReachEdge = false;
  10706. const placeholderRect = useRect(placeholder);
  10707. if (direction === "up") {
  10708. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset2;
  10709. } else {
  10710. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset2;
  10711. }
  10712. if (isReachEdge) {
  10713. loading.value = true;
  10714. emit("update:loading", true);
  10715. emit("load");
  10716. }
  10717. });
  10718. };
  10719. const renderFinishedText = () => {
  10720. if (props.finished) {
  10721. const text = slots.finished ? slots.finished() : props.finishedText;
  10722. if (text) {
  10723. return vue.createVNode("div", {
  10724. "class": bem$r("finished-text")
  10725. }, [text]);
  10726. }
  10727. }
  10728. };
  10729. const clickErrorText = () => {
  10730. emit("update:error", false);
  10731. check();
  10732. };
  10733. const renderErrorText = () => {
  10734. if (props.error) {
  10735. const text = slots.error ? slots.error() : props.errorText;
  10736. if (text) {
  10737. return vue.createVNode("div", {
  10738. "role": "button",
  10739. "class": bem$r("error-text"),
  10740. "tabindex": 0,
  10741. "onClick": clickErrorText
  10742. }, [text]);
  10743. }
  10744. }
  10745. };
  10746. const renderLoading = () => {
  10747. if (loading.value && !props.finished) {
  10748. return vue.createVNode("div", {
  10749. "class": bem$r("loading")
  10750. }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
  10751. "class": bem$r("loading-icon")
  10752. }, {
  10753. default: () => [props.loadingText || t$6("loading")]
  10754. })]);
  10755. }
  10756. };
  10757. vue.watch(() => [props.loading, props.finished, props.error], check);
  10758. if (tabStatus) {
  10759. vue.watch(tabStatus, (tabActive) => {
  10760. if (tabActive) {
  10761. check();
  10762. }
  10763. });
  10764. }
  10765. vue.onUpdated(() => {
  10766. loading.value = props.loading;
  10767. });
  10768. vue.onMounted(() => {
  10769. if (props.immediateCheck) {
  10770. check();
  10771. }
  10772. });
  10773. useExpose({
  10774. check
  10775. });
  10776. useEventListener("scroll", check, {
  10777. target: scrollParent,
  10778. passive: true
  10779. });
  10780. return () => {
  10781. var _a;
  10782. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10783. const Placeholder = vue.createVNode("div", {
  10784. "ref": placeholder,
  10785. "class": bem$r("placeholder")
  10786. }, null);
  10787. return vue.createVNode("div", {
  10788. "ref": root,
  10789. "role": "feed",
  10790. "class": bem$r(),
  10791. "aria-busy": loading.value
  10792. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10793. };
  10794. }
  10795. });
  10796. const List = withInstall(stdin_default$w);
  10797. const [name$q, bem$q] = createNamespace("nav-bar");
  10798. const navBarProps = {
  10799. title: String,
  10800. fixed: Boolean,
  10801. zIndex: numericProp,
  10802. border: truthProp,
  10803. leftText: String,
  10804. rightText: String,
  10805. leftArrow: Boolean,
  10806. placeholder: Boolean,
  10807. safeAreaInsetTop: Boolean
  10808. };
  10809. var stdin_default$v = vue.defineComponent({
  10810. name: name$q,
  10811. props: navBarProps,
  10812. emits: ["click-left", "click-right"],
  10813. setup(props, {
  10814. emit,
  10815. slots
  10816. }) {
  10817. const navBarRef = vue.ref();
  10818. const renderPlaceholder = usePlaceholder(navBarRef, bem$q);
  10819. const onClickLeft = (event) => emit("click-left", event);
  10820. const onClickRight = (event) => emit("click-right", event);
  10821. const renderLeft = () => {
  10822. if (slots.left) {
  10823. return slots.left();
  10824. }
  10825. return [props.leftArrow && vue.createVNode(Icon, {
  10826. "class": bem$q("arrow"),
  10827. "name": "arrow-left"
  10828. }, null), props.leftText && vue.createVNode("span", {
  10829. "class": bem$q("text")
  10830. }, [props.leftText])];
  10831. };
  10832. const renderRight = () => {
  10833. if (slots.right) {
  10834. return slots.right();
  10835. }
  10836. return vue.createVNode("span", {
  10837. "class": bem$q("text")
  10838. }, [props.rightText]);
  10839. };
  10840. const renderNavBar = () => {
  10841. const {
  10842. title,
  10843. fixed,
  10844. border,
  10845. zIndex
  10846. } = props;
  10847. const style = getZIndexStyle(zIndex);
  10848. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10849. const hasRight = props.rightText || slots.right;
  10850. return vue.createVNode("div", {
  10851. "ref": navBarRef,
  10852. "style": style,
  10853. "class": [bem$q({
  10854. fixed
  10855. }), {
  10856. [BORDER_BOTTOM]: border,
  10857. "van-safe-area-top": props.safeAreaInsetTop
  10858. }]
  10859. }, [vue.createVNode("div", {
  10860. "class": bem$q("content")
  10861. }, [hasLeft && vue.createVNode("div", {
  10862. "class": [bem$q("left"), HAPTICS_FEEDBACK],
  10863. "onClick": onClickLeft
  10864. }, [renderLeft()]), vue.createVNode("div", {
  10865. "class": [bem$q("title"), "van-ellipsis"]
  10866. }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
  10867. "class": [bem$q("right"), HAPTICS_FEEDBACK],
  10868. "onClick": onClickRight
  10869. }, [renderRight()])])]);
  10870. };
  10871. return () => {
  10872. if (props.fixed && props.placeholder) {
  10873. return renderPlaceholder(renderNavBar);
  10874. }
  10875. return renderNavBar();
  10876. };
  10877. }
  10878. });
  10879. const NavBar = withInstall(stdin_default$v);
  10880. const [name$p, bem$p] = createNamespace("notice-bar");
  10881. const noticeBarProps = {
  10882. text: String,
  10883. mode: String,
  10884. color: String,
  10885. delay: makeNumericProp(1),
  10886. speed: makeNumericProp(60),
  10887. leftIcon: String,
  10888. wrapable: Boolean,
  10889. background: String,
  10890. scrollable: {
  10891. type: Boolean,
  10892. default: null
  10893. }
  10894. };
  10895. var stdin_default$u = vue.defineComponent({
  10896. name: name$p,
  10897. props: noticeBarProps,
  10898. emits: ["close", "replay"],
  10899. setup(props, {
  10900. emit,
  10901. slots
  10902. }) {
  10903. let wrapWidth = 0;
  10904. let contentWidth = 0;
  10905. let startTimer;
  10906. const wrapRef = vue.ref();
  10907. const contentRef = vue.ref();
  10908. const state = vue.reactive({
  10909. show: true,
  10910. offset: 0,
  10911. duration: 0
  10912. });
  10913. const renderLeftIcon = () => {
  10914. if (slots["left-icon"]) {
  10915. return slots["left-icon"]();
  10916. }
  10917. if (props.leftIcon) {
  10918. return vue.createVNode(Icon, {
  10919. "class": bem$p("left-icon"),
  10920. "name": props.leftIcon
  10921. }, null);
  10922. }
  10923. };
  10924. const getRightIconName = () => {
  10925. if (props.mode === "closeable") {
  10926. return "cross";
  10927. }
  10928. if (props.mode === "link") {
  10929. return "arrow";
  10930. }
  10931. };
  10932. const onClickRightIcon = (event) => {
  10933. if (props.mode === "closeable") {
  10934. state.show = false;
  10935. emit("close", event);
  10936. }
  10937. };
  10938. const renderRightIcon = () => {
  10939. if (slots["right-icon"]) {
  10940. return slots["right-icon"]();
  10941. }
  10942. const name2 = getRightIconName();
  10943. if (name2) {
  10944. return vue.createVNode(Icon, {
  10945. "name": name2,
  10946. "class": bem$p("right-icon"),
  10947. "onClick": onClickRightIcon
  10948. }, null);
  10949. }
  10950. };
  10951. const onTransitionEnd = () => {
  10952. state.offset = wrapWidth;
  10953. state.duration = 0;
  10954. raf(() => {
  10955. doubleRaf(() => {
  10956. state.offset = -contentWidth;
  10957. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10958. emit("replay");
  10959. });
  10960. });
  10961. };
  10962. const renderMarquee = () => {
  10963. const ellipsis = props.scrollable === false && !props.wrapable;
  10964. const style = {
  10965. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10966. transitionDuration: `${state.duration}s`
  10967. };
  10968. return vue.createVNode("div", {
  10969. "ref": wrapRef,
  10970. "role": "marquee",
  10971. "class": bem$p("wrap")
  10972. }, [vue.createVNode("div", {
  10973. "ref": contentRef,
  10974. "style": style,
  10975. "class": [bem$p("content"), {
  10976. "van-ellipsis": ellipsis
  10977. }],
  10978. "onTransitionend": onTransitionEnd
  10979. }, [slots.default ? slots.default() : props.text])]);
  10980. };
  10981. const reset = () => {
  10982. const {
  10983. delay,
  10984. speed,
  10985. scrollable
  10986. } = props;
  10987. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10988. wrapWidth = 0;
  10989. contentWidth = 0;
  10990. state.offset = 0;
  10991. state.duration = 0;
  10992. clearTimeout(startTimer);
  10993. startTimer = setTimeout(() => {
  10994. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10995. return;
  10996. }
  10997. const wrapRefWidth = useRect(wrapRef).width;
  10998. const contentRefWidth = useRect(contentRef).width;
  10999. if (scrollable || contentRefWidth > wrapRefWidth) {
  11000. doubleRaf(() => {
  11001. wrapWidth = wrapRefWidth;
  11002. contentWidth = contentRefWidth;
  11003. state.offset = -contentWidth;
  11004. state.duration = contentWidth / +speed;
  11005. });
  11006. }
  11007. }, ms);
  11008. };
  11009. onPopupReopen(reset);
  11010. onMountedOrActivated(reset);
  11011. useEventListener("pageshow", reset);
  11012. useExpose({
  11013. reset
  11014. });
  11015. vue.watch(() => [props.text, props.scrollable], reset);
  11016. return () => {
  11017. const {
  11018. color,
  11019. wrapable,
  11020. background
  11021. } = props;
  11022. return vue.withDirectives(vue.createVNode("div", {
  11023. "role": "alert",
  11024. "class": bem$p({
  11025. wrapable
  11026. }),
  11027. "style": {
  11028. color,
  11029. background
  11030. }
  11031. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
  11032. };
  11033. }
  11034. });
  11035. const NoticeBar = withInstall(stdin_default$u);
  11036. const [name$o, bem$o] = createNamespace("notify");
  11037. const notifyProps = extend({}, popupSharedProps, {
  11038. type: makeStringProp("danger"),
  11039. color: String,
  11040. message: numericProp,
  11041. position: makeStringProp("top"),
  11042. className: unknownProp,
  11043. background: String,
  11044. lockScroll: Boolean
  11045. });
  11046. var stdin_default$t = vue.defineComponent({
  11047. name: name$o,
  11048. props: notifyProps,
  11049. emits: ["update:show"],
  11050. setup(props, {
  11051. emit,
  11052. slots
  11053. }) {
  11054. const updateShow = (show) => emit("update:show", show);
  11055. return () => vue.createVNode(Popup, {
  11056. "show": props.show,
  11057. "class": [bem$o([props.type]), props.className],
  11058. "style": {
  11059. color: props.color,
  11060. background: props.background
  11061. },
  11062. "overlay": false,
  11063. "position": props.position,
  11064. "duration": 0.2,
  11065. "lockScroll": props.lockScroll,
  11066. "onUpdate:show": updateShow
  11067. }, {
  11068. default: () => [slots.default ? slots.default() : props.message]
  11069. });
  11070. }
  11071. });
  11072. let timer;
  11073. let instance;
  11074. const parseOptions = (message) => isObject(message) ? message : {
  11075. message
  11076. };
  11077. function initInstance() {
  11078. ({
  11079. instance
  11080. } = mountComponent({
  11081. setup() {
  11082. const {
  11083. state,
  11084. toggle
  11085. } = usePopupState();
  11086. return () => vue.createVNode(stdin_default$t, vue.mergeProps(state, {
  11087. "onUpdate:show": toggle
  11088. }), null);
  11089. }
  11090. }));
  11091. }
  11092. function Notify(options) {
  11093. if (!inBrowser$1) {
  11094. return;
  11095. }
  11096. if (!instance) {
  11097. initInstance();
  11098. }
  11099. options = extend({}, Notify.currentOptions, parseOptions(options));
  11100. instance.open(options);
  11101. clearTimeout(timer);
  11102. if (options.duration > 0) {
  11103. timer = window.setTimeout(Notify.clear, options.duration);
  11104. }
  11105. return instance;
  11106. }
  11107. const getDefaultOptions = () => ({
  11108. type: "danger",
  11109. color: void 0,
  11110. message: "",
  11111. onClose: void 0,
  11112. onClick: void 0,
  11113. onOpened: void 0,
  11114. duration: 3e3,
  11115. position: void 0,
  11116. className: "",
  11117. lockScroll: false,
  11118. background: void 0
  11119. });
  11120. Notify.clear = () => {
  11121. if (instance) {
  11122. instance.toggle(false);
  11123. }
  11124. };
  11125. Notify.currentOptions = getDefaultOptions();
  11126. Notify.setDefaultOptions = (options) => {
  11127. extend(Notify.currentOptions, options);
  11128. };
  11129. Notify.resetDefaultOptions = () => {
  11130. Notify.currentOptions = getDefaultOptions();
  11131. };
  11132. Notify.Component = withInstall(stdin_default$t);
  11133. Notify.install = (app) => {
  11134. app.use(Notify.Component);
  11135. app.config.globalProperties.$notify = Notify;
  11136. };
  11137. const [name$n, bem$n] = createNamespace("key");
  11138. const CollapseIcon = vue.createVNode("svg", {
  11139. "class": bem$n("collapse-icon"),
  11140. "viewBox": "0 0 30 24"
  11141. }, [vue.createVNode("path", {
  11142. "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",
  11143. "fill": "currentColor"
  11144. }, null)]);
  11145. const DeleteIcon = vue.createVNode("svg", {
  11146. "class": bem$n("delete-icon"),
  11147. "viewBox": "0 0 32 22"
  11148. }, [vue.createVNode("path", {
  11149. "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",
  11150. "fill": "currentColor"
  11151. }, null)]);
  11152. var stdin_default$s = vue.defineComponent({
  11153. name: name$n,
  11154. props: {
  11155. type: String,
  11156. text: numericProp,
  11157. color: String,
  11158. wider: Boolean,
  11159. large: Boolean,
  11160. loading: Boolean
  11161. },
  11162. emits: ["press"],
  11163. setup(props, {
  11164. emit,
  11165. slots
  11166. }) {
  11167. const active = vue.ref(false);
  11168. const touch = useTouch();
  11169. const onTouchStart = (event) => {
  11170. touch.start(event);
  11171. active.value = true;
  11172. };
  11173. const onTouchMove = (event) => {
  11174. touch.move(event);
  11175. if (touch.direction.value) {
  11176. active.value = false;
  11177. }
  11178. };
  11179. const onTouchEnd = (event) => {
  11180. if (active.value) {
  11181. if (!slots.default) {
  11182. preventDefault(event);
  11183. }
  11184. active.value = false;
  11185. emit("press", props.text, props.type);
  11186. }
  11187. };
  11188. const renderContent = () => {
  11189. if (props.loading) {
  11190. return vue.createVNode(Loading, {
  11191. "class": bem$n("loading-icon")
  11192. }, null);
  11193. }
  11194. const text = slots.default ? slots.default() : props.text;
  11195. switch (props.type) {
  11196. case "delete":
  11197. return text || DeleteIcon;
  11198. case "extra":
  11199. return text || CollapseIcon;
  11200. default:
  11201. return text;
  11202. }
  11203. };
  11204. return () => vue.createVNode("div", {
  11205. "class": bem$n("wrapper", {
  11206. wider: props.wider
  11207. }),
  11208. "onTouchstartPassive": onTouchStart,
  11209. "onTouchmovePassive": onTouchMove,
  11210. "onTouchend": onTouchEnd,
  11211. "onTouchcancel": onTouchEnd
  11212. }, [vue.createVNode("div", {
  11213. "role": "button",
  11214. "tabindex": 0,
  11215. "class": bem$n([props.color, {
  11216. large: props.large,
  11217. active: active.value,
  11218. delete: props.type === "delete"
  11219. }])
  11220. }, [renderContent()])]);
  11221. }
  11222. });
  11223. const [name$m, bem$m] = createNamespace("number-keyboard");
  11224. const numberKeyboardProps = {
  11225. show: Boolean,
  11226. title: String,
  11227. theme: makeStringProp("default"),
  11228. zIndex: numericProp,
  11229. teleport: [String, Object],
  11230. maxlength: makeNumericProp(Infinity),
  11231. modelValue: makeStringProp(""),
  11232. transition: truthProp,
  11233. blurOnClose: truthProp,
  11234. showDeleteKey: truthProp,
  11235. randomKeyOrder: Boolean,
  11236. closeButtonText: String,
  11237. deleteButtonText: String,
  11238. closeButtonLoading: Boolean,
  11239. hideOnClickOutside: truthProp,
  11240. safeAreaInsetBottom: truthProp,
  11241. extraKey: {
  11242. type: [String, Array],
  11243. default: ""
  11244. }
  11245. };
  11246. function shuffle(array) {
  11247. for (let i = array.length - 1; i > 0; i--) {
  11248. const j = Math.floor(Math.random() * (i + 1));
  11249. const temp = array[i];
  11250. array[i] = array[j];
  11251. array[j] = temp;
  11252. }
  11253. return array;
  11254. }
  11255. var stdin_default$r = vue.defineComponent({
  11256. name: name$m,
  11257. inheritAttrs: false,
  11258. props: numberKeyboardProps,
  11259. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  11260. setup(props, {
  11261. emit,
  11262. slots,
  11263. attrs
  11264. }) {
  11265. const root = vue.ref();
  11266. const genBasicKeys = () => {
  11267. const keys2 = Array(9).fill("").map((_, i) => ({
  11268. text: i + 1
  11269. }));
  11270. if (props.randomKeyOrder) {
  11271. shuffle(keys2);
  11272. }
  11273. return keys2;
  11274. };
  11275. const genDefaultKeys = () => [...genBasicKeys(), {
  11276. text: props.extraKey,
  11277. type: "extra"
  11278. }, {
  11279. text: 0
  11280. }, {
  11281. text: props.showDeleteKey ? props.deleteButtonText : "",
  11282. type: props.showDeleteKey ? "delete" : ""
  11283. }];
  11284. const genCustomKeys = () => {
  11285. const keys2 = genBasicKeys();
  11286. const {
  11287. extraKey
  11288. } = props;
  11289. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  11290. if (extraKeys.length === 1) {
  11291. keys2.push({
  11292. text: 0,
  11293. wider: true
  11294. }, {
  11295. text: extraKeys[0],
  11296. type: "extra"
  11297. });
  11298. } else if (extraKeys.length === 2) {
  11299. keys2.push({
  11300. text: extraKeys[0],
  11301. type: "extra"
  11302. }, {
  11303. text: 0
  11304. }, {
  11305. text: extraKeys[1],
  11306. type: "extra"
  11307. });
  11308. }
  11309. return keys2;
  11310. };
  11311. const keys = vue.computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  11312. const onBlur = () => {
  11313. if (props.show) {
  11314. emit("blur");
  11315. }
  11316. };
  11317. const onClose = () => {
  11318. emit("close");
  11319. if (props.blurOnClose) {
  11320. onBlur();
  11321. }
  11322. };
  11323. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  11324. const onPress = (text, type) => {
  11325. if (text === "") {
  11326. if (type === "extra") {
  11327. onBlur();
  11328. }
  11329. return;
  11330. }
  11331. const value = props.modelValue;
  11332. if (type === "delete") {
  11333. emit("delete");
  11334. emit("update:modelValue", value.slice(0, value.length - 1));
  11335. } else if (type === "close") {
  11336. onClose();
  11337. } else if (value.length < props.maxlength) {
  11338. emit("input", text);
  11339. emit("update:modelValue", value + text);
  11340. }
  11341. };
  11342. const renderTitle = () => {
  11343. const {
  11344. title,
  11345. theme,
  11346. closeButtonText
  11347. } = props;
  11348. const leftSlot = slots["title-left"];
  11349. const showClose = closeButtonText && theme === "default";
  11350. const showTitle = title || showClose || leftSlot;
  11351. if (!showTitle) {
  11352. return;
  11353. }
  11354. return vue.createVNode("div", {
  11355. "class": bem$m("header")
  11356. }, [leftSlot && vue.createVNode("span", {
  11357. "class": bem$m("title-left")
  11358. }, [leftSlot()]), title && vue.createVNode("h2", {
  11359. "class": bem$m("title")
  11360. }, [title]), showClose && vue.createVNode("button", {
  11361. "type": "button",
  11362. "class": [bem$m("close"), HAPTICS_FEEDBACK],
  11363. "onClick": onClose
  11364. }, [closeButtonText])]);
  11365. };
  11366. const renderKeys = () => keys.value.map((key) => {
  11367. const keySlots = {};
  11368. if (key.type === "delete") {
  11369. keySlots.default = slots.delete;
  11370. }
  11371. if (key.type === "extra") {
  11372. keySlots.default = slots["extra-key"];
  11373. }
  11374. return vue.createVNode(stdin_default$s, {
  11375. "key": key.text,
  11376. "text": key.text,
  11377. "type": key.type,
  11378. "wider": key.wider,
  11379. "color": key.color,
  11380. "onPress": onPress
  11381. }, keySlots);
  11382. });
  11383. const renderSidebar = () => {
  11384. if (props.theme === "custom") {
  11385. return vue.createVNode("div", {
  11386. "class": bem$m("sidebar")
  11387. }, [props.showDeleteKey && vue.createVNode(stdin_default$s, {
  11388. "large": true,
  11389. "text": props.deleteButtonText,
  11390. "type": "delete",
  11391. "onPress": onPress
  11392. }, {
  11393. delete: slots.delete
  11394. }), vue.createVNode(stdin_default$s, {
  11395. "large": true,
  11396. "text": props.closeButtonText,
  11397. "type": "close",
  11398. "color": "blue",
  11399. "loading": props.closeButtonLoading,
  11400. "onPress": onPress
  11401. }, null)]);
  11402. }
  11403. };
  11404. vue.watch(() => props.show, (value) => {
  11405. if (!props.transition) {
  11406. emit(value ? "show" : "hide");
  11407. }
  11408. });
  11409. if (props.hideOnClickOutside) {
  11410. useClickAway(root, onBlur, {
  11411. eventName: "touchstart"
  11412. });
  11413. }
  11414. return () => {
  11415. const Title = renderTitle();
  11416. const Content = vue.createVNode(vue.Transition, {
  11417. "name": props.transition ? "van-slide-up" : ""
  11418. }, {
  11419. default: () => [vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  11420. "ref": root,
  11421. "style": getZIndexStyle(props.zIndex),
  11422. "class": bem$m({
  11423. unfit: !props.safeAreaInsetBottom,
  11424. "with-title": !!Title
  11425. }),
  11426. "onAnimationend": onAnimationEnd,
  11427. "onTouchstartPassive": stopPropagation
  11428. }, attrs), [Title, vue.createVNode("div", {
  11429. "class": bem$m("body")
  11430. }, [vue.createVNode("div", {
  11431. "class": bem$m("keys")
  11432. }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props.show]])]
  11433. });
  11434. if (props.teleport) {
  11435. return vue.createVNode(vue.Teleport, {
  11436. "to": props.teleport
  11437. }, {
  11438. default: () => [Content]
  11439. });
  11440. }
  11441. return Content;
  11442. };
  11443. }
  11444. });
  11445. const NumberKeyboard = withInstall(stdin_default$r);
  11446. const [name$l, bem$l, t$5] = createNamespace("pagination");
  11447. const makePage = (number, text, active) => ({
  11448. number,
  11449. text,
  11450. active
  11451. });
  11452. const paginationProps = {
  11453. mode: makeStringProp("multi"),
  11454. prevText: String,
  11455. nextText: String,
  11456. pageCount: makeNumericProp(0),
  11457. modelValue: makeNumberProp(0),
  11458. totalItems: makeNumericProp(0),
  11459. showPageSize: makeNumericProp(5),
  11460. itemsPerPage: makeNumericProp(10),
  11461. forceEllipses: Boolean
  11462. };
  11463. var stdin_default$q = vue.defineComponent({
  11464. name: name$l,
  11465. props: paginationProps,
  11466. emits: ["change", "update:modelValue"],
  11467. setup(props, {
  11468. emit,
  11469. slots
  11470. }) {
  11471. const count = vue.computed(() => {
  11472. const {
  11473. pageCount,
  11474. totalItems,
  11475. itemsPerPage
  11476. } = props;
  11477. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11478. return Math.max(1, count2);
  11479. });
  11480. const pages = vue.computed(() => {
  11481. const items = [];
  11482. const pageCount = count.value;
  11483. const showPageSize = +props.showPageSize;
  11484. const {
  11485. modelValue,
  11486. forceEllipses
  11487. } = props;
  11488. let startPage = 1;
  11489. let endPage = pageCount;
  11490. const isMaxSized = showPageSize < pageCount;
  11491. if (isMaxSized) {
  11492. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11493. endPage = startPage + showPageSize - 1;
  11494. if (endPage > pageCount) {
  11495. endPage = pageCount;
  11496. startPage = endPage - showPageSize + 1;
  11497. }
  11498. }
  11499. for (let number = startPage; number <= endPage; number++) {
  11500. const page = makePage(number, number, number === modelValue);
  11501. items.push(page);
  11502. }
  11503. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11504. if (startPage > 1) {
  11505. const prevPages = makePage(startPage - 1, "...");
  11506. items.unshift(prevPages);
  11507. }
  11508. if (endPage < pageCount) {
  11509. const nextPages = makePage(endPage + 1, "...");
  11510. items.push(nextPages);
  11511. }
  11512. }
  11513. return items;
  11514. });
  11515. const updateModelValue = (value, emitChange) => {
  11516. value = clamp(value, 1, count.value);
  11517. if (props.modelValue !== value) {
  11518. emit("update:modelValue", value);
  11519. if (emitChange) {
  11520. emit("change", value);
  11521. }
  11522. }
  11523. };
  11524. vue.watchEffect(() => updateModelValue(props.modelValue));
  11525. const renderDesc = () => vue.createVNode("li", {
  11526. "class": bem$l("page-desc")
  11527. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11528. const renderPrevButton = () => {
  11529. const {
  11530. mode,
  11531. modelValue
  11532. } = props;
  11533. const slot = slots["prev-text"];
  11534. const disabled = modelValue === 1;
  11535. return vue.createVNode("li", {
  11536. "class": [bem$l("item", {
  11537. disabled,
  11538. border: mode === "simple",
  11539. prev: true
  11540. }), BORDER_SURROUND]
  11541. }, [vue.createVNode("button", {
  11542. "type": "button",
  11543. "disabled": disabled,
  11544. "onClick": () => updateModelValue(modelValue - 1, true)
  11545. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11546. };
  11547. const renderNextButton = () => {
  11548. const {
  11549. mode,
  11550. modelValue
  11551. } = props;
  11552. const slot = slots["next-text"];
  11553. const disabled = modelValue === count.value;
  11554. return vue.createVNode("li", {
  11555. "class": [bem$l("item", {
  11556. disabled,
  11557. border: mode === "simple",
  11558. next: true
  11559. }), BORDER_SURROUND]
  11560. }, [vue.createVNode("button", {
  11561. "type": "button",
  11562. "disabled": disabled,
  11563. "onClick": () => updateModelValue(modelValue + 1, true)
  11564. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11565. };
  11566. const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
  11567. "class": [bem$l("item", {
  11568. active: page.active,
  11569. page: true
  11570. }), BORDER_SURROUND]
  11571. }, [vue.createVNode("button", {
  11572. "type": "button",
  11573. "aria-current": page.active || void 0,
  11574. "onClick": () => updateModelValue(page.number, true)
  11575. }, [slots.page ? slots.page(page) : page.text])]));
  11576. return () => vue.createVNode("nav", {
  11577. "role": "navigation",
  11578. "class": bem$l()
  11579. }, [vue.createVNode("ul", {
  11580. "class": bem$l("items")
  11581. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11582. }
  11583. });
  11584. const Pagination = withInstall(stdin_default$q);
  11585. const [name$k, bem$k] = createNamespace("password-input");
  11586. const passwordInputProps = {
  11587. info: String,
  11588. mask: truthProp,
  11589. value: makeStringProp(""),
  11590. gutter: numericProp,
  11591. length: makeNumericProp(6),
  11592. focused: Boolean,
  11593. errorInfo: String
  11594. };
  11595. var stdin_default$p = vue.defineComponent({
  11596. name: name$k,
  11597. props: passwordInputProps,
  11598. emits: ["focus"],
  11599. setup(props, {
  11600. emit
  11601. }) {
  11602. const onTouchStart = (event) => {
  11603. event.stopPropagation();
  11604. emit("focus", event);
  11605. };
  11606. const renderPoints = () => {
  11607. const Points = [];
  11608. const {
  11609. mask,
  11610. value,
  11611. length,
  11612. gutter,
  11613. focused
  11614. } = props;
  11615. for (let i = 0; i < length; i++) {
  11616. const char = value[i];
  11617. const showBorder = i !== 0 && !gutter;
  11618. const showCursor = focused && i === value.length;
  11619. let style;
  11620. if (i !== 0 && gutter) {
  11621. style = {
  11622. marginLeft: addUnit(gutter)
  11623. };
  11624. }
  11625. Points.push(vue.createVNode("li", {
  11626. "class": [{
  11627. [BORDER_LEFT]: showBorder
  11628. }, bem$k("item", {
  11629. focus: showCursor
  11630. })],
  11631. "style": style
  11632. }, [mask ? vue.createVNode("i", {
  11633. "style": {
  11634. visibility: char ? "visible" : "hidden"
  11635. }
  11636. }, null) : char, showCursor && vue.createVNode("div", {
  11637. "class": bem$k("cursor")
  11638. }, null)]));
  11639. }
  11640. return Points;
  11641. };
  11642. return () => {
  11643. const info = props.errorInfo || props.info;
  11644. return vue.createVNode("div", {
  11645. "class": bem$k()
  11646. }, [vue.createVNode("ul", {
  11647. "class": [bem$k("security"), {
  11648. [BORDER_SURROUND]: !props.gutter
  11649. }],
  11650. "onTouchstartPassive": onTouchStart
  11651. }, [renderPoints()]), info && vue.createVNode("div", {
  11652. "class": bem$k(props.errorInfo ? "error-info" : "info")
  11653. }, [info])]);
  11654. };
  11655. }
  11656. });
  11657. const PasswordInput = withInstall(stdin_default$p);
  11658. function getWindow(node) {
  11659. if (node == null) {
  11660. return window;
  11661. }
  11662. if (node.toString() !== "[object Window]") {
  11663. var ownerDocument = node.ownerDocument;
  11664. return ownerDocument ? ownerDocument.defaultView || window : window;
  11665. }
  11666. return node;
  11667. }
  11668. function isElement(node) {
  11669. var OwnElement = getWindow(node).Element;
  11670. return node instanceof OwnElement || node instanceof Element;
  11671. }
  11672. function isHTMLElement(node) {
  11673. var OwnElement = getWindow(node).HTMLElement;
  11674. return node instanceof OwnElement || node instanceof HTMLElement;
  11675. }
  11676. function isShadowRoot(node) {
  11677. if (typeof ShadowRoot === "undefined") {
  11678. return false;
  11679. }
  11680. var OwnElement = getWindow(node).ShadowRoot;
  11681. return node instanceof OwnElement || node instanceof ShadowRoot;
  11682. }
  11683. var round = Math.round;
  11684. function getUAString() {
  11685. var uaData = navigator.userAgentData;
  11686. if (uaData != null && uaData.brands) {
  11687. return uaData.brands.map(function(item) {
  11688. return item.brand + "/" + item.version;
  11689. }).join(" ");
  11690. }
  11691. return navigator.userAgent;
  11692. }
  11693. function isLayoutViewport() {
  11694. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  11695. }
  11696. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  11697. if (includeScale === void 0) {
  11698. includeScale = false;
  11699. }
  11700. if (isFixedStrategy === void 0) {
  11701. isFixedStrategy = false;
  11702. }
  11703. var clientRect = element.getBoundingClientRect();
  11704. var scaleX = 1;
  11705. var scaleY = 1;
  11706. if (includeScale && isHTMLElement(element)) {
  11707. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  11708. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  11709. }
  11710. var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
  11711. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  11712. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  11713. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  11714. var width2 = clientRect.width / scaleX;
  11715. var height2 = clientRect.height / scaleY;
  11716. return {
  11717. width: width2,
  11718. height: height2,
  11719. top: y,
  11720. right: x + width2,
  11721. bottom: y + height2,
  11722. left: x,
  11723. x,
  11724. y
  11725. };
  11726. }
  11727. function getWindowScroll(node) {
  11728. var win = getWindow(node);
  11729. var scrollLeft = win.pageXOffset;
  11730. var scrollTop = win.pageYOffset;
  11731. return {
  11732. scrollLeft,
  11733. scrollTop
  11734. };
  11735. }
  11736. function getHTMLElementScroll(element) {
  11737. return {
  11738. scrollLeft: element.scrollLeft,
  11739. scrollTop: element.scrollTop
  11740. };
  11741. }
  11742. function getNodeScroll(node) {
  11743. if (node === getWindow(node) || !isHTMLElement(node)) {
  11744. return getWindowScroll(node);
  11745. } else {
  11746. return getHTMLElementScroll(node);
  11747. }
  11748. }
  11749. function getNodeName(element) {
  11750. return element ? (element.nodeName || "").toLowerCase() : null;
  11751. }
  11752. function getDocumentElement(element) {
  11753. return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
  11754. }
  11755. function getWindowScrollBarX(element) {
  11756. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  11757. }
  11758. function getComputedStyle(element) {
  11759. return getWindow(element).getComputedStyle(element);
  11760. }
  11761. function isScrollParent(element) {
  11762. var _getComputedStyle = getComputedStyle(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
  11763. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  11764. }
  11765. function isElementScaled(element) {
  11766. var rect = element.getBoundingClientRect();
  11767. var scaleX = round(rect.width) / element.offsetWidth || 1;
  11768. var scaleY = round(rect.height) / element.offsetHeight || 1;
  11769. return scaleX !== 1 || scaleY !== 1;
  11770. }
  11771. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  11772. if (isFixed === void 0) {
  11773. isFixed = false;
  11774. }
  11775. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  11776. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  11777. var documentElement = getDocumentElement(offsetParent);
  11778. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  11779. var scroll = {
  11780. scrollLeft: 0,
  11781. scrollTop: 0
  11782. };
  11783. var offsets = {
  11784. x: 0,
  11785. y: 0
  11786. };
  11787. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  11788. if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
  11789. scroll = getNodeScroll(offsetParent);
  11790. }
  11791. if (isHTMLElement(offsetParent)) {
  11792. offsets = getBoundingClientRect(offsetParent, true);
  11793. offsets.x += offsetParent.clientLeft;
  11794. offsets.y += offsetParent.clientTop;
  11795. } else if (documentElement) {
  11796. offsets.x = getWindowScrollBarX(documentElement);
  11797. }
  11798. }
  11799. return {
  11800. x: rect.left + scroll.scrollLeft - offsets.x,
  11801. y: rect.top + scroll.scrollTop - offsets.y,
  11802. width: rect.width,
  11803. height: rect.height
  11804. };
  11805. }
  11806. function getLayoutRect(element) {
  11807. var clientRect = getBoundingClientRect(element);
  11808. var width2 = element.offsetWidth;
  11809. var height2 = element.offsetHeight;
  11810. if (Math.abs(clientRect.width - width2) <= 1) {
  11811. width2 = clientRect.width;
  11812. }
  11813. if (Math.abs(clientRect.height - height2) <= 1) {
  11814. height2 = clientRect.height;
  11815. }
  11816. return {
  11817. x: element.offsetLeft,
  11818. y: element.offsetTop,
  11819. width: width2,
  11820. height: height2
  11821. };
  11822. }
  11823. function getParentNode(element) {
  11824. if (getNodeName(element) === "html") {
  11825. return element;
  11826. }
  11827. return element.assignedSlot || element.parentNode || (isShadowRoot(element) ? element.host : null) || getDocumentElement(element);
  11828. }
  11829. function getScrollParent(node) {
  11830. if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
  11831. return node.ownerDocument.body;
  11832. }
  11833. if (isHTMLElement(node) && isScrollParent(node)) {
  11834. return node;
  11835. }
  11836. return getScrollParent(getParentNode(node));
  11837. }
  11838. function listScrollParents(element, list) {
  11839. var _element$ownerDocumen;
  11840. if (list === void 0) {
  11841. list = [];
  11842. }
  11843. var scrollParent = getScrollParent(element);
  11844. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  11845. var win = getWindow(scrollParent);
  11846. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  11847. var updatedList = list.concat(target);
  11848. return isBody ? updatedList : updatedList.concat(listScrollParents(getParentNode(target)));
  11849. }
  11850. function isTableElement(element) {
  11851. return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
  11852. }
  11853. function getTrueOffsetParent(element) {
  11854. if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
  11855. return null;
  11856. }
  11857. return element.offsetParent;
  11858. }
  11859. function getContainingBlock(element) {
  11860. var isFirefox = /firefox/i.test(getUAString());
  11861. var isIE = /Trident/i.test(getUAString());
  11862. if (isIE && isHTMLElement(element)) {
  11863. var elementCss = getComputedStyle(element);
  11864. if (elementCss.position === "fixed") {
  11865. return null;
  11866. }
  11867. }
  11868. var currentNode = getParentNode(element);
  11869. if (isShadowRoot(currentNode)) {
  11870. currentNode = currentNode.host;
  11871. }
  11872. while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
  11873. var css = getComputedStyle(currentNode);
  11874. if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
  11875. return currentNode;
  11876. } else {
  11877. currentNode = currentNode.parentNode;
  11878. }
  11879. }
  11880. return null;
  11881. }
  11882. function getOffsetParent(element) {
  11883. var window2 = getWindow(element);
  11884. var offsetParent = getTrueOffsetParent(element);
  11885. while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
  11886. offsetParent = getTrueOffsetParent(offsetParent);
  11887. }
  11888. if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
  11889. return window2;
  11890. }
  11891. return offsetParent || getContainingBlock(element) || window2;
  11892. }
  11893. var top = "top";
  11894. var bottom = "bottom";
  11895. var right = "right";
  11896. var left = "left";
  11897. var auto = "auto";
  11898. var basePlacements = [top, bottom, right, left];
  11899. var start = "start";
  11900. var end = "end";
  11901. var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
  11902. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  11903. }, []);
  11904. var beforeRead = "beforeRead";
  11905. var read = "read";
  11906. var afterRead = "afterRead";
  11907. var beforeMain = "beforeMain";
  11908. var main = "main";
  11909. var afterMain = "afterMain";
  11910. var beforeWrite = "beforeWrite";
  11911. var write = "write";
  11912. var afterWrite = "afterWrite";
  11913. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  11914. function order(modifiers) {
  11915. var map = /* @__PURE__ */ new Map();
  11916. var visited = /* @__PURE__ */ new Set();
  11917. var result = [];
  11918. modifiers.forEach(function(modifier) {
  11919. map.set(modifier.name, modifier);
  11920. });
  11921. function sort(modifier) {
  11922. visited.add(modifier.name);
  11923. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  11924. requires.forEach(function(dep) {
  11925. if (!visited.has(dep)) {
  11926. var depModifier = map.get(dep);
  11927. if (depModifier) {
  11928. sort(depModifier);
  11929. }
  11930. }
  11931. });
  11932. result.push(modifier);
  11933. }
  11934. modifiers.forEach(function(modifier) {
  11935. if (!visited.has(modifier.name)) {
  11936. sort(modifier);
  11937. }
  11938. });
  11939. return result;
  11940. }
  11941. function orderModifiers(modifiers) {
  11942. var orderedModifiers = order(modifiers);
  11943. return modifierPhases.reduce(function(acc, phase) {
  11944. return acc.concat(orderedModifiers.filter(function(modifier) {
  11945. return modifier.phase === phase;
  11946. }));
  11947. }, []);
  11948. }
  11949. function debounce(fn2) {
  11950. var pending;
  11951. return function() {
  11952. if (!pending) {
  11953. pending = new Promise(function(resolve) {
  11954. Promise.resolve().then(function() {
  11955. pending = void 0;
  11956. resolve(fn2());
  11957. });
  11958. });
  11959. }
  11960. return pending;
  11961. };
  11962. }
  11963. function format(str) {
  11964. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  11965. args[_key - 1] = arguments[_key];
  11966. }
  11967. return [].concat(args).reduce(function(p, c) {
  11968. return p.replace(/%s/, c);
  11969. }, str);
  11970. }
  11971. var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
  11972. var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
  11973. var VALID_PROPERTIES = ["name", "enabled", "phase", "fn", "effect", "requires", "options"];
  11974. function validateModifiers(modifiers) {
  11975. modifiers.forEach(function(modifier) {
  11976. [].concat(Object.keys(modifier), VALID_PROPERTIES).filter(function(value, index, self2) {
  11977. return self2.indexOf(value) === index;
  11978. }).forEach(function(key) {
  11979. switch (key) {
  11980. case "name":
  11981. if (typeof modifier.name !== "string") {
  11982. console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', '"' + String(modifier.name) + '"'));
  11983. }
  11984. break;
  11985. case "enabled":
  11986. if (typeof modifier.enabled !== "boolean") {
  11987. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', '"' + String(modifier.enabled) + '"'));
  11988. }
  11989. break;
  11990. case "phase":
  11991. if (modifierPhases.indexOf(modifier.phase) < 0) {
  11992. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(", "), '"' + String(modifier.phase) + '"'));
  11993. }
  11994. break;
  11995. case "fn":
  11996. if (typeof modifier.fn !== "function") {
  11997. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', '"' + String(modifier.fn) + '"'));
  11998. }
  11999. break;
  12000. case "effect":
  12001. if (modifier.effect != null && typeof modifier.effect !== "function") {
  12002. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', '"' + String(modifier.fn) + '"'));
  12003. }
  12004. break;
  12005. case "requires":
  12006. if (modifier.requires != null && !Array.isArray(modifier.requires)) {
  12007. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', '"' + String(modifier.requires) + '"'));
  12008. }
  12009. break;
  12010. case "requiresIfExists":
  12011. if (!Array.isArray(modifier.requiresIfExists)) {
  12012. console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', '"' + String(modifier.requiresIfExists) + '"'));
  12013. }
  12014. break;
  12015. case "options":
  12016. case "data":
  12017. break;
  12018. default:
  12019. console.error('PopperJS: an invalid property has been provided to the "' + modifier.name + '" modifier, valid properties are ' + VALID_PROPERTIES.map(function(s) {
  12020. return '"' + s + '"';
  12021. }).join(", ") + '; but "' + key + '" was provided.');
  12022. }
  12023. modifier.requires && modifier.requires.forEach(function(requirement) {
  12024. if (modifiers.find(function(mod) {
  12025. return mod.name === requirement;
  12026. }) == null) {
  12027. console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
  12028. }
  12029. });
  12030. });
  12031. });
  12032. }
  12033. function uniqueBy(arr, fn2) {
  12034. var identifiers = /* @__PURE__ */ new Set();
  12035. return arr.filter(function(item) {
  12036. var identifier = fn2(item);
  12037. if (!identifiers.has(identifier)) {
  12038. identifiers.add(identifier);
  12039. return true;
  12040. }
  12041. });
  12042. }
  12043. function getBasePlacement(placement) {
  12044. return placement.split("-")[0];
  12045. }
  12046. function mergeByName(modifiers) {
  12047. var merged = modifiers.reduce(function(merged2, current2) {
  12048. var existing = merged2[current2.name];
  12049. merged2[current2.name] = existing ? Object.assign({}, existing, current2, {
  12050. options: Object.assign({}, existing.options, current2.options),
  12051. data: Object.assign({}, existing.data, current2.data)
  12052. }) : current2;
  12053. return merged2;
  12054. }, {});
  12055. return Object.keys(merged).map(function(key) {
  12056. return merged[key];
  12057. });
  12058. }
  12059. function getVariation(placement) {
  12060. return placement.split("-")[1];
  12061. }
  12062. function getMainAxisFromPlacement(placement) {
  12063. return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
  12064. }
  12065. function computeOffsets(_ref) {
  12066. var reference = _ref.reference, element = _ref.element, placement = _ref.placement;
  12067. var basePlacement = placement ? getBasePlacement(placement) : null;
  12068. var variation = placement ? getVariation(placement) : null;
  12069. var commonX = reference.x + reference.width / 2 - element.width / 2;
  12070. var commonY = reference.y + reference.height / 2 - element.height / 2;
  12071. var offsets;
  12072. switch (basePlacement) {
  12073. case top:
  12074. offsets = {
  12075. x: commonX,
  12076. y: reference.y - element.height
  12077. };
  12078. break;
  12079. case bottom:
  12080. offsets = {
  12081. x: commonX,
  12082. y: reference.y + reference.height
  12083. };
  12084. break;
  12085. case right:
  12086. offsets = {
  12087. x: reference.x + reference.width,
  12088. y: commonY
  12089. };
  12090. break;
  12091. case left:
  12092. offsets = {
  12093. x: reference.x - element.width,
  12094. y: commonY
  12095. };
  12096. break;
  12097. default:
  12098. offsets = {
  12099. x: reference.x,
  12100. y: reference.y
  12101. };
  12102. }
  12103. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  12104. if (mainAxis != null) {
  12105. var len = mainAxis === "y" ? "height" : "width";
  12106. switch (variation) {
  12107. case start:
  12108. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  12109. break;
  12110. case end:
  12111. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  12112. break;
  12113. }
  12114. }
  12115. return offsets;
  12116. }
  12117. var INVALID_ELEMENT_ERROR = "Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.";
  12118. var INFINITE_LOOP_ERROR = "Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.";
  12119. var DEFAULT_OPTIONS = {
  12120. placement: "bottom",
  12121. modifiers: [],
  12122. strategy: "absolute"
  12123. };
  12124. function areValidElements() {
  12125. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  12126. args[_key] = arguments[_key];
  12127. }
  12128. return !args.some(function(element) {
  12129. return !(element && typeof element.getBoundingClientRect === "function");
  12130. });
  12131. }
  12132. function popperGenerator(generatorOptions) {
  12133. if (generatorOptions === void 0) {
  12134. generatorOptions = {};
  12135. }
  12136. var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions2 = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  12137. return function createPopper2(reference, popper, options) {
  12138. if (options === void 0) {
  12139. options = defaultOptions2;
  12140. }
  12141. var state = {
  12142. placement: "bottom",
  12143. orderedModifiers: [],
  12144. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions2),
  12145. modifiersData: {},
  12146. elements: {
  12147. reference,
  12148. popper
  12149. },
  12150. attributes: {},
  12151. styles: {}
  12152. };
  12153. var effectCleanupFns = [];
  12154. var isDestroyed = false;
  12155. var instance2 = {
  12156. state,
  12157. setOptions: function setOptions(setOptionsAction) {
  12158. var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
  12159. cleanupModifierEffects();
  12160. state.options = Object.assign({}, defaultOptions2, state.options, options2);
  12161. state.scrollParents = {
  12162. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  12163. popper: listScrollParents(popper)
  12164. };
  12165. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
  12166. state.orderedModifiers = orderedModifiers.filter(function(m) {
  12167. return m.enabled;
  12168. });
  12169. {
  12170. var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function(_ref) {
  12171. var name2 = _ref.name;
  12172. return name2;
  12173. });
  12174. validateModifiers(modifiers);
  12175. if (getBasePlacement(state.options.placement) === auto) {
  12176. var flipModifier = state.orderedModifiers.find(function(_ref2) {
  12177. var name2 = _ref2.name;
  12178. return name2 === "flip";
  12179. });
  12180. if (!flipModifier) {
  12181. console.error(['Popper: "auto" placements require the "flip" modifier be', "present and enabled to work."].join(" "));
  12182. }
  12183. }
  12184. var _getComputedStyle = getComputedStyle(popper), marginTop = _getComputedStyle.marginTop, marginRight = _getComputedStyle.marginRight, marginBottom = _getComputedStyle.marginBottom, marginLeft = _getComputedStyle.marginLeft;
  12185. if ([marginTop, marginRight, marginBottom, marginLeft].some(function(margin) {
  12186. return parseFloat(margin);
  12187. })) {
  12188. console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', "between the popper and its reference element or boundary.", "To replicate margin, use the `offset` modifier, as well as", "the `padding` option in the `preventOverflow` and `flip`", "modifiers."].join(" "));
  12189. }
  12190. }
  12191. runModifierEffects();
  12192. return instance2.update();
  12193. },
  12194. forceUpdate: function forceUpdate() {
  12195. if (isDestroyed) {
  12196. return;
  12197. }
  12198. var _state$elements = state.elements, reference2 = _state$elements.reference, popper2 = _state$elements.popper;
  12199. if (!areValidElements(reference2, popper2)) {
  12200. {
  12201. console.error(INVALID_ELEMENT_ERROR);
  12202. }
  12203. return;
  12204. }
  12205. state.rects = {
  12206. reference: getCompositeRect(reference2, getOffsetParent(popper2), state.options.strategy === "fixed"),
  12207. popper: getLayoutRect(popper2)
  12208. };
  12209. state.reset = false;
  12210. state.placement = state.options.placement;
  12211. state.orderedModifiers.forEach(function(modifier) {
  12212. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  12213. });
  12214. var __debug_loops__ = 0;
  12215. for (var index = 0; index < state.orderedModifiers.length; index++) {
  12216. {
  12217. __debug_loops__ += 1;
  12218. if (__debug_loops__ > 100) {
  12219. console.error(INFINITE_LOOP_ERROR);
  12220. break;
  12221. }
  12222. }
  12223. if (state.reset === true) {
  12224. state.reset = false;
  12225. index = -1;
  12226. continue;
  12227. }
  12228. var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name2 = _state$orderedModifie.name;
  12229. if (typeof fn2 === "function") {
  12230. state = fn2({
  12231. state,
  12232. options: _options,
  12233. name: name2,
  12234. instance: instance2
  12235. }) || state;
  12236. }
  12237. }
  12238. },
  12239. update: debounce(function() {
  12240. return new Promise(function(resolve) {
  12241. instance2.forceUpdate();
  12242. resolve(state);
  12243. });
  12244. }),
  12245. destroy: function destroy() {
  12246. cleanupModifierEffects();
  12247. isDestroyed = true;
  12248. }
  12249. };
  12250. if (!areValidElements(reference, popper)) {
  12251. {
  12252. console.error(INVALID_ELEMENT_ERROR);
  12253. }
  12254. return instance2;
  12255. }
  12256. instance2.setOptions(options).then(function(state2) {
  12257. if (!isDestroyed && options.onFirstUpdate) {
  12258. options.onFirstUpdate(state2);
  12259. }
  12260. });
  12261. function runModifierEffects() {
  12262. state.orderedModifiers.forEach(function(_ref3) {
  12263. var name2 = _ref3.name, _ref3$options = _ref3.options, options2 = _ref3$options === void 0 ? {} : _ref3$options, effect3 = _ref3.effect;
  12264. if (typeof effect3 === "function") {
  12265. var cleanupFn = effect3({
  12266. state,
  12267. name: name2,
  12268. instance: instance2,
  12269. options: options2
  12270. });
  12271. var noopFn = function noopFn2() {
  12272. };
  12273. effectCleanupFns.push(cleanupFn || noopFn);
  12274. }
  12275. });
  12276. }
  12277. function cleanupModifierEffects() {
  12278. effectCleanupFns.forEach(function(fn2) {
  12279. return fn2();
  12280. });
  12281. effectCleanupFns = [];
  12282. }
  12283. return instance2;
  12284. };
  12285. }
  12286. var passive = {
  12287. passive: true
  12288. };
  12289. function effect(_ref) {
  12290. var state = _ref.state, instance2 = _ref.instance, options = _ref.options;
  12291. var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
  12292. var window2 = getWindow(state.elements.popper);
  12293. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  12294. if (scroll) {
  12295. scrollParents.forEach(function(scrollParent) {
  12296. scrollParent.addEventListener("scroll", instance2.update, passive);
  12297. });
  12298. }
  12299. if (resize) {
  12300. window2.addEventListener("resize", instance2.update, passive);
  12301. }
  12302. return function() {
  12303. if (scroll) {
  12304. scrollParents.forEach(function(scrollParent) {
  12305. scrollParent.removeEventListener("scroll", instance2.update, passive);
  12306. });
  12307. }
  12308. if (resize) {
  12309. window2.removeEventListener("resize", instance2.update, passive);
  12310. }
  12311. };
  12312. }
  12313. var eventListeners_default = {
  12314. name: "eventListeners",
  12315. enabled: true,
  12316. phase: "write",
  12317. fn: function fn() {
  12318. },
  12319. effect,
  12320. data: {}
  12321. };
  12322. function popperOffsets(_ref) {
  12323. var state = _ref.state, name2 = _ref.name;
  12324. state.modifiersData[name2] = computeOffsets({
  12325. reference: state.rects.reference,
  12326. element: state.rects.popper,
  12327. strategy: "absolute",
  12328. placement: state.placement
  12329. });
  12330. }
  12331. var popperOffsets_default = {
  12332. name: "popperOffsets",
  12333. enabled: true,
  12334. phase: "read",
  12335. fn: popperOffsets,
  12336. data: {}
  12337. };
  12338. var unsetSides = {
  12339. top: "auto",
  12340. right: "auto",
  12341. bottom: "auto",
  12342. left: "auto"
  12343. };
  12344. function roundOffsetsByDPR(_ref) {
  12345. var x = _ref.x, y = _ref.y;
  12346. var win = window;
  12347. var dpr = win.devicePixelRatio || 1;
  12348. return {
  12349. x: round(x * dpr) / dpr || 0,
  12350. y: round(y * dpr) / dpr || 0
  12351. };
  12352. }
  12353. function mapToStyles(_ref2) {
  12354. var _Object$assign2;
  12355. var popper = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
  12356. var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
  12357. var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
  12358. x,
  12359. y
  12360. }) : {
  12361. x,
  12362. y
  12363. };
  12364. x = _ref3.x;
  12365. y = _ref3.y;
  12366. var hasX = offsets.hasOwnProperty("x");
  12367. var hasY = offsets.hasOwnProperty("y");
  12368. var sideX = left;
  12369. var sideY = top;
  12370. var win = window;
  12371. if (adaptive) {
  12372. var offsetParent = getOffsetParent(popper);
  12373. var heightProp = "clientHeight";
  12374. var widthProp = "clientWidth";
  12375. if (offsetParent === getWindow(popper)) {
  12376. offsetParent = getDocumentElement(popper);
  12377. if (getComputedStyle(offsetParent).position !== "static" && position === "absolute") {
  12378. heightProp = "scrollHeight";
  12379. widthProp = "scrollWidth";
  12380. }
  12381. }
  12382. offsetParent = offsetParent;
  12383. if (placement === top || (placement === left || placement === right) && variation === end) {
  12384. sideY = bottom;
  12385. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : offsetParent[heightProp];
  12386. y -= offsetY - popperRect.height;
  12387. y *= gpuAcceleration ? 1 : -1;
  12388. }
  12389. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  12390. sideX = right;
  12391. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : offsetParent[widthProp];
  12392. x -= offsetX - popperRect.width;
  12393. x *= gpuAcceleration ? 1 : -1;
  12394. }
  12395. }
  12396. var commonStyles = Object.assign({
  12397. position
  12398. }, adaptive && unsetSides);
  12399. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  12400. x,
  12401. y
  12402. }) : {
  12403. x,
  12404. y
  12405. };
  12406. x = _ref4.x;
  12407. y = _ref4.y;
  12408. if (gpuAcceleration) {
  12409. var _Object$assign;
  12410. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  12411. }
  12412. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
  12413. }
  12414. function computeStyles(_ref5) {
  12415. var state = _ref5.state, options = _ref5.options;
  12416. var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  12417. {
  12418. var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || "";
  12419. if (adaptive && ["transform", "top", "right", "bottom", "left"].some(function(property) {
  12420. return transitionProperty.indexOf(property) >= 0;
  12421. })) {
  12422. console.warn(["Popper: Detected CSS transitions on at least one of the following", 'CSS properties: "transform", "top", "right", "bottom", "left".', "\n\n", 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', "for smooth transitions, or remove these properties from the CSS", "transition declaration on the popper element if only transitioning", "opacity or background-color for example.", "\n\n", "We recommend using the popper element as a wrapper around an inner", "element that can have any CSS property transitioned for animations."].join(" "));
  12423. }
  12424. }
  12425. var commonStyles = {
  12426. placement: getBasePlacement(state.placement),
  12427. variation: getVariation(state.placement),
  12428. popper: state.elements.popper,
  12429. popperRect: state.rects.popper,
  12430. gpuAcceleration,
  12431. isFixed: state.options.strategy === "fixed"
  12432. };
  12433. if (state.modifiersData.popperOffsets != null) {
  12434. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  12435. offsets: state.modifiersData.popperOffsets,
  12436. position: state.options.strategy,
  12437. adaptive,
  12438. roundOffsets
  12439. })));
  12440. }
  12441. if (state.modifiersData.arrow != null) {
  12442. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  12443. offsets: state.modifiersData.arrow,
  12444. position: "absolute",
  12445. adaptive: false,
  12446. roundOffsets
  12447. })));
  12448. }
  12449. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  12450. "data-popper-placement": state.placement
  12451. });
  12452. }
  12453. var computeStyles_default = {
  12454. name: "computeStyles",
  12455. enabled: true,
  12456. phase: "beforeWrite",
  12457. fn: computeStyles,
  12458. data: {}
  12459. };
  12460. function applyStyles(_ref) {
  12461. var state = _ref.state;
  12462. Object.keys(state.elements).forEach(function(name2) {
  12463. var style = state.styles[name2] || {};
  12464. var attributes = state.attributes[name2] || {};
  12465. var element = state.elements[name2];
  12466. if (!isHTMLElement(element) || !getNodeName(element)) {
  12467. return;
  12468. }
  12469. Object.assign(element.style, style);
  12470. Object.keys(attributes).forEach(function(name22) {
  12471. var value = attributes[name22];
  12472. if (value === false) {
  12473. element.removeAttribute(name22);
  12474. } else {
  12475. element.setAttribute(name22, value === true ? "" : value);
  12476. }
  12477. });
  12478. });
  12479. }
  12480. function effect2(_ref2) {
  12481. var state = _ref2.state;
  12482. var initialStyles = {
  12483. popper: {
  12484. position: state.options.strategy,
  12485. left: "0",
  12486. top: "0",
  12487. margin: "0"
  12488. },
  12489. arrow: {
  12490. position: "absolute"
  12491. },
  12492. reference: {}
  12493. };
  12494. Object.assign(state.elements.popper.style, initialStyles.popper);
  12495. state.styles = initialStyles;
  12496. if (state.elements.arrow) {
  12497. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  12498. }
  12499. return function() {
  12500. Object.keys(state.elements).forEach(function(name2) {
  12501. var element = state.elements[name2];
  12502. var attributes = state.attributes[name2] || {};
  12503. var styleProperties = Object.keys(state.styles.hasOwnProperty(name2) ? state.styles[name2] : initialStyles[name2]);
  12504. var style = styleProperties.reduce(function(style2, property) {
  12505. style2[property] = "";
  12506. return style2;
  12507. }, {});
  12508. if (!isHTMLElement(element) || !getNodeName(element)) {
  12509. return;
  12510. }
  12511. Object.assign(element.style, style);
  12512. Object.keys(attributes).forEach(function(attribute) {
  12513. element.removeAttribute(attribute);
  12514. });
  12515. });
  12516. };
  12517. }
  12518. var applyStyles_default = {
  12519. name: "applyStyles",
  12520. enabled: true,
  12521. phase: "write",
  12522. fn: applyStyles,
  12523. effect: effect2,
  12524. requires: ["computeStyles"]
  12525. };
  12526. var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default];
  12527. var createPopper = /* @__PURE__ */ popperGenerator({
  12528. defaultModifiers
  12529. });
  12530. function distanceAndSkiddingToXY(placement, rects, offset2) {
  12531. var basePlacement = getBasePlacement(placement);
  12532. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  12533. var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
  12534. placement
  12535. })) : offset2, skidding = _ref[0], distance = _ref[1];
  12536. skidding = skidding || 0;
  12537. distance = (distance || 0) * invertDistance;
  12538. return [left, right].indexOf(basePlacement) >= 0 ? {
  12539. x: distance,
  12540. y: skidding
  12541. } : {
  12542. x: skidding,
  12543. y: distance
  12544. };
  12545. }
  12546. function offset(_ref2) {
  12547. var state = _ref2.state, options = _ref2.options, name2 = _ref2.name;
  12548. var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
  12549. var data = placements.reduce(function(acc, placement) {
  12550. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
  12551. return acc;
  12552. }, {});
  12553. var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
  12554. if (state.modifiersData.popperOffsets != null) {
  12555. state.modifiersData.popperOffsets.x += x;
  12556. state.modifiersData.popperOffsets.y += y;
  12557. }
  12558. state.modifiersData[name2] = data;
  12559. }
  12560. var offset_default = {
  12561. name: "offset",
  12562. enabled: true,
  12563. phase: "main",
  12564. requires: ["popperOffsets"],
  12565. fn: offset
  12566. };
  12567. const [name$j, bem$j] = createNamespace("popover");
  12568. const popupProps = ["show", "overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  12569. const popoverProps = {
  12570. show: Boolean,
  12571. theme: makeStringProp("light"),
  12572. overlay: Boolean,
  12573. actions: makeArrayProp(),
  12574. trigger: makeStringProp("click"),
  12575. duration: numericProp,
  12576. showArrow: truthProp,
  12577. placement: makeStringProp("bottom"),
  12578. iconPrefix: String,
  12579. overlayClass: unknownProp,
  12580. overlayStyle: Object,
  12581. closeOnClickAction: truthProp,
  12582. closeOnClickOverlay: truthProp,
  12583. closeOnClickOutside: truthProp,
  12584. offset: {
  12585. type: Array,
  12586. default: () => [0, 8]
  12587. },
  12588. teleport: {
  12589. type: [String, Object],
  12590. default: "body"
  12591. }
  12592. };
  12593. var stdin_default$o = vue.defineComponent({
  12594. name: name$j,
  12595. props: popoverProps,
  12596. emits: ["select", "touchstart", "update:show"],
  12597. setup(props, {
  12598. emit,
  12599. slots,
  12600. attrs
  12601. }) {
  12602. let popper;
  12603. const popupRef = vue.ref();
  12604. const wrapperRef = vue.ref();
  12605. const popoverRef = vue.ref();
  12606. const getPopoverOptions = () => ({
  12607. placement: props.placement,
  12608. modifiers: [{
  12609. name: "computeStyles",
  12610. options: {
  12611. adaptive: false,
  12612. gpuAcceleration: false
  12613. }
  12614. }, extend({}, offset_default, {
  12615. options: {
  12616. offset: props.offset
  12617. }
  12618. })]
  12619. });
  12620. const createPopperInstance = () => {
  12621. if (wrapperRef.value && popoverRef.value) {
  12622. return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  12623. }
  12624. return null;
  12625. };
  12626. const updateLocation = () => {
  12627. vue.nextTick(() => {
  12628. if (!props.show) {
  12629. return;
  12630. }
  12631. if (!popper) {
  12632. popper = createPopperInstance();
  12633. } else {
  12634. popper.setOptions(getPopoverOptions());
  12635. }
  12636. });
  12637. };
  12638. const updateShow = (value) => emit("update:show", value);
  12639. const onClickWrapper = () => {
  12640. if (props.trigger === "click") {
  12641. updateShow(!props.show);
  12642. }
  12643. };
  12644. const onClickAction = (action, index) => {
  12645. if (action.disabled) {
  12646. return;
  12647. }
  12648. emit("select", action, index);
  12649. if (props.closeOnClickAction) {
  12650. updateShow(false);
  12651. }
  12652. };
  12653. const onClickAway = () => {
  12654. if (props.show && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  12655. updateShow(false);
  12656. }
  12657. };
  12658. const renderActionContent = (action, index) => {
  12659. if (slots.action) {
  12660. return slots.action({
  12661. action,
  12662. index
  12663. });
  12664. }
  12665. return [action.icon && vue.createVNode(Icon, {
  12666. "name": action.icon,
  12667. "classPrefix": props.iconPrefix,
  12668. "class": bem$j("action-icon")
  12669. }, null), vue.createVNode("div", {
  12670. "class": [bem$j("action-text"), BORDER_BOTTOM]
  12671. }, [action.text])];
  12672. };
  12673. const renderAction = (action, index) => {
  12674. const {
  12675. icon,
  12676. color,
  12677. disabled,
  12678. className
  12679. } = action;
  12680. return vue.createVNode("div", {
  12681. "role": "menuitem",
  12682. "class": [bem$j("action", {
  12683. disabled,
  12684. "with-icon": icon
  12685. }), className],
  12686. "style": {
  12687. color
  12688. },
  12689. "tabindex": disabled ? void 0 : 0,
  12690. "aria-disabled": disabled || void 0,
  12691. "onClick": () => onClickAction(action, index)
  12692. }, [renderActionContent(action, index)]);
  12693. };
  12694. vue.onMounted(() => {
  12695. updateLocation();
  12696. vue.watchEffect(() => {
  12697. var _a;
  12698. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  12699. });
  12700. });
  12701. vue.onBeforeUnmount(() => {
  12702. if (popper) {
  12703. popper.destroy();
  12704. popper = null;
  12705. }
  12706. });
  12707. vue.watch(() => [props.show, props.offset, props.placement], updateLocation);
  12708. useClickAway([wrapperRef, popupRef], onClickAway, {
  12709. eventName: "touchstart"
  12710. });
  12711. return () => {
  12712. var _a;
  12713. return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
  12714. "ref": wrapperRef,
  12715. "class": bem$j("wrapper"),
  12716. "onClick": onClickWrapper
  12717. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
  12718. "ref": popoverRef,
  12719. "class": bem$j([props.theme]),
  12720. "position": "",
  12721. "transition": "van-popover-zoom",
  12722. "lockScroll": false,
  12723. "onUpdate:show": updateShow
  12724. }, attrs, pick(props, popupProps)), {
  12725. default: () => [props.showArrow && vue.createVNode("div", {
  12726. "class": bem$j("arrow")
  12727. }, null), vue.createVNode("div", {
  12728. "role": "menu",
  12729. "class": bem$j("content")
  12730. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  12731. })]);
  12732. };
  12733. }
  12734. });
  12735. const Popover = withInstall(stdin_default$o);
  12736. const [name$i, bem$i] = createNamespace("progress");
  12737. const progressProps = {
  12738. color: String,
  12739. inactive: Boolean,
  12740. pivotText: String,
  12741. textColor: String,
  12742. showPivot: truthProp,
  12743. pivotColor: String,
  12744. trackColor: String,
  12745. strokeWidth: numericProp,
  12746. percentage: {
  12747. type: numericProp,
  12748. default: 0,
  12749. validator: (value) => value >= 0 && value <= 100
  12750. }
  12751. };
  12752. var stdin_default$n = vue.defineComponent({
  12753. name: name$i,
  12754. props: progressProps,
  12755. setup(props) {
  12756. const background = vue.computed(() => props.inactive ? void 0 : props.color);
  12757. const renderPivot = () => {
  12758. const {
  12759. textColor,
  12760. pivotText,
  12761. pivotColor,
  12762. percentage
  12763. } = props;
  12764. const text = pivotText != null ? pivotText : `${percentage}%`;
  12765. if (props.showPivot && text) {
  12766. const style = {
  12767. color: textColor,
  12768. left: `${+percentage}%`,
  12769. transform: `translate(-${+percentage}%,-50%)`,
  12770. background: pivotColor || background.value
  12771. };
  12772. return vue.createVNode("span", {
  12773. "style": style,
  12774. "class": bem$i("pivot", {
  12775. inactive: props.inactive
  12776. })
  12777. }, [text]);
  12778. }
  12779. };
  12780. return () => {
  12781. const {
  12782. trackColor,
  12783. percentage,
  12784. strokeWidth
  12785. } = props;
  12786. const rootStyle = {
  12787. background: trackColor,
  12788. height: addUnit(strokeWidth)
  12789. };
  12790. const portionStyle = {
  12791. width: `${percentage}%`,
  12792. background: background.value
  12793. };
  12794. return vue.createVNode("div", {
  12795. "class": bem$i(),
  12796. "style": rootStyle
  12797. }, [vue.createVNode("span", {
  12798. "class": bem$i("portion", {
  12799. inactive: props.inactive
  12800. }),
  12801. "style": portionStyle
  12802. }, null), renderPivot()]);
  12803. };
  12804. }
  12805. });
  12806. const Progress = withInstall(stdin_default$n);
  12807. const [name$h, bem$h, t$4] = createNamespace("pull-refresh");
  12808. const DEFAULT_HEAD_HEIGHT = 50;
  12809. const TEXT_STATUS = ["pulling", "loosing", "success"];
  12810. const pullRefreshProps = {
  12811. disabled: Boolean,
  12812. modelValue: Boolean,
  12813. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  12814. successText: String,
  12815. pullingText: String,
  12816. loosingText: String,
  12817. loadingText: String,
  12818. pullDistance: numericProp,
  12819. successDuration: makeNumericProp(500),
  12820. animationDuration: makeNumericProp(300)
  12821. };
  12822. var stdin_default$m = vue.defineComponent({
  12823. name: name$h,
  12824. props: pullRefreshProps,
  12825. emits: ["change", "refresh", "update:modelValue"],
  12826. setup(props, {
  12827. emit,
  12828. slots
  12829. }) {
  12830. let reachTop;
  12831. const root = vue.ref();
  12832. const track = vue.ref();
  12833. const scrollParent = useScrollParent(root);
  12834. const state = vue.reactive({
  12835. status: "normal",
  12836. distance: 0,
  12837. duration: 0
  12838. });
  12839. const touch = useTouch();
  12840. const getHeadStyle = () => {
  12841. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  12842. return {
  12843. height: `${props.headHeight}px`
  12844. };
  12845. }
  12846. };
  12847. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  12848. const ease = (distance) => {
  12849. const pullDistance = +(props.pullDistance || props.headHeight);
  12850. if (distance > pullDistance) {
  12851. if (distance < pullDistance * 2) {
  12852. distance = pullDistance + (distance - pullDistance) / 2;
  12853. } else {
  12854. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  12855. }
  12856. }
  12857. return Math.round(distance);
  12858. };
  12859. const setStatus = (distance, isLoading) => {
  12860. const pullDistance = +(props.pullDistance || props.headHeight);
  12861. state.distance = distance;
  12862. if (isLoading) {
  12863. state.status = "loading";
  12864. } else if (distance === 0) {
  12865. state.status = "normal";
  12866. } else if (distance < pullDistance) {
  12867. state.status = "pulling";
  12868. } else {
  12869. state.status = "loosing";
  12870. }
  12871. emit("change", {
  12872. status: state.status,
  12873. distance
  12874. });
  12875. };
  12876. const getStatusText = () => {
  12877. const {
  12878. status
  12879. } = state;
  12880. if (status === "normal") {
  12881. return "";
  12882. }
  12883. return props[`${status}Text`] || t$4(status);
  12884. };
  12885. const renderStatus = () => {
  12886. const {
  12887. status,
  12888. distance
  12889. } = state;
  12890. if (slots[status]) {
  12891. return slots[status]({
  12892. distance
  12893. });
  12894. }
  12895. const nodes = [];
  12896. if (TEXT_STATUS.includes(status)) {
  12897. nodes.push(vue.createVNode("div", {
  12898. "class": bem$h("text")
  12899. }, [getStatusText()]));
  12900. }
  12901. if (status === "loading") {
  12902. nodes.push(vue.createVNode(Loading, {
  12903. "class": bem$h("loading")
  12904. }, {
  12905. default: getStatusText
  12906. }));
  12907. }
  12908. return nodes;
  12909. };
  12910. const showSuccessTip = () => {
  12911. state.status = "success";
  12912. setTimeout(() => {
  12913. setStatus(0);
  12914. }, +props.successDuration);
  12915. };
  12916. const checkPosition = (event) => {
  12917. reachTop = getScrollTop(scrollParent.value) === 0;
  12918. if (reachTop) {
  12919. state.duration = 0;
  12920. touch.start(event);
  12921. }
  12922. };
  12923. const onTouchStart = (event) => {
  12924. if (isTouchable()) {
  12925. checkPosition(event);
  12926. }
  12927. };
  12928. const onTouchMove = (event) => {
  12929. if (isTouchable()) {
  12930. if (!reachTop) {
  12931. checkPosition(event);
  12932. }
  12933. const {
  12934. deltaY
  12935. } = touch;
  12936. touch.move(event);
  12937. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  12938. preventDefault(event);
  12939. setStatus(ease(deltaY.value));
  12940. }
  12941. }
  12942. };
  12943. const onTouchEnd = () => {
  12944. if (reachTop && touch.deltaY.value && isTouchable()) {
  12945. state.duration = +props.animationDuration;
  12946. if (state.status === "loosing") {
  12947. setStatus(+props.headHeight, true);
  12948. emit("update:modelValue", true);
  12949. vue.nextTick(() => emit("refresh"));
  12950. } else {
  12951. setStatus(0);
  12952. }
  12953. }
  12954. };
  12955. vue.watch(() => props.modelValue, (value) => {
  12956. state.duration = +props.animationDuration;
  12957. if (value) {
  12958. setStatus(+props.headHeight, true);
  12959. } else if (slots.success || props.successText) {
  12960. showSuccessTip();
  12961. } else {
  12962. setStatus(0, false);
  12963. }
  12964. });
  12965. useEventListener("touchmove", onTouchMove, {
  12966. target: track
  12967. });
  12968. return () => {
  12969. var _a;
  12970. const trackStyle = {
  12971. transitionDuration: `${state.duration}ms`,
  12972. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  12973. };
  12974. return vue.createVNode("div", {
  12975. "ref": root,
  12976. "class": bem$h()
  12977. }, [vue.createVNode("div", {
  12978. "ref": track,
  12979. "class": bem$h("track"),
  12980. "style": trackStyle,
  12981. "onTouchstartPassive": onTouchStart,
  12982. "onTouchend": onTouchEnd,
  12983. "onTouchcancel": onTouchEnd
  12984. }, [vue.createVNode("div", {
  12985. "class": bem$h("head"),
  12986. "style": getHeadStyle()
  12987. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12988. };
  12989. }
  12990. });
  12991. const PullRefresh = withInstall(stdin_default$m);
  12992. const [name$g, bem$g] = createNamespace("rate");
  12993. function getRateStatus(value, index, allowHalf, readonly) {
  12994. if (value >= index) {
  12995. return {
  12996. status: "full",
  12997. value: 1
  12998. };
  12999. }
  13000. if (value + 0.5 >= index && allowHalf && !readonly) {
  13001. return {
  13002. status: "half",
  13003. value: 0.5
  13004. };
  13005. }
  13006. if (value + 1 >= index && allowHalf && readonly) {
  13007. const cardinal = 10 ** 10;
  13008. return {
  13009. status: "half",
  13010. value: Math.round((value - index + 1) * cardinal) / cardinal
  13011. };
  13012. }
  13013. return {
  13014. status: "void",
  13015. value: 0
  13016. };
  13017. }
  13018. const rateProps = {
  13019. size: numericProp,
  13020. icon: makeStringProp("star"),
  13021. color: String,
  13022. count: makeNumericProp(5),
  13023. gutter: numericProp,
  13024. readonly: Boolean,
  13025. disabled: Boolean,
  13026. voidIcon: makeStringProp("star-o"),
  13027. allowHalf: Boolean,
  13028. voidColor: String,
  13029. touchable: truthProp,
  13030. iconPrefix: String,
  13031. modelValue: makeNumberProp(0),
  13032. disabledColor: String
  13033. };
  13034. var stdin_default$l = vue.defineComponent({
  13035. name: name$g,
  13036. props: rateProps,
  13037. emits: ["change", "update:modelValue"],
  13038. setup(props, {
  13039. emit
  13040. }) {
  13041. const touch = useTouch();
  13042. const [itemRefs, setItemRefs] = useRefs();
  13043. const groupRef = vue.ref();
  13044. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  13045. const list = vue.computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  13046. let ranges;
  13047. let groupRefRect;
  13048. let minRectTop = Number.MAX_SAFE_INTEGER;
  13049. let maxRectTop = Number.MIN_SAFE_INTEGER;
  13050. const updateRanges = () => {
  13051. groupRefRect = useRect(groupRef);
  13052. const rects = itemRefs.value.map(useRect);
  13053. ranges = [];
  13054. rects.forEach((rect, index) => {
  13055. minRectTop = Math.min(rect.top, minRectTop);
  13056. maxRectTop = Math.max(rect.top, maxRectTop);
  13057. if (props.allowHalf) {
  13058. ranges.push({
  13059. score: index + 0.5,
  13060. left: rect.left,
  13061. top: rect.top,
  13062. height: rect.height
  13063. }, {
  13064. score: index + 1,
  13065. left: rect.left + rect.width / 2,
  13066. top: rect.top,
  13067. height: rect.height
  13068. });
  13069. } else {
  13070. ranges.push({
  13071. score: index + 1,
  13072. left: rect.left,
  13073. top: rect.top,
  13074. height: rect.height
  13075. });
  13076. }
  13077. });
  13078. };
  13079. const getScoreByPosition = (x, y) => {
  13080. for (let i = ranges.length - 1; i > 0; i--) {
  13081. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  13082. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  13083. return ranges[i].score;
  13084. }
  13085. } else {
  13086. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  13087. if (x > ranges[i].left && ranges[i].top === curTop) {
  13088. return ranges[i].score;
  13089. }
  13090. }
  13091. }
  13092. return props.allowHalf ? 0.5 : 1;
  13093. };
  13094. const select = (index) => {
  13095. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  13096. emit("update:modelValue", index);
  13097. emit("change", index);
  13098. }
  13099. };
  13100. const onTouchStart = (event) => {
  13101. if (untouchable()) {
  13102. return;
  13103. }
  13104. touch.start(event);
  13105. updateRanges();
  13106. };
  13107. const onTouchMove = (event) => {
  13108. if (untouchable()) {
  13109. return;
  13110. }
  13111. touch.move(event);
  13112. if (touch.isHorizontal()) {
  13113. const {
  13114. clientX,
  13115. clientY
  13116. } = event.touches[0];
  13117. preventDefault(event);
  13118. select(getScoreByPosition(clientX, clientY));
  13119. }
  13120. };
  13121. const renderStar = (item, index) => {
  13122. const {
  13123. icon,
  13124. size,
  13125. color,
  13126. count,
  13127. gutter,
  13128. voidIcon,
  13129. disabled,
  13130. voidColor,
  13131. allowHalf,
  13132. iconPrefix,
  13133. disabledColor
  13134. } = props;
  13135. const score = index + 1;
  13136. const isFull = item.status === "full";
  13137. const isVoid = item.status === "void";
  13138. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  13139. let style;
  13140. if (gutter && score !== +count) {
  13141. style = {
  13142. paddingRight: addUnit(gutter)
  13143. };
  13144. }
  13145. const onClickItem = (event) => {
  13146. updateRanges();
  13147. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  13148. };
  13149. return vue.createVNode("div", {
  13150. "key": index,
  13151. "ref": setItemRefs(index),
  13152. "role": "radio",
  13153. "style": style,
  13154. "class": bem$g("item"),
  13155. "tabindex": disabled ? void 0 : 0,
  13156. "aria-setsize": count,
  13157. "aria-posinset": score,
  13158. "aria-checked": !isVoid,
  13159. "onClick": onClickItem
  13160. }, [vue.createVNode(Icon, {
  13161. "size": size,
  13162. "name": isFull ? icon : voidIcon,
  13163. "class": bem$g("icon", {
  13164. disabled,
  13165. full: isFull
  13166. }),
  13167. "color": disabled ? disabledColor : isFull ? color : voidColor,
  13168. "classPrefix": iconPrefix
  13169. }, null), renderHalf && vue.createVNode(Icon, {
  13170. "size": size,
  13171. "style": {
  13172. width: item.value + "em"
  13173. },
  13174. "name": isVoid ? voidIcon : icon,
  13175. "class": bem$g("icon", ["half", {
  13176. disabled,
  13177. full: !isVoid
  13178. }]),
  13179. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  13180. "classPrefix": iconPrefix
  13181. }, null)]);
  13182. };
  13183. useCustomFieldValue(() => props.modelValue);
  13184. useEventListener("touchmove", onTouchMove, {
  13185. target: groupRef
  13186. });
  13187. return () => vue.createVNode("div", {
  13188. "ref": groupRef,
  13189. "role": "radiogroup",
  13190. "class": bem$g({
  13191. readonly: props.readonly,
  13192. disabled: props.disabled
  13193. }),
  13194. "tabindex": props.disabled ? void 0 : 0,
  13195. "aria-disabled": props.disabled,
  13196. "aria-readonly": props.readonly,
  13197. "onTouchstartPassive": onTouchStart
  13198. }, [list.value.map(renderStar)]);
  13199. }
  13200. });
  13201. const Rate = withInstall(stdin_default$l);
  13202. const Row = withInstall(stdin_default$V);
  13203. const [name$f, bem$f, t$3] = createNamespace("search");
  13204. const searchProps = extend({}, fieldSharedProps, {
  13205. label: String,
  13206. shape: makeStringProp("square"),
  13207. leftIcon: makeStringProp("search"),
  13208. clearable: truthProp,
  13209. actionText: String,
  13210. background: String,
  13211. showAction: Boolean
  13212. });
  13213. var stdin_default$k = vue.defineComponent({
  13214. name: name$f,
  13215. props: searchProps,
  13216. emits: ["blur", "focus", "clear", "search", "cancel", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
  13217. setup(props, {
  13218. emit,
  13219. slots,
  13220. attrs
  13221. }) {
  13222. const id = useId();
  13223. const filedRef = vue.ref();
  13224. const onCancel = () => {
  13225. if (!slots.action) {
  13226. emit("update:modelValue", "");
  13227. emit("cancel");
  13228. }
  13229. };
  13230. const onKeypress = (event) => {
  13231. const ENTER_CODE = 13;
  13232. if (event.keyCode === ENTER_CODE) {
  13233. preventDefault(event);
  13234. emit("search", props.modelValue);
  13235. }
  13236. };
  13237. const getInputId = () => props.id || `${id}-input`;
  13238. const renderLabel = () => {
  13239. if (slots.label || props.label) {
  13240. return vue.createVNode("label", {
  13241. "class": bem$f("label"),
  13242. "for": getInputId()
  13243. }, [slots.label ? slots.label() : props.label]);
  13244. }
  13245. };
  13246. const renderAction = () => {
  13247. if (props.showAction) {
  13248. const text = props.actionText || t$3("cancel");
  13249. return vue.createVNode("div", {
  13250. "class": bem$f("action"),
  13251. "role": "button",
  13252. "tabindex": 0,
  13253. "onClick": onCancel
  13254. }, [slots.action ? slots.action() : text]);
  13255. }
  13256. };
  13257. const blur = () => {
  13258. var _a;
  13259. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  13260. };
  13261. const focus = () => {
  13262. var _a;
  13263. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  13264. };
  13265. const onBlur = (event) => emit("blur", event);
  13266. const onFocus = (event) => emit("focus", event);
  13267. const onClear = (event) => emit("clear", event);
  13268. const onClickInput = (event) => emit("click-input", event);
  13269. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  13270. const onClickRightIcon = (event) => emit("click-right-icon", event);
  13271. const fieldPropNames = Object.keys(fieldSharedProps);
  13272. const renderField = () => {
  13273. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  13274. id: getInputId()
  13275. });
  13276. const onInput = (value) => emit("update:modelValue", value);
  13277. return vue.createVNode(Field, vue.mergeProps({
  13278. "ref": filedRef,
  13279. "type": "search",
  13280. "class": bem$f("field"),
  13281. "border": false,
  13282. "onBlur": onBlur,
  13283. "onFocus": onFocus,
  13284. "onClear": onClear,
  13285. "onKeypress": onKeypress,
  13286. "onClick-input": onClickInput,
  13287. "onClick-left-icon": onClickLeftIcon,
  13288. "onClick-right-icon": onClickRightIcon,
  13289. "onUpdate:modelValue": onInput
  13290. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  13291. };
  13292. useExpose({
  13293. focus,
  13294. blur
  13295. });
  13296. return () => {
  13297. var _a;
  13298. return vue.createVNode("div", {
  13299. "class": bem$f({
  13300. "show-action": props.showAction
  13301. }),
  13302. "style": {
  13303. background: props.background
  13304. }
  13305. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
  13306. "class": bem$f("content", props.shape)
  13307. }, [renderLabel(), renderField()]), renderAction()]);
  13308. };
  13309. }
  13310. });
  13311. const Search = withInstall(stdin_default$k);
  13312. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  13313. const iconMap = {
  13314. qq: "qq",
  13315. link: "link-o",
  13316. weibo: "weibo",
  13317. qrcode: "qr",
  13318. poster: "photo-o",
  13319. wechat: "wechat",
  13320. "weapp-qrcode": "miniprogram-o",
  13321. "wechat-moments": "wechat-moments"
  13322. };
  13323. const [name$e, bem$e, t$2] = createNamespace("share-sheet");
  13324. const shareSheetProps = extend({}, popupSharedProps, {
  13325. title: String,
  13326. round: truthProp,
  13327. options: makeArrayProp(),
  13328. cancelText: String,
  13329. description: String,
  13330. closeOnPopstate: truthProp,
  13331. safeAreaInsetBottom: truthProp
  13332. });
  13333. var stdin_default$j = vue.defineComponent({
  13334. name: name$e,
  13335. props: shareSheetProps,
  13336. emits: ["cancel", "select", "update:show"],
  13337. setup(props, {
  13338. emit,
  13339. slots
  13340. }) {
  13341. const updateShow = (value) => emit("update:show", value);
  13342. const onCancel = () => {
  13343. updateShow(false);
  13344. emit("cancel");
  13345. };
  13346. const onSelect = (option, index) => emit("select", option, index);
  13347. const renderHeader = () => {
  13348. const title = slots.title ? slots.title() : props.title;
  13349. const description = slots.description ? slots.description() : props.description;
  13350. if (title || description) {
  13351. return vue.createVNode("div", {
  13352. "class": bem$e("header")
  13353. }, [title && vue.createVNode("h2", {
  13354. "class": bem$e("title")
  13355. }, [title]), description && vue.createVNode("span", {
  13356. "class": bem$e("description")
  13357. }, [description])]);
  13358. }
  13359. };
  13360. const renderIcon = (icon) => {
  13361. if (iconMap[icon]) {
  13362. return vue.createVNode("div", {
  13363. "class": bem$e("icon", [icon])
  13364. }, [vue.createVNode(Icon, {
  13365. "name": iconMap[icon] || icon
  13366. }, null)]);
  13367. }
  13368. return vue.createVNode("img", {
  13369. "src": icon,
  13370. "class": bem$e("image-icon")
  13371. }, null);
  13372. };
  13373. const renderOption = (option, index) => {
  13374. const {
  13375. name: name2,
  13376. icon,
  13377. className,
  13378. description
  13379. } = option;
  13380. return vue.createVNode("div", {
  13381. "role": "button",
  13382. "tabindex": 0,
  13383. "class": [bem$e("option"), className, HAPTICS_FEEDBACK],
  13384. "onClick": () => onSelect(option, index)
  13385. }, [renderIcon(icon), name2 && vue.createVNode("span", {
  13386. "class": bem$e("name")
  13387. }, [name2]), description && vue.createVNode("span", {
  13388. "class": bem$e("option-description")
  13389. }, [description])]);
  13390. };
  13391. const renderOptions = (options, border) => vue.createVNode("div", {
  13392. "class": bem$e("options", {
  13393. border
  13394. })
  13395. }, [options.map(renderOption)]);
  13396. const renderRows = () => {
  13397. const {
  13398. options
  13399. } = props;
  13400. if (Array.isArray(options[0])) {
  13401. return options.map((item, index) => renderOptions(item, index !== 0));
  13402. }
  13403. return renderOptions(options);
  13404. };
  13405. const renderCancelButton = () => {
  13406. var _a;
  13407. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  13408. if (slots.cancel || cancelText) {
  13409. return vue.createVNode("button", {
  13410. "type": "button",
  13411. "class": bem$e("cancel"),
  13412. "onClick": onCancel
  13413. }, [slots.cancel ? slots.cancel() : cancelText]);
  13414. }
  13415. };
  13416. return () => vue.createVNode(Popup, vue.mergeProps({
  13417. "class": bem$e(),
  13418. "position": "bottom",
  13419. "onUpdate:show": updateShow
  13420. }, pick(props, popupInheritKeys)), {
  13421. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  13422. });
  13423. }
  13424. });
  13425. const ShareSheet = withInstall(stdin_default$j);
  13426. const [name$d, bem$d] = createNamespace("sidebar");
  13427. const SIDEBAR_KEY = Symbol(name$d);
  13428. const sidebarProps = {
  13429. modelValue: makeNumericProp(0)
  13430. };
  13431. var stdin_default$i = vue.defineComponent({
  13432. name: name$d,
  13433. props: sidebarProps,
  13434. emits: ["change", "update:modelValue"],
  13435. setup(props, {
  13436. emit,
  13437. slots
  13438. }) {
  13439. const {
  13440. linkChildren
  13441. } = useChildren(SIDEBAR_KEY);
  13442. const getActive = () => +props.modelValue;
  13443. const setActive = (value) => {
  13444. if (value !== getActive()) {
  13445. emit("update:modelValue", value);
  13446. emit("change", value);
  13447. }
  13448. };
  13449. linkChildren({
  13450. getActive,
  13451. setActive
  13452. });
  13453. return () => {
  13454. var _a;
  13455. return vue.createVNode("div", {
  13456. "role": "tablist",
  13457. "class": bem$d()
  13458. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13459. };
  13460. }
  13461. });
  13462. const Sidebar = withInstall(stdin_default$i);
  13463. const [name$c, bem$c] = createNamespace("sidebar-item");
  13464. const sidebarItemProps = extend({}, routeProps, {
  13465. dot: Boolean,
  13466. title: String,
  13467. badge: numericProp,
  13468. disabled: Boolean,
  13469. badgeProps: Object
  13470. });
  13471. var stdin_default$h = vue.defineComponent({
  13472. name: name$c,
  13473. props: sidebarItemProps,
  13474. emits: ["click"],
  13475. setup(props, {
  13476. emit,
  13477. slots
  13478. }) {
  13479. const route2 = useRoute();
  13480. const {
  13481. parent,
  13482. index
  13483. } = useParent(SIDEBAR_KEY);
  13484. if (!parent) {
  13485. return;
  13486. }
  13487. const onClick = () => {
  13488. if (props.disabled) {
  13489. return;
  13490. }
  13491. emit("click", index.value);
  13492. parent.setActive(index.value);
  13493. route2();
  13494. };
  13495. return () => {
  13496. const {
  13497. dot,
  13498. badge,
  13499. title,
  13500. disabled
  13501. } = props;
  13502. const selected = index.value === parent.getActive();
  13503. return vue.createVNode("div", {
  13504. "role": "tab",
  13505. "class": bem$c({
  13506. select: selected,
  13507. disabled
  13508. }),
  13509. "tabindex": disabled ? void 0 : 0,
  13510. "aria-selected": selected,
  13511. "onClick": onClick
  13512. }, [vue.createVNode(Badge, vue.mergeProps({
  13513. "dot": dot,
  13514. "class": bem$c("text"),
  13515. "content": badge
  13516. }, props.badgeProps), {
  13517. default: () => [slots.title ? slots.title() : title]
  13518. })]);
  13519. };
  13520. }
  13521. });
  13522. const SidebarItem = withInstall(stdin_default$h);
  13523. const [name$b, bem$b] = createNamespace("skeleton");
  13524. const DEFAULT_ROW_WIDTH = "100%";
  13525. const DEFAULT_LAST_ROW_WIDTH = "60%";
  13526. const skeletonProps = {
  13527. row: makeNumericProp(0),
  13528. title: Boolean,
  13529. round: Boolean,
  13530. avatar: Boolean,
  13531. loading: truthProp,
  13532. animate: truthProp,
  13533. avatarSize: numericProp,
  13534. titleWidth: numericProp,
  13535. avatarShape: makeStringProp("round"),
  13536. rowWidth: {
  13537. type: [Number, String, Array],
  13538. default: DEFAULT_ROW_WIDTH
  13539. }
  13540. };
  13541. var stdin_default$g = vue.defineComponent({
  13542. name: name$b,
  13543. inheritAttrs: false,
  13544. props: skeletonProps,
  13545. setup(props, {
  13546. slots,
  13547. attrs
  13548. }) {
  13549. const renderAvatar = () => {
  13550. if (props.avatar) {
  13551. return vue.createVNode("div", {
  13552. "class": bem$b("avatar", props.avatarShape),
  13553. "style": getSizeStyle(props.avatarSize)
  13554. }, null);
  13555. }
  13556. };
  13557. const renderTitle = () => {
  13558. if (props.title) {
  13559. return vue.createVNode("h3", {
  13560. "class": bem$b("title"),
  13561. "style": {
  13562. width: addUnit(props.titleWidth)
  13563. }
  13564. }, null);
  13565. }
  13566. };
  13567. const getRowWidth = (index) => {
  13568. const {
  13569. rowWidth
  13570. } = props;
  13571. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  13572. return DEFAULT_LAST_ROW_WIDTH;
  13573. }
  13574. if (Array.isArray(rowWidth)) {
  13575. return rowWidth[index];
  13576. }
  13577. return rowWidth;
  13578. };
  13579. const renderRows = () => Array(+props.row).fill("").map((_, i) => vue.createVNode("div", {
  13580. "class": bem$b("row"),
  13581. "style": {
  13582. width: addUnit(getRowWidth(i))
  13583. }
  13584. }, null));
  13585. return () => {
  13586. var _a;
  13587. if (!props.loading) {
  13588. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  13589. }
  13590. return vue.createVNode("div", vue.mergeProps({
  13591. "class": bem$b({
  13592. animate: props.animate,
  13593. round: props.round
  13594. })
  13595. }, attrs), [renderAvatar(), vue.createVNode("div", {
  13596. "class": bem$b("content")
  13597. }, [renderTitle(), renderRows()])]);
  13598. };
  13599. }
  13600. });
  13601. const Skeleton = withInstall(stdin_default$g);
  13602. const [name$a, bem$a] = createNamespace("slider");
  13603. const sliderProps = {
  13604. min: makeNumericProp(0),
  13605. max: makeNumericProp(100),
  13606. step: makeNumericProp(1),
  13607. range: Boolean,
  13608. reverse: Boolean,
  13609. disabled: Boolean,
  13610. readonly: Boolean,
  13611. vertical: Boolean,
  13612. barHeight: numericProp,
  13613. buttonSize: numericProp,
  13614. activeColor: String,
  13615. inactiveColor: String,
  13616. modelValue: {
  13617. type: [Number, Array],
  13618. default: 0
  13619. }
  13620. };
  13621. var stdin_default$f = vue.defineComponent({
  13622. name: name$a,
  13623. props: sliderProps,
  13624. emits: ["change", "drag-end", "drag-start", "update:modelValue"],
  13625. setup(props, {
  13626. emit,
  13627. slots
  13628. }) {
  13629. let buttonIndex;
  13630. let current2;
  13631. let startValue;
  13632. const root = vue.ref();
  13633. const slider = vue.ref();
  13634. const dragStatus = vue.ref();
  13635. const touch = useTouch();
  13636. const scope = vue.computed(() => Number(props.max) - Number(props.min));
  13637. const wrapperStyle = vue.computed(() => {
  13638. const crossAxis = props.vertical ? "width" : "height";
  13639. return {
  13640. background: props.inactiveColor,
  13641. [crossAxis]: addUnit(props.barHeight)
  13642. };
  13643. });
  13644. const isRange = (val) => props.range && Array.isArray(val);
  13645. const calcMainAxis = () => {
  13646. const {
  13647. modelValue,
  13648. min
  13649. } = props;
  13650. if (isRange(modelValue)) {
  13651. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  13652. }
  13653. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  13654. };
  13655. const calcOffset = () => {
  13656. const {
  13657. modelValue,
  13658. min
  13659. } = props;
  13660. if (isRange(modelValue)) {
  13661. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  13662. }
  13663. return "0%";
  13664. };
  13665. const barStyle = vue.computed(() => {
  13666. const mainAxis = props.vertical ? "height" : "width";
  13667. const style = {
  13668. [mainAxis]: calcMainAxis(),
  13669. background: props.activeColor
  13670. };
  13671. if (dragStatus.value) {
  13672. style.transition = "none";
  13673. }
  13674. const getPositionKey = () => {
  13675. if (props.vertical) {
  13676. return props.reverse ? "bottom" : "top";
  13677. }
  13678. return props.reverse ? "right" : "left";
  13679. };
  13680. style[getPositionKey()] = calcOffset();
  13681. return style;
  13682. });
  13683. const format2 = (value) => {
  13684. const min = +props.min;
  13685. const max = +props.max;
  13686. const step = +props.step;
  13687. value = clamp(value, min, max);
  13688. const diff = Math.round((value - min) / step) * step;
  13689. return addNumber(min, diff);
  13690. };
  13691. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  13692. const handleRangeValue = (value) => {
  13693. var _a, _b;
  13694. const left2 = (_a = value[0]) != null ? _a : Number(props.min);
  13695. const right2 = (_b = value[1]) != null ? _b : Number(props.max);
  13696. return left2 > right2 ? [right2, left2] : [left2, right2];
  13697. };
  13698. const updateValue = (value, end2) => {
  13699. if (isRange(value)) {
  13700. value = handleRangeValue(value).map(format2);
  13701. } else {
  13702. value = format2(value);
  13703. }
  13704. if (!isSameValue(value, props.modelValue)) {
  13705. emit("update:modelValue", value);
  13706. }
  13707. if (end2 && !isSameValue(value, startValue)) {
  13708. emit("change", value);
  13709. }
  13710. };
  13711. const onClick = (event) => {
  13712. event.stopPropagation();
  13713. if (props.disabled || props.readonly) {
  13714. return;
  13715. }
  13716. const {
  13717. min,
  13718. reverse,
  13719. vertical,
  13720. modelValue
  13721. } = props;
  13722. const rect = useRect(root);
  13723. const getDelta = () => {
  13724. if (vertical) {
  13725. if (reverse) {
  13726. return rect.bottom - event.clientY;
  13727. }
  13728. return event.clientY - rect.top;
  13729. }
  13730. if (reverse) {
  13731. return rect.right - event.clientX;
  13732. }
  13733. return event.clientX - rect.left;
  13734. };
  13735. const total = vertical ? rect.height : rect.width;
  13736. const value = Number(min) + getDelta() / total * scope.value;
  13737. if (isRange(modelValue)) {
  13738. const [left2, right2] = modelValue;
  13739. const middle = (left2 + right2) / 2;
  13740. if (value <= middle) {
  13741. updateValue([value, right2], true);
  13742. } else {
  13743. updateValue([left2, value], true);
  13744. }
  13745. } else {
  13746. updateValue(value, true);
  13747. }
  13748. };
  13749. const onTouchStart = (event) => {
  13750. if (props.disabled || props.readonly) {
  13751. return;
  13752. }
  13753. touch.start(event);
  13754. current2 = props.modelValue;
  13755. if (isRange(current2)) {
  13756. startValue = current2.map(format2);
  13757. } else {
  13758. startValue = format2(current2);
  13759. }
  13760. dragStatus.value = "start";
  13761. };
  13762. const onTouchMove = (event) => {
  13763. if (props.disabled || props.readonly) {
  13764. return;
  13765. }
  13766. if (dragStatus.value === "start") {
  13767. emit("drag-start", event);
  13768. }
  13769. preventDefault(event, true);
  13770. touch.move(event);
  13771. dragStatus.value = "dragging";
  13772. const rect = useRect(root);
  13773. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  13774. const total = props.vertical ? rect.height : rect.width;
  13775. let diff = delta / total * scope.value;
  13776. if (props.reverse) {
  13777. diff = -diff;
  13778. }
  13779. if (isRange(startValue)) {
  13780. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  13781. current2[index] = startValue[index] + diff;
  13782. } else {
  13783. current2 = startValue + diff;
  13784. }
  13785. updateValue(current2);
  13786. };
  13787. const onTouchEnd = (event) => {
  13788. if (props.disabled || props.readonly) {
  13789. return;
  13790. }
  13791. if (dragStatus.value === "dragging") {
  13792. updateValue(current2, true);
  13793. emit("drag-end", event);
  13794. }
  13795. dragStatus.value = "";
  13796. };
  13797. const getButtonClassName = (index) => {
  13798. if (typeof index === "number") {
  13799. const position = ["left", "right"];
  13800. return bem$a(`button-wrapper`, position[index]);
  13801. }
  13802. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  13803. };
  13804. const renderButtonContent = (value, index) => {
  13805. if (typeof index === "number") {
  13806. const slot = slots[index === 0 ? "left-button" : "right-button"];
  13807. if (slot) {
  13808. return slot({
  13809. value
  13810. });
  13811. }
  13812. }
  13813. if (slots.button) {
  13814. return slots.button({
  13815. value
  13816. });
  13817. }
  13818. return vue.createVNode("div", {
  13819. "class": bem$a("button"),
  13820. "style": getSizeStyle(props.buttonSize)
  13821. }, null);
  13822. };
  13823. const renderButton = (index) => {
  13824. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  13825. return vue.createVNode("div", {
  13826. "ref": slider,
  13827. "role": "slider",
  13828. "class": getButtonClassName(index),
  13829. "tabindex": props.disabled ? void 0 : 0,
  13830. "aria-valuemin": props.min,
  13831. "aria-valuenow": current22,
  13832. "aria-valuemax": props.max,
  13833. "aria-disabled": props.disabled || void 0,
  13834. "aria-readonly": props.readonly || void 0,
  13835. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  13836. "onTouchstartPassive": (event) => {
  13837. if (typeof index === "number") {
  13838. buttonIndex = index;
  13839. }
  13840. onTouchStart(event);
  13841. },
  13842. "onTouchend": onTouchEnd,
  13843. "onTouchcancel": onTouchEnd,
  13844. "onClick": stopPropagation
  13845. }, [renderButtonContent(current22, index)]);
  13846. };
  13847. updateValue(props.modelValue);
  13848. useCustomFieldValue(() => props.modelValue);
  13849. useEventListener("touchmove", onTouchMove, {
  13850. target: slider
  13851. });
  13852. return () => vue.createVNode("div", {
  13853. "ref": root,
  13854. "style": wrapperStyle.value,
  13855. "class": bem$a({
  13856. vertical: props.vertical,
  13857. disabled: props.disabled
  13858. }),
  13859. "onClick": onClick
  13860. }, [vue.createVNode("div", {
  13861. "class": bem$a("bar"),
  13862. "style": barStyle.value
  13863. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  13864. }
  13865. });
  13866. const Slider = withInstall(stdin_default$f);
  13867. const [name$9, bem$9] = createNamespace("space");
  13868. const spaceProps = {
  13869. align: String,
  13870. direction: {
  13871. type: String,
  13872. default: "horizontal"
  13873. },
  13874. size: {
  13875. type: [Number, String, Array],
  13876. default: 8
  13877. },
  13878. wrap: Boolean,
  13879. fill: Boolean
  13880. };
  13881. function filterEmpty(children = []) {
  13882. const nodes = [];
  13883. children.forEach((child) => {
  13884. if (Array.isArray(child)) {
  13885. nodes.push(...child);
  13886. } else if (child.type === vue.Fragment) {
  13887. nodes.push(...filterEmpty(child.children));
  13888. } else {
  13889. nodes.push(child);
  13890. }
  13891. });
  13892. return nodes.filter((c) => {
  13893. var _a;
  13894. return !(c && (typeof Comment !== "undefined" && c.type === Comment || c.type === vue.Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
  13895. });
  13896. }
  13897. var stdin_default$e = vue.defineComponent({
  13898. name: name$9,
  13899. props: spaceProps,
  13900. setup(props, {
  13901. slots
  13902. }) {
  13903. const mergedAlign = vue.computed(() => {
  13904. var _a;
  13905. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  13906. });
  13907. const getMargin = (size) => {
  13908. if (typeof size === "number") {
  13909. return size + "px";
  13910. }
  13911. return size;
  13912. };
  13913. const getMarginStyle = (isLast) => {
  13914. const style = {};
  13915. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  13916. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  13917. if (isLast) {
  13918. return props.wrap ? {
  13919. marginBottom
  13920. } : {};
  13921. }
  13922. if (props.direction === "horizontal") {
  13923. style.marginRight = marginRight;
  13924. }
  13925. if (props.direction === "vertical" || props.wrap) {
  13926. style.marginBottom = marginBottom;
  13927. }
  13928. return style;
  13929. };
  13930. return () => {
  13931. var _a;
  13932. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  13933. return vue.createVNode("div", {
  13934. "class": [bem$9({
  13935. [props.direction]: props.direction,
  13936. [`align-${mergedAlign.value}`]: mergedAlign.value,
  13937. wrap: props.wrap,
  13938. fill: props.fill
  13939. })]
  13940. }, [children.map((c, i) => vue.createVNode("div", {
  13941. "key": `item-${i}`,
  13942. "class": `${name$9}-item`,
  13943. "style": getMarginStyle(i === children.length - 1)
  13944. }, [c]))]);
  13945. };
  13946. }
  13947. });
  13948. const Space = withInstall(stdin_default$e);
  13949. const [name$8, bem$8] = createNamespace("steps");
  13950. const stepsProps = {
  13951. active: makeNumericProp(0),
  13952. direction: makeStringProp("horizontal"),
  13953. activeIcon: makeStringProp("checked"),
  13954. iconPrefix: String,
  13955. finishIcon: String,
  13956. activeColor: String,
  13957. inactiveIcon: String,
  13958. inactiveColor: String
  13959. };
  13960. const STEPS_KEY = Symbol(name$8);
  13961. var stdin_default$d = vue.defineComponent({
  13962. name: name$8,
  13963. props: stepsProps,
  13964. emits: ["click-step"],
  13965. setup(props, {
  13966. emit,
  13967. slots
  13968. }) {
  13969. const {
  13970. linkChildren
  13971. } = useChildren(STEPS_KEY);
  13972. const onClickStep = (index) => emit("click-step", index);
  13973. linkChildren({
  13974. props,
  13975. onClickStep
  13976. });
  13977. return () => {
  13978. var _a;
  13979. return vue.createVNode("div", {
  13980. "class": bem$8([props.direction])
  13981. }, [vue.createVNode("div", {
  13982. "class": bem$8("items")
  13983. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  13984. };
  13985. }
  13986. });
  13987. const [name$7, bem$7] = createNamespace("step");
  13988. var stdin_default$c = vue.defineComponent({
  13989. name: name$7,
  13990. setup(props, {
  13991. slots
  13992. }) {
  13993. const {
  13994. parent,
  13995. index
  13996. } = useParent(STEPS_KEY);
  13997. if (!parent) {
  13998. return;
  13999. }
  14000. const parentProps = parent.props;
  14001. const getStatus = () => {
  14002. const active = +parentProps.active;
  14003. if (index.value < active) {
  14004. return "finish";
  14005. }
  14006. return index.value === active ? "process" : "waiting";
  14007. };
  14008. const isActive = () => getStatus() === "process";
  14009. const lineStyle = vue.computed(() => ({
  14010. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  14011. }));
  14012. const titleStyle = vue.computed(() => {
  14013. if (isActive()) {
  14014. return {
  14015. color: parentProps.activeColor
  14016. };
  14017. }
  14018. if (getStatus() === "waiting") {
  14019. return {
  14020. color: parentProps.inactiveColor
  14021. };
  14022. }
  14023. });
  14024. const onClickStep = () => parent.onClickStep(index.value);
  14025. const renderCircle = () => {
  14026. const {
  14027. iconPrefix,
  14028. finishIcon,
  14029. activeIcon,
  14030. activeColor,
  14031. inactiveIcon
  14032. } = parentProps;
  14033. if (isActive()) {
  14034. if (slots["active-icon"]) {
  14035. return slots["active-icon"]();
  14036. }
  14037. return vue.createVNode(Icon, {
  14038. "class": bem$7("icon", "active"),
  14039. "name": activeIcon,
  14040. "color": activeColor,
  14041. "classPrefix": iconPrefix
  14042. }, null);
  14043. }
  14044. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  14045. if (slots["finish-icon"]) {
  14046. return slots["finish-icon"]();
  14047. }
  14048. return vue.createVNode(Icon, {
  14049. "class": bem$7("icon", "finish"),
  14050. "name": finishIcon,
  14051. "color": activeColor,
  14052. "classPrefix": iconPrefix
  14053. }, null);
  14054. }
  14055. if (slots["inactive-icon"]) {
  14056. return slots["inactive-icon"]();
  14057. }
  14058. if (inactiveIcon) {
  14059. return vue.createVNode(Icon, {
  14060. "class": bem$7("icon"),
  14061. "name": inactiveIcon,
  14062. "classPrefix": iconPrefix
  14063. }, null);
  14064. }
  14065. return vue.createVNode("i", {
  14066. "class": bem$7("circle"),
  14067. "style": lineStyle.value
  14068. }, null);
  14069. };
  14070. return () => {
  14071. var _a;
  14072. const status = getStatus();
  14073. return vue.createVNode("div", {
  14074. "class": [BORDER, bem$7([parentProps.direction, {
  14075. [status]: status
  14076. }])]
  14077. }, [vue.createVNode("div", {
  14078. "class": bem$7("title", {
  14079. active: isActive()
  14080. }),
  14081. "style": titleStyle.value,
  14082. "onClick": onClickStep
  14083. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
  14084. "class": bem$7("circle-container"),
  14085. "onClick": onClickStep
  14086. }, [renderCircle()]), vue.createVNode("div", {
  14087. "class": bem$7("line"),
  14088. "style": lineStyle.value
  14089. }, null)]);
  14090. };
  14091. }
  14092. });
  14093. const Step = withInstall(stdin_default$c);
  14094. const [name$6, bem$6] = createNamespace("stepper");
  14095. const LONG_PRESS_INTERVAL = 200;
  14096. const LONG_PRESS_START_TIME = 600;
  14097. const isEqual = (value1, value2) => String(value1) === String(value2);
  14098. const stepperProps = {
  14099. min: makeNumericProp(1),
  14100. max: makeNumericProp(Infinity),
  14101. name: makeNumericProp(""),
  14102. step: makeNumericProp(1),
  14103. theme: String,
  14104. integer: Boolean,
  14105. disabled: Boolean,
  14106. showPlus: truthProp,
  14107. showMinus: truthProp,
  14108. showInput: truthProp,
  14109. longPress: truthProp,
  14110. allowEmpty: Boolean,
  14111. modelValue: numericProp,
  14112. inputWidth: numericProp,
  14113. buttonSize: numericProp,
  14114. placeholder: String,
  14115. disablePlus: Boolean,
  14116. disableMinus: Boolean,
  14117. disableInput: Boolean,
  14118. beforeChange: Function,
  14119. defaultValue: makeNumericProp(1),
  14120. decimalLength: numericProp
  14121. };
  14122. var stdin_default$b = vue.defineComponent({
  14123. name: name$6,
  14124. props: stepperProps,
  14125. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  14126. setup(props, {
  14127. emit
  14128. }) {
  14129. const format2 = (value) => {
  14130. const {
  14131. min,
  14132. max,
  14133. allowEmpty,
  14134. decimalLength
  14135. } = props;
  14136. if (allowEmpty && value === "") {
  14137. return value;
  14138. }
  14139. value = formatNumber(String(value), !props.integer);
  14140. value = value === "" ? 0 : +value;
  14141. value = Number.isNaN(value) ? +min : value;
  14142. value = Math.max(Math.min(+max, value), +min);
  14143. if (isDef(decimalLength)) {
  14144. value = value.toFixed(+decimalLength);
  14145. }
  14146. return value;
  14147. };
  14148. const getInitialValue = () => {
  14149. var _a;
  14150. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  14151. const value = format2(defaultValue);
  14152. if (!isEqual(value, props.modelValue)) {
  14153. emit("update:modelValue", value);
  14154. }
  14155. return value;
  14156. };
  14157. let actionType;
  14158. const inputRef = vue.ref();
  14159. const current2 = vue.ref(getInitialValue());
  14160. const minusDisabled = vue.computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  14161. const plusDisabled = vue.computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  14162. const inputStyle = vue.computed(() => ({
  14163. width: addUnit(props.inputWidth),
  14164. height: addUnit(props.buttonSize)
  14165. }));
  14166. const buttonStyle = vue.computed(() => getSizeStyle(props.buttonSize));
  14167. const check = () => {
  14168. const value = format2(current2.value);
  14169. if (!isEqual(value, current2.value)) {
  14170. current2.value = value;
  14171. }
  14172. };
  14173. const setValue = (value) => {
  14174. if (props.beforeChange) {
  14175. callInterceptor(props.beforeChange, {
  14176. args: [value],
  14177. done() {
  14178. current2.value = value;
  14179. }
  14180. });
  14181. } else {
  14182. current2.value = value;
  14183. }
  14184. };
  14185. const onChange = () => {
  14186. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  14187. emit("overlimit", actionType);
  14188. return;
  14189. }
  14190. const diff = actionType === "minus" ? -props.step : +props.step;
  14191. const value = format2(addNumber(+current2.value, diff));
  14192. setValue(value);
  14193. emit(actionType);
  14194. };
  14195. const onInput = (event) => {
  14196. const input = event.target;
  14197. const {
  14198. value
  14199. } = input;
  14200. const {
  14201. decimalLength
  14202. } = props;
  14203. let formatted = formatNumber(String(value), !props.integer);
  14204. if (isDef(decimalLength) && formatted.includes(".")) {
  14205. const pair = formatted.split(".");
  14206. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  14207. }
  14208. if (props.beforeChange) {
  14209. input.value = String(current2.value);
  14210. } else if (!isEqual(value, formatted)) {
  14211. input.value = formatted;
  14212. }
  14213. const isNumeric2 = formatted === String(+formatted);
  14214. setValue(isNumeric2 ? +formatted : formatted);
  14215. };
  14216. const onFocus = (event) => {
  14217. var _a;
  14218. if (props.disableInput) {
  14219. (_a = inputRef.value) == null ? void 0 : _a.blur();
  14220. } else {
  14221. emit("focus", event);
  14222. }
  14223. };
  14224. const onBlur = (event) => {
  14225. const input = event.target;
  14226. const value = format2(input.value);
  14227. input.value = String(value);
  14228. current2.value = value;
  14229. vue.nextTick(() => {
  14230. emit("blur", event);
  14231. resetScroll();
  14232. });
  14233. };
  14234. let isLongPress;
  14235. let longPressTimer;
  14236. const longPressStep = () => {
  14237. longPressTimer = setTimeout(() => {
  14238. onChange();
  14239. longPressStep();
  14240. }, LONG_PRESS_INTERVAL);
  14241. };
  14242. const onTouchStart = () => {
  14243. if (props.longPress) {
  14244. isLongPress = false;
  14245. clearTimeout(longPressTimer);
  14246. longPressTimer = setTimeout(() => {
  14247. isLongPress = true;
  14248. onChange();
  14249. longPressStep();
  14250. }, LONG_PRESS_START_TIME);
  14251. }
  14252. };
  14253. const onTouchEnd = (event) => {
  14254. if (props.longPress) {
  14255. clearTimeout(longPressTimer);
  14256. if (isLongPress) {
  14257. preventDefault(event);
  14258. }
  14259. }
  14260. };
  14261. const onMousedown = (event) => {
  14262. if (props.disableInput) {
  14263. preventDefault(event);
  14264. }
  14265. };
  14266. const createListeners = (type) => ({
  14267. onClick: (event) => {
  14268. preventDefault(event);
  14269. actionType = type;
  14270. onChange();
  14271. },
  14272. onTouchstartPassive: () => {
  14273. actionType = type;
  14274. onTouchStart();
  14275. },
  14276. onTouchend: onTouchEnd,
  14277. onTouchcancel: onTouchEnd
  14278. });
  14279. vue.watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  14280. vue.watch(() => props.modelValue, (value) => {
  14281. if (!isEqual(value, current2.value)) {
  14282. current2.value = format2(value);
  14283. }
  14284. });
  14285. vue.watch(current2, (value) => {
  14286. emit("update:modelValue", value);
  14287. emit("change", value, {
  14288. name: props.name
  14289. });
  14290. });
  14291. useCustomFieldValue(() => props.modelValue);
  14292. return () => vue.createVNode("div", {
  14293. "role": "group",
  14294. "class": bem$6([props.theme])
  14295. }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  14296. "type": "button",
  14297. "style": buttonStyle.value,
  14298. "class": [bem$6("minus", {
  14299. disabled: minusDisabled.value
  14300. }), {
  14301. [HAPTICS_FEEDBACK]: !minusDisabled.value
  14302. }],
  14303. "aria-disabled": minusDisabled.value || void 0
  14304. }, createListeners("minus")), null), [[vue.vShow, props.showMinus]]), vue.withDirectives(vue.createVNode("input", {
  14305. "ref": inputRef,
  14306. "type": props.integer ? "tel" : "text",
  14307. "role": "spinbutton",
  14308. "class": bem$6("input"),
  14309. "value": current2.value,
  14310. "style": inputStyle.value,
  14311. "disabled": props.disabled,
  14312. "readonly": props.disableInput,
  14313. "inputmode": props.integer ? "numeric" : "decimal",
  14314. "placeholder": props.placeholder,
  14315. "aria-valuemax": props.max,
  14316. "aria-valuemin": props.min,
  14317. "aria-valuenow": current2.value,
  14318. "onBlur": onBlur,
  14319. "onInput": onInput,
  14320. "onFocus": onFocus,
  14321. "onMousedown": onMousedown
  14322. }, null), [[vue.vShow, props.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  14323. "type": "button",
  14324. "style": buttonStyle.value,
  14325. "class": [bem$6("plus", {
  14326. disabled: plusDisabled.value
  14327. }), {
  14328. [HAPTICS_FEEDBACK]: !plusDisabled.value
  14329. }],
  14330. "aria-disabled": plusDisabled.value || void 0
  14331. }, createListeners("plus")), null), [[vue.vShow, props.showPlus]])]);
  14332. }
  14333. });
  14334. const Stepper = withInstall(stdin_default$b);
  14335. const Steps = withInstall(stdin_default$d);
  14336. const [name$5, bem$5, t$1] = createNamespace("submit-bar");
  14337. const submitBarProps = {
  14338. tip: String,
  14339. label: String,
  14340. price: Number,
  14341. tipIcon: String,
  14342. loading: Boolean,
  14343. currency: makeStringProp("\xA5"),
  14344. disabled: Boolean,
  14345. textAlign: String,
  14346. buttonText: String,
  14347. buttonType: makeStringProp("danger"),
  14348. buttonColor: String,
  14349. suffixLabel: String,
  14350. placeholder: Boolean,
  14351. decimalLength: makeNumericProp(2),
  14352. safeAreaInsetBottom: truthProp
  14353. };
  14354. var stdin_default$a = vue.defineComponent({
  14355. name: name$5,
  14356. props: submitBarProps,
  14357. emits: ["submit"],
  14358. setup(props, {
  14359. emit,
  14360. slots
  14361. }) {
  14362. const root = vue.ref();
  14363. const renderPlaceholder = usePlaceholder(root, bem$5);
  14364. const renderText = () => {
  14365. const {
  14366. price,
  14367. label,
  14368. currency,
  14369. textAlign,
  14370. suffixLabel,
  14371. decimalLength
  14372. } = props;
  14373. if (typeof price === "number") {
  14374. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  14375. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  14376. return vue.createVNode("div", {
  14377. "class": bem$5("text"),
  14378. "style": {
  14379. textAlign
  14380. }
  14381. }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
  14382. "class": bem$5("price")
  14383. }, [currency, vue.createVNode("span", {
  14384. "class": bem$5("price-integer")
  14385. }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
  14386. "class": bem$5("suffix-label")
  14387. }, [suffixLabel])]);
  14388. }
  14389. };
  14390. const renderTip = () => {
  14391. var _a;
  14392. const {
  14393. tip,
  14394. tipIcon
  14395. } = props;
  14396. if (slots.tip || tip) {
  14397. return vue.createVNode("div", {
  14398. "class": bem$5("tip")
  14399. }, [tipIcon && vue.createVNode(Icon, {
  14400. "class": bem$5("tip-icon"),
  14401. "name": tipIcon
  14402. }, null), tip && vue.createVNode("span", {
  14403. "class": bem$5("tip-text")
  14404. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  14405. }
  14406. };
  14407. const onClickButton = () => emit("submit");
  14408. const renderButton = () => {
  14409. if (slots.button) {
  14410. return slots.button();
  14411. }
  14412. return vue.createVNode(Button, {
  14413. "round": true,
  14414. "type": props.buttonType,
  14415. "text": props.buttonText,
  14416. "class": bem$5("button", props.buttonType),
  14417. "color": props.buttonColor,
  14418. "loading": props.loading,
  14419. "disabled": props.disabled,
  14420. "onClick": onClickButton
  14421. }, null);
  14422. };
  14423. const renderSubmitBar = () => {
  14424. var _a, _b;
  14425. return vue.createVNode("div", {
  14426. "ref": root,
  14427. "class": [bem$5(), {
  14428. "van-safe-area-bottom": props.safeAreaInsetBottom
  14429. }]
  14430. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
  14431. "class": bem$5("bar")
  14432. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  14433. };
  14434. return () => {
  14435. if (props.placeholder) {
  14436. return renderPlaceholder(renderSubmitBar);
  14437. }
  14438. return renderSubmitBar();
  14439. };
  14440. }
  14441. });
  14442. const SubmitBar = withInstall(stdin_default$a);
  14443. const [name$4, bem$4] = createNamespace("swipe-cell");
  14444. const swipeCellProps = {
  14445. name: makeNumericProp(""),
  14446. disabled: Boolean,
  14447. leftWidth: numericProp,
  14448. rightWidth: numericProp,
  14449. beforeClose: Function,
  14450. stopPropagation: Boolean
  14451. };
  14452. var stdin_default$9 = vue.defineComponent({
  14453. name: name$4,
  14454. props: swipeCellProps,
  14455. emits: ["open", "close", "click"],
  14456. setup(props, {
  14457. emit,
  14458. slots
  14459. }) {
  14460. let opened;
  14461. let lockClick2;
  14462. let startOffset;
  14463. const root = vue.ref();
  14464. const leftRef = vue.ref();
  14465. const rightRef = vue.ref();
  14466. const state = vue.reactive({
  14467. offset: 0,
  14468. dragging: false
  14469. });
  14470. const touch = useTouch();
  14471. const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
  14472. const leftWidth = vue.computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  14473. const rightWidth = vue.computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  14474. const open = (side) => {
  14475. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  14476. if (!opened) {
  14477. opened = true;
  14478. emit("open", {
  14479. name: props.name,
  14480. position: side
  14481. });
  14482. }
  14483. };
  14484. const close = (position) => {
  14485. state.offset = 0;
  14486. if (opened) {
  14487. opened = false;
  14488. emit("close", {
  14489. name: props.name,
  14490. position
  14491. });
  14492. }
  14493. };
  14494. const toggle = (side) => {
  14495. const offset2 = Math.abs(state.offset);
  14496. const THRESHOLD = 0.15;
  14497. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  14498. const width2 = side === "left" ? leftWidth.value : rightWidth.value;
  14499. if (width2 && offset2 > width2 * threshold) {
  14500. open(side);
  14501. } else {
  14502. close(side);
  14503. }
  14504. };
  14505. const onTouchStart = (event) => {
  14506. if (!props.disabled) {
  14507. startOffset = state.offset;
  14508. touch.start(event);
  14509. }
  14510. };
  14511. const onTouchMove = (event) => {
  14512. if (props.disabled) {
  14513. return;
  14514. }
  14515. const {
  14516. deltaX
  14517. } = touch;
  14518. touch.move(event);
  14519. if (touch.isHorizontal()) {
  14520. lockClick2 = true;
  14521. state.dragging = true;
  14522. const isEdge = !opened || deltaX.value * startOffset < 0;
  14523. if (isEdge) {
  14524. preventDefault(event, props.stopPropagation);
  14525. }
  14526. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  14527. }
  14528. };
  14529. const onTouchEnd = () => {
  14530. if (state.dragging) {
  14531. state.dragging = false;
  14532. toggle(state.offset > 0 ? "left" : "right");
  14533. setTimeout(() => {
  14534. lockClick2 = false;
  14535. }, 0);
  14536. }
  14537. };
  14538. const onClick = (position = "outside") => {
  14539. emit("click", position);
  14540. if (opened && !lockClick2) {
  14541. callInterceptor(props.beforeClose, {
  14542. args: [{
  14543. name: props.name,
  14544. position
  14545. }],
  14546. done: () => close(position)
  14547. });
  14548. }
  14549. };
  14550. const getClickHandler = (position, stop) => (event) => {
  14551. if (stop) {
  14552. event.stopPropagation();
  14553. }
  14554. onClick(position);
  14555. };
  14556. const renderSideContent = (side, ref2) => {
  14557. const contentSlot = slots[side];
  14558. if (contentSlot) {
  14559. return vue.createVNode("div", {
  14560. "ref": ref2,
  14561. "class": bem$4(side),
  14562. "onClick": getClickHandler(side, true)
  14563. }, [contentSlot()]);
  14564. }
  14565. };
  14566. useExpose({
  14567. open,
  14568. close
  14569. });
  14570. useClickAway(root, () => onClick("outside"), {
  14571. eventName: "touchstart"
  14572. });
  14573. useEventListener("touchmove", onTouchMove, {
  14574. target: root
  14575. });
  14576. return () => {
  14577. var _a;
  14578. const wrapperStyle = {
  14579. transform: `translate3d(${state.offset}px, 0, 0)`,
  14580. transitionDuration: state.dragging ? "0s" : ".6s"
  14581. };
  14582. return vue.createVNode("div", {
  14583. "ref": root,
  14584. "class": bem$4(),
  14585. "onClick": getClickHandler("cell", lockClick2),
  14586. "onTouchstartPassive": onTouchStart,
  14587. "onTouchend": onTouchEnd,
  14588. "onTouchcancel": onTouchEnd
  14589. }, [vue.createVNode("div", {
  14590. "class": bem$4("wrapper"),
  14591. "style": wrapperStyle
  14592. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  14593. };
  14594. }
  14595. });
  14596. const SwipeCell = withInstall(stdin_default$9);
  14597. const [name$3, bem$3] = createNamespace("tabbar");
  14598. const tabbarProps = {
  14599. route: Boolean,
  14600. fixed: truthProp,
  14601. border: truthProp,
  14602. zIndex: numericProp,
  14603. placeholder: Boolean,
  14604. activeColor: String,
  14605. beforeChange: Function,
  14606. inactiveColor: String,
  14607. modelValue: makeNumericProp(0),
  14608. safeAreaInsetBottom: {
  14609. type: Boolean,
  14610. default: null
  14611. }
  14612. };
  14613. const TABBAR_KEY = Symbol(name$3);
  14614. var stdin_default$8 = vue.defineComponent({
  14615. name: name$3,
  14616. props: tabbarProps,
  14617. emits: ["change", "update:modelValue"],
  14618. setup(props, {
  14619. emit,
  14620. slots
  14621. }) {
  14622. const root = vue.ref();
  14623. const {
  14624. linkChildren
  14625. } = useChildren(TABBAR_KEY);
  14626. const renderPlaceholder = usePlaceholder(root, bem$3);
  14627. const enableSafeArea = () => {
  14628. var _a;
  14629. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  14630. };
  14631. const renderTabbar = () => {
  14632. var _a;
  14633. const {
  14634. fixed,
  14635. zIndex,
  14636. border
  14637. } = props;
  14638. return vue.createVNode("div", {
  14639. "ref": root,
  14640. "role": "tablist",
  14641. "style": getZIndexStyle(zIndex),
  14642. "class": [bem$3({
  14643. fixed
  14644. }), {
  14645. [BORDER_TOP_BOTTOM]: border,
  14646. "van-safe-area-bottom": enableSafeArea()
  14647. }]
  14648. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  14649. };
  14650. const setActive = (active, afterChange) => {
  14651. callInterceptor(props.beforeChange, {
  14652. args: [active],
  14653. done() {
  14654. emit("update:modelValue", active);
  14655. emit("change", active);
  14656. afterChange();
  14657. }
  14658. });
  14659. };
  14660. linkChildren({
  14661. props,
  14662. setActive
  14663. });
  14664. return () => {
  14665. if (props.fixed && props.placeholder) {
  14666. return renderPlaceholder(renderTabbar);
  14667. }
  14668. return renderTabbar();
  14669. };
  14670. }
  14671. });
  14672. const Tabbar = withInstall(stdin_default$8);
  14673. const [name$2, bem$2] = createNamespace("tabbar-item");
  14674. const tabbarItemProps = extend({}, routeProps, {
  14675. dot: Boolean,
  14676. icon: String,
  14677. name: numericProp,
  14678. badge: numericProp,
  14679. badgeProps: Object,
  14680. iconPrefix: String
  14681. });
  14682. var stdin_default$7 = vue.defineComponent({
  14683. name: name$2,
  14684. props: tabbarItemProps,
  14685. emits: ["click"],
  14686. setup(props, {
  14687. emit,
  14688. slots
  14689. }) {
  14690. const route2 = useRoute();
  14691. const vm = vue.getCurrentInstance().proxy;
  14692. const {
  14693. parent,
  14694. index
  14695. } = useParent(TABBAR_KEY);
  14696. if (!parent) {
  14697. return;
  14698. }
  14699. const active = vue.computed(() => {
  14700. var _a;
  14701. const {
  14702. route: route22,
  14703. modelValue
  14704. } = parent.props;
  14705. if (route22 && "$route" in vm) {
  14706. const {
  14707. $route
  14708. } = vm;
  14709. const {
  14710. to
  14711. } = props;
  14712. const config = isObject(to) ? to : {
  14713. path: to
  14714. };
  14715. return !!$route.matched.find((val) => {
  14716. const pathMatched = "path" in config && config.path === val.path;
  14717. const nameMatched = "name" in config && config.name === val.name;
  14718. return pathMatched || nameMatched;
  14719. });
  14720. }
  14721. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  14722. });
  14723. const onClick = (event) => {
  14724. var _a;
  14725. if (!active.value) {
  14726. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  14727. }
  14728. emit("click", event);
  14729. };
  14730. const renderIcon = () => {
  14731. if (slots.icon) {
  14732. return slots.icon({
  14733. active: active.value
  14734. });
  14735. }
  14736. if (props.icon) {
  14737. return vue.createVNode(Icon, {
  14738. "name": props.icon,
  14739. "classPrefix": props.iconPrefix
  14740. }, null);
  14741. }
  14742. };
  14743. return () => {
  14744. var _a;
  14745. const {
  14746. dot,
  14747. badge
  14748. } = props;
  14749. const {
  14750. activeColor,
  14751. inactiveColor
  14752. } = parent.props;
  14753. const color = active.value ? activeColor : inactiveColor;
  14754. return vue.createVNode("div", {
  14755. "role": "tab",
  14756. "class": bem$2({
  14757. active: active.value
  14758. }),
  14759. "style": {
  14760. color
  14761. },
  14762. "tabindex": 0,
  14763. "aria-selected": active.value,
  14764. "onClick": onClick
  14765. }, [vue.createVNode(Badge, vue.mergeProps({
  14766. "dot": dot,
  14767. "class": bem$2("icon"),
  14768. "content": badge
  14769. }, props.badgeProps), {
  14770. default: renderIcon
  14771. }), vue.createVNode("div", {
  14772. "class": bem$2("text")
  14773. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  14774. active: active.value
  14775. })])]);
  14776. };
  14777. }
  14778. });
  14779. const TabbarItem = withInstall(stdin_default$7);
  14780. const [name$1, bem$1] = createNamespace("tree-select");
  14781. const treeSelectProps = {
  14782. max: makeNumericProp(Infinity),
  14783. items: makeArrayProp(),
  14784. height: makeNumericProp(300),
  14785. selectedIcon: makeStringProp("success"),
  14786. mainActiveIndex: makeNumericProp(0),
  14787. activeId: {
  14788. type: [Number, String, Array],
  14789. default: 0
  14790. }
  14791. };
  14792. var stdin_default$6 = vue.defineComponent({
  14793. name: name$1,
  14794. props: treeSelectProps,
  14795. emits: ["click-nav", "click-item", "update:activeId", "update:mainActiveIndex"],
  14796. setup(props, {
  14797. emit,
  14798. slots
  14799. }) {
  14800. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  14801. const renderSubItem = (item) => {
  14802. const onClick = () => {
  14803. if (item.disabled) {
  14804. return;
  14805. }
  14806. let activeId;
  14807. if (Array.isArray(props.activeId)) {
  14808. activeId = props.activeId.slice();
  14809. const index = activeId.indexOf(item.id);
  14810. if (index !== -1) {
  14811. activeId.splice(index, 1);
  14812. } else if (activeId.length < props.max) {
  14813. activeId.push(item.id);
  14814. }
  14815. } else {
  14816. activeId = item.id;
  14817. }
  14818. emit("update:activeId", activeId);
  14819. emit("click-item", item);
  14820. };
  14821. return vue.createVNode("div", {
  14822. "key": item.id,
  14823. "class": ["van-ellipsis", bem$1("item", {
  14824. active: isActiveItem(item.id),
  14825. disabled: item.disabled
  14826. })],
  14827. "onClick": onClick
  14828. }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
  14829. "name": props.selectedIcon,
  14830. "class": bem$1("selected")
  14831. }, null)]);
  14832. };
  14833. const onSidebarChange = (index) => {
  14834. emit("update:mainActiveIndex", index);
  14835. };
  14836. const onClickSidebarItem = (index) => emit("click-nav", index);
  14837. const renderSidebar = () => {
  14838. const Items = props.items.map((item) => vue.createVNode(SidebarItem, {
  14839. "dot": item.dot,
  14840. "title": item.text,
  14841. "badge": item.badge,
  14842. "class": [bem$1("nav-item"), item.className],
  14843. "disabled": item.disabled,
  14844. "onClick": onClickSidebarItem
  14845. }, null));
  14846. return vue.createVNode(Sidebar, {
  14847. "class": bem$1("nav"),
  14848. "modelValue": props.mainActiveIndex,
  14849. "onChange": onSidebarChange
  14850. }, {
  14851. default: () => [Items]
  14852. });
  14853. };
  14854. const renderContent = () => {
  14855. if (slots.content) {
  14856. return slots.content();
  14857. }
  14858. const selected = props.items[+props.mainActiveIndex] || {};
  14859. if (selected.children) {
  14860. return selected.children.map(renderSubItem);
  14861. }
  14862. };
  14863. return () => vue.createVNode("div", {
  14864. "class": bem$1(),
  14865. "style": {
  14866. height: addUnit(props.height)
  14867. }
  14868. }, [renderSidebar(), vue.createVNode("div", {
  14869. "class": bem$1("content")
  14870. }, [renderContent()])]);
  14871. }
  14872. });
  14873. const TreeSelect = withInstall(stdin_default$6);
  14874. const [name, bem, t] = createNamespace("uploader");
  14875. function readFileContent(file, resultType) {
  14876. return new Promise((resolve) => {
  14877. if (resultType === "file") {
  14878. resolve();
  14879. return;
  14880. }
  14881. const reader = new FileReader();
  14882. reader.onload = (event) => {
  14883. resolve(event.target.result);
  14884. };
  14885. if (resultType === "dataUrl") {
  14886. reader.readAsDataURL(file);
  14887. } else if (resultType === "text") {
  14888. reader.readAsText(file);
  14889. }
  14890. });
  14891. }
  14892. function isOversize(items, maxSize) {
  14893. return toArray(items).some((item) => {
  14894. if (item.file) {
  14895. if (isFunction(maxSize)) {
  14896. return maxSize(item.file);
  14897. }
  14898. return item.file.size > maxSize;
  14899. }
  14900. return false;
  14901. });
  14902. }
  14903. function filterFiles(items, maxSize) {
  14904. const valid = [];
  14905. const invalid = [];
  14906. items.forEach((item) => {
  14907. if (isOversize(item, maxSize)) {
  14908. invalid.push(item);
  14909. } else {
  14910. valid.push(item);
  14911. }
  14912. });
  14913. return { valid, invalid };
  14914. }
  14915. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  14916. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  14917. function isImageFile(item) {
  14918. if (item.isImage) {
  14919. return true;
  14920. }
  14921. if (item.file && item.file.type) {
  14922. return item.file.type.indexOf("image") === 0;
  14923. }
  14924. if (item.url) {
  14925. return isImageUrl(item.url);
  14926. }
  14927. if (typeof item.content === "string") {
  14928. return item.content.indexOf("data:image") === 0;
  14929. }
  14930. return false;
  14931. }
  14932. var stdin_default$5 = vue.defineComponent({
  14933. props: {
  14934. name: numericProp,
  14935. item: makeRequiredProp(Object),
  14936. index: Number,
  14937. imageFit: String,
  14938. lazyLoad: Boolean,
  14939. deletable: Boolean,
  14940. previewSize: [Number, String, Array],
  14941. beforeDelete: Function
  14942. },
  14943. emits: ["delete", "preview"],
  14944. setup(props, {
  14945. emit,
  14946. slots
  14947. }) {
  14948. const renderMask = () => {
  14949. const {
  14950. status,
  14951. message
  14952. } = props.item;
  14953. if (status === "uploading" || status === "failed") {
  14954. const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
  14955. "name": "close",
  14956. "class": bem("mask-icon")
  14957. }, null) : vue.createVNode(Loading, {
  14958. "class": bem("loading")
  14959. }, null);
  14960. const showMessage = isDef(message) && message !== "";
  14961. return vue.createVNode("div", {
  14962. "class": bem("mask")
  14963. }, [MaskIcon, showMessage && vue.createVNode("div", {
  14964. "class": bem("mask-message")
  14965. }, [message])]);
  14966. }
  14967. };
  14968. const onDelete = (event) => {
  14969. const {
  14970. name: name2,
  14971. item,
  14972. index,
  14973. beforeDelete
  14974. } = props;
  14975. event.stopPropagation();
  14976. callInterceptor(beforeDelete, {
  14977. args: [item, {
  14978. name: name2,
  14979. index
  14980. }],
  14981. done: () => emit("delete")
  14982. });
  14983. };
  14984. const onPreview = () => emit("preview");
  14985. const renderDeleteIcon = () => {
  14986. if (props.deletable && props.item.status !== "uploading") {
  14987. const slot = slots["preview-delete"];
  14988. return vue.createVNode("div", {
  14989. "role": "button",
  14990. "class": bem("preview-delete", {
  14991. shadow: !slot
  14992. }),
  14993. "tabindex": 0,
  14994. "aria-label": t("delete"),
  14995. "onClick": onDelete
  14996. }, [slot ? slot() : vue.createVNode(Icon, {
  14997. "name": "cross",
  14998. "class": bem("preview-delete-icon")
  14999. }, null)]);
  15000. }
  15001. };
  15002. const renderCover = () => {
  15003. if (slots["preview-cover"]) {
  15004. const {
  15005. index,
  15006. item
  15007. } = props;
  15008. return vue.createVNode("div", {
  15009. "class": bem("preview-cover")
  15010. }, [slots["preview-cover"](extend({
  15011. index
  15012. }, item))]);
  15013. }
  15014. };
  15015. const renderPreview = () => {
  15016. const {
  15017. item,
  15018. lazyLoad,
  15019. imageFit,
  15020. previewSize
  15021. } = props;
  15022. if (isImageFile(item)) {
  15023. return vue.createVNode(Image$1, {
  15024. "fit": imageFit,
  15025. "src": item.content || item.url,
  15026. "class": bem("preview-image"),
  15027. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  15028. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  15029. "lazyLoad": lazyLoad,
  15030. "onClick": onPreview
  15031. }, {
  15032. default: renderCover
  15033. });
  15034. }
  15035. return vue.createVNode("div", {
  15036. "class": bem("file"),
  15037. "style": getSizeStyle(props.previewSize)
  15038. }, [vue.createVNode(Icon, {
  15039. "class": bem("file-icon"),
  15040. "name": "description"
  15041. }, null), vue.createVNode("div", {
  15042. "class": [bem("file-name"), "van-ellipsis"]
  15043. }, [item.file ? item.file.name : item.url]), renderCover()]);
  15044. };
  15045. return () => vue.createVNode("div", {
  15046. "class": bem("preview")
  15047. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  15048. }
  15049. });
  15050. const uploaderProps = {
  15051. name: makeNumericProp(""),
  15052. accept: makeStringProp("image/*"),
  15053. capture: String,
  15054. multiple: Boolean,
  15055. disabled: Boolean,
  15056. readonly: Boolean,
  15057. lazyLoad: Boolean,
  15058. maxCount: makeNumericProp(Infinity),
  15059. imageFit: makeStringProp("cover"),
  15060. resultType: makeStringProp("dataUrl"),
  15061. uploadIcon: makeStringProp("photograph"),
  15062. uploadText: String,
  15063. deletable: truthProp,
  15064. afterRead: Function,
  15065. showUpload: truthProp,
  15066. modelValue: makeArrayProp(),
  15067. beforeRead: Function,
  15068. beforeDelete: Function,
  15069. previewSize: [Number, String, Array],
  15070. previewImage: truthProp,
  15071. previewOptions: Object,
  15072. previewFullImage: truthProp,
  15073. maxSize: {
  15074. type: [Number, String, Function],
  15075. default: Infinity
  15076. }
  15077. };
  15078. var stdin_default$4 = vue.defineComponent({
  15079. name,
  15080. props: uploaderProps,
  15081. emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
  15082. setup(props, {
  15083. emit,
  15084. slots
  15085. }) {
  15086. const inputRef = vue.ref();
  15087. const urls = [];
  15088. const getDetail = (index = props.modelValue.length) => ({
  15089. name: props.name,
  15090. index
  15091. });
  15092. const resetInput = () => {
  15093. if (inputRef.value) {
  15094. inputRef.value.value = "";
  15095. }
  15096. };
  15097. const onAfterRead = (items) => {
  15098. resetInput();
  15099. if (isOversize(items, props.maxSize)) {
  15100. if (Array.isArray(items)) {
  15101. const result = filterFiles(items, props.maxSize);
  15102. items = result.valid;
  15103. emit("oversize", result.invalid, getDetail());
  15104. if (!items.length) {
  15105. return;
  15106. }
  15107. } else {
  15108. emit("oversize", items, getDetail());
  15109. return;
  15110. }
  15111. }
  15112. items = vue.reactive(items);
  15113. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  15114. if (props.afterRead) {
  15115. props.afterRead(items, getDetail());
  15116. }
  15117. };
  15118. const readFile = (files) => {
  15119. const {
  15120. maxCount,
  15121. modelValue,
  15122. resultType
  15123. } = props;
  15124. if (Array.isArray(files)) {
  15125. const remainCount = +maxCount - modelValue.length;
  15126. if (files.length > remainCount) {
  15127. files = files.slice(0, remainCount);
  15128. }
  15129. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  15130. const fileList = files.map((file, index) => {
  15131. const result = {
  15132. file,
  15133. status: "",
  15134. message: ""
  15135. };
  15136. if (contents[index]) {
  15137. result.content = contents[index];
  15138. }
  15139. return result;
  15140. });
  15141. onAfterRead(fileList);
  15142. });
  15143. } else {
  15144. readFileContent(files, resultType).then((content) => {
  15145. const result = {
  15146. file: files,
  15147. status: "",
  15148. message: ""
  15149. };
  15150. if (content) {
  15151. result.content = content;
  15152. }
  15153. onAfterRead(result);
  15154. });
  15155. }
  15156. };
  15157. const onChange = (event) => {
  15158. const {
  15159. files
  15160. } = event.target;
  15161. if (props.disabled || !files || !files.length) {
  15162. return;
  15163. }
  15164. const file = files.length === 1 ? files[0] : [].slice.call(files);
  15165. if (props.beforeRead) {
  15166. const response = props.beforeRead(file, getDetail());
  15167. if (!response) {
  15168. resetInput();
  15169. return;
  15170. }
  15171. if (isPromise(response)) {
  15172. response.then((data) => {
  15173. if (data) {
  15174. readFile(data);
  15175. } else {
  15176. readFile(file);
  15177. }
  15178. }).catch(resetInput);
  15179. return;
  15180. }
  15181. }
  15182. readFile(file);
  15183. };
  15184. let imagePreview;
  15185. const onClosePreview = () => emit("close-preview");
  15186. const previewImage = (item) => {
  15187. if (props.previewFullImage) {
  15188. const imageFiles = props.modelValue.filter(isImageFile);
  15189. const images = imageFiles.map((item2) => {
  15190. if (item2.file && !item2.url && item2.status !== "failed") {
  15191. item2.url = URL.createObjectURL(item2.file);
  15192. urls.push(item2.url);
  15193. }
  15194. return item2.url;
  15195. }).filter(Boolean);
  15196. imagePreview = ImagePreview(extend({
  15197. images,
  15198. startPosition: imageFiles.indexOf(item),
  15199. onClose: onClosePreview
  15200. }, props.previewOptions));
  15201. }
  15202. };
  15203. const closeImagePreview = () => {
  15204. if (imagePreview) {
  15205. imagePreview.close();
  15206. }
  15207. };
  15208. const deleteFile = (item, index) => {
  15209. const fileList = props.modelValue.slice(0);
  15210. fileList.splice(index, 1);
  15211. emit("update:modelValue", fileList);
  15212. emit("delete", item, getDetail(index));
  15213. };
  15214. const renderPreviewItem = (item, index) => {
  15215. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  15216. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  15217. return vue.createVNode(stdin_default$5, vue.mergeProps({
  15218. "item": item,
  15219. "index": index,
  15220. "onClick": () => emit("click-preview", item, getDetail(index)),
  15221. "onDelete": () => deleteFile(item, index),
  15222. "onPreview": () => previewImage(item)
  15223. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  15224. };
  15225. const renderPreviewList = () => {
  15226. if (props.previewImage) {
  15227. return props.modelValue.map(renderPreviewItem);
  15228. }
  15229. };
  15230. const onClickUpload = (event) => emit("click-upload", event);
  15231. const renderUpload = () => {
  15232. if (props.modelValue.length >= props.maxCount || !props.showUpload) {
  15233. return;
  15234. }
  15235. const Input = props.readonly ? null : vue.createVNode("input", {
  15236. "ref": inputRef,
  15237. "type": "file",
  15238. "class": bem("input"),
  15239. "accept": props.accept,
  15240. "capture": props.capture,
  15241. "multiple": props.multiple,
  15242. "disabled": props.disabled,
  15243. "onChange": onChange
  15244. }, null);
  15245. if (slots.default) {
  15246. return vue.createVNode("div", {
  15247. "class": bem("input-wrapper"),
  15248. "onClick": onClickUpload
  15249. }, [slots.default(), Input]);
  15250. }
  15251. return vue.createVNode("div", {
  15252. "class": bem("upload", {
  15253. readonly: props.readonly
  15254. }),
  15255. "style": getSizeStyle(props.previewSize),
  15256. "onClick": onClickUpload
  15257. }, [vue.createVNode(Icon, {
  15258. "name": props.uploadIcon,
  15259. "class": bem("upload-icon")
  15260. }, null), props.uploadText && vue.createVNode("span", {
  15261. "class": bem("upload-text")
  15262. }, [props.uploadText]), Input]);
  15263. };
  15264. const chooseFile = () => {
  15265. if (inputRef.value && !props.disabled) {
  15266. inputRef.value.click();
  15267. }
  15268. };
  15269. vue.onBeforeUnmount(() => {
  15270. urls.forEach((url) => URL.revokeObjectURL(url));
  15271. });
  15272. useExpose({
  15273. chooseFile,
  15274. closeImagePreview
  15275. });
  15276. useCustomFieldValue(() => props.modelValue);
  15277. return () => vue.createVNode("div", {
  15278. "class": bem()
  15279. }, [vue.createVNode("div", {
  15280. "class": bem("wrapper", {
  15281. disabled: props.disabled
  15282. })
  15283. }, [renderPreviewList(), renderUpload()])]);
  15284. }
  15285. });
  15286. const Uploader = withInstall(stdin_default$4);
  15287. const hasIntersectionObserver = inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  15288. const modeType = {
  15289. event: "event",
  15290. observer: "observer"
  15291. };
  15292. function remove(arr, item) {
  15293. if (!arr.length)
  15294. return;
  15295. const index = arr.indexOf(item);
  15296. if (index > -1)
  15297. return arr.splice(index, 1);
  15298. }
  15299. function getBestSelectionFromSrcset(el, scale) {
  15300. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  15301. return;
  15302. let options = el.getAttribute("data-srcset");
  15303. const container = el.parentNode;
  15304. const containerWidth = container.offsetWidth * scale;
  15305. let spaceIndex;
  15306. let tmpSrc;
  15307. let tmpWidth;
  15308. options = options.trim().split(",");
  15309. const result = options.map((item) => {
  15310. item = item.trim();
  15311. spaceIndex = item.lastIndexOf(" ");
  15312. if (spaceIndex === -1) {
  15313. tmpSrc = item;
  15314. tmpWidth = 999998;
  15315. } else {
  15316. tmpSrc = item.substr(0, spaceIndex);
  15317. tmpWidth = parseInt(
  15318. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  15319. 10
  15320. );
  15321. }
  15322. return [tmpWidth, tmpSrc];
  15323. });
  15324. result.sort((a, b) => {
  15325. if (a[0] < b[0]) {
  15326. return 1;
  15327. }
  15328. if (a[0] > b[0]) {
  15329. return -1;
  15330. }
  15331. if (a[0] === b[0]) {
  15332. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  15333. return 1;
  15334. }
  15335. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  15336. return -1;
  15337. }
  15338. }
  15339. return 0;
  15340. });
  15341. let bestSelectedSrc = "";
  15342. let tmpOption;
  15343. for (let i = 0; i < result.length; i++) {
  15344. tmpOption = result[i];
  15345. bestSelectedSrc = tmpOption[1];
  15346. const next = result[i + 1];
  15347. if (next && next[0] < containerWidth) {
  15348. bestSelectedSrc = tmpOption[1];
  15349. break;
  15350. } else if (!next) {
  15351. bestSelectedSrc = tmpOption[1];
  15352. break;
  15353. }
  15354. }
  15355. return bestSelectedSrc;
  15356. }
  15357. const getDPR = (scale = 1) => inBrowser ? window.devicePixelRatio || scale : scale;
  15358. function supportWebp() {
  15359. if (!inBrowser)
  15360. return false;
  15361. let support = true;
  15362. try {
  15363. const elem = document.createElement("canvas");
  15364. if (elem.getContext && elem.getContext("2d")) {
  15365. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  15366. }
  15367. } catch (err) {
  15368. support = false;
  15369. }
  15370. return support;
  15371. }
  15372. function throttle(action, delay) {
  15373. let timeout = null;
  15374. let lastRun = 0;
  15375. return function(...args) {
  15376. if (timeout) {
  15377. return;
  15378. }
  15379. const elapsed = Date.now() - lastRun;
  15380. const runCallback = () => {
  15381. lastRun = Date.now();
  15382. timeout = false;
  15383. action.apply(this, args);
  15384. };
  15385. if (elapsed >= delay) {
  15386. runCallback();
  15387. } else {
  15388. timeout = setTimeout(runCallback, delay);
  15389. }
  15390. };
  15391. }
  15392. function on(el, type, func) {
  15393. el.addEventListener(type, func, {
  15394. capture: false,
  15395. passive: true
  15396. });
  15397. }
  15398. function off(el, type, func) {
  15399. el.removeEventListener(type, func, false);
  15400. }
  15401. const loadImageAsync = (item, resolve, reject) => {
  15402. const image = new Image();
  15403. if (!item || !item.src) {
  15404. return reject(new Error("image src is required"));
  15405. }
  15406. image.src = item.src;
  15407. if (item.cors) {
  15408. image.crossOrigin = item.cors;
  15409. }
  15410. image.onload = () => resolve({
  15411. naturalHeight: image.naturalHeight,
  15412. naturalWidth: image.naturalWidth,
  15413. src: image.src
  15414. });
  15415. image.onerror = (e) => reject(e);
  15416. };
  15417. class ImageCache {
  15418. constructor({ max }) {
  15419. this.options = {
  15420. max: max || 100
  15421. };
  15422. this.caches = [];
  15423. }
  15424. has(key) {
  15425. return this.caches.indexOf(key) > -1;
  15426. }
  15427. add(key) {
  15428. if (this.has(key))
  15429. return;
  15430. this.caches.push(key);
  15431. if (this.caches.length > this.options.max) {
  15432. this.free();
  15433. }
  15434. }
  15435. free() {
  15436. this.caches.shift();
  15437. }
  15438. }
  15439. class ReactiveListener {
  15440. constructor({
  15441. el,
  15442. src,
  15443. error,
  15444. loading,
  15445. bindType,
  15446. $parent,
  15447. options,
  15448. cors,
  15449. elRenderer,
  15450. imageCache
  15451. }) {
  15452. this.el = el;
  15453. this.src = src;
  15454. this.error = error;
  15455. this.loading = loading;
  15456. this.bindType = bindType;
  15457. this.attempt = 0;
  15458. this.cors = cors;
  15459. this.naturalHeight = 0;
  15460. this.naturalWidth = 0;
  15461. this.options = options;
  15462. this.$parent = $parent;
  15463. this.elRenderer = elRenderer;
  15464. this.imageCache = imageCache;
  15465. this.performanceData = {
  15466. loadStart: 0,
  15467. loadEnd: 0
  15468. };
  15469. this.filter();
  15470. this.initState();
  15471. this.render("loading", false);
  15472. }
  15473. initState() {
  15474. if ("dataset" in this.el) {
  15475. this.el.dataset.src = this.src;
  15476. } else {
  15477. this.el.setAttribute("data-src", this.src);
  15478. }
  15479. this.state = {
  15480. loading: false,
  15481. error: false,
  15482. loaded: false,
  15483. rendered: false
  15484. };
  15485. }
  15486. record(event) {
  15487. this.performanceData[event] = Date.now();
  15488. }
  15489. update({ src, loading, error }) {
  15490. const oldSrc = this.src;
  15491. this.src = src;
  15492. this.loading = loading;
  15493. this.error = error;
  15494. this.filter();
  15495. if (oldSrc !== this.src) {
  15496. this.attempt = 0;
  15497. this.initState();
  15498. }
  15499. }
  15500. checkInView() {
  15501. const rect = useRect(this.el);
  15502. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  15503. }
  15504. filter() {
  15505. Object.keys(this.options.filter).forEach((key) => {
  15506. this.options.filter[key](this, this.options);
  15507. });
  15508. }
  15509. renderLoading(cb) {
  15510. this.state.loading = true;
  15511. loadImageAsync(
  15512. {
  15513. src: this.loading,
  15514. cors: this.cors
  15515. },
  15516. () => {
  15517. this.render("loading", false);
  15518. this.state.loading = false;
  15519. cb();
  15520. },
  15521. () => {
  15522. cb();
  15523. this.state.loading = false;
  15524. }
  15525. );
  15526. }
  15527. load(onFinish = noop) {
  15528. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  15529. onFinish();
  15530. return;
  15531. }
  15532. if (this.state.rendered && this.state.loaded)
  15533. return;
  15534. if (this.imageCache.has(this.src)) {
  15535. this.state.loaded = true;
  15536. this.render("loaded", true);
  15537. this.state.rendered = true;
  15538. return onFinish();
  15539. }
  15540. this.renderLoading(() => {
  15541. var _a, _b;
  15542. this.attempt++;
  15543. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  15544. this.record("loadStart");
  15545. loadImageAsync(
  15546. {
  15547. src: this.src,
  15548. cors: this.cors
  15549. },
  15550. (data) => {
  15551. this.naturalHeight = data.naturalHeight;
  15552. this.naturalWidth = data.naturalWidth;
  15553. this.state.loaded = true;
  15554. this.state.error = false;
  15555. this.record("loadEnd");
  15556. this.render("loaded", false);
  15557. this.state.rendered = true;
  15558. this.imageCache.add(this.src);
  15559. onFinish();
  15560. },
  15561. (err) => {
  15562. !this.options.silent && console.error(err);
  15563. this.state.error = true;
  15564. this.state.loaded = false;
  15565. this.render("error", false);
  15566. }
  15567. );
  15568. });
  15569. }
  15570. render(state, cache) {
  15571. this.elRenderer(this, state, cache);
  15572. }
  15573. performance() {
  15574. let state = "loading";
  15575. let time = 0;
  15576. if (this.state.loaded) {
  15577. state = "loaded";
  15578. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  15579. }
  15580. if (this.state.error)
  15581. state = "error";
  15582. return {
  15583. src: this.src,
  15584. state,
  15585. time
  15586. };
  15587. }
  15588. $destroy() {
  15589. this.el = null;
  15590. this.src = null;
  15591. this.error = null;
  15592. this.loading = null;
  15593. this.bindType = null;
  15594. this.attempt = 0;
  15595. }
  15596. }
  15597. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  15598. const DEFAULT_EVENTS = [
  15599. "scroll",
  15600. "wheel",
  15601. "mousewheel",
  15602. "resize",
  15603. "animationend",
  15604. "transitionend",
  15605. "touchmove"
  15606. ];
  15607. const DEFAULT_OBSERVER_OPTIONS = {
  15608. rootMargin: "0px",
  15609. threshold: 0
  15610. };
  15611. function stdin_default$3() {
  15612. return class Lazy {
  15613. constructor({
  15614. preLoad,
  15615. error,
  15616. throttleWait,
  15617. preLoadTop,
  15618. dispatchEvent,
  15619. loading,
  15620. attempt,
  15621. silent = true,
  15622. scale,
  15623. listenEvents,
  15624. filter,
  15625. adapter,
  15626. observer,
  15627. observerOptions
  15628. }) {
  15629. this.mode = modeType.event;
  15630. this.listeners = [];
  15631. this.targetIndex = 0;
  15632. this.targets = [];
  15633. this.options = {
  15634. silent,
  15635. dispatchEvent: !!dispatchEvent,
  15636. throttleWait: throttleWait || 200,
  15637. preLoad: preLoad || 1.3,
  15638. preLoadTop: preLoadTop || 0,
  15639. error: error || DEFAULT_URL,
  15640. loading: loading || DEFAULT_URL,
  15641. attempt: attempt || 3,
  15642. scale: scale || getDPR(scale),
  15643. ListenEvents: listenEvents || DEFAULT_EVENTS,
  15644. supportWebp: supportWebp(),
  15645. filter: filter || {},
  15646. adapter: adapter || {},
  15647. observer: !!observer,
  15648. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  15649. };
  15650. this.initEvent();
  15651. this.imageCache = new ImageCache({ max: 200 });
  15652. this.lazyLoadHandler = throttle(
  15653. this.lazyLoadHandler.bind(this),
  15654. this.options.throttleWait
  15655. );
  15656. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  15657. }
  15658. config(options = {}) {
  15659. Object.assign(this.options, options);
  15660. }
  15661. performance() {
  15662. return this.listeners.map((item) => item.performance());
  15663. }
  15664. addLazyBox(vm) {
  15665. this.listeners.push(vm);
  15666. if (inBrowser) {
  15667. this.addListenerTarget(window);
  15668. this.observer && this.observer.observe(vm.el);
  15669. if (vm.$el && vm.$el.parentNode) {
  15670. this.addListenerTarget(vm.$el.parentNode);
  15671. }
  15672. }
  15673. }
  15674. add(el, binding, vnode) {
  15675. if (this.listeners.some((item) => item.el === el)) {
  15676. this.update(el, binding);
  15677. return vue.nextTick(this.lazyLoadHandler);
  15678. }
  15679. const value = this.valueFormatter(binding.value);
  15680. let { src } = value;
  15681. vue.nextTick(() => {
  15682. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  15683. this.observer && this.observer.observe(el);
  15684. const container = Object.keys(binding.modifiers)[0];
  15685. let $parent;
  15686. if (container) {
  15687. $parent = vnode.context.$refs[container];
  15688. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  15689. }
  15690. if (!$parent) {
  15691. $parent = getScrollParent$1(el);
  15692. }
  15693. const newListener = new ReactiveListener({
  15694. bindType: binding.arg,
  15695. $parent,
  15696. el,
  15697. src,
  15698. loading: value.loading,
  15699. error: value.error,
  15700. cors: value.cors,
  15701. elRenderer: this.elRenderer.bind(this),
  15702. options: this.options,
  15703. imageCache: this.imageCache
  15704. });
  15705. this.listeners.push(newListener);
  15706. if (inBrowser) {
  15707. this.addListenerTarget(window);
  15708. this.addListenerTarget($parent);
  15709. }
  15710. this.lazyLoadHandler();
  15711. vue.nextTick(() => this.lazyLoadHandler());
  15712. });
  15713. }
  15714. update(el, binding, vnode) {
  15715. const value = this.valueFormatter(binding.value);
  15716. let { src } = value;
  15717. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  15718. const exist = this.listeners.find((item) => item.el === el);
  15719. if (!exist) {
  15720. this.add(el, binding, vnode);
  15721. } else {
  15722. exist.update({
  15723. src,
  15724. error: value.error,
  15725. loading: value.loading
  15726. });
  15727. }
  15728. if (this.observer) {
  15729. this.observer.unobserve(el);
  15730. this.observer.observe(el);
  15731. }
  15732. this.lazyLoadHandler();
  15733. vue.nextTick(() => this.lazyLoadHandler());
  15734. }
  15735. remove(el) {
  15736. if (!el)
  15737. return;
  15738. this.observer && this.observer.unobserve(el);
  15739. const existItem = this.listeners.find((item) => item.el === el);
  15740. if (existItem) {
  15741. this.removeListenerTarget(existItem.$parent);
  15742. this.removeListenerTarget(window);
  15743. remove(this.listeners, existItem);
  15744. existItem.$destroy();
  15745. }
  15746. }
  15747. removeComponent(vm) {
  15748. if (!vm)
  15749. return;
  15750. remove(this.listeners, vm);
  15751. this.observer && this.observer.unobserve(vm.el);
  15752. if (vm.$parent && vm.$el.parentNode) {
  15753. this.removeListenerTarget(vm.$el.parentNode);
  15754. }
  15755. this.removeListenerTarget(window);
  15756. }
  15757. setMode(mode) {
  15758. if (!hasIntersectionObserver && mode === modeType.observer) {
  15759. mode = modeType.event;
  15760. }
  15761. this.mode = mode;
  15762. if (mode === modeType.event) {
  15763. if (this.observer) {
  15764. this.listeners.forEach((listener) => {
  15765. this.observer.unobserve(listener.el);
  15766. });
  15767. this.observer = null;
  15768. }
  15769. this.targets.forEach((target) => {
  15770. this.initListen(target.el, true);
  15771. });
  15772. } else {
  15773. this.targets.forEach((target) => {
  15774. this.initListen(target.el, false);
  15775. });
  15776. this.initIntersectionObserver();
  15777. }
  15778. }
  15779. addListenerTarget(el) {
  15780. if (!el)
  15781. return;
  15782. let target = this.targets.find((target2) => target2.el === el);
  15783. if (!target) {
  15784. target = {
  15785. el,
  15786. id: ++this.targetIndex,
  15787. childrenCount: 1,
  15788. listened: true
  15789. };
  15790. this.mode === modeType.event && this.initListen(target.el, true);
  15791. this.targets.push(target);
  15792. } else {
  15793. target.childrenCount++;
  15794. }
  15795. return this.targetIndex;
  15796. }
  15797. removeListenerTarget(el) {
  15798. this.targets.forEach((target, index) => {
  15799. if (target.el === el) {
  15800. target.childrenCount--;
  15801. if (!target.childrenCount) {
  15802. this.initListen(target.el, false);
  15803. this.targets.splice(index, 1);
  15804. target = null;
  15805. }
  15806. }
  15807. });
  15808. }
  15809. initListen(el, start2) {
  15810. this.options.ListenEvents.forEach(
  15811. (evt) => (start2 ? on : off)(el, evt, this.lazyLoadHandler)
  15812. );
  15813. }
  15814. initEvent() {
  15815. this.Event = {
  15816. listeners: {
  15817. loading: [],
  15818. loaded: [],
  15819. error: []
  15820. }
  15821. };
  15822. this.$on = (event, func) => {
  15823. if (!this.Event.listeners[event])
  15824. this.Event.listeners[event] = [];
  15825. this.Event.listeners[event].push(func);
  15826. };
  15827. this.$once = (event, func) => {
  15828. const on2 = (...args) => {
  15829. this.$off(event, on2);
  15830. func.apply(this, args);
  15831. };
  15832. this.$on(event, on2);
  15833. };
  15834. this.$off = (event, func) => {
  15835. if (!func) {
  15836. if (!this.Event.listeners[event])
  15837. return;
  15838. this.Event.listeners[event].length = 0;
  15839. return;
  15840. }
  15841. remove(this.Event.listeners[event], func);
  15842. };
  15843. this.$emit = (event, context, inCache) => {
  15844. if (!this.Event.listeners[event])
  15845. return;
  15846. this.Event.listeners[event].forEach((func) => func(context, inCache));
  15847. };
  15848. }
  15849. lazyLoadHandler() {
  15850. const freeList = [];
  15851. this.listeners.forEach((listener) => {
  15852. if (!listener.el || !listener.el.parentNode) {
  15853. freeList.push(listener);
  15854. }
  15855. const catIn = listener.checkInView();
  15856. if (!catIn)
  15857. return;
  15858. listener.load();
  15859. });
  15860. freeList.forEach((item) => {
  15861. remove(this.listeners, item);
  15862. item.$destroy();
  15863. });
  15864. }
  15865. initIntersectionObserver() {
  15866. if (!hasIntersectionObserver) {
  15867. return;
  15868. }
  15869. this.observer = new IntersectionObserver(
  15870. this.observerHandler.bind(this),
  15871. this.options.observerOptions
  15872. );
  15873. if (this.listeners.length) {
  15874. this.listeners.forEach((listener) => {
  15875. this.observer.observe(listener.el);
  15876. });
  15877. }
  15878. }
  15879. observerHandler(entries) {
  15880. entries.forEach((entry) => {
  15881. if (entry.isIntersecting) {
  15882. this.listeners.forEach((listener) => {
  15883. if (listener.el === entry.target) {
  15884. if (listener.state.loaded)
  15885. return this.observer.unobserve(listener.el);
  15886. listener.load();
  15887. }
  15888. });
  15889. }
  15890. });
  15891. }
  15892. elRenderer(listener, state, cache) {
  15893. if (!listener.el)
  15894. return;
  15895. const { el, bindType } = listener;
  15896. let src;
  15897. switch (state) {
  15898. case "loading":
  15899. src = listener.loading;
  15900. break;
  15901. case "error":
  15902. src = listener.error;
  15903. break;
  15904. default:
  15905. ({ src } = listener);
  15906. break;
  15907. }
  15908. if (bindType) {
  15909. el.style[bindType] = 'url("' + src + '")';
  15910. } else if (el.getAttribute("src") !== src) {
  15911. el.setAttribute("src", src);
  15912. }
  15913. el.setAttribute("lazy", state);
  15914. this.$emit(state, listener, cache);
  15915. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  15916. if (this.options.dispatchEvent) {
  15917. const event = new CustomEvent(state, {
  15918. detail: listener
  15919. });
  15920. el.dispatchEvent(event);
  15921. }
  15922. }
  15923. valueFormatter(value) {
  15924. let src = value;
  15925. let { loading, error } = this.options;
  15926. if (isObject(value)) {
  15927. ({ src } = value);
  15928. loading = value.loading || this.options.loading;
  15929. error = value.error || this.options.error;
  15930. }
  15931. return {
  15932. src,
  15933. loading,
  15934. error
  15935. };
  15936. }
  15937. };
  15938. }
  15939. var stdin_default$2 = (lazy) => ({
  15940. props: {
  15941. tag: {
  15942. type: String,
  15943. default: "div"
  15944. }
  15945. },
  15946. emits: ["show"],
  15947. render() {
  15948. return vue.h(
  15949. this.tag,
  15950. this.show && this.$slots.default ? this.$slots.default() : null
  15951. );
  15952. },
  15953. data() {
  15954. return {
  15955. el: null,
  15956. state: {
  15957. loaded: false
  15958. },
  15959. show: false
  15960. };
  15961. },
  15962. mounted() {
  15963. this.el = this.$el;
  15964. lazy.addLazyBox(this);
  15965. lazy.lazyLoadHandler();
  15966. },
  15967. beforeUnmount() {
  15968. lazy.removeComponent(this);
  15969. },
  15970. methods: {
  15971. checkInView() {
  15972. const rect = useRect(this.$el);
  15973. return inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  15974. },
  15975. load() {
  15976. this.show = true;
  15977. this.state.loaded = true;
  15978. this.$emit("show", this);
  15979. },
  15980. destroy() {
  15981. return this.$destroy;
  15982. }
  15983. }
  15984. });
  15985. const defaultOptions = {
  15986. selector: "img"
  15987. };
  15988. class LazyContainer {
  15989. constructor({ el, binding, vnode, lazy }) {
  15990. this.el = null;
  15991. this.vnode = vnode;
  15992. this.binding = binding;
  15993. this.options = {};
  15994. this.lazy = lazy;
  15995. this.queue = [];
  15996. this.update({ el, binding });
  15997. }
  15998. update({ el, binding }) {
  15999. this.el = el;
  16000. this.options = Object.assign({}, defaultOptions, binding.value);
  16001. const imgs = this.getImgs();
  16002. imgs.forEach((el2) => {
  16003. this.lazy.add(
  16004. el2,
  16005. Object.assign({}, this.binding, {
  16006. value: {
  16007. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  16008. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  16009. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  16010. }
  16011. }),
  16012. this.vnode
  16013. );
  16014. });
  16015. }
  16016. getImgs() {
  16017. return Array.from(this.el.querySelectorAll(this.options.selector));
  16018. }
  16019. clear() {
  16020. const imgs = this.getImgs();
  16021. imgs.forEach((el) => this.lazy.remove(el));
  16022. this.vnode = null;
  16023. this.binding = null;
  16024. this.lazy = null;
  16025. }
  16026. }
  16027. class LazyContainerManager {
  16028. constructor({ lazy }) {
  16029. this.lazy = lazy;
  16030. this.queue = [];
  16031. }
  16032. bind(el, binding, vnode) {
  16033. const container = new LazyContainer({
  16034. el,
  16035. binding,
  16036. vnode,
  16037. lazy: this.lazy
  16038. });
  16039. this.queue.push(container);
  16040. }
  16041. update(el, binding, vnode) {
  16042. const container = this.queue.find((item) => item.el === el);
  16043. if (!container)
  16044. return;
  16045. container.update({ el, binding, vnode });
  16046. }
  16047. unbind(el) {
  16048. const container = this.queue.find((item) => item.el === el);
  16049. if (!container)
  16050. return;
  16051. container.clear();
  16052. remove(this.queue, container);
  16053. }
  16054. }
  16055. var stdin_default$1 = (lazyManager) => ({
  16056. props: {
  16057. src: [String, Object],
  16058. tag: {
  16059. type: String,
  16060. default: "img"
  16061. }
  16062. },
  16063. render() {
  16064. var _a, _b;
  16065. return vue.h(
  16066. this.tag,
  16067. {
  16068. src: this.renderSrc
  16069. },
  16070. (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
  16071. );
  16072. },
  16073. data() {
  16074. return {
  16075. el: null,
  16076. options: {
  16077. src: "",
  16078. error: "",
  16079. loading: "",
  16080. attempt: lazyManager.options.attempt
  16081. },
  16082. state: {
  16083. loaded: false,
  16084. error: false,
  16085. attempt: 0
  16086. },
  16087. renderSrc: ""
  16088. };
  16089. },
  16090. watch: {
  16091. src() {
  16092. this.init();
  16093. lazyManager.addLazyBox(this);
  16094. lazyManager.lazyLoadHandler();
  16095. }
  16096. },
  16097. created() {
  16098. this.init();
  16099. this.renderSrc = this.options.loading;
  16100. },
  16101. mounted() {
  16102. this.el = this.$el;
  16103. lazyManager.addLazyBox(this);
  16104. lazyManager.lazyLoadHandler();
  16105. },
  16106. beforeUnmount() {
  16107. lazyManager.removeComponent(this);
  16108. },
  16109. methods: {
  16110. init() {
  16111. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  16112. this.state.loaded = false;
  16113. this.options.src = src;
  16114. this.options.error = error;
  16115. this.options.loading = loading;
  16116. this.renderSrc = this.options.loading;
  16117. },
  16118. checkInView() {
  16119. const rect = useRect(this.$el);
  16120. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  16121. },
  16122. load(onFinish = noop) {
  16123. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  16124. onFinish();
  16125. return;
  16126. }
  16127. const { src } = this.options;
  16128. loadImageAsync(
  16129. { src },
  16130. ({ src: src2 }) => {
  16131. this.renderSrc = src2;
  16132. this.state.loaded = true;
  16133. },
  16134. () => {
  16135. this.state.attempt++;
  16136. this.renderSrc = this.options.error;
  16137. this.state.error = true;
  16138. }
  16139. );
  16140. }
  16141. }
  16142. });
  16143. const Lazyload = {
  16144. install(app, options = {}) {
  16145. const LazyClass = stdin_default$3();
  16146. const lazy = new LazyClass(options);
  16147. const lazyContainer = new LazyContainerManager({ lazy });
  16148. app.config.globalProperties.$Lazyload = lazy;
  16149. if (options.lazyComponent) {
  16150. app.component("LazyComponent", stdin_default$2(lazy));
  16151. }
  16152. if (options.lazyImage) {
  16153. app.component("LazyImage", stdin_default$1(lazy));
  16154. }
  16155. app.directive("lazy", {
  16156. beforeMount: lazy.add.bind(lazy),
  16157. updated: lazy.update.bind(lazy),
  16158. unmounted: lazy.remove.bind(lazy)
  16159. });
  16160. app.directive("lazy-container", {
  16161. beforeMount: lazyContainer.bind.bind(lazyContainer),
  16162. updated: lazyContainer.update.bind(lazyContainer),
  16163. unmounted: lazyContainer.unbind.bind(lazyContainer)
  16164. });
  16165. }
  16166. };
  16167. const version = "3.6.10";
  16168. function install(app) {
  16169. const components = [
  16170. ActionBar,
  16171. ActionBarButton,
  16172. ActionBarIcon,
  16173. ActionSheet,
  16174. AddressEdit,
  16175. AddressList,
  16176. Area,
  16177. Badge,
  16178. Button,
  16179. Calendar,
  16180. Card,
  16181. Cascader,
  16182. Cell,
  16183. CellGroup,
  16184. Checkbox,
  16185. CheckboxGroup,
  16186. Circle,
  16187. Col,
  16188. Collapse,
  16189. CollapseItem,
  16190. ConfigProvider,
  16191. ContactCard,
  16192. ContactEdit,
  16193. ContactList,
  16194. CountDown,
  16195. Coupon,
  16196. CouponCell,
  16197. CouponList,
  16198. DatetimePicker,
  16199. Dialog,
  16200. Divider,
  16201. DropdownItem,
  16202. DropdownMenu,
  16203. Empty,
  16204. Field,
  16205. Form,
  16206. Grid,
  16207. GridItem,
  16208. Icon,
  16209. Image$1,
  16210. ImagePreview,
  16211. IndexAnchor,
  16212. IndexBar,
  16213. List,
  16214. Loading,
  16215. Locale,
  16216. NavBar,
  16217. NoticeBar,
  16218. Notify,
  16219. NumberKeyboard,
  16220. Overlay,
  16221. Pagination,
  16222. PasswordInput,
  16223. Picker,
  16224. Popover,
  16225. Popup,
  16226. Progress,
  16227. PullRefresh,
  16228. Radio,
  16229. RadioGroup,
  16230. Rate,
  16231. Row,
  16232. Search,
  16233. ShareSheet,
  16234. Sidebar,
  16235. SidebarItem,
  16236. Skeleton,
  16237. Slider,
  16238. Space,
  16239. Step,
  16240. Stepper,
  16241. Steps,
  16242. Sticky,
  16243. SubmitBar,
  16244. Swipe,
  16245. SwipeCell,
  16246. SwipeItem,
  16247. Switch,
  16248. Tab,
  16249. Tabbar,
  16250. TabbarItem,
  16251. Tabs,
  16252. Tag,
  16253. Toast,
  16254. TreeSelect,
  16255. Uploader
  16256. ];
  16257. components.forEach((item) => {
  16258. if (item.install) {
  16259. app.use(item);
  16260. } else if (item.name) {
  16261. app.component(item.name, item);
  16262. }
  16263. });
  16264. }
  16265. var stdin_default = {
  16266. install,
  16267. version
  16268. };
  16269. exports2.ActionBar = ActionBar;
  16270. exports2.ActionBarButton = ActionBarButton;
  16271. exports2.ActionBarIcon = ActionBarIcon;
  16272. exports2.ActionSheet = ActionSheet;
  16273. exports2.AddressEdit = AddressEdit;
  16274. exports2.AddressList = AddressList;
  16275. exports2.Area = Area;
  16276. exports2.Badge = Badge;
  16277. exports2.Button = Button;
  16278. exports2.Calendar = Calendar;
  16279. exports2.Card = Card;
  16280. exports2.Cascader = Cascader;
  16281. exports2.Cell = Cell;
  16282. exports2.CellGroup = CellGroup;
  16283. exports2.Checkbox = Checkbox;
  16284. exports2.CheckboxGroup = CheckboxGroup;
  16285. exports2.Circle = Circle;
  16286. exports2.Col = Col;
  16287. exports2.Collapse = Collapse;
  16288. exports2.CollapseItem = CollapseItem;
  16289. exports2.ConfigProvider = ConfigProvider;
  16290. exports2.ContactCard = ContactCard;
  16291. exports2.ContactEdit = ContactEdit;
  16292. exports2.ContactList = ContactList;
  16293. exports2.CountDown = CountDown;
  16294. exports2.Coupon = Coupon;
  16295. exports2.CouponCell = CouponCell;
  16296. exports2.CouponList = CouponList;
  16297. exports2.DatetimePicker = DatetimePicker;
  16298. exports2.Dialog = Dialog;
  16299. exports2.Divider = Divider;
  16300. exports2.DropdownItem = DropdownItem;
  16301. exports2.DropdownMenu = DropdownMenu;
  16302. exports2.Empty = Empty;
  16303. exports2.Field = Field;
  16304. exports2.Form = Form;
  16305. exports2.Grid = Grid;
  16306. exports2.GridItem = GridItem;
  16307. exports2.Icon = Icon;
  16308. exports2.Image = Image$1;
  16309. exports2.ImagePreview = ImagePreview;
  16310. exports2.IndexAnchor = IndexAnchor;
  16311. exports2.IndexBar = IndexBar;
  16312. exports2.Lazyload = Lazyload;
  16313. exports2.List = List;
  16314. exports2.Loading = Loading;
  16315. exports2.Locale = Locale;
  16316. exports2.NavBar = NavBar;
  16317. exports2.NoticeBar = NoticeBar;
  16318. exports2.Notify = Notify;
  16319. exports2.NumberKeyboard = NumberKeyboard;
  16320. exports2.Overlay = Overlay;
  16321. exports2.Pagination = Pagination;
  16322. exports2.PasswordInput = PasswordInput;
  16323. exports2.Picker = Picker;
  16324. exports2.Popover = Popover;
  16325. exports2.Popup = Popup;
  16326. exports2.Progress = Progress;
  16327. exports2.PullRefresh = PullRefresh;
  16328. exports2.Radio = Radio;
  16329. exports2.RadioGroup = RadioGroup;
  16330. exports2.Rate = Rate;
  16331. exports2.Row = Row;
  16332. exports2.Search = Search;
  16333. exports2.ShareSheet = ShareSheet;
  16334. exports2.Sidebar = Sidebar;
  16335. exports2.SidebarItem = SidebarItem;
  16336. exports2.Skeleton = Skeleton;
  16337. exports2.Slider = Slider;
  16338. exports2.Space = Space;
  16339. exports2.Step = Step;
  16340. exports2.Stepper = Stepper;
  16341. exports2.Steps = Steps;
  16342. exports2.Sticky = Sticky;
  16343. exports2.SubmitBar = SubmitBar;
  16344. exports2.Swipe = Swipe;
  16345. exports2.SwipeCell = SwipeCell;
  16346. exports2.SwipeItem = SwipeItem;
  16347. exports2.Switch = Switch;
  16348. exports2.Tab = Tab;
  16349. exports2.Tabbar = Tabbar;
  16350. exports2.TabbarItem = TabbarItem;
  16351. exports2.Tabs = Tabs;
  16352. exports2.Tag = Tag;
  16353. exports2.Toast = Toast;
  16354. exports2.TreeSelect = TreeSelect;
  16355. exports2.Uploader = Uploader;
  16356. exports2.default = stdin_default;
  16357. exports2.install = install;
  16358. exports2.version = version;
  16359. Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
  16360. });