vant.cjs.js 500 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400
  1. "use strict";
  2. Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
  3. const vue = require("vue");
  4. const use = require("@vant/use");
  5. const shared = require("@vue/shared");
  6. const popperjs = require("@vant/popperjs");
  7. function noop() {
  8. }
  9. const extend = Object.assign;
  10. const inBrowser = typeof window !== "undefined";
  11. const isObject = (val) => val !== null && typeof val === "object";
  12. const isDef = (val) => val !== void 0 && val !== null;
  13. const isFunction = (val) => typeof val === "function";
  14. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  15. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  16. function isMobile(value) {
  17. value = value.replace(/[^-|\d]/g, "");
  18. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  19. }
  20. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  21. const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  22. function get(object, path) {
  23. const keys = path.split(".");
  24. let result = object;
  25. keys.forEach((key) => {
  26. var _a;
  27. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  28. });
  29. return result;
  30. }
  31. function pick(obj, keys, ignoreUndefined) {
  32. return keys.reduce(
  33. (ret, key) => {
  34. if (!ignoreUndefined || obj[key] !== void 0) {
  35. ret[key] = obj[key];
  36. }
  37. return ret;
  38. },
  39. {}
  40. );
  41. }
  42. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  43. const toArray = (item) => Array.isArray(item) ? item : [item];
  44. const flat = (arr) => arr.reduce((acc, val) => acc.concat(val), []);
  45. const unknownProp = null;
  46. const numericProp = [Number, String];
  47. const truthProp = {
  48. type: Boolean,
  49. default: true
  50. };
  51. const makeRequiredProp = (type) => ({
  52. type,
  53. required: true
  54. });
  55. const makeArrayProp = () => ({
  56. type: Array,
  57. default: () => []
  58. });
  59. const makeNumberProp = (defaultVal) => ({
  60. type: Number,
  61. default: defaultVal
  62. });
  63. const makeNumericProp = (defaultVal) => ({
  64. type: numericProp,
  65. default: defaultVal
  66. });
  67. const makeStringProp = (defaultVal) => ({
  68. type: String,
  69. default: defaultVal
  70. });
  71. function getScrollTop(el) {
  72. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  73. return Math.max(top, 0);
  74. }
  75. function setScrollTop(el, value) {
  76. if ("scrollTop" in el) {
  77. el.scrollTop = value;
  78. } else {
  79. el.scrollTo(el.scrollX, value);
  80. }
  81. }
  82. function getRootScrollTop() {
  83. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  84. }
  85. function setRootScrollTop(value) {
  86. setScrollTop(window, value);
  87. setScrollTop(document.body, value);
  88. }
  89. function getElementTop(el, scroller) {
  90. if (el === window) {
  91. return 0;
  92. }
  93. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  94. return use.useRect(el).top + scrollTop;
  95. }
  96. const isIOS = isIOS$1();
  97. function resetScroll() {
  98. if (isIOS) {
  99. setRootScrollTop(getRootScrollTop());
  100. }
  101. }
  102. const stopPropagation = (event) => event.stopPropagation();
  103. function preventDefault(event, isStopPropagation) {
  104. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  105. event.preventDefault();
  106. }
  107. if (isStopPropagation) {
  108. stopPropagation(event);
  109. }
  110. }
  111. function isHidden(elementRef) {
  112. const el = vue.unref(elementRef);
  113. if (!el) {
  114. return false;
  115. }
  116. const style = window.getComputedStyle(el);
  117. const hidden = style.display === "none";
  118. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  119. return hidden || parentHidden;
  120. }
  121. const { width: windowWidth, height: windowHeight } = use.useWindowSize();
  122. function isContainingBlock(el) {
  123. const css = window.getComputedStyle(el);
  124. return css.transform !== "none" || css.perspective !== "none" || ["transform", "perspective", "filter"].some(
  125. (value) => (css.willChange || "").includes(value)
  126. );
  127. }
  128. function getContainingBlock(el) {
  129. let node = el.parentElement;
  130. while (node) {
  131. if (node && node.tagName !== "HTML" && node.tagName !== "BODY" && isContainingBlock(node)) {
  132. return node;
  133. }
  134. node = node.parentElement;
  135. }
  136. return null;
  137. }
  138. function addUnit(value) {
  139. if (isDef(value)) {
  140. return isNumeric(value) ? `${value}px` : String(value);
  141. }
  142. return void 0;
  143. }
  144. function getSizeStyle(originSize) {
  145. if (isDef(originSize)) {
  146. if (Array.isArray(originSize)) {
  147. return {
  148. width: addUnit(originSize[0]),
  149. height: addUnit(originSize[1])
  150. };
  151. }
  152. const size = addUnit(originSize);
  153. return {
  154. width: size,
  155. height: size
  156. };
  157. }
  158. }
  159. function getZIndexStyle(zIndex) {
  160. const style = {};
  161. if (zIndex !== void 0) {
  162. style.zIndex = +zIndex;
  163. }
  164. return style;
  165. }
  166. let rootFontSize;
  167. function getRootFontSize() {
  168. if (!rootFontSize) {
  169. const doc = document.documentElement;
  170. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  171. rootFontSize = parseFloat(fontSize);
  172. }
  173. return rootFontSize;
  174. }
  175. function convertRem(value) {
  176. value = value.replace(/rem/g, "");
  177. return +value * getRootFontSize();
  178. }
  179. function convertVw(value) {
  180. value = value.replace(/vw/g, "");
  181. return +value * windowWidth.value / 100;
  182. }
  183. function convertVh(value) {
  184. value = value.replace(/vh/g, "");
  185. return +value * windowHeight.value / 100;
  186. }
  187. function unitToPx(value) {
  188. if (typeof value === "number") {
  189. return value;
  190. }
  191. if (inBrowser) {
  192. if (value.includes("rem")) {
  193. return convertRem(value);
  194. }
  195. if (value.includes("vw")) {
  196. return convertVw(value);
  197. }
  198. if (value.includes("vh")) {
  199. return convertVh(value);
  200. }
  201. }
  202. return parseFloat(value);
  203. }
  204. const camelizeRE = /-(\w)/g;
  205. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  206. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  207. function padZero(num, targetLength = 2) {
  208. let str = num + "";
  209. while (str.length < targetLength) {
  210. str = "0" + str;
  211. }
  212. return str;
  213. }
  214. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  215. function trimExtraChar(value, char, regExp) {
  216. const index = value.indexOf(char);
  217. if (index === -1) {
  218. return value;
  219. }
  220. if (char === "-" && index !== 0) {
  221. return value.slice(0, index);
  222. }
  223. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  224. }
  225. function formatNumber(value, allowDot = true, allowMinus = true) {
  226. if (allowDot) {
  227. value = trimExtraChar(value, ".", /\./g);
  228. } else {
  229. value = value.split(".")[0];
  230. }
  231. if (allowMinus) {
  232. value = trimExtraChar(value, "-", /-/g);
  233. } else {
  234. value = value.replace(/-/, "");
  235. }
  236. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  237. return value.replace(regExp, "");
  238. }
  239. function addNumber(num1, num2) {
  240. const cardinal = 10 ** 10;
  241. return Math.round((num1 + num2) * cardinal) / cardinal;
  242. }
  243. const { hasOwnProperty } = Object.prototype;
  244. function assignKey(to, from, key) {
  245. const val = from[key];
  246. if (!isDef(val)) {
  247. return;
  248. }
  249. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  250. to[key] = val;
  251. } else {
  252. to[key] = deepAssign(Object(to[key]), val);
  253. }
  254. }
  255. function deepAssign(to, from) {
  256. Object.keys(from).forEach((key) => {
  257. assignKey(to, from, key);
  258. });
  259. return to;
  260. }
  261. var stdin_default$1W = {
  262. name: "姓名",
  263. tel: "电话",
  264. save: "保存",
  265. clear: "清空",
  266. cancel: "取消",
  267. confirm: "确认",
  268. delete: "删除",
  269. loading: "加载中...",
  270. noCoupon: "暂无优惠券",
  271. nameEmpty: "请填写姓名",
  272. addContact: "添加联系人",
  273. telInvalid: "请填写正确的电话",
  274. vanCalendar: {
  275. end: "结束",
  276. start: "开始",
  277. title: "日期选择",
  278. weekdays: ["日", "一", "二", "三", "四", "五", "六"],
  279. monthTitle: (year, month) => `${year}年${month}月`,
  280. rangePrompt: (maxRange) => `最多选择 ${maxRange} 天`
  281. },
  282. vanCascader: {
  283. select: "请选择"
  284. },
  285. vanPagination: {
  286. prev: "上一页",
  287. next: "下一页"
  288. },
  289. vanPullRefresh: {
  290. pulling: "下拉即可刷新...",
  291. loosing: "释放即可刷新..."
  292. },
  293. vanSubmitBar: {
  294. label: "合计:"
  295. },
  296. vanCoupon: {
  297. unlimited: "无门槛",
  298. discount: (discount) => `${discount}折`,
  299. condition: (condition) => `满${condition}元可用`
  300. },
  301. vanCouponCell: {
  302. title: "优惠券",
  303. count: (count) => `${count}张可用`
  304. },
  305. vanCouponList: {
  306. exchange: "兑换",
  307. close: "不使用",
  308. enable: "可用",
  309. disabled: "不可用",
  310. placeholder: "输入优惠码"
  311. },
  312. vanAddressEdit: {
  313. area: "地区",
  314. areaEmpty: "请选择地区",
  315. addressEmpty: "请填写详细地址",
  316. addressDetail: "详细地址",
  317. defaultAddress: "设为默认收货地址"
  318. },
  319. vanAddressList: {
  320. add: "新增地址"
  321. }
  322. };
  323. const lang = vue.ref("zh-CN");
  324. const messages = vue.reactive({
  325. "zh-CN": stdin_default$1W
  326. });
  327. const Locale = {
  328. messages() {
  329. return messages[lang.value];
  330. },
  331. use(newLang, newMessages) {
  332. lang.value = newLang;
  333. this.add({ [newLang]: newMessages });
  334. },
  335. add(newMessages = {}) {
  336. deepAssign(messages, newMessages);
  337. }
  338. };
  339. const useCurrentLang = () => lang;
  340. var stdin_default$1V = Locale;
  341. function createTranslate(name2) {
  342. const prefix = camelize(name2) + ".";
  343. return (path, ...args) => {
  344. const messages2 = stdin_default$1V.messages();
  345. const message = get(messages2, prefix + path) || get(messages2, path);
  346. return isFunction(message) ? message(...args) : message;
  347. };
  348. }
  349. function genBem(name2, mods) {
  350. if (!mods) {
  351. return "";
  352. }
  353. if (typeof mods === "string") {
  354. return ` ${name2}--${mods}`;
  355. }
  356. if (Array.isArray(mods)) {
  357. return mods.reduce(
  358. (ret, item) => ret + genBem(name2, item),
  359. ""
  360. );
  361. }
  362. return Object.keys(mods).reduce(
  363. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  364. ""
  365. );
  366. }
  367. function createBEM(name2) {
  368. return (el, mods) => {
  369. if (el && typeof el !== "string") {
  370. mods = el;
  371. el = "";
  372. }
  373. el = el ? `${name2}__${el}` : name2;
  374. return `${el}${genBem(el, mods)}`;
  375. };
  376. }
  377. function createNamespace(name2) {
  378. const prefixedName = `van-${name2}`;
  379. return [
  380. prefixedName,
  381. createBEM(prefixedName),
  382. createTranslate(prefixedName)
  383. ];
  384. }
  385. const BORDER = "van-hairline";
  386. const BORDER_TOP = `${BORDER}--top`;
  387. const BORDER_LEFT = `${BORDER}--left`;
  388. const BORDER_RIGHT = `${BORDER}--right`;
  389. const BORDER_BOTTOM = `${BORDER}--bottom`;
  390. const BORDER_SURROUND = `${BORDER}--surround`;
  391. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  392. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  393. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  394. const FORM_KEY = Symbol("van-form");
  395. const LONG_PRESS_START_TIME = 500;
  396. const TAP_OFFSET = 5;
  397. function callInterceptor(interceptor, {
  398. args = [],
  399. done,
  400. canceled,
  401. error
  402. }) {
  403. if (interceptor) {
  404. const returnVal = interceptor.apply(null, args);
  405. if (isPromise(returnVal)) {
  406. returnVal.then((value) => {
  407. if (value) {
  408. done();
  409. } else if (canceled) {
  410. canceled();
  411. }
  412. }).catch(error || noop);
  413. } else if (returnVal) {
  414. done();
  415. } else if (canceled) {
  416. canceled();
  417. }
  418. } else {
  419. done();
  420. }
  421. }
  422. function withInstall(options) {
  423. options.install = (app) => {
  424. const { name: name2 } = options;
  425. if (name2) {
  426. app.component(name2, options);
  427. app.component(camelize(`-${name2}`), options);
  428. }
  429. };
  430. return options;
  431. }
  432. function closest(arr, target) {
  433. return arr.reduce(
  434. (pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur
  435. );
  436. }
  437. const POPUP_TOGGLE_KEY = Symbol();
  438. function onPopupReopen(callback) {
  439. const popupToggleStatus = vue.inject(POPUP_TOGGLE_KEY, null);
  440. if (popupToggleStatus) {
  441. vue.watch(popupToggleStatus, (show) => {
  442. if (show) {
  443. callback();
  444. }
  445. });
  446. }
  447. }
  448. const useHeight = (element, withSafeArea) => {
  449. const height = vue.ref();
  450. const setHeight = () => {
  451. height.value = use.useRect(element).height;
  452. };
  453. vue.onMounted(() => {
  454. vue.nextTick(setHeight);
  455. if (withSafeArea) {
  456. for (let i = 1; i <= 3; i++) {
  457. setTimeout(setHeight, 100 * i);
  458. }
  459. }
  460. });
  461. onPopupReopen(() => vue.nextTick(setHeight));
  462. vue.watch([windowWidth, windowHeight], setHeight);
  463. return height;
  464. };
  465. function usePlaceholder(contentRef, bem2) {
  466. const height = useHeight(contentRef, true);
  467. return (renderContent) => vue.createVNode("div", {
  468. "class": bem2("placeholder"),
  469. "style": {
  470. height: height.value ? `${height.value}px` : void 0
  471. }
  472. }, [renderContent()]);
  473. }
  474. const [name$1K, bem$1F] = createNamespace("action-bar");
  475. const ACTION_BAR_KEY = Symbol(name$1K);
  476. const actionBarProps = {
  477. placeholder: Boolean,
  478. safeAreaInsetBottom: truthProp
  479. };
  480. var stdin_default$1U = vue.defineComponent({
  481. name: name$1K,
  482. props: actionBarProps,
  483. setup(props2, {
  484. slots
  485. }) {
  486. const root = vue.ref();
  487. const renderPlaceholder = usePlaceholder(root, bem$1F);
  488. const {
  489. linkChildren
  490. } = use.useChildren(ACTION_BAR_KEY);
  491. linkChildren();
  492. const renderActionBar = () => {
  493. var _a;
  494. return vue.createVNode("div", {
  495. "ref": root,
  496. "class": [bem$1F(), {
  497. "van-safe-area-bottom": props2.safeAreaInsetBottom
  498. }]
  499. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  500. };
  501. return () => {
  502. if (props2.placeholder) {
  503. return renderPlaceholder(renderActionBar);
  504. }
  505. return renderActionBar();
  506. };
  507. }
  508. });
  509. const ActionBar = withInstall(stdin_default$1U);
  510. function useExpose(apis) {
  511. const instance2 = vue.getCurrentInstance();
  512. if (instance2) {
  513. extend(instance2.proxy, apis);
  514. }
  515. }
  516. const routeProps = {
  517. to: [String, Object],
  518. url: String,
  519. replace: Boolean
  520. };
  521. function route({
  522. to,
  523. url,
  524. replace,
  525. $router: router
  526. }) {
  527. if (to && router) {
  528. router[replace ? "replace" : "push"](to);
  529. } else if (url) {
  530. replace ? location.replace(url) : location.href = url;
  531. }
  532. }
  533. function useRoute() {
  534. const vm = vue.getCurrentInstance().proxy;
  535. return () => route(vm);
  536. }
  537. const [name$1J, bem$1E] = createNamespace("badge");
  538. const badgeProps = {
  539. dot: Boolean,
  540. max: numericProp,
  541. tag: makeStringProp("div"),
  542. color: String,
  543. offset: Array,
  544. content: numericProp,
  545. showZero: truthProp,
  546. position: makeStringProp("top-right")
  547. };
  548. var stdin_default$1T = vue.defineComponent({
  549. name: name$1J,
  550. props: badgeProps,
  551. setup(props2, {
  552. slots
  553. }) {
  554. const hasContent = () => {
  555. if (slots.content) {
  556. return true;
  557. }
  558. const {
  559. content,
  560. showZero
  561. } = props2;
  562. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  563. };
  564. const renderContent = () => {
  565. const {
  566. dot,
  567. max,
  568. content
  569. } = props2;
  570. if (!dot && hasContent()) {
  571. if (slots.content) {
  572. return slots.content();
  573. }
  574. if (isDef(max) && isNumeric(content) && +content > +max) {
  575. return `${max}+`;
  576. }
  577. return content;
  578. }
  579. };
  580. const getOffsetWithMinusString = (val) => val.startsWith("-") ? val.replace("-", "") : `-${val}`;
  581. const style = vue.computed(() => {
  582. const style2 = {
  583. background: props2.color
  584. };
  585. if (props2.offset) {
  586. const [x, y] = props2.offset;
  587. const {
  588. position
  589. } = props2;
  590. const [offsetY, offsetX] = position.split("-");
  591. if (slots.default) {
  592. if (typeof y === "number") {
  593. style2[offsetY] = addUnit(offsetY === "top" ? y : -y);
  594. } else {
  595. style2[offsetY] = offsetY === "top" ? addUnit(y) : getOffsetWithMinusString(y);
  596. }
  597. if (typeof x === "number") {
  598. style2[offsetX] = addUnit(offsetX === "left" ? x : -x);
  599. } else {
  600. style2[offsetX] = offsetX === "left" ? addUnit(x) : getOffsetWithMinusString(x);
  601. }
  602. } else {
  603. style2.marginTop = addUnit(y);
  604. style2.marginLeft = addUnit(x);
  605. }
  606. }
  607. return style2;
  608. });
  609. const renderBadge = () => {
  610. if (hasContent() || props2.dot) {
  611. return vue.createVNode("div", {
  612. "class": bem$1E([props2.position, {
  613. dot: props2.dot,
  614. fixed: !!slots.default
  615. }]),
  616. "style": style.value
  617. }, [renderContent()]);
  618. }
  619. };
  620. return () => {
  621. if (slots.default) {
  622. const {
  623. tag
  624. } = props2;
  625. return vue.createVNode(tag, {
  626. "class": bem$1E("wrapper")
  627. }, {
  628. default: () => [slots.default(), renderBadge()]
  629. });
  630. }
  631. return renderBadge();
  632. };
  633. }
  634. });
  635. const Badge = withInstall(stdin_default$1T);
  636. let globalZIndex = 2e3;
  637. const useGlobalZIndex = () => ++globalZIndex;
  638. const setGlobalZIndex = (val) => {
  639. globalZIndex = val;
  640. };
  641. const [name$1I, bem$1D] = createNamespace("config-provider");
  642. const CONFIG_PROVIDER_KEY = Symbol(name$1I);
  643. const configProviderProps = {
  644. tag: makeStringProp("div"),
  645. theme: makeStringProp("light"),
  646. zIndex: Number,
  647. themeVars: Object,
  648. themeVarsDark: Object,
  649. themeVarsLight: Object,
  650. themeVarsScope: makeStringProp("local"),
  651. iconPrefix: String
  652. };
  653. function insertDash(str) {
  654. return str.replace(/([a-zA-Z])(\d)/g, "$1-$2");
  655. }
  656. function mapThemeVarsToCSSVars(themeVars) {
  657. const cssVars = {};
  658. Object.keys(themeVars).forEach((key) => {
  659. const formattedKey = insertDash(kebabCase(key));
  660. cssVars[`--van-${formattedKey}`] = themeVars[key];
  661. });
  662. return cssVars;
  663. }
  664. function syncThemeVarsOnRoot(newStyle = {}, oldStyle = {}) {
  665. Object.keys(newStyle).forEach((key) => {
  666. if (newStyle[key] !== oldStyle[key]) {
  667. document.documentElement.style.setProperty(key, newStyle[key]);
  668. }
  669. });
  670. Object.keys(oldStyle).forEach((key) => {
  671. if (!newStyle[key]) {
  672. document.documentElement.style.removeProperty(key);
  673. }
  674. });
  675. }
  676. var stdin_default$1S = vue.defineComponent({
  677. name: name$1I,
  678. props: configProviderProps,
  679. setup(props2, {
  680. slots
  681. }) {
  682. const style = vue.computed(() => mapThemeVarsToCSSVars(extend({}, props2.themeVars, props2.theme === "dark" ? props2.themeVarsDark : props2.themeVarsLight)));
  683. if (inBrowser) {
  684. const addTheme = () => {
  685. document.documentElement.classList.add(`van-theme-${props2.theme}`);
  686. };
  687. const removeTheme = (theme = props2.theme) => {
  688. document.documentElement.classList.remove(`van-theme-${theme}`);
  689. };
  690. vue.watch(() => props2.theme, (newVal, oldVal) => {
  691. if (oldVal) {
  692. removeTheme(oldVal);
  693. }
  694. addTheme();
  695. }, {
  696. immediate: true
  697. });
  698. vue.onActivated(addTheme);
  699. vue.onDeactivated(removeTheme);
  700. vue.onBeforeUnmount(removeTheme);
  701. vue.watch(style, (newStyle, oldStyle) => {
  702. if (props2.themeVarsScope === "global") {
  703. syncThemeVarsOnRoot(newStyle, oldStyle);
  704. }
  705. });
  706. vue.watch(() => props2.themeVarsScope, (newScope, oldScope) => {
  707. if (oldScope === "global") {
  708. syncThemeVarsOnRoot({}, style.value);
  709. }
  710. if (newScope === "global") {
  711. syncThemeVarsOnRoot(style.value, {});
  712. }
  713. });
  714. if (props2.themeVarsScope === "global") {
  715. syncThemeVarsOnRoot(style.value, {});
  716. }
  717. }
  718. vue.provide(CONFIG_PROVIDER_KEY, props2);
  719. vue.watchEffect(() => {
  720. if (props2.zIndex !== void 0) {
  721. setGlobalZIndex(props2.zIndex);
  722. }
  723. });
  724. return () => vue.createVNode(props2.tag, {
  725. "class": bem$1D(),
  726. "style": props2.themeVarsScope === "local" ? style.value : void 0
  727. }, {
  728. default: () => {
  729. var _a;
  730. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  731. }
  732. });
  733. }
  734. });
  735. const [name$1H, bem$1C] = createNamespace("icon");
  736. const isImage$1 = (name2) => name2 == null ? void 0 : name2.includes("/");
  737. const iconProps = {
  738. dot: Boolean,
  739. tag: makeStringProp("i"),
  740. name: String,
  741. size: numericProp,
  742. badge: numericProp,
  743. color: String,
  744. badgeProps: Object,
  745. classPrefix: String
  746. };
  747. var stdin_default$1R = vue.defineComponent({
  748. name: name$1H,
  749. props: iconProps,
  750. setup(props2, {
  751. slots
  752. }) {
  753. const config = vue.inject(CONFIG_PROVIDER_KEY, null);
  754. const classPrefix = vue.computed(() => props2.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1C());
  755. return () => {
  756. const {
  757. tag,
  758. dot,
  759. name: name2,
  760. size,
  761. badge,
  762. color
  763. } = props2;
  764. const isImageIcon = isImage$1(name2);
  765. return vue.createVNode(Badge, vue.mergeProps({
  766. "dot": dot,
  767. "tag": tag,
  768. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  769. "style": {
  770. color,
  771. fontSize: addUnit(size)
  772. },
  773. "content": badge
  774. }, props2.badgeProps), {
  775. default: () => {
  776. var _a;
  777. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
  778. "class": bem$1C("image"),
  779. "src": name2
  780. }, null)];
  781. }
  782. });
  783. };
  784. }
  785. });
  786. const Icon = withInstall(stdin_default$1R);
  787. var stdin_default$1Q = Icon;
  788. const [name$1G, bem$1B] = createNamespace("loading");
  789. const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
  790. "class": bem$1B("line", String(index + 1))
  791. }, null));
  792. const CircularIcon = vue.createVNode("svg", {
  793. "class": bem$1B("circular"),
  794. "viewBox": "25 25 50 50"
  795. }, [vue.createVNode("circle", {
  796. "cx": "50",
  797. "cy": "50",
  798. "r": "20",
  799. "fill": "none"
  800. }, null)]);
  801. const loadingProps = {
  802. size: numericProp,
  803. type: makeStringProp("circular"),
  804. color: String,
  805. vertical: Boolean,
  806. textSize: numericProp,
  807. textColor: String
  808. };
  809. var stdin_default$1P = vue.defineComponent({
  810. name: name$1G,
  811. props: loadingProps,
  812. setup(props2, {
  813. slots
  814. }) {
  815. const spinnerStyle = vue.computed(() => extend({
  816. color: props2.color
  817. }, getSizeStyle(props2.size)));
  818. const renderIcon = () => {
  819. const DefaultIcon = props2.type === "spinner" ? SpinIcon : CircularIcon;
  820. return vue.createVNode("span", {
  821. "class": bem$1B("spinner", props2.type),
  822. "style": spinnerStyle.value
  823. }, [slots.icon ? slots.icon() : DefaultIcon]);
  824. };
  825. const renderText = () => {
  826. var _a;
  827. if (slots.default) {
  828. return vue.createVNode("span", {
  829. "class": bem$1B("text"),
  830. "style": {
  831. fontSize: addUnit(props2.textSize),
  832. color: (_a = props2.textColor) != null ? _a : props2.color
  833. }
  834. }, [slots.default()]);
  835. }
  836. };
  837. return () => {
  838. const {
  839. type,
  840. vertical
  841. } = props2;
  842. return vue.createVNode("div", {
  843. "class": bem$1B([type, {
  844. vertical
  845. }]),
  846. "aria-live": "polite",
  847. "aria-busy": true
  848. }, [renderIcon(), renderText()]);
  849. };
  850. }
  851. });
  852. const Loading = withInstall(stdin_default$1P);
  853. const [name$1F, bem$1A] = createNamespace("button");
  854. const buttonProps = extend({}, routeProps, {
  855. tag: makeStringProp("button"),
  856. text: String,
  857. icon: String,
  858. type: makeStringProp("default"),
  859. size: makeStringProp("normal"),
  860. color: String,
  861. block: Boolean,
  862. plain: Boolean,
  863. round: Boolean,
  864. square: Boolean,
  865. loading: Boolean,
  866. hairline: Boolean,
  867. disabled: Boolean,
  868. iconPrefix: String,
  869. nativeType: makeStringProp("button"),
  870. loadingSize: numericProp,
  871. loadingText: String,
  872. loadingType: String,
  873. iconPosition: makeStringProp("left")
  874. });
  875. var stdin_default$1O = vue.defineComponent({
  876. name: name$1F,
  877. props: buttonProps,
  878. emits: ["click"],
  879. setup(props2, {
  880. emit,
  881. slots
  882. }) {
  883. const route2 = useRoute();
  884. const renderLoadingIcon = () => {
  885. if (slots.loading) {
  886. return slots.loading();
  887. }
  888. return vue.createVNode(Loading, {
  889. "size": props2.loadingSize,
  890. "type": props2.loadingType,
  891. "class": bem$1A("loading")
  892. }, null);
  893. };
  894. const renderIcon = () => {
  895. if (props2.loading) {
  896. return renderLoadingIcon();
  897. }
  898. if (slots.icon) {
  899. return vue.createVNode("div", {
  900. "class": bem$1A("icon")
  901. }, [slots.icon()]);
  902. }
  903. if (props2.icon) {
  904. return vue.createVNode(Icon, {
  905. "name": props2.icon,
  906. "class": bem$1A("icon"),
  907. "classPrefix": props2.iconPrefix
  908. }, null);
  909. }
  910. };
  911. const renderText = () => {
  912. let text;
  913. if (props2.loading) {
  914. text = props2.loadingText;
  915. } else {
  916. text = slots.default ? slots.default() : props2.text;
  917. }
  918. if (text) {
  919. return vue.createVNode("span", {
  920. "class": bem$1A("text")
  921. }, [text]);
  922. }
  923. };
  924. const getStyle = () => {
  925. const {
  926. color,
  927. plain
  928. } = props2;
  929. if (color) {
  930. const style = {
  931. color: plain ? color : "white"
  932. };
  933. if (!plain) {
  934. style.background = color;
  935. }
  936. if (color.includes("gradient")) {
  937. style.border = 0;
  938. } else {
  939. style.borderColor = color;
  940. }
  941. return style;
  942. }
  943. };
  944. const onClick = (event) => {
  945. if (props2.loading) {
  946. preventDefault(event);
  947. } else if (!props2.disabled) {
  948. emit("click", event);
  949. route2();
  950. }
  951. };
  952. return () => {
  953. const {
  954. tag,
  955. type,
  956. size,
  957. block,
  958. round,
  959. plain,
  960. square,
  961. loading,
  962. disabled,
  963. hairline,
  964. nativeType,
  965. iconPosition
  966. } = props2;
  967. const classes = [bem$1A([type, size, {
  968. plain,
  969. block,
  970. round,
  971. square,
  972. loading,
  973. disabled,
  974. hairline
  975. }]), {
  976. [BORDER_SURROUND]: hairline
  977. }];
  978. return vue.createVNode(tag, {
  979. "type": nativeType,
  980. "class": classes,
  981. "style": getStyle(),
  982. "disabled": disabled,
  983. "onClick": onClick
  984. }, {
  985. default: () => [vue.createVNode("div", {
  986. "class": bem$1A("content")
  987. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  988. });
  989. };
  990. }
  991. });
  992. const Button = withInstall(stdin_default$1O);
  993. const [name$1E, bem$1z] = createNamespace("action-bar-button");
  994. const actionBarButtonProps = extend({}, routeProps, {
  995. type: String,
  996. text: String,
  997. icon: String,
  998. color: String,
  999. loading: Boolean,
  1000. disabled: Boolean
  1001. });
  1002. var stdin_default$1N = vue.defineComponent({
  1003. name: name$1E,
  1004. props: actionBarButtonProps,
  1005. setup(props2, {
  1006. slots
  1007. }) {
  1008. const route2 = useRoute();
  1009. const {
  1010. parent,
  1011. index
  1012. } = use.useParent(ACTION_BAR_KEY);
  1013. const isFirst = vue.computed(() => {
  1014. if (parent) {
  1015. const prev = parent.children[index.value - 1];
  1016. return !(prev && "isButton" in prev);
  1017. }
  1018. });
  1019. const isLast = vue.computed(() => {
  1020. if (parent) {
  1021. const next = parent.children[index.value + 1];
  1022. return !(next && "isButton" in next);
  1023. }
  1024. });
  1025. useExpose({
  1026. isButton: true
  1027. });
  1028. return () => {
  1029. const {
  1030. type,
  1031. icon,
  1032. text,
  1033. color,
  1034. loading,
  1035. disabled
  1036. } = props2;
  1037. return vue.createVNode(Button, {
  1038. "class": bem$1z([type, {
  1039. last: isLast.value,
  1040. first: isFirst.value
  1041. }]),
  1042. "size": "large",
  1043. "type": type,
  1044. "icon": icon,
  1045. "color": color,
  1046. "loading": loading,
  1047. "disabled": disabled,
  1048. "onClick": route2
  1049. }, {
  1050. default: () => [slots.default ? slots.default() : text]
  1051. });
  1052. };
  1053. }
  1054. });
  1055. const ActionBarButton = withInstall(stdin_default$1N);
  1056. const [name$1D, bem$1y] = createNamespace("action-bar-icon");
  1057. const actionBarIconProps = extend({}, routeProps, {
  1058. dot: Boolean,
  1059. text: String,
  1060. icon: String,
  1061. color: String,
  1062. badge: numericProp,
  1063. iconClass: unknownProp,
  1064. badgeProps: Object,
  1065. iconPrefix: String
  1066. });
  1067. var stdin_default$1M = vue.defineComponent({
  1068. name: name$1D,
  1069. props: actionBarIconProps,
  1070. setup(props2, {
  1071. slots
  1072. }) {
  1073. const route2 = useRoute();
  1074. use.useParent(ACTION_BAR_KEY);
  1075. const renderIcon = () => {
  1076. const {
  1077. dot,
  1078. badge,
  1079. icon,
  1080. color,
  1081. iconClass,
  1082. badgeProps: badgeProps2,
  1083. iconPrefix
  1084. } = props2;
  1085. if (slots.icon) {
  1086. return vue.createVNode(Badge, vue.mergeProps({
  1087. "dot": dot,
  1088. "class": bem$1y("icon"),
  1089. "content": badge
  1090. }, badgeProps2), {
  1091. default: slots.icon
  1092. });
  1093. }
  1094. return vue.createVNode(Icon, {
  1095. "tag": "div",
  1096. "dot": dot,
  1097. "name": icon,
  1098. "badge": badge,
  1099. "color": color,
  1100. "class": [bem$1y("icon"), iconClass],
  1101. "badgeProps": badgeProps2,
  1102. "classPrefix": iconPrefix
  1103. }, null);
  1104. };
  1105. return () => vue.createVNode("div", {
  1106. "role": "button",
  1107. "class": bem$1y(),
  1108. "tabindex": 0,
  1109. "onClick": route2
  1110. }, [renderIcon(), slots.default ? slots.default() : props2.text]);
  1111. }
  1112. });
  1113. const ActionBarIcon = withInstall(stdin_default$1M);
  1114. const popupSharedProps = {
  1115. // whether to show popup
  1116. show: Boolean,
  1117. // z-index
  1118. zIndex: numericProp,
  1119. // whether to show overlay
  1120. overlay: truthProp,
  1121. // transition duration
  1122. duration: numericProp,
  1123. // teleport
  1124. teleport: [String, Object],
  1125. // prevent body scroll
  1126. lockScroll: truthProp,
  1127. // whether to lazy render
  1128. lazyRender: truthProp,
  1129. // callback function before close
  1130. beforeClose: Function,
  1131. // overlay custom style
  1132. overlayStyle: Object,
  1133. // overlay custom class name
  1134. overlayClass: unknownProp,
  1135. // Initial rendering animation
  1136. transitionAppear: Boolean,
  1137. // whether to close popup when overlay is clicked
  1138. closeOnClickOverlay: truthProp
  1139. };
  1140. const popupSharedPropKeys = Object.keys(
  1141. popupSharedProps
  1142. );
  1143. function getDirection(x, y) {
  1144. if (x > y) {
  1145. return "horizontal";
  1146. }
  1147. if (y > x) {
  1148. return "vertical";
  1149. }
  1150. return "";
  1151. }
  1152. function useTouch() {
  1153. const startX = vue.ref(0);
  1154. const startY = vue.ref(0);
  1155. const deltaX = vue.ref(0);
  1156. const deltaY = vue.ref(0);
  1157. const offsetX = vue.ref(0);
  1158. const offsetY = vue.ref(0);
  1159. const direction = vue.ref("");
  1160. const isTap = vue.ref(true);
  1161. const isVertical = () => direction.value === "vertical";
  1162. const isHorizontal = () => direction.value === "horizontal";
  1163. const reset = () => {
  1164. deltaX.value = 0;
  1165. deltaY.value = 0;
  1166. offsetX.value = 0;
  1167. offsetY.value = 0;
  1168. direction.value = "";
  1169. isTap.value = true;
  1170. };
  1171. const start = (event) => {
  1172. reset();
  1173. startX.value = event.touches[0].clientX;
  1174. startY.value = event.touches[0].clientY;
  1175. };
  1176. const move = (event) => {
  1177. const touch = event.touches[0];
  1178. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1179. deltaY.value = touch.clientY - startY.value;
  1180. offsetX.value = Math.abs(deltaX.value);
  1181. offsetY.value = Math.abs(deltaY.value);
  1182. const LOCK_DIRECTION_DISTANCE = 10;
  1183. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1184. direction.value = getDirection(offsetX.value, offsetY.value);
  1185. }
  1186. if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
  1187. isTap.value = false;
  1188. }
  1189. };
  1190. return {
  1191. move,
  1192. start,
  1193. reset,
  1194. startX,
  1195. startY,
  1196. deltaX,
  1197. deltaY,
  1198. offsetX,
  1199. offsetY,
  1200. direction,
  1201. isVertical,
  1202. isHorizontal,
  1203. isTap
  1204. };
  1205. }
  1206. let totalLockCount = 0;
  1207. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1208. function useLockScroll(rootRef, shouldLock) {
  1209. const touch = useTouch();
  1210. const DIRECTION_UP = "01";
  1211. const DIRECTION_DOWN = "10";
  1212. const onTouchMove = (event) => {
  1213. touch.move(event);
  1214. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1215. const el = use.getScrollParent(
  1216. event.target,
  1217. rootRef.value
  1218. );
  1219. const { scrollHeight, offsetHeight, scrollTop } = el;
  1220. let status = "11";
  1221. if (scrollTop === 0) {
  1222. status = offsetHeight >= scrollHeight ? "00" : "01";
  1223. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1224. status = "10";
  1225. }
  1226. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1227. preventDefault(event, true);
  1228. }
  1229. };
  1230. const lock = () => {
  1231. document.addEventListener("touchstart", touch.start);
  1232. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1233. if (!totalLockCount) {
  1234. document.body.classList.add(BODY_LOCK_CLASS);
  1235. }
  1236. totalLockCount++;
  1237. };
  1238. const unlock = () => {
  1239. if (totalLockCount) {
  1240. document.removeEventListener("touchstart", touch.start);
  1241. document.removeEventListener("touchmove", onTouchMove);
  1242. totalLockCount--;
  1243. if (!totalLockCount) {
  1244. document.body.classList.remove(BODY_LOCK_CLASS);
  1245. }
  1246. }
  1247. };
  1248. const init = () => shouldLock() && lock();
  1249. const destroy = () => shouldLock() && unlock();
  1250. use.onMountedOrActivated(init);
  1251. vue.onDeactivated(destroy);
  1252. vue.onBeforeUnmount(destroy);
  1253. vue.watch(shouldLock, (value) => {
  1254. value ? lock() : unlock();
  1255. });
  1256. }
  1257. function useLazyRender(show) {
  1258. const inited = vue.ref(false);
  1259. vue.watch(
  1260. show,
  1261. (value) => {
  1262. if (value) {
  1263. inited.value = value;
  1264. }
  1265. },
  1266. { immediate: true }
  1267. );
  1268. return (render) => () => inited.value ? render() : null;
  1269. }
  1270. const useScopeId = () => {
  1271. var _a;
  1272. const { scopeId } = ((_a = vue.getCurrentInstance()) == null ? void 0 : _a.vnode) || {};
  1273. return scopeId ? { [scopeId]: "" } : null;
  1274. };
  1275. const [name$1C, bem$1x] = createNamespace("overlay");
  1276. const overlayProps = {
  1277. show: Boolean,
  1278. zIndex: numericProp,
  1279. duration: numericProp,
  1280. className: unknownProp,
  1281. lockScroll: truthProp,
  1282. lazyRender: truthProp,
  1283. customStyle: Object,
  1284. teleport: [String, Object]
  1285. };
  1286. var stdin_default$1L = vue.defineComponent({
  1287. name: name$1C,
  1288. props: overlayProps,
  1289. setup(props2, {
  1290. slots
  1291. }) {
  1292. const root = vue.ref();
  1293. const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
  1294. const onTouchMove = (event) => {
  1295. if (props2.lockScroll) {
  1296. preventDefault(event, true);
  1297. }
  1298. };
  1299. const renderOverlay = lazyRender(() => {
  1300. var _a;
  1301. const style = extend(getZIndexStyle(props2.zIndex), props2.customStyle);
  1302. if (isDef(props2.duration)) {
  1303. style.animationDuration = `${props2.duration}s`;
  1304. }
  1305. return vue.withDirectives(vue.createVNode("div", {
  1306. "ref": root,
  1307. "style": style,
  1308. "class": [bem$1x(), props2.className]
  1309. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props2.show]]);
  1310. });
  1311. use.useEventListener("touchmove", onTouchMove, {
  1312. target: root
  1313. });
  1314. return () => {
  1315. const Content = vue.createVNode(vue.Transition, {
  1316. "name": "van-fade",
  1317. "appear": true
  1318. }, {
  1319. default: renderOverlay
  1320. });
  1321. if (props2.teleport) {
  1322. return vue.createVNode(vue.Teleport, {
  1323. "to": props2.teleport
  1324. }, {
  1325. default: () => [Content]
  1326. });
  1327. }
  1328. return Content;
  1329. };
  1330. }
  1331. });
  1332. const Overlay = withInstall(stdin_default$1L);
  1333. const popupProps$2 = extend({}, popupSharedProps, {
  1334. round: Boolean,
  1335. position: makeStringProp("center"),
  1336. closeIcon: makeStringProp("cross"),
  1337. closeable: Boolean,
  1338. transition: String,
  1339. iconPrefix: String,
  1340. closeOnPopstate: Boolean,
  1341. closeIconPosition: makeStringProp("top-right"),
  1342. safeAreaInsetTop: Boolean,
  1343. safeAreaInsetBottom: Boolean
  1344. });
  1345. const [name$1B, bem$1w] = createNamespace("popup");
  1346. var stdin_default$1K = vue.defineComponent({
  1347. name: name$1B,
  1348. inheritAttrs: false,
  1349. props: popupProps$2,
  1350. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
  1351. setup(props2, {
  1352. emit,
  1353. attrs,
  1354. slots
  1355. }) {
  1356. let opened;
  1357. let shouldReopen;
  1358. const zIndex = vue.ref();
  1359. const popupRef = vue.ref();
  1360. const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
  1361. const style = vue.computed(() => {
  1362. const style2 = {
  1363. zIndex: zIndex.value
  1364. };
  1365. if (isDef(props2.duration)) {
  1366. const key = props2.position === "center" ? "animationDuration" : "transitionDuration";
  1367. style2[key] = `${props2.duration}s`;
  1368. }
  1369. return style2;
  1370. });
  1371. const open = () => {
  1372. if (!opened) {
  1373. opened = true;
  1374. zIndex.value = props2.zIndex !== void 0 ? +props2.zIndex : useGlobalZIndex();
  1375. emit("open");
  1376. }
  1377. };
  1378. const close = () => {
  1379. if (opened) {
  1380. callInterceptor(props2.beforeClose, {
  1381. done() {
  1382. opened = false;
  1383. emit("close");
  1384. emit("update:show", false);
  1385. }
  1386. });
  1387. }
  1388. };
  1389. const onClickOverlay = (event) => {
  1390. emit("clickOverlay", event);
  1391. if (props2.closeOnClickOverlay) {
  1392. close();
  1393. }
  1394. };
  1395. const renderOverlay = () => {
  1396. if (props2.overlay) {
  1397. return vue.createVNode(Overlay, vue.mergeProps({
  1398. "show": props2.show,
  1399. "class": props2.overlayClass,
  1400. "zIndex": zIndex.value,
  1401. "duration": props2.duration,
  1402. "customStyle": props2.overlayStyle,
  1403. "role": props2.closeOnClickOverlay ? "button" : void 0,
  1404. "tabindex": props2.closeOnClickOverlay ? 0 : void 0
  1405. }, useScopeId(), {
  1406. "onClick": onClickOverlay
  1407. }), {
  1408. default: slots["overlay-content"]
  1409. });
  1410. }
  1411. };
  1412. const onClickCloseIcon = (event) => {
  1413. emit("clickCloseIcon", event);
  1414. close();
  1415. };
  1416. const renderCloseIcon = () => {
  1417. if (props2.closeable) {
  1418. return vue.createVNode(Icon, {
  1419. "role": "button",
  1420. "tabindex": 0,
  1421. "name": props2.closeIcon,
  1422. "class": [bem$1w("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
  1423. "classPrefix": props2.iconPrefix,
  1424. "onClick": onClickCloseIcon
  1425. }, null);
  1426. }
  1427. };
  1428. let timer2;
  1429. const onOpened = () => {
  1430. if (timer2) clearTimeout(timer2);
  1431. timer2 = setTimeout(() => {
  1432. emit("opened");
  1433. });
  1434. };
  1435. const onClosed = () => emit("closed");
  1436. const onKeydown = (event) => emit("keydown", event);
  1437. const renderPopup = lazyRender(() => {
  1438. var _a;
  1439. const {
  1440. round,
  1441. position,
  1442. safeAreaInsetTop,
  1443. safeAreaInsetBottom
  1444. } = props2;
  1445. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  1446. "ref": popupRef,
  1447. "style": style.value,
  1448. "role": "dialog",
  1449. "tabindex": 0,
  1450. "class": [bem$1w({
  1451. round,
  1452. [position]: position
  1453. }), {
  1454. "van-safe-area-top": safeAreaInsetTop,
  1455. "van-safe-area-bottom": safeAreaInsetBottom
  1456. }],
  1457. "onKeydown": onKeydown
  1458. }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props2.show]]);
  1459. });
  1460. const renderTransition = () => {
  1461. const {
  1462. position,
  1463. transition,
  1464. transitionAppear
  1465. } = props2;
  1466. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1467. return vue.createVNode(vue.Transition, {
  1468. "name": transition || name2,
  1469. "appear": transitionAppear,
  1470. "onAfterEnter": onOpened,
  1471. "onAfterLeave": onClosed
  1472. }, {
  1473. default: renderPopup
  1474. });
  1475. };
  1476. vue.watch(() => props2.show, (show) => {
  1477. if (show && !opened) {
  1478. open();
  1479. if (attrs.tabindex === 0) {
  1480. vue.nextTick(() => {
  1481. var _a;
  1482. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1483. });
  1484. }
  1485. }
  1486. if (!show && opened) {
  1487. opened = false;
  1488. emit("close");
  1489. }
  1490. });
  1491. useExpose({
  1492. popupRef
  1493. });
  1494. useLockScroll(popupRef, () => props2.show && props2.lockScroll);
  1495. use.useEventListener("popstate", () => {
  1496. if (props2.closeOnPopstate) {
  1497. close();
  1498. shouldReopen = false;
  1499. }
  1500. });
  1501. vue.onMounted(() => {
  1502. if (props2.show) {
  1503. open();
  1504. }
  1505. });
  1506. vue.onActivated(() => {
  1507. if (shouldReopen) {
  1508. emit("update:show", true);
  1509. shouldReopen = false;
  1510. }
  1511. });
  1512. vue.onDeactivated(() => {
  1513. if (props2.show && props2.teleport) {
  1514. close();
  1515. shouldReopen = true;
  1516. }
  1517. });
  1518. vue.provide(POPUP_TOGGLE_KEY, () => props2.show);
  1519. return () => {
  1520. if (props2.teleport) {
  1521. return vue.createVNode(vue.Teleport, {
  1522. "to": props2.teleport
  1523. }, {
  1524. default: () => [renderOverlay(), renderTransition()]
  1525. });
  1526. }
  1527. return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
  1528. };
  1529. }
  1530. });
  1531. const Popup = withInstall(stdin_default$1K);
  1532. const [name$1A, bem$1v] = createNamespace("action-sheet");
  1533. const actionSheetProps = extend({}, popupSharedProps, {
  1534. title: String,
  1535. round: truthProp,
  1536. actions: makeArrayProp(),
  1537. closeIcon: makeStringProp("cross"),
  1538. closeable: truthProp,
  1539. cancelText: String,
  1540. description: String,
  1541. closeOnPopstate: truthProp,
  1542. closeOnClickAction: Boolean,
  1543. safeAreaInsetBottom: truthProp
  1544. });
  1545. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1546. var stdin_default$1J = vue.defineComponent({
  1547. name: name$1A,
  1548. props: actionSheetProps,
  1549. emits: ["select", "cancel", "update:show"],
  1550. setup(props2, {
  1551. slots,
  1552. emit
  1553. }) {
  1554. const updateShow = (show) => emit("update:show", show);
  1555. const onCancel = () => {
  1556. updateShow(false);
  1557. emit("cancel");
  1558. };
  1559. const renderHeader = () => {
  1560. if (props2.title) {
  1561. return vue.createVNode("div", {
  1562. "class": bem$1v("header")
  1563. }, [props2.title, props2.closeable && vue.createVNode(Icon, {
  1564. "name": props2.closeIcon,
  1565. "class": [bem$1v("close"), HAPTICS_FEEDBACK],
  1566. "onClick": onCancel
  1567. }, null)]);
  1568. }
  1569. };
  1570. const renderCancel = () => {
  1571. if (slots.cancel || props2.cancelText) {
  1572. return [vue.createVNode("div", {
  1573. "class": bem$1v("gap")
  1574. }, null), vue.createVNode("button", {
  1575. "type": "button",
  1576. "class": bem$1v("cancel"),
  1577. "onClick": onCancel
  1578. }, [slots.cancel ? slots.cancel() : props2.cancelText])];
  1579. }
  1580. };
  1581. const renderIcon = (action) => {
  1582. if (action.icon) {
  1583. return vue.createVNode(Icon, {
  1584. "class": bem$1v("item-icon"),
  1585. "name": action.icon
  1586. }, null);
  1587. }
  1588. };
  1589. const renderActionContent = (action, index) => {
  1590. if (action.loading) {
  1591. return vue.createVNode(Loading, {
  1592. "class": bem$1v("loading-icon")
  1593. }, null);
  1594. }
  1595. if (slots.action) {
  1596. return slots.action({
  1597. action,
  1598. index
  1599. });
  1600. }
  1601. return [vue.createVNode("span", {
  1602. "class": bem$1v("name")
  1603. }, [action.name]), action.subname && vue.createVNode("div", {
  1604. "class": bem$1v("subname")
  1605. }, [action.subname])];
  1606. };
  1607. const renderAction = (action, index) => {
  1608. const {
  1609. color,
  1610. loading,
  1611. callback,
  1612. disabled,
  1613. className
  1614. } = action;
  1615. const onClick = () => {
  1616. if (disabled || loading) {
  1617. return;
  1618. }
  1619. if (callback) {
  1620. callback(action);
  1621. }
  1622. if (props2.closeOnClickAction) {
  1623. updateShow(false);
  1624. }
  1625. vue.nextTick(() => emit("select", action, index));
  1626. };
  1627. return vue.createVNode("button", {
  1628. "type": "button",
  1629. "style": {
  1630. color
  1631. },
  1632. "class": [bem$1v("item", {
  1633. loading,
  1634. disabled
  1635. }), className],
  1636. "onClick": onClick
  1637. }, [renderIcon(action), renderActionContent(action, index)]);
  1638. };
  1639. const renderDescription = () => {
  1640. if (props2.description || slots.description) {
  1641. const content = slots.description ? slots.description() : props2.description;
  1642. return vue.createVNode("div", {
  1643. "class": bem$1v("description")
  1644. }, [content]);
  1645. }
  1646. };
  1647. return () => vue.createVNode(Popup, vue.mergeProps({
  1648. "class": bem$1v(),
  1649. "position": "bottom",
  1650. "onUpdate:show": updateShow
  1651. }, pick(props2, popupInheritKeys$2)), {
  1652. default: () => {
  1653. var _a;
  1654. return [renderHeader(), renderDescription(), vue.createVNode("div", {
  1655. "class": bem$1v("content")
  1656. }, [props2.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1657. }
  1658. });
  1659. }
  1660. });
  1661. const ActionSheet = withInstall(stdin_default$1J);
  1662. const [name$1z, bem$1u, t$k] = createNamespace("picker");
  1663. const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
  1664. function getColumnsType(columns, fields) {
  1665. const firstColumn = columns[0];
  1666. if (firstColumn) {
  1667. if (Array.isArray(firstColumn)) {
  1668. return "multiple";
  1669. }
  1670. if (fields.children in firstColumn) {
  1671. return "cascade";
  1672. }
  1673. }
  1674. return "default";
  1675. }
  1676. function findIndexOfEnabledOption(options, index) {
  1677. index = clamp(index, 0, options.length);
  1678. for (let i = index; i < options.length; i++) {
  1679. if (!options[i].disabled) return i;
  1680. }
  1681. for (let i = index - 1; i >= 0; i--) {
  1682. if (!options[i].disabled) return i;
  1683. }
  1684. return 0;
  1685. }
  1686. const isOptionExist = (options, value, fields) => value !== void 0 && !!options.find((option) => option[fields.value] === value);
  1687. function findOptionByValue(options, value, fields) {
  1688. const index = options.findIndex((option) => option[fields.value] === value);
  1689. const enabledIndex = findIndexOfEnabledOption(options, index);
  1690. return options[enabledIndex];
  1691. }
  1692. function formatCascadeColumns(columns, fields, selectedValues) {
  1693. const formatted = [];
  1694. let cursor = {
  1695. [fields.children]: columns
  1696. };
  1697. let columnIndex = 0;
  1698. while (cursor && cursor[fields.children]) {
  1699. const options = cursor[fields.children];
  1700. const value = selectedValues.value[columnIndex];
  1701. cursor = isDef(value) ? findOptionByValue(options, value, fields) : void 0;
  1702. if (!cursor && options.length) {
  1703. const firstValue = getFirstEnabledOption(options)[fields.value];
  1704. cursor = findOptionByValue(options, firstValue, fields);
  1705. }
  1706. columnIndex++;
  1707. formatted.push(options);
  1708. }
  1709. return formatted;
  1710. }
  1711. function getElementTranslateY(element) {
  1712. const { transform } = window.getComputedStyle(element);
  1713. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1714. return Number(translateY);
  1715. }
  1716. function assignDefaultFields(fields) {
  1717. return extend(
  1718. {
  1719. text: "text",
  1720. value: "value",
  1721. children: "children"
  1722. },
  1723. fields
  1724. );
  1725. }
  1726. const DEFAULT_DURATION = 200;
  1727. const MOMENTUM_TIME = 300;
  1728. const MOMENTUM_DISTANCE = 15;
  1729. const [name$1y, bem$1t] = createNamespace("picker-column");
  1730. const PICKER_KEY = Symbol(name$1y);
  1731. var stdin_default$1I = vue.defineComponent({
  1732. name: name$1y,
  1733. props: {
  1734. value: numericProp,
  1735. fields: makeRequiredProp(Object),
  1736. options: makeArrayProp(),
  1737. readonly: Boolean,
  1738. allowHtml: Boolean,
  1739. optionHeight: makeRequiredProp(Number),
  1740. swipeDuration: makeRequiredProp(numericProp),
  1741. visibleOptionNum: makeRequiredProp(numericProp)
  1742. },
  1743. emits: ["change", "clickOption", "scrollInto"],
  1744. setup(props2, {
  1745. emit,
  1746. slots
  1747. }) {
  1748. let moving;
  1749. let startOffset;
  1750. let touchStartTime;
  1751. let momentumOffset;
  1752. let transitionEndTrigger;
  1753. const root = vue.ref();
  1754. const wrapper = vue.ref();
  1755. const currentOffset = vue.ref(0);
  1756. const currentDuration = vue.ref(0);
  1757. const touch = useTouch();
  1758. const count = () => props2.options.length;
  1759. const baseOffset = () => props2.optionHeight * (+props2.visibleOptionNum - 1) / 2;
  1760. const updateValueByIndex = (index) => {
  1761. let enabledIndex = findIndexOfEnabledOption(props2.options, index);
  1762. const offset = -enabledIndex * props2.optionHeight;
  1763. const trigger = () => {
  1764. if (enabledIndex > count() - 1) {
  1765. enabledIndex = findIndexOfEnabledOption(props2.options, index);
  1766. }
  1767. const value = props2.options[enabledIndex][props2.fields.value];
  1768. if (value !== props2.value) {
  1769. emit("change", value);
  1770. }
  1771. };
  1772. if (moving && offset !== currentOffset.value) {
  1773. transitionEndTrigger = trigger;
  1774. } else {
  1775. trigger();
  1776. }
  1777. currentOffset.value = offset;
  1778. };
  1779. const isReadonly = () => props2.readonly || !props2.options.length;
  1780. const onClickOption = (index) => {
  1781. if (moving || isReadonly()) {
  1782. return;
  1783. }
  1784. transitionEndTrigger = null;
  1785. currentDuration.value = DEFAULT_DURATION;
  1786. updateValueByIndex(index);
  1787. emit("clickOption", props2.options[index]);
  1788. };
  1789. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props2.optionHeight), 0, count() - 1);
  1790. const currentIndex = vue.computed(() => getIndexByOffset(currentOffset.value));
  1791. const momentum = (distance, duration) => {
  1792. const speed = Math.abs(distance / duration);
  1793. distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1794. const index = getIndexByOffset(distance);
  1795. currentDuration.value = +props2.swipeDuration;
  1796. updateValueByIndex(index);
  1797. };
  1798. const stopMomentum = () => {
  1799. moving = false;
  1800. currentDuration.value = 0;
  1801. if (transitionEndTrigger) {
  1802. transitionEndTrigger();
  1803. transitionEndTrigger = null;
  1804. }
  1805. };
  1806. const onTouchStart = (event) => {
  1807. if (isReadonly()) {
  1808. return;
  1809. }
  1810. touch.start(event);
  1811. if (moving) {
  1812. const translateY = getElementTranslateY(wrapper.value);
  1813. currentOffset.value = Math.min(0, translateY - baseOffset());
  1814. }
  1815. currentDuration.value = 0;
  1816. startOffset = currentOffset.value;
  1817. touchStartTime = Date.now();
  1818. momentumOffset = startOffset;
  1819. transitionEndTrigger = null;
  1820. };
  1821. const onTouchMove = (event) => {
  1822. if (isReadonly()) {
  1823. return;
  1824. }
  1825. touch.move(event);
  1826. if (touch.isVertical()) {
  1827. moving = true;
  1828. preventDefault(event, true);
  1829. }
  1830. const newOffset = clamp(startOffset + touch.deltaY.value, -(count() * props2.optionHeight), props2.optionHeight);
  1831. const newIndex = getIndexByOffset(newOffset);
  1832. if (newIndex !== currentIndex.value) {
  1833. emit("scrollInto", props2.options[newIndex]);
  1834. }
  1835. currentOffset.value = newOffset;
  1836. const now = Date.now();
  1837. if (now - touchStartTime > MOMENTUM_TIME) {
  1838. touchStartTime = now;
  1839. momentumOffset = newOffset;
  1840. }
  1841. };
  1842. const onTouchEnd = () => {
  1843. if (isReadonly()) {
  1844. return;
  1845. }
  1846. const distance = currentOffset.value - momentumOffset;
  1847. const duration = Date.now() - touchStartTime;
  1848. const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
  1849. if (startMomentum) {
  1850. momentum(distance, duration);
  1851. return;
  1852. }
  1853. const index = getIndexByOffset(currentOffset.value);
  1854. currentDuration.value = DEFAULT_DURATION;
  1855. updateValueByIndex(index);
  1856. setTimeout(() => {
  1857. moving = false;
  1858. }, 0);
  1859. };
  1860. const renderOptions = () => {
  1861. const optionStyle = {
  1862. height: `${props2.optionHeight}px`
  1863. };
  1864. return props2.options.map((option, index) => {
  1865. const text = option[props2.fields.text];
  1866. const {
  1867. disabled
  1868. } = option;
  1869. const value = option[props2.fields.value];
  1870. const data = {
  1871. role: "button",
  1872. style: optionStyle,
  1873. tabindex: disabled ? -1 : 0,
  1874. class: [bem$1t("item", {
  1875. disabled,
  1876. selected: value === props2.value
  1877. }), option.className],
  1878. onClick: () => onClickOption(index)
  1879. };
  1880. const childData = {
  1881. class: "van-ellipsis",
  1882. [props2.allowHtml ? "innerHTML" : "textContent"]: text
  1883. };
  1884. return vue.createVNode("li", data, [slots.option ? slots.option(option, index) : vue.createVNode("div", childData, null)]);
  1885. });
  1886. };
  1887. use.useParent(PICKER_KEY);
  1888. useExpose({
  1889. stopMomentum
  1890. });
  1891. vue.watchEffect(() => {
  1892. const index = moving ? Math.floor(-currentOffset.value / props2.optionHeight) : props2.options.findIndex((option) => option[props2.fields.value] === props2.value);
  1893. const enabledIndex = findIndexOfEnabledOption(props2.options, index);
  1894. const offset = -enabledIndex * props2.optionHeight;
  1895. if (moving && enabledIndex < index) stopMomentum();
  1896. currentOffset.value = offset;
  1897. });
  1898. use.useEventListener("touchmove", onTouchMove, {
  1899. target: root
  1900. });
  1901. return () => vue.createVNode("div", {
  1902. "ref": root,
  1903. "class": bem$1t(),
  1904. "onTouchstartPassive": onTouchStart,
  1905. "onTouchend": onTouchEnd,
  1906. "onTouchcancel": onTouchEnd
  1907. }, [vue.createVNode("ul", {
  1908. "ref": wrapper,
  1909. "style": {
  1910. transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
  1911. transitionDuration: `${currentDuration.value}ms`,
  1912. transitionProperty: currentDuration.value ? "all" : "none"
  1913. },
  1914. "class": bem$1t("wrapper"),
  1915. "onTransitionend": stopMomentum
  1916. }, [renderOptions()])]);
  1917. }
  1918. });
  1919. const [name$1x] = createNamespace("picker-toolbar");
  1920. const pickerToolbarProps = {
  1921. title: String,
  1922. cancelButtonText: String,
  1923. confirmButtonText: String
  1924. };
  1925. const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
  1926. const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
  1927. var stdin_default$1H = vue.defineComponent({
  1928. name: name$1x,
  1929. props: pickerToolbarProps,
  1930. emits: ["confirm", "cancel"],
  1931. setup(props2, {
  1932. emit,
  1933. slots
  1934. }) {
  1935. const renderTitle = () => {
  1936. if (slots.title) {
  1937. return slots.title();
  1938. }
  1939. if (props2.title) {
  1940. return vue.createVNode("div", {
  1941. "class": [bem$1u("title"), "van-ellipsis"]
  1942. }, [props2.title]);
  1943. }
  1944. };
  1945. const onCancel = () => emit("cancel");
  1946. const onConfirm = () => emit("confirm");
  1947. const renderCancel = () => {
  1948. var _a;
  1949. const text = (_a = props2.cancelButtonText) != null ? _a : t$k("cancel");
  1950. if (!slots.cancel && !text) {
  1951. return;
  1952. }
  1953. return vue.createVNode("button", {
  1954. "type": "button",
  1955. "class": [bem$1u("cancel"), HAPTICS_FEEDBACK],
  1956. "onClick": onCancel
  1957. }, [slots.cancel ? slots.cancel() : text]);
  1958. };
  1959. const renderConfirm = () => {
  1960. var _a;
  1961. const text = (_a = props2.confirmButtonText) != null ? _a : t$k("confirm");
  1962. if (!slots.confirm && !text) {
  1963. return;
  1964. }
  1965. return vue.createVNode("button", {
  1966. "type": "button",
  1967. "class": [bem$1u("confirm"), HAPTICS_FEEDBACK],
  1968. "onClick": onConfirm
  1969. }, [slots.confirm ? slots.confirm() : text]);
  1970. };
  1971. return () => vue.createVNode("div", {
  1972. "class": bem$1u("toolbar")
  1973. }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1974. }
  1975. });
  1976. const useSyncPropRef = (getProp, setProp) => {
  1977. const propRef = vue.ref(getProp());
  1978. vue.watch(getProp, (value) => {
  1979. if (value !== propRef.value) {
  1980. propRef.value = value;
  1981. }
  1982. });
  1983. vue.watch(propRef, (value) => {
  1984. if (value !== getProp()) {
  1985. setProp(value);
  1986. }
  1987. });
  1988. return propRef;
  1989. };
  1990. function scrollLeftTo(scroller, to, duration) {
  1991. let rafId;
  1992. let count = 0;
  1993. const from = scroller.scrollLeft;
  1994. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  1995. let scrollLeft = from;
  1996. function cancel() {
  1997. use.cancelRaf(rafId);
  1998. }
  1999. function animate() {
  2000. scrollLeft += (to - from) / frames;
  2001. scroller.scrollLeft = scrollLeft;
  2002. if (++count < frames) {
  2003. rafId = use.raf(animate);
  2004. }
  2005. }
  2006. animate();
  2007. return cancel;
  2008. }
  2009. function scrollTopTo(scroller, to, duration, callback) {
  2010. let rafId;
  2011. let current2 = getScrollTop(scroller);
  2012. const isDown = current2 < to;
  2013. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  2014. const step = (to - current2) / frames;
  2015. function cancel() {
  2016. use.cancelRaf(rafId);
  2017. }
  2018. function animate() {
  2019. current2 += step;
  2020. if (isDown && current2 > to || !isDown && current2 < to) {
  2021. current2 = to;
  2022. }
  2023. setScrollTop(scroller, current2);
  2024. if (isDown && current2 < to || !isDown && current2 > to) {
  2025. rafId = use.raf(animate);
  2026. } else if (callback) {
  2027. rafId = use.raf(callback);
  2028. }
  2029. }
  2030. animate();
  2031. return cancel;
  2032. }
  2033. let current = 0;
  2034. function useId() {
  2035. const vm = vue.getCurrentInstance();
  2036. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  2037. if (process.env.NODE_ENV === "test") {
  2038. return name2;
  2039. }
  2040. return `${name2}-${++current}`;
  2041. }
  2042. function useRefs() {
  2043. const refs = vue.ref([]);
  2044. const cache = [];
  2045. vue.onBeforeUpdate(() => {
  2046. refs.value = [];
  2047. });
  2048. const setRefs = (index) => {
  2049. if (!cache[index]) {
  2050. cache[index] = (el) => {
  2051. refs.value[index] = el;
  2052. };
  2053. }
  2054. return cache[index];
  2055. };
  2056. return [refs, setRefs];
  2057. }
  2058. function useVisibilityChange(target, onChange) {
  2059. if (!inBrowser || !window.IntersectionObserver) {
  2060. return;
  2061. }
  2062. const observer = new IntersectionObserver(
  2063. (entries) => {
  2064. onChange(entries[0].intersectionRatio > 0);
  2065. },
  2066. { root: document.body }
  2067. );
  2068. const observe = () => {
  2069. if (target.value) {
  2070. observer.observe(target.value);
  2071. }
  2072. };
  2073. const unobserve = () => {
  2074. if (target.value) {
  2075. observer.unobserve(target.value);
  2076. }
  2077. };
  2078. vue.onDeactivated(unobserve);
  2079. vue.onBeforeUnmount(unobserve);
  2080. use.onMountedOrActivated(observe);
  2081. }
  2082. const [name$1w, bem$1s] = createNamespace("sticky");
  2083. const stickyProps = {
  2084. zIndex: numericProp,
  2085. position: makeStringProp("top"),
  2086. container: Object,
  2087. offsetTop: makeNumericProp(0),
  2088. offsetBottom: makeNumericProp(0)
  2089. };
  2090. var stdin_default$1G = vue.defineComponent({
  2091. name: name$1w,
  2092. props: stickyProps,
  2093. emits: ["scroll", "change"],
  2094. setup(props2, {
  2095. emit,
  2096. slots
  2097. }) {
  2098. const root = vue.ref();
  2099. const scrollParent = use.useScrollParent(root);
  2100. const state = vue.reactive({
  2101. fixed: false,
  2102. width: 0,
  2103. // root width
  2104. height: 0,
  2105. // root height
  2106. transform: 0
  2107. });
  2108. const isReset = vue.ref(false);
  2109. const offset = vue.computed(() => unitToPx(props2.position === "top" ? props2.offsetTop : props2.offsetBottom));
  2110. const rootStyle = vue.computed(() => {
  2111. if (isReset.value) {
  2112. return;
  2113. }
  2114. const {
  2115. fixed,
  2116. height,
  2117. width
  2118. } = state;
  2119. if (fixed) {
  2120. return {
  2121. width: `${width}px`,
  2122. height: `${height}px`
  2123. };
  2124. }
  2125. });
  2126. const stickyStyle = vue.computed(() => {
  2127. if (!state.fixed || isReset.value) {
  2128. return;
  2129. }
  2130. const style = extend(getZIndexStyle(props2.zIndex), {
  2131. width: `${state.width}px`,
  2132. height: `${state.height}px`,
  2133. [props2.position]: `${offset.value}px`
  2134. });
  2135. if (state.transform) {
  2136. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  2137. }
  2138. return style;
  2139. });
  2140. const emitScroll = (scrollTop) => emit("scroll", {
  2141. scrollTop,
  2142. isFixed: state.fixed
  2143. });
  2144. const onScroll = () => {
  2145. if (!root.value || isHidden(root)) {
  2146. return;
  2147. }
  2148. const {
  2149. container,
  2150. position
  2151. } = props2;
  2152. const rootRect = use.useRect(root);
  2153. const scrollTop = getScrollTop(window);
  2154. state.width = rootRect.width;
  2155. state.height = rootRect.height;
  2156. if (position === "top") {
  2157. if (container) {
  2158. const containerRect = use.useRect(container);
  2159. const difference = containerRect.bottom - offset.value - state.height;
  2160. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  2161. state.transform = difference < 0 ? difference : 0;
  2162. } else {
  2163. state.fixed = offset.value > rootRect.top;
  2164. }
  2165. } else {
  2166. const {
  2167. clientHeight
  2168. } = document.documentElement;
  2169. if (container) {
  2170. const containerRect = use.useRect(container);
  2171. const difference = clientHeight - containerRect.top - offset.value - state.height;
  2172. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  2173. state.transform = difference < 0 ? -difference : 0;
  2174. } else {
  2175. state.fixed = clientHeight - offset.value < rootRect.bottom;
  2176. }
  2177. }
  2178. emitScroll(scrollTop);
  2179. };
  2180. vue.watch(() => state.fixed, (value) => emit("change", value));
  2181. use.useEventListener("scroll", onScroll, {
  2182. target: scrollParent,
  2183. passive: true
  2184. });
  2185. useVisibilityChange(root, onScroll);
  2186. vue.watch([windowWidth, windowHeight], () => {
  2187. if (!root.value || isHidden(root) || !state.fixed) {
  2188. return;
  2189. }
  2190. isReset.value = true;
  2191. vue.nextTick(() => {
  2192. const rootRect = use.useRect(root);
  2193. state.width = rootRect.width;
  2194. state.height = rootRect.height;
  2195. isReset.value = false;
  2196. });
  2197. });
  2198. return () => {
  2199. var _a;
  2200. return vue.createVNode("div", {
  2201. "ref": root,
  2202. "style": rootStyle.value
  2203. }, [vue.createVNode("div", {
  2204. "class": bem$1s({
  2205. fixed: state.fixed && !isReset.value
  2206. }),
  2207. "style": stickyStyle.value
  2208. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  2209. };
  2210. }
  2211. });
  2212. const Sticky = withInstall(stdin_default$1G);
  2213. const [name$1v, bem$1r] = createNamespace("swipe");
  2214. const swipeProps = {
  2215. loop: truthProp,
  2216. width: numericProp,
  2217. height: numericProp,
  2218. vertical: Boolean,
  2219. autoplay: makeNumericProp(0),
  2220. duration: makeNumericProp(500),
  2221. touchable: truthProp,
  2222. lazyRender: Boolean,
  2223. initialSwipe: makeNumericProp(0),
  2224. indicatorColor: String,
  2225. showIndicators: truthProp,
  2226. stopPropagation: truthProp
  2227. };
  2228. const SWIPE_KEY = Symbol(name$1v);
  2229. var stdin_default$1F = vue.defineComponent({
  2230. name: name$1v,
  2231. props: swipeProps,
  2232. emits: ["change", "dragStart", "dragEnd"],
  2233. setup(props2, {
  2234. emit,
  2235. slots
  2236. }) {
  2237. const root = vue.ref();
  2238. const track = vue.ref();
  2239. const state = vue.reactive({
  2240. rect: null,
  2241. width: 0,
  2242. height: 0,
  2243. offset: 0,
  2244. active: 0,
  2245. swiping: false
  2246. });
  2247. let dragging = false;
  2248. const touch = useTouch();
  2249. const {
  2250. children,
  2251. linkChildren
  2252. } = use.useChildren(SWIPE_KEY);
  2253. const count = vue.computed(() => children.length);
  2254. const size = vue.computed(() => state[props2.vertical ? "height" : "width"]);
  2255. const delta = vue.computed(() => props2.vertical ? touch.deltaY.value : touch.deltaX.value);
  2256. const minOffset = vue.computed(() => {
  2257. if (state.rect) {
  2258. const base = props2.vertical ? state.rect.height : state.rect.width;
  2259. return base - size.value * count.value;
  2260. }
  2261. return 0;
  2262. });
  2263. const maxCount = vue.computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
  2264. const trackSize = vue.computed(() => count.value * size.value);
  2265. const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
  2266. const isCorrectDirection = vue.computed(() => {
  2267. const expect = props2.vertical ? "vertical" : "horizontal";
  2268. return touch.direction.value === expect;
  2269. });
  2270. const trackStyle = vue.computed(() => {
  2271. const style = {
  2272. transitionDuration: `${state.swiping ? 0 : props2.duration}ms`,
  2273. transform: `translate${props2.vertical ? "Y" : "X"}(${+state.offset.toFixed(2)}px)`
  2274. };
  2275. if (size.value) {
  2276. const mainAxis = props2.vertical ? "height" : "width";
  2277. const crossAxis = props2.vertical ? "width" : "height";
  2278. style[mainAxis] = `${trackSize.value}px`;
  2279. style[crossAxis] = props2[crossAxis] ? `${props2[crossAxis]}px` : "";
  2280. }
  2281. return style;
  2282. });
  2283. const getTargetActive = (pace) => {
  2284. const {
  2285. active
  2286. } = state;
  2287. if (pace) {
  2288. if (props2.loop) {
  2289. return clamp(active + pace, -1, count.value);
  2290. }
  2291. return clamp(active + pace, 0, maxCount.value);
  2292. }
  2293. return active;
  2294. };
  2295. const getTargetOffset = (targetActive, offset = 0) => {
  2296. let currentPosition = targetActive * size.value;
  2297. if (!props2.loop) {
  2298. currentPosition = Math.min(currentPosition, -minOffset.value);
  2299. }
  2300. let targetOffset = offset - currentPosition;
  2301. if (!props2.loop) {
  2302. targetOffset = clamp(targetOffset, minOffset.value, 0);
  2303. }
  2304. return targetOffset;
  2305. };
  2306. const move = ({
  2307. pace = 0,
  2308. offset = 0,
  2309. emitChange
  2310. }) => {
  2311. if (count.value <= 1) {
  2312. return;
  2313. }
  2314. const {
  2315. active
  2316. } = state;
  2317. const targetActive = getTargetActive(pace);
  2318. const targetOffset = getTargetOffset(targetActive, offset);
  2319. if (props2.loop) {
  2320. if (children[0] && targetOffset !== minOffset.value) {
  2321. const outRightBound = targetOffset < minOffset.value;
  2322. children[0].setOffset(outRightBound ? trackSize.value : 0);
  2323. }
  2324. if (children[count.value - 1] && targetOffset !== 0) {
  2325. const outLeftBound = targetOffset > 0;
  2326. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  2327. }
  2328. }
  2329. state.active = targetActive;
  2330. state.offset = targetOffset;
  2331. if (emitChange && targetActive !== active) {
  2332. emit("change", activeIndicator.value);
  2333. }
  2334. };
  2335. const correctPosition = () => {
  2336. state.swiping = true;
  2337. if (state.active <= -1) {
  2338. move({
  2339. pace: count.value
  2340. });
  2341. } else if (state.active >= count.value) {
  2342. move({
  2343. pace: -count.value
  2344. });
  2345. }
  2346. };
  2347. const prev = () => {
  2348. correctPosition();
  2349. touch.reset();
  2350. use.doubleRaf(() => {
  2351. state.swiping = false;
  2352. move({
  2353. pace: -1,
  2354. emitChange: true
  2355. });
  2356. });
  2357. };
  2358. const next = () => {
  2359. correctPosition();
  2360. touch.reset();
  2361. use.doubleRaf(() => {
  2362. state.swiping = false;
  2363. move({
  2364. pace: 1,
  2365. emitChange: true
  2366. });
  2367. });
  2368. };
  2369. let autoplayTimer;
  2370. const stopAutoplay = () => clearTimeout(autoplayTimer);
  2371. const autoplay = () => {
  2372. stopAutoplay();
  2373. if (+props2.autoplay > 0 && count.value > 1) {
  2374. autoplayTimer = setTimeout(() => {
  2375. next();
  2376. autoplay();
  2377. }, +props2.autoplay);
  2378. }
  2379. };
  2380. const initialize = (active = +props2.initialSwipe) => {
  2381. if (!root.value) {
  2382. return;
  2383. }
  2384. const cb = () => {
  2385. var _a, _b;
  2386. if (!isHidden(root)) {
  2387. const rect = {
  2388. width: root.value.offsetWidth,
  2389. height: root.value.offsetHeight
  2390. };
  2391. state.rect = rect;
  2392. state.width = +((_a = props2.width) != null ? _a : rect.width);
  2393. state.height = +((_b = props2.height) != null ? _b : rect.height);
  2394. }
  2395. if (count.value) {
  2396. active = Math.min(count.value - 1, active);
  2397. if (active === -1) {
  2398. active = count.value - 1;
  2399. }
  2400. }
  2401. state.active = active;
  2402. state.swiping = true;
  2403. state.offset = getTargetOffset(active);
  2404. children.forEach((swipe) => {
  2405. swipe.setOffset(0);
  2406. });
  2407. autoplay();
  2408. };
  2409. if (isHidden(root)) {
  2410. vue.nextTick().then(cb);
  2411. } else {
  2412. cb();
  2413. }
  2414. };
  2415. const resize = () => initialize(state.active);
  2416. let touchStartTime;
  2417. const onTouchStart = (event) => {
  2418. if (!props2.touchable || // avoid resetting position on multi-finger touch
  2419. event.touches.length > 1) return;
  2420. touch.start(event);
  2421. dragging = false;
  2422. touchStartTime = Date.now();
  2423. stopAutoplay();
  2424. correctPosition();
  2425. };
  2426. const onTouchMove = (event) => {
  2427. if (props2.touchable && state.swiping) {
  2428. touch.move(event);
  2429. if (isCorrectDirection.value) {
  2430. const isEdgeTouch = !props2.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  2431. if (!isEdgeTouch) {
  2432. preventDefault(event, props2.stopPropagation);
  2433. move({
  2434. offset: delta.value
  2435. });
  2436. if (!dragging) {
  2437. emit("dragStart", {
  2438. index: activeIndicator.value
  2439. });
  2440. dragging = true;
  2441. }
  2442. }
  2443. }
  2444. }
  2445. };
  2446. const onTouchEnd = () => {
  2447. if (!props2.touchable || !state.swiping) {
  2448. return;
  2449. }
  2450. const duration = Date.now() - touchStartTime;
  2451. const speed = delta.value / duration;
  2452. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  2453. if (shouldSwipe && isCorrectDirection.value) {
  2454. const offset = props2.vertical ? touch.offsetY.value : touch.offsetX.value;
  2455. let pace = 0;
  2456. if (props2.loop) {
  2457. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  2458. } else {
  2459. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  2460. }
  2461. move({
  2462. pace,
  2463. emitChange: true
  2464. });
  2465. } else if (delta.value) {
  2466. move({
  2467. pace: 0
  2468. });
  2469. }
  2470. dragging = false;
  2471. state.swiping = false;
  2472. emit("dragEnd", {
  2473. index: activeIndicator.value
  2474. });
  2475. autoplay();
  2476. };
  2477. const swipeTo = (index, options = {}) => {
  2478. correctPosition();
  2479. touch.reset();
  2480. use.doubleRaf(() => {
  2481. let targetIndex;
  2482. if (props2.loop && index === count.value) {
  2483. targetIndex = state.active === 0 ? 0 : index;
  2484. } else {
  2485. targetIndex = index % count.value;
  2486. }
  2487. if (options.immediate) {
  2488. use.doubleRaf(() => {
  2489. state.swiping = false;
  2490. });
  2491. } else {
  2492. state.swiping = false;
  2493. }
  2494. move({
  2495. pace: targetIndex - state.active,
  2496. emitChange: true
  2497. });
  2498. });
  2499. };
  2500. const renderDot = (_, index) => {
  2501. const active = index === activeIndicator.value;
  2502. const style = active ? {
  2503. backgroundColor: props2.indicatorColor
  2504. } : void 0;
  2505. return vue.createVNode("i", {
  2506. "style": style,
  2507. "class": bem$1r("indicator", {
  2508. active
  2509. })
  2510. }, null);
  2511. };
  2512. const renderIndicator = () => {
  2513. if (slots.indicator) {
  2514. return slots.indicator({
  2515. active: activeIndicator.value,
  2516. total: count.value
  2517. });
  2518. }
  2519. if (props2.showIndicators && count.value > 1) {
  2520. return vue.createVNode("div", {
  2521. "class": bem$1r("indicators", {
  2522. vertical: props2.vertical
  2523. })
  2524. }, [Array(count.value).fill("").map(renderDot)]);
  2525. }
  2526. };
  2527. useExpose({
  2528. prev,
  2529. next,
  2530. state,
  2531. resize,
  2532. swipeTo
  2533. });
  2534. linkChildren({
  2535. size,
  2536. props: props2,
  2537. count,
  2538. activeIndicator
  2539. });
  2540. vue.watch(() => props2.initialSwipe, (value) => initialize(+value));
  2541. vue.watch(count, () => initialize(state.active));
  2542. vue.watch(() => props2.autoplay, autoplay);
  2543. vue.watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
  2544. vue.watch(use.usePageVisibility(), (visible) => {
  2545. if (visible === "visible") {
  2546. autoplay();
  2547. } else {
  2548. stopAutoplay();
  2549. }
  2550. });
  2551. vue.onMounted(initialize);
  2552. vue.onActivated(() => initialize(state.active));
  2553. onPopupReopen(() => initialize(state.active));
  2554. vue.onDeactivated(stopAutoplay);
  2555. vue.onBeforeUnmount(stopAutoplay);
  2556. use.useEventListener("touchmove", onTouchMove, {
  2557. target: track
  2558. });
  2559. return () => {
  2560. var _a;
  2561. return vue.createVNode("div", {
  2562. "ref": root,
  2563. "class": bem$1r()
  2564. }, [vue.createVNode("div", {
  2565. "ref": track,
  2566. "style": trackStyle.value,
  2567. "class": bem$1r("track", {
  2568. vertical: props2.vertical
  2569. }),
  2570. "onTouchstartPassive": onTouchStart,
  2571. "onTouchend": onTouchEnd,
  2572. "onTouchcancel": onTouchEnd
  2573. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  2574. };
  2575. }
  2576. });
  2577. const Swipe = withInstall(stdin_default$1F);
  2578. const [name$1u, bem$1q] = createNamespace("tabs");
  2579. var stdin_default$1E = vue.defineComponent({
  2580. name: name$1u,
  2581. props: {
  2582. count: makeRequiredProp(Number),
  2583. inited: Boolean,
  2584. animated: Boolean,
  2585. duration: makeRequiredProp(numericProp),
  2586. swipeable: Boolean,
  2587. lazyRender: Boolean,
  2588. currentIndex: makeRequiredProp(Number)
  2589. },
  2590. emits: ["change"],
  2591. setup(props2, {
  2592. emit,
  2593. slots
  2594. }) {
  2595. const swipeRef = vue.ref();
  2596. const onChange = (index) => emit("change", index);
  2597. const renderChildren = () => {
  2598. var _a;
  2599. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  2600. if (props2.animated || props2.swipeable) {
  2601. return vue.createVNode(Swipe, {
  2602. "ref": swipeRef,
  2603. "loop": false,
  2604. "class": bem$1q("track"),
  2605. "duration": +props2.duration * 1e3,
  2606. "touchable": props2.swipeable,
  2607. "lazyRender": props2.lazyRender,
  2608. "showIndicators": false,
  2609. "onChange": onChange
  2610. }, {
  2611. default: () => [Content]
  2612. });
  2613. }
  2614. return Content;
  2615. };
  2616. const swipeToCurrentTab = (index) => {
  2617. const swipe = swipeRef.value;
  2618. if (swipe && swipe.state.active !== index) {
  2619. swipe.swipeTo(index, {
  2620. immediate: !props2.inited
  2621. });
  2622. }
  2623. };
  2624. vue.watch(() => props2.currentIndex, swipeToCurrentTab);
  2625. vue.onMounted(() => {
  2626. swipeToCurrentTab(props2.currentIndex);
  2627. });
  2628. useExpose({
  2629. swipeRef
  2630. });
  2631. return () => vue.createVNode("div", {
  2632. "class": bem$1q("content", {
  2633. animated: props2.animated || props2.swipeable
  2634. })
  2635. }, [renderChildren()]);
  2636. }
  2637. });
  2638. const [name$1t, bem$1p] = createNamespace("tabs");
  2639. const tabsProps = {
  2640. type: makeStringProp("line"),
  2641. color: String,
  2642. border: Boolean,
  2643. sticky: Boolean,
  2644. shrink: Boolean,
  2645. active: makeNumericProp(0),
  2646. duration: makeNumericProp(0.3),
  2647. animated: Boolean,
  2648. ellipsis: truthProp,
  2649. swipeable: Boolean,
  2650. scrollspy: Boolean,
  2651. offsetTop: makeNumericProp(0),
  2652. background: String,
  2653. lazyRender: truthProp,
  2654. showHeader: truthProp,
  2655. lineWidth: numericProp,
  2656. lineHeight: numericProp,
  2657. beforeChange: Function,
  2658. swipeThreshold: makeNumericProp(5),
  2659. titleActiveColor: String,
  2660. titleInactiveColor: String
  2661. };
  2662. const TABS_KEY = Symbol(name$1t);
  2663. var stdin_default$1D = vue.defineComponent({
  2664. name: name$1t,
  2665. props: tabsProps,
  2666. emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
  2667. setup(props2, {
  2668. emit,
  2669. slots
  2670. }) {
  2671. let tabHeight;
  2672. let lockScroll;
  2673. let stickyFixed;
  2674. let cancelScrollLeftToRaf;
  2675. let cancelScrollTopToRaf;
  2676. const root = vue.ref();
  2677. const navRef = vue.ref();
  2678. const wrapRef = vue.ref();
  2679. const contentRef = vue.ref();
  2680. const id = useId();
  2681. const scroller = use.useScrollParent(root);
  2682. const [titleRefs, setTitleRefs] = useRefs();
  2683. const {
  2684. children,
  2685. linkChildren
  2686. } = use.useChildren(TABS_KEY);
  2687. const state = vue.reactive({
  2688. inited: false,
  2689. position: "",
  2690. lineStyle: {},
  2691. currentIndex: -1
  2692. });
  2693. const scrollable = vue.computed(() => children.length > +props2.swipeThreshold || !props2.ellipsis || props2.shrink);
  2694. const navStyle = vue.computed(() => ({
  2695. borderColor: props2.color,
  2696. background: props2.background
  2697. }));
  2698. const getTabName = (tab, index) => {
  2699. var _a;
  2700. return (_a = tab.name) != null ? _a : index;
  2701. };
  2702. const currentName = vue.computed(() => {
  2703. const activeTab = children[state.currentIndex];
  2704. if (activeTab) {
  2705. return getTabName(activeTab, state.currentIndex);
  2706. }
  2707. });
  2708. const offsetTopPx = vue.computed(() => unitToPx(props2.offsetTop));
  2709. const scrollOffset = vue.computed(() => {
  2710. if (props2.sticky) {
  2711. return offsetTopPx.value + tabHeight;
  2712. }
  2713. return 0;
  2714. });
  2715. const scrollIntoView = (immediate) => {
  2716. const nav = navRef.value;
  2717. const titles = titleRefs.value;
  2718. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  2719. return;
  2720. }
  2721. const title = titles[state.currentIndex].$el;
  2722. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  2723. if (cancelScrollLeftToRaf) cancelScrollLeftToRaf();
  2724. cancelScrollLeftToRaf = scrollLeftTo(nav, to, immediate ? 0 : +props2.duration);
  2725. };
  2726. const setLine = () => {
  2727. const shouldAnimate = state.inited;
  2728. vue.nextTick(() => {
  2729. const titles = titleRefs.value;
  2730. if (!titles || !titles[state.currentIndex] || props2.type !== "line" || isHidden(root.value)) {
  2731. return;
  2732. }
  2733. const title = titles[state.currentIndex].$el;
  2734. const {
  2735. lineWidth,
  2736. lineHeight
  2737. } = props2;
  2738. const left = title.offsetLeft + title.offsetWidth / 2;
  2739. const lineStyle = {
  2740. width: addUnit(lineWidth),
  2741. backgroundColor: props2.color,
  2742. transform: `translateX(${left}px) translateX(-50%)`
  2743. };
  2744. if (shouldAnimate) {
  2745. lineStyle.transitionDuration = `${props2.duration}s`;
  2746. }
  2747. if (isDef(lineHeight)) {
  2748. const height = addUnit(lineHeight);
  2749. lineStyle.height = height;
  2750. lineStyle.borderRadius = height;
  2751. }
  2752. state.lineStyle = lineStyle;
  2753. });
  2754. };
  2755. const findAvailableTab = (index) => {
  2756. const diff = index < state.currentIndex ? -1 : 1;
  2757. while (index >= 0 && index < children.length) {
  2758. if (!children[index].disabled) {
  2759. return index;
  2760. }
  2761. index += diff;
  2762. }
  2763. };
  2764. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  2765. const newIndex = findAvailableTab(currentIndex);
  2766. if (!isDef(newIndex)) {
  2767. return;
  2768. }
  2769. const newTab = children[newIndex];
  2770. const newName = getTabName(newTab, newIndex);
  2771. const shouldEmitChange = state.currentIndex !== null;
  2772. if (state.currentIndex !== newIndex) {
  2773. state.currentIndex = newIndex;
  2774. if (!skipScrollIntoView) {
  2775. scrollIntoView();
  2776. }
  2777. setLine();
  2778. }
  2779. if (newName !== props2.active) {
  2780. emit("update:active", newName);
  2781. if (shouldEmitChange) {
  2782. emit("change", newName, newTab.title);
  2783. }
  2784. }
  2785. if (stickyFixed && !props2.scrollspy) {
  2786. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  2787. }
  2788. };
  2789. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  2790. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  2791. const index = matched ? children.indexOf(matched) : 0;
  2792. setCurrentIndex(index, skipScrollIntoView);
  2793. };
  2794. const scrollToCurrentContent = (immediate = false) => {
  2795. if (props2.scrollspy) {
  2796. const target = children[state.currentIndex].$el;
  2797. if (target && scroller.value) {
  2798. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  2799. lockScroll = true;
  2800. if (cancelScrollTopToRaf) cancelScrollTopToRaf();
  2801. cancelScrollTopToRaf = scrollTopTo(scroller.value, to, immediate ? 0 : +props2.duration, () => {
  2802. lockScroll = false;
  2803. });
  2804. }
  2805. }
  2806. };
  2807. const onClickTab = (item, index, event) => {
  2808. const {
  2809. title,
  2810. disabled
  2811. } = children[index];
  2812. const name2 = getTabName(children[index], index);
  2813. if (!disabled) {
  2814. callInterceptor(props2.beforeChange, {
  2815. args: [name2],
  2816. done: () => {
  2817. setCurrentIndex(index);
  2818. scrollToCurrentContent();
  2819. }
  2820. });
  2821. route(item);
  2822. }
  2823. emit("clickTab", {
  2824. name: name2,
  2825. title,
  2826. event,
  2827. disabled
  2828. });
  2829. };
  2830. const onStickyScroll = (params) => {
  2831. stickyFixed = params.isFixed;
  2832. emit("scroll", params);
  2833. };
  2834. const scrollTo = (name2) => {
  2835. vue.nextTick(() => {
  2836. setCurrentIndexByName(name2);
  2837. scrollToCurrentContent(true);
  2838. });
  2839. };
  2840. const getCurrentIndexOnScroll = () => {
  2841. for (let index = 0; index < children.length; index++) {
  2842. const {
  2843. top
  2844. } = use.useRect(children[index].$el);
  2845. if (top > scrollOffset.value) {
  2846. return index === 0 ? 0 : index - 1;
  2847. }
  2848. }
  2849. return children.length - 1;
  2850. };
  2851. const onScroll = () => {
  2852. if (props2.scrollspy && !lockScroll) {
  2853. const index = getCurrentIndexOnScroll();
  2854. setCurrentIndex(index);
  2855. }
  2856. };
  2857. const renderLine = () => {
  2858. if (props2.type === "line" && children.length) {
  2859. return vue.createVNode("div", {
  2860. "class": bem$1p("line"),
  2861. "style": state.lineStyle
  2862. }, null);
  2863. }
  2864. };
  2865. const renderHeader = () => {
  2866. var _a, _b, _c;
  2867. const {
  2868. type,
  2869. border,
  2870. sticky
  2871. } = props2;
  2872. const Header = [vue.createVNode("div", {
  2873. "ref": sticky ? void 0 : wrapRef,
  2874. "class": [bem$1p("wrap"), {
  2875. [BORDER_TOP_BOTTOM]: type === "line" && border
  2876. }]
  2877. }, [vue.createVNode("div", {
  2878. "ref": navRef,
  2879. "role": "tablist",
  2880. "class": bem$1p("nav", [type, {
  2881. shrink: props2.shrink,
  2882. complete: scrollable.value
  2883. }]),
  2884. "style": navStyle.value,
  2885. "aria-orientation": "horizontal"
  2886. }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), children.map((item) => item.renderTitle(onClickTab)), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  2887. if (sticky) {
  2888. return vue.createVNode("div", {
  2889. "ref": wrapRef
  2890. }, [Header]);
  2891. }
  2892. return Header;
  2893. };
  2894. const resize = () => {
  2895. setLine();
  2896. vue.nextTick(() => {
  2897. var _a, _b;
  2898. scrollIntoView(true);
  2899. (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
  2900. });
  2901. };
  2902. vue.watch(() => [props2.color, props2.duration, props2.lineWidth, props2.lineHeight], setLine);
  2903. vue.watch(windowWidth, resize);
  2904. vue.watch(() => props2.active, (value) => {
  2905. if (value !== currentName.value) {
  2906. setCurrentIndexByName(value);
  2907. }
  2908. });
  2909. vue.watch(() => children.length, () => {
  2910. if (state.inited) {
  2911. setCurrentIndexByName(props2.active);
  2912. setLine();
  2913. vue.nextTick(() => {
  2914. scrollIntoView(true);
  2915. });
  2916. }
  2917. });
  2918. const init = () => {
  2919. setCurrentIndexByName(props2.active, true);
  2920. vue.nextTick(() => {
  2921. state.inited = true;
  2922. if (wrapRef.value) {
  2923. tabHeight = use.useRect(wrapRef.value).height;
  2924. }
  2925. scrollIntoView(true);
  2926. });
  2927. };
  2928. const onRendered = (name2, title) => emit("rendered", name2, title);
  2929. useExpose({
  2930. resize,
  2931. scrollTo
  2932. });
  2933. vue.onActivated(setLine);
  2934. onPopupReopen(setLine);
  2935. use.onMountedOrActivated(init);
  2936. useVisibilityChange(root, setLine);
  2937. use.useEventListener("scroll", onScroll, {
  2938. target: scroller,
  2939. passive: true
  2940. });
  2941. linkChildren({
  2942. id,
  2943. props: props2,
  2944. setLine,
  2945. scrollable,
  2946. onRendered,
  2947. currentName,
  2948. setTitleRefs,
  2949. scrollIntoView
  2950. });
  2951. return () => vue.createVNode("div", {
  2952. "ref": root,
  2953. "class": bem$1p([props2.type])
  2954. }, [props2.showHeader ? props2.sticky ? vue.createVNode(Sticky, {
  2955. "container": root.value,
  2956. "offsetTop": offsetTopPx.value,
  2957. "onScroll": onStickyScroll
  2958. }, {
  2959. default: () => [renderHeader()]
  2960. }) : renderHeader() : null, vue.createVNode(stdin_default$1E, {
  2961. "ref": contentRef,
  2962. "count": children.length,
  2963. "inited": state.inited,
  2964. "animated": props2.animated,
  2965. "duration": props2.duration,
  2966. "swipeable": props2.swipeable,
  2967. "lazyRender": props2.lazyRender,
  2968. "currentIndex": state.currentIndex,
  2969. "onChange": setCurrentIndex
  2970. }, {
  2971. default: () => {
  2972. var _a;
  2973. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  2974. }
  2975. })]);
  2976. }
  2977. });
  2978. const TAB_STATUS_KEY = Symbol();
  2979. const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
  2980. const [name$1s, bem$1o] = createNamespace("tab");
  2981. const TabTitle = vue.defineComponent({
  2982. name: name$1s,
  2983. props: {
  2984. id: String,
  2985. dot: Boolean,
  2986. type: String,
  2987. color: String,
  2988. title: String,
  2989. badge: numericProp,
  2990. shrink: Boolean,
  2991. isActive: Boolean,
  2992. disabled: Boolean,
  2993. controls: String,
  2994. scrollable: Boolean,
  2995. activeColor: String,
  2996. inactiveColor: String,
  2997. showZeroBadge: truthProp
  2998. },
  2999. setup(props2, {
  3000. slots
  3001. }) {
  3002. const style = vue.computed(() => {
  3003. const style2 = {};
  3004. const {
  3005. type,
  3006. color,
  3007. disabled,
  3008. isActive,
  3009. activeColor,
  3010. inactiveColor
  3011. } = props2;
  3012. const isCard = type === "card";
  3013. if (color && isCard) {
  3014. style2.borderColor = color;
  3015. if (!disabled) {
  3016. if (isActive) {
  3017. style2.backgroundColor = color;
  3018. } else {
  3019. style2.color = color;
  3020. }
  3021. }
  3022. }
  3023. const titleColor = isActive ? activeColor : inactiveColor;
  3024. if (titleColor) {
  3025. style2.color = titleColor;
  3026. }
  3027. return style2;
  3028. });
  3029. const renderText = () => {
  3030. const Text = vue.createVNode("span", {
  3031. "class": bem$1o("text", {
  3032. ellipsis: !props2.scrollable
  3033. })
  3034. }, [slots.title ? slots.title() : props2.title]);
  3035. if (props2.dot || isDef(props2.badge) && props2.badge !== "") {
  3036. return vue.createVNode(Badge, {
  3037. "dot": props2.dot,
  3038. "content": props2.badge,
  3039. "showZero": props2.showZeroBadge
  3040. }, {
  3041. default: () => [Text]
  3042. });
  3043. }
  3044. return Text;
  3045. };
  3046. return () => vue.createVNode("div", {
  3047. "id": props2.id,
  3048. "role": "tab",
  3049. "class": [bem$1o([props2.type, {
  3050. grow: props2.scrollable && !props2.shrink,
  3051. shrink: props2.shrink,
  3052. active: props2.isActive,
  3053. disabled: props2.disabled
  3054. }])],
  3055. "style": style.value,
  3056. "tabindex": props2.disabled ? void 0 : props2.isActive ? 0 : -1,
  3057. "aria-selected": props2.isActive,
  3058. "aria-disabled": props2.disabled || void 0,
  3059. "aria-controls": props2.controls,
  3060. "data-allow-mismatch": "attribute"
  3061. }, [renderText()]);
  3062. }
  3063. });
  3064. const [name$1r, bem$1n] = createNamespace("swipe-item");
  3065. var stdin_default$1C = vue.defineComponent({
  3066. name: name$1r,
  3067. setup(props2, {
  3068. slots
  3069. }) {
  3070. let rendered;
  3071. const state = vue.reactive({
  3072. offset: 0,
  3073. inited: false,
  3074. mounted: false
  3075. });
  3076. const {
  3077. parent,
  3078. index
  3079. } = use.useParent(SWIPE_KEY);
  3080. if (!parent) {
  3081. if (process.env.NODE_ENV !== "production") {
  3082. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  3083. }
  3084. return;
  3085. }
  3086. const style = vue.computed(() => {
  3087. const style2 = {};
  3088. const {
  3089. vertical
  3090. } = parent.props;
  3091. if (parent.size.value) {
  3092. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  3093. }
  3094. if (state.offset) {
  3095. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  3096. }
  3097. return style2;
  3098. });
  3099. const shouldRender = vue.computed(() => {
  3100. const {
  3101. loop,
  3102. lazyRender
  3103. } = parent.props;
  3104. if (!lazyRender || rendered) {
  3105. return true;
  3106. }
  3107. if (!state.mounted) {
  3108. return false;
  3109. }
  3110. const active = parent.activeIndicator.value;
  3111. const maxActive = parent.count.value - 1;
  3112. const prevActive = active === 0 && loop ? maxActive : active - 1;
  3113. const nextActive = active === maxActive && loop ? 0 : active + 1;
  3114. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  3115. return rendered;
  3116. });
  3117. const setOffset = (offset) => {
  3118. state.offset = offset;
  3119. };
  3120. vue.onMounted(() => {
  3121. vue.nextTick(() => {
  3122. state.mounted = true;
  3123. });
  3124. });
  3125. useExpose({
  3126. setOffset
  3127. });
  3128. return () => {
  3129. var _a;
  3130. return vue.createVNode("div", {
  3131. "class": bem$1n(),
  3132. "style": style.value
  3133. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  3134. };
  3135. }
  3136. });
  3137. const SwipeItem = withInstall(stdin_default$1C);
  3138. const [name$1q, bem$1m] = createNamespace("tab");
  3139. const tabProps = extend({}, routeProps, {
  3140. dot: Boolean,
  3141. name: numericProp,
  3142. badge: numericProp,
  3143. title: String,
  3144. disabled: Boolean,
  3145. titleClass: unknownProp,
  3146. titleStyle: [String, Object],
  3147. showZeroBadge: truthProp
  3148. });
  3149. var stdin_default$1B = vue.defineComponent({
  3150. name: name$1q,
  3151. props: tabProps,
  3152. setup(props2, {
  3153. slots
  3154. }) {
  3155. const id = useId();
  3156. const inited = vue.ref(false);
  3157. const instance2 = vue.getCurrentInstance();
  3158. const {
  3159. parent,
  3160. index
  3161. } = use.useParent(TABS_KEY);
  3162. if (!parent) {
  3163. if (process.env.NODE_ENV !== "production") {
  3164. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  3165. }
  3166. return;
  3167. }
  3168. const getName = () => {
  3169. var _a;
  3170. return (_a = props2.name) != null ? _a : index.value;
  3171. };
  3172. const init = () => {
  3173. inited.value = true;
  3174. if (parent.props.lazyRender) {
  3175. vue.nextTick(() => {
  3176. parent.onRendered(getName(), props2.title);
  3177. });
  3178. }
  3179. };
  3180. const active = vue.computed(() => {
  3181. const isActive = getName() === parent.currentName.value;
  3182. if (isActive && !inited.value) {
  3183. init();
  3184. }
  3185. return isActive;
  3186. });
  3187. const parsedClass = vue.ref("");
  3188. const parsedStyle = vue.ref("");
  3189. vue.watchEffect(() => {
  3190. const {
  3191. titleClass,
  3192. titleStyle
  3193. } = props2;
  3194. parsedClass.value = titleClass ? shared.normalizeClass(titleClass) : "";
  3195. parsedStyle.value = titleStyle && typeof titleStyle !== "string" ? shared.stringifyStyle(shared.normalizeStyle(titleStyle)) : titleStyle;
  3196. });
  3197. const renderTitle = (onClickTab) => vue.createVNode(TabTitle, vue.mergeProps({
  3198. "key": id,
  3199. "id": `${parent.id}-${index.value}`,
  3200. "ref": parent.setTitleRefs(index.value),
  3201. "style": parsedStyle.value,
  3202. "class": parsedClass.value,
  3203. "isActive": active.value,
  3204. "controls": id,
  3205. "scrollable": parent.scrollable.value,
  3206. "activeColor": parent.props.titleActiveColor,
  3207. "inactiveColor": parent.props.titleInactiveColor,
  3208. "onClick": (event) => onClickTab(instance2.proxy, index.value, event)
  3209. }, pick(parent.props, ["type", "color", "shrink"]), pick(props2, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  3210. title: slots.title
  3211. });
  3212. const hasInactiveClass = vue.ref(!active.value);
  3213. vue.watch(active, (val) => {
  3214. if (val) {
  3215. hasInactiveClass.value = false;
  3216. } else {
  3217. use.doubleRaf(() => {
  3218. hasInactiveClass.value = true;
  3219. });
  3220. }
  3221. });
  3222. vue.watch(() => props2.title, () => {
  3223. parent.setLine();
  3224. parent.scrollIntoView();
  3225. });
  3226. vue.provide(TAB_STATUS_KEY, active);
  3227. useExpose({
  3228. id,
  3229. renderTitle
  3230. });
  3231. return () => {
  3232. var _a;
  3233. const label = `${parent.id}-${index.value}`;
  3234. const {
  3235. animated,
  3236. swipeable,
  3237. scrollspy,
  3238. lazyRender
  3239. } = parent.props;
  3240. if (!slots.default && !animated) {
  3241. return;
  3242. }
  3243. const show = scrollspy || active.value;
  3244. if (animated || swipeable) {
  3245. return vue.createVNode(SwipeItem, {
  3246. "id": id,
  3247. "role": "tabpanel",
  3248. "class": bem$1m("panel-wrapper", {
  3249. inactive: hasInactiveClass.value
  3250. }),
  3251. "tabindex": active.value ? 0 : -1,
  3252. "aria-hidden": !active.value,
  3253. "aria-labelledby": label,
  3254. "data-allow-mismatch": "attribute"
  3255. }, {
  3256. default: () => {
  3257. var _a2;
  3258. return [vue.createVNode("div", {
  3259. "class": bem$1m("panel")
  3260. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  3261. }
  3262. });
  3263. }
  3264. const shouldRender = inited.value || scrollspy || !lazyRender;
  3265. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  3266. return vue.withDirectives(vue.createVNode("div", {
  3267. "id": id,
  3268. "role": "tabpanel",
  3269. "class": bem$1m("panel"),
  3270. "tabindex": show ? 0 : -1,
  3271. "aria-labelledby": label,
  3272. "data-allow-mismatch": "attribute"
  3273. }, [Content]), [[vue.vShow, show]]);
  3274. };
  3275. }
  3276. });
  3277. const Tab = withInstall(stdin_default$1B);
  3278. const Tabs = withInstall(stdin_default$1D);
  3279. const [name$1p, bem$1l] = createNamespace("picker-group");
  3280. const PICKER_GROUP_KEY = Symbol(name$1p);
  3281. const pickerGroupProps = extend({
  3282. tabs: makeArrayProp(),
  3283. activeTab: makeNumericProp(0),
  3284. nextStepText: String,
  3285. showToolbar: truthProp
  3286. }, pickerToolbarProps);
  3287. var stdin_default$1A = vue.defineComponent({
  3288. name: name$1p,
  3289. props: pickerGroupProps,
  3290. emits: ["confirm", "cancel", "update:activeTab"],
  3291. setup(props2, {
  3292. emit,
  3293. slots
  3294. }) {
  3295. const activeTab = useSyncPropRef(() => props2.activeTab, (value) => emit("update:activeTab", value));
  3296. const {
  3297. children,
  3298. linkChildren
  3299. } = use.useChildren(PICKER_GROUP_KEY);
  3300. linkChildren();
  3301. const showNextButton = () => +activeTab.value < props2.tabs.length - 1 && props2.nextStepText;
  3302. const onConfirm = () => {
  3303. if (showNextButton()) {
  3304. activeTab.value = +activeTab.value + 1;
  3305. } else {
  3306. emit("confirm", children.map((item) => item.confirm()));
  3307. }
  3308. };
  3309. const onCancel = () => emit("cancel");
  3310. return () => {
  3311. var _a, _b;
  3312. let childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== vue.Comment).map((node) => {
  3313. if (node.type === vue.Fragment) {
  3314. return node.children;
  3315. }
  3316. return node;
  3317. });
  3318. if (childNodes) {
  3319. childNodes = flat(childNodes);
  3320. }
  3321. const confirmButtonText = showNextButton() ? props2.nextStepText : props2.confirmButtonText;
  3322. return vue.createVNode("div", {
  3323. "class": bem$1l()
  3324. }, [props2.showToolbar ? vue.createVNode(stdin_default$1H, {
  3325. "title": props2.title,
  3326. "cancelButtonText": props2.cancelButtonText,
  3327. "confirmButtonText": confirmButtonText,
  3328. "onConfirm": onConfirm,
  3329. "onCancel": onCancel
  3330. }, pick(slots, pickerToolbarSlots)) : null, vue.createVNode(Tabs, {
  3331. "active": activeTab.value,
  3332. "onUpdate:active": ($event) => activeTab.value = $event,
  3333. "class": bem$1l("tabs"),
  3334. "shrink": true,
  3335. "animated": true,
  3336. "lazyRender": false
  3337. }, {
  3338. default: () => [props2.tabs.map((title, index) => vue.createVNode(Tab, {
  3339. "title": title,
  3340. "titleClass": bem$1l("tab-title")
  3341. }, {
  3342. default: () => [childNodes == null ? void 0 : childNodes[index]]
  3343. }))]
  3344. })]);
  3345. };
  3346. }
  3347. });
  3348. const pickerSharedProps = extend({
  3349. loading: Boolean,
  3350. readonly: Boolean,
  3351. allowHtml: Boolean,
  3352. optionHeight: makeNumericProp(44),
  3353. showToolbar: truthProp,
  3354. swipeDuration: makeNumericProp(1e3),
  3355. visibleOptionNum: makeNumericProp(6)
  3356. }, pickerToolbarProps);
  3357. const pickerProps = extend({}, pickerSharedProps, {
  3358. columns: makeArrayProp(),
  3359. modelValue: makeArrayProp(),
  3360. toolbarPosition: makeStringProp("top"),
  3361. columnsFieldNames: Object
  3362. });
  3363. var stdin_default$1z = vue.defineComponent({
  3364. name: name$1z,
  3365. props: pickerProps,
  3366. emits: ["confirm", "cancel", "change", "scrollInto", "clickOption", "update:modelValue"],
  3367. setup(props2, {
  3368. emit,
  3369. slots
  3370. }) {
  3371. const columnsRef = vue.ref();
  3372. const selectedValues = vue.ref(props2.modelValue.slice(0));
  3373. const {
  3374. parent
  3375. } = use.useParent(PICKER_GROUP_KEY);
  3376. const {
  3377. children,
  3378. linkChildren
  3379. } = use.useChildren(PICKER_KEY);
  3380. linkChildren();
  3381. const fields = vue.computed(() => assignDefaultFields(props2.columnsFieldNames));
  3382. const optionHeight = vue.computed(() => unitToPx(props2.optionHeight));
  3383. const columnsType = vue.computed(() => getColumnsType(props2.columns, fields.value));
  3384. const currentColumns = vue.computed(() => {
  3385. const {
  3386. columns
  3387. } = props2;
  3388. switch (columnsType.value) {
  3389. case "multiple":
  3390. return columns;
  3391. case "cascade":
  3392. return formatCascadeColumns(columns, fields.value, selectedValues);
  3393. default:
  3394. return [columns];
  3395. }
  3396. });
  3397. const hasOptions = vue.computed(() => currentColumns.value.some((options) => options.length));
  3398. const selectedOptions = vue.computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
  3399. const selectedIndexes = vue.computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
  3400. const setValue = (index, value) => {
  3401. if (selectedValues.value[index] !== value) {
  3402. const newValues = selectedValues.value.slice(0);
  3403. newValues[index] = value;
  3404. selectedValues.value = newValues;
  3405. }
  3406. };
  3407. const getEventParams = () => ({
  3408. selectedValues: selectedValues.value.slice(0),
  3409. selectedOptions: selectedOptions.value,
  3410. selectedIndexes: selectedIndexes.value
  3411. });
  3412. const onChange = (value, columnIndex) => {
  3413. setValue(columnIndex, value);
  3414. if (columnsType.value === "cascade") {
  3415. selectedValues.value.forEach((value2, index) => {
  3416. const options = currentColumns.value[index];
  3417. if (!isOptionExist(options, value2, fields.value)) {
  3418. setValue(index, options.length ? options[0][fields.value.value] : void 0);
  3419. }
  3420. });
  3421. }
  3422. vue.nextTick(() => {
  3423. emit("change", extend({
  3424. columnIndex
  3425. }, getEventParams()));
  3426. });
  3427. };
  3428. const onClickOption = (currentOption, columnIndex) => {
  3429. const params = {
  3430. columnIndex,
  3431. currentOption
  3432. };
  3433. emit("clickOption", extend(getEventParams(), params));
  3434. emit("scrollInto", params);
  3435. };
  3436. const confirm = () => {
  3437. children.forEach((child) => child.stopMomentum());
  3438. const params = getEventParams();
  3439. vue.nextTick(() => {
  3440. emit("confirm", params);
  3441. });
  3442. return params;
  3443. };
  3444. const cancel = () => emit("cancel", getEventParams());
  3445. const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => vue.createVNode(stdin_default$1I, {
  3446. "value": selectedValues.value[columnIndex],
  3447. "fields": fields.value,
  3448. "options": options,
  3449. "readonly": props2.readonly,
  3450. "allowHtml": props2.allowHtml,
  3451. "optionHeight": optionHeight.value,
  3452. "swipeDuration": props2.swipeDuration,
  3453. "visibleOptionNum": props2.visibleOptionNum,
  3454. "onChange": (value) => onChange(value, columnIndex),
  3455. "onClickOption": (option) => onClickOption(option, columnIndex),
  3456. "onScrollInto": (option) => {
  3457. emit("scrollInto", {
  3458. currentOption: option,
  3459. columnIndex
  3460. });
  3461. }
  3462. }, {
  3463. option: slots.option
  3464. }));
  3465. const renderMask = (wrapHeight) => {
  3466. if (hasOptions.value) {
  3467. const frameStyle = {
  3468. height: `${optionHeight.value}px`
  3469. };
  3470. const maskStyle = {
  3471. backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
  3472. };
  3473. return [vue.createVNode("div", {
  3474. "class": bem$1u("mask"),
  3475. "style": maskStyle
  3476. }, null), vue.createVNode("div", {
  3477. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1u("frame")],
  3478. "style": frameStyle
  3479. }, null)];
  3480. }
  3481. };
  3482. const renderColumns = () => {
  3483. const wrapHeight = optionHeight.value * +props2.visibleOptionNum;
  3484. const columnsStyle = {
  3485. height: `${wrapHeight}px`
  3486. };
  3487. return vue.createVNode("div", {
  3488. "ref": columnsRef,
  3489. "class": bem$1u("columns"),
  3490. "style": columnsStyle
  3491. }, [renderColumnItems(), renderMask(wrapHeight)]);
  3492. };
  3493. const renderToolbar = () => {
  3494. if (props2.showToolbar && !parent) {
  3495. return vue.createVNode(stdin_default$1H, vue.mergeProps(pick(props2, pickerToolbarPropKeys), {
  3496. "onConfirm": confirm,
  3497. "onCancel": cancel
  3498. }), pick(slots, pickerToolbarSlots));
  3499. }
  3500. };
  3501. vue.watch(currentColumns, (columns) => {
  3502. columns.forEach((options, index) => {
  3503. if (options.length && !isOptionExist(options, selectedValues.value[index], fields.value)) {
  3504. setValue(index, getFirstEnabledOption(options)[fields.value.value]);
  3505. }
  3506. });
  3507. }, {
  3508. immediate: true
  3509. });
  3510. let lastEmittedModelValue;
  3511. vue.watch(() => props2.modelValue, (newValues) => {
  3512. if (!isSameValue(newValues, selectedValues.value) && !isSameValue(newValues, lastEmittedModelValue)) {
  3513. selectedValues.value = newValues.slice(0);
  3514. lastEmittedModelValue = newValues.slice(0);
  3515. }
  3516. }, {
  3517. deep: true
  3518. });
  3519. vue.watch(selectedValues, (newValues) => {
  3520. if (!isSameValue(newValues, props2.modelValue)) {
  3521. lastEmittedModelValue = newValues.slice(0);
  3522. emit("update:modelValue", lastEmittedModelValue);
  3523. }
  3524. }, {
  3525. immediate: true
  3526. });
  3527. use.useEventListener("touchmove", preventDefault, {
  3528. target: columnsRef
  3529. });
  3530. const getSelectedOptions = () => selectedOptions.value;
  3531. useExpose({
  3532. confirm,
  3533. getSelectedOptions
  3534. });
  3535. return () => {
  3536. var _a, _b;
  3537. return vue.createVNode("div", {
  3538. "class": bem$1u()
  3539. }, [props2.toolbarPosition === "top" ? renderToolbar() : null, props2.loading ? vue.createVNode(Loading, {
  3540. "class": bem$1u("loading")
  3541. }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props2.toolbarPosition === "bottom" ? renderToolbar() : null]);
  3542. };
  3543. }
  3544. });
  3545. const AREA_EMPTY_CODE = "000000";
  3546. const INHERIT_SLOTS = [
  3547. "title",
  3548. "cancel",
  3549. "confirm",
  3550. "toolbar",
  3551. "columns-top",
  3552. "columns-bottom"
  3553. ];
  3554. const INHERIT_PROPS = [
  3555. "title",
  3556. "loading",
  3557. "readonly",
  3558. "optionHeight",
  3559. "swipeDuration",
  3560. "visibleOptionNum",
  3561. "cancelButtonText",
  3562. "confirmButtonText"
  3563. ];
  3564. const makeOption = (text = "", value = AREA_EMPTY_CODE, children = void 0) => ({
  3565. text,
  3566. value,
  3567. children
  3568. });
  3569. function formatDataForCascade({
  3570. areaList,
  3571. columnsNum,
  3572. columnsPlaceholder: placeholder
  3573. }) {
  3574. const {
  3575. city_list: city = {},
  3576. county_list: county = {},
  3577. province_list: province = {}
  3578. } = areaList;
  3579. const showCity = +columnsNum > 1;
  3580. const showCounty = +columnsNum > 2;
  3581. const getProvinceChildren = () => {
  3582. if (showCity) {
  3583. return placeholder.length > 1 ? [
  3584. makeOption(
  3585. placeholder[1],
  3586. AREA_EMPTY_CODE,
  3587. showCounty ? [] : void 0
  3588. )
  3589. ] : [];
  3590. }
  3591. };
  3592. const provinceMap = /* @__PURE__ */ new Map();
  3593. Object.keys(province).forEach((code) => {
  3594. provinceMap.set(
  3595. code.slice(0, 2),
  3596. makeOption(province[code], code, getProvinceChildren())
  3597. );
  3598. });
  3599. const cityMap = /* @__PURE__ */ new Map();
  3600. if (showCity) {
  3601. const getCityChildren = () => {
  3602. if (showCounty) {
  3603. return placeholder.length > 2 ? [makeOption(placeholder[2])] : [];
  3604. }
  3605. };
  3606. Object.keys(city).forEach((code) => {
  3607. const option = makeOption(city[code], code, getCityChildren());
  3608. cityMap.set(code.slice(0, 4), option);
  3609. const province2 = provinceMap.get(code.slice(0, 2));
  3610. if (province2) {
  3611. province2.children.push(option);
  3612. }
  3613. });
  3614. }
  3615. if (showCounty) {
  3616. Object.keys(county).forEach((code) => {
  3617. const city2 = cityMap.get(code.slice(0, 4));
  3618. if (city2) {
  3619. city2.children.push(makeOption(county[code], code));
  3620. }
  3621. });
  3622. }
  3623. const options = Array.from(provinceMap.values());
  3624. if (placeholder.length) {
  3625. const county2 = showCounty ? [makeOption(placeholder[2])] : void 0;
  3626. const city2 = showCity ? [makeOption(placeholder[1], AREA_EMPTY_CODE, county2)] : void 0;
  3627. options.unshift(makeOption(placeholder[0], AREA_EMPTY_CODE, city2));
  3628. }
  3629. return options;
  3630. }
  3631. const Picker = withInstall(stdin_default$1z);
  3632. const [name$1o, bem$1k] = createNamespace("area");
  3633. const areaProps = extend({}, pick(pickerSharedProps, INHERIT_PROPS), {
  3634. modelValue: String,
  3635. columnsNum: makeNumericProp(3),
  3636. columnsPlaceholder: makeArrayProp(),
  3637. areaList: {
  3638. type: Object,
  3639. default: () => ({})
  3640. }
  3641. });
  3642. var stdin_default$1y = vue.defineComponent({
  3643. name: name$1o,
  3644. props: areaProps,
  3645. emits: ["change", "confirm", "cancel", "update:modelValue"],
  3646. setup(props2, {
  3647. emit,
  3648. slots
  3649. }) {
  3650. const codes = vue.ref([]);
  3651. const picker = vue.ref();
  3652. const columns = vue.computed(() => formatDataForCascade(props2));
  3653. const onChange = (...args) => emit("change", ...args);
  3654. const onCancel = (...args) => emit("cancel", ...args);
  3655. const onConfirm = (...args) => emit("confirm", ...args);
  3656. vue.watch(codes, (newCodes) => {
  3657. const lastCode = newCodes.length ? newCodes[newCodes.length - 1] : "";
  3658. if (lastCode && lastCode !== props2.modelValue) {
  3659. emit("update:modelValue", lastCode);
  3660. }
  3661. }, {
  3662. deep: true
  3663. });
  3664. vue.watch(() => props2.modelValue, (newCode) => {
  3665. if (newCode) {
  3666. const lastCode = codes.value.length ? codes.value[codes.value.length - 1] : "";
  3667. if (newCode !== lastCode) {
  3668. codes.value = [`${newCode.slice(0, 2)}0000`, `${newCode.slice(0, 4)}00`, newCode].slice(0, +props2.columnsNum);
  3669. }
  3670. } else {
  3671. codes.value = [];
  3672. }
  3673. }, {
  3674. immediate: true
  3675. });
  3676. useExpose({
  3677. confirm: () => {
  3678. var _a;
  3679. return (_a = picker.value) == null ? void 0 : _a.confirm();
  3680. },
  3681. getSelectedOptions: () => {
  3682. var _a;
  3683. return ((_a = picker.value) == null ? void 0 : _a.getSelectedOptions()) || [];
  3684. }
  3685. });
  3686. return () => vue.createVNode(Picker, vue.mergeProps({
  3687. "ref": picker,
  3688. "modelValue": codes.value,
  3689. "onUpdate:modelValue": ($event) => codes.value = $event,
  3690. "class": bem$1k(),
  3691. "columns": columns.value,
  3692. "onChange": onChange,
  3693. "onCancel": onCancel,
  3694. "onConfirm": onConfirm
  3695. }, pick(props2, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  3696. }
  3697. });
  3698. const Area = withInstall(stdin_default$1y);
  3699. const [name$1n, bem$1j] = createNamespace("cell");
  3700. const cellSharedProps = {
  3701. tag: makeStringProp("div"),
  3702. icon: String,
  3703. size: String,
  3704. title: numericProp,
  3705. value: numericProp,
  3706. label: numericProp,
  3707. center: Boolean,
  3708. isLink: Boolean,
  3709. border: truthProp,
  3710. iconPrefix: String,
  3711. valueClass: unknownProp,
  3712. labelClass: unknownProp,
  3713. titleClass: unknownProp,
  3714. titleStyle: null,
  3715. arrowDirection: String,
  3716. required: {
  3717. type: [Boolean, String],
  3718. default: null
  3719. },
  3720. clickable: {
  3721. type: Boolean,
  3722. default: null
  3723. }
  3724. };
  3725. const cellProps = extend({}, cellSharedProps, routeProps);
  3726. var stdin_default$1x = vue.defineComponent({
  3727. name: name$1n,
  3728. props: cellProps,
  3729. setup(props2, {
  3730. slots
  3731. }) {
  3732. const route2 = useRoute();
  3733. const renderLabel = () => {
  3734. const showLabel = slots.label || isDef(props2.label);
  3735. if (showLabel) {
  3736. return vue.createVNode("div", {
  3737. "class": [bem$1j("label"), props2.labelClass]
  3738. }, [slots.label ? slots.label() : props2.label]);
  3739. }
  3740. };
  3741. const renderTitle = () => {
  3742. var _a;
  3743. if (slots.title || isDef(props2.title)) {
  3744. const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
  3745. if (Array.isArray(titleSlot) && titleSlot.length === 0) {
  3746. return;
  3747. }
  3748. return vue.createVNode("div", {
  3749. "class": [bem$1j("title"), props2.titleClass],
  3750. "style": props2.titleStyle
  3751. }, [titleSlot || vue.createVNode("span", null, [props2.title]), renderLabel()]);
  3752. }
  3753. };
  3754. const renderValue = () => {
  3755. const slot = slots.value || slots.default;
  3756. const hasValue = slot || isDef(props2.value);
  3757. if (hasValue) {
  3758. return vue.createVNode("div", {
  3759. "class": [bem$1j("value"), props2.valueClass]
  3760. }, [slot ? slot() : vue.createVNode("span", null, [props2.value])]);
  3761. }
  3762. };
  3763. const renderLeftIcon = () => {
  3764. if (slots.icon) {
  3765. return slots.icon();
  3766. }
  3767. if (props2.icon) {
  3768. return vue.createVNode(Icon, {
  3769. "name": props2.icon,
  3770. "class": bem$1j("left-icon"),
  3771. "classPrefix": props2.iconPrefix
  3772. }, null);
  3773. }
  3774. };
  3775. const renderRightIcon = () => {
  3776. if (slots["right-icon"]) {
  3777. return slots["right-icon"]();
  3778. }
  3779. if (props2.isLink) {
  3780. const name2 = props2.arrowDirection && props2.arrowDirection !== "right" ? `arrow-${props2.arrowDirection}` : "arrow";
  3781. return vue.createVNode(Icon, {
  3782. "name": name2,
  3783. "class": bem$1j("right-icon")
  3784. }, null);
  3785. }
  3786. };
  3787. return () => {
  3788. var _a;
  3789. const {
  3790. tag,
  3791. size,
  3792. center,
  3793. border,
  3794. isLink,
  3795. required
  3796. } = props2;
  3797. const clickable = (_a = props2.clickable) != null ? _a : isLink;
  3798. const classes = {
  3799. center,
  3800. required: !!required,
  3801. clickable,
  3802. borderless: !border
  3803. };
  3804. if (size) {
  3805. classes[size] = !!size;
  3806. }
  3807. return vue.createVNode(tag, {
  3808. "class": bem$1j(classes),
  3809. "role": clickable ? "button" : void 0,
  3810. "tabindex": clickable ? 0 : void 0,
  3811. "onClick": route2
  3812. }, {
  3813. default: () => {
  3814. var _a2;
  3815. return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
  3816. }
  3817. });
  3818. };
  3819. }
  3820. });
  3821. const Cell = withInstall(stdin_default$1x);
  3822. const [name$1m, bem$1i] = createNamespace("form");
  3823. const formProps = {
  3824. colon: Boolean,
  3825. disabled: Boolean,
  3826. readonly: Boolean,
  3827. required: [Boolean, String],
  3828. showError: Boolean,
  3829. labelWidth: numericProp,
  3830. labelAlign: String,
  3831. inputAlign: String,
  3832. scrollToError: Boolean,
  3833. scrollToErrorPosition: String,
  3834. validateFirst: Boolean,
  3835. submitOnEnter: truthProp,
  3836. showErrorMessage: truthProp,
  3837. errorMessageAlign: String,
  3838. validateTrigger: {
  3839. type: [String, Array],
  3840. default: "onBlur"
  3841. }
  3842. };
  3843. var stdin_default$1w = vue.defineComponent({
  3844. name: name$1m,
  3845. props: formProps,
  3846. emits: ["submit", "failed"],
  3847. setup(props2, {
  3848. emit,
  3849. slots
  3850. }) {
  3851. const {
  3852. children,
  3853. linkChildren
  3854. } = use.useChildren(FORM_KEY);
  3855. const getFieldsByNames = (names) => {
  3856. if (names) {
  3857. return children.filter((field) => names.includes(field.name));
  3858. }
  3859. return children;
  3860. };
  3861. const validateSeq = (names) => new Promise((resolve, reject) => {
  3862. const errors = [];
  3863. const fields = getFieldsByNames(names);
  3864. fields.reduce((promise, field) => promise.then(() => {
  3865. if (!errors.length) {
  3866. return field.validate().then((error) => {
  3867. if (error) {
  3868. errors.push(error);
  3869. }
  3870. });
  3871. }
  3872. }), Promise.resolve()).then(() => {
  3873. if (errors.length) {
  3874. reject(errors);
  3875. } else {
  3876. resolve();
  3877. }
  3878. });
  3879. });
  3880. const validateAll = (names) => new Promise((resolve, reject) => {
  3881. const fields = getFieldsByNames(names);
  3882. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  3883. errors = errors.filter(Boolean);
  3884. if (errors.length) {
  3885. reject(errors);
  3886. } else {
  3887. resolve();
  3888. }
  3889. });
  3890. });
  3891. const validateField = (name2) => {
  3892. const matched = children.find((item) => item.name === name2);
  3893. if (matched) {
  3894. return new Promise((resolve, reject) => {
  3895. matched.validate().then((error) => {
  3896. if (error) {
  3897. reject(error);
  3898. } else {
  3899. resolve();
  3900. }
  3901. });
  3902. });
  3903. }
  3904. return Promise.reject();
  3905. };
  3906. const validate = (name2) => {
  3907. if (typeof name2 === "string") {
  3908. return validateField(name2);
  3909. }
  3910. return props2.validateFirst ? validateSeq(name2) : validateAll(name2);
  3911. };
  3912. const resetValidation = (name2) => {
  3913. if (typeof name2 === "string") {
  3914. name2 = [name2];
  3915. }
  3916. const fields = getFieldsByNames(name2);
  3917. fields.forEach((item) => {
  3918. item.resetValidation();
  3919. });
  3920. };
  3921. const getValidationStatus = () => children.reduce((form, field) => {
  3922. form[field.name] = field.getValidationStatus();
  3923. return form;
  3924. }, {});
  3925. const scrollToField = (name2, options) => {
  3926. children.some((item) => {
  3927. if (item.name === name2) {
  3928. item.$el.scrollIntoView(options);
  3929. return true;
  3930. }
  3931. return false;
  3932. });
  3933. };
  3934. const getValues = () => children.reduce((form, field) => {
  3935. if (field.name !== void 0) {
  3936. form[field.name] = field.formValue.value;
  3937. }
  3938. return form;
  3939. }, {});
  3940. const submit = () => {
  3941. const values = getValues();
  3942. validate().then(() => emit("submit", values)).catch((errors) => {
  3943. emit("failed", {
  3944. values,
  3945. errors
  3946. });
  3947. const {
  3948. scrollToError,
  3949. scrollToErrorPosition
  3950. } = props2;
  3951. if (scrollToError && errors[0].name) {
  3952. scrollToField(errors[0].name, scrollToErrorPosition ? {
  3953. block: scrollToErrorPosition
  3954. } : void 0);
  3955. }
  3956. });
  3957. };
  3958. const onSubmit = (event) => {
  3959. preventDefault(event);
  3960. submit();
  3961. };
  3962. linkChildren({
  3963. props: props2
  3964. });
  3965. useExpose({
  3966. submit,
  3967. validate,
  3968. getValues,
  3969. scrollToField,
  3970. resetValidation,
  3971. getValidationStatus
  3972. });
  3973. return () => {
  3974. var _a;
  3975. return vue.createVNode("form", {
  3976. "class": bem$1i(),
  3977. "onSubmit": onSubmit
  3978. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3979. };
  3980. }
  3981. });
  3982. const Form = withInstall(stdin_default$1w);
  3983. function isEmptyValue(value) {
  3984. if (Array.isArray(value)) {
  3985. return !value.length;
  3986. }
  3987. if (value === 0) {
  3988. return false;
  3989. }
  3990. return !value;
  3991. }
  3992. function runSyncRule(value, rule) {
  3993. if (isEmptyValue(value)) {
  3994. if (rule.required) {
  3995. return false;
  3996. }
  3997. if (rule.validateEmpty === false) {
  3998. return true;
  3999. }
  4000. }
  4001. if (rule.pattern && !rule.pattern.test(String(value))) {
  4002. return false;
  4003. }
  4004. return true;
  4005. }
  4006. function runRuleValidator(value, rule) {
  4007. return new Promise((resolve) => {
  4008. const returnVal = rule.validator(value, rule);
  4009. if (isPromise(returnVal)) {
  4010. returnVal.then(resolve);
  4011. return;
  4012. }
  4013. resolve(returnVal);
  4014. });
  4015. }
  4016. function getRuleMessage(value, rule) {
  4017. const { message } = rule;
  4018. if (isFunction(message)) {
  4019. return message(value, rule);
  4020. }
  4021. return message || "";
  4022. }
  4023. function startComposing({ target }) {
  4024. target.composing = true;
  4025. }
  4026. function endComposing({ target }) {
  4027. if (target.composing) {
  4028. target.composing = false;
  4029. target.dispatchEvent(new Event("input"));
  4030. }
  4031. }
  4032. function resizeTextarea(input, autosize) {
  4033. const scrollTop = getRootScrollTop();
  4034. input.style.height = "auto";
  4035. let height = input.scrollHeight;
  4036. if (isObject(autosize)) {
  4037. const { maxHeight, minHeight } = autosize;
  4038. if (maxHeight !== void 0) {
  4039. height = Math.min(height, maxHeight);
  4040. }
  4041. if (minHeight !== void 0) {
  4042. height = Math.max(height, minHeight);
  4043. }
  4044. }
  4045. if (height) {
  4046. input.style.height = `${height}px`;
  4047. setRootScrollTop(scrollTop);
  4048. }
  4049. }
  4050. function mapInputType(type, inputmode) {
  4051. if (type === "number") {
  4052. type = "text";
  4053. inputmode != null ? inputmode : inputmode = "decimal";
  4054. }
  4055. if (type === "digit") {
  4056. type = "tel";
  4057. inputmode != null ? inputmode : inputmode = "numeric";
  4058. }
  4059. return { type, inputmode };
  4060. }
  4061. function getStringLength(str) {
  4062. return [...str].length;
  4063. }
  4064. function cutString(str, maxlength) {
  4065. return [...str].slice(0, maxlength).join("");
  4066. }
  4067. const [name$1l, bem$1h] = createNamespace("field");
  4068. const fieldSharedProps = {
  4069. id: String,
  4070. name: String,
  4071. leftIcon: String,
  4072. rightIcon: String,
  4073. autofocus: Boolean,
  4074. clearable: Boolean,
  4075. maxlength: numericProp,
  4076. max: Number,
  4077. min: Number,
  4078. formatter: Function,
  4079. clearIcon: makeStringProp("clear"),
  4080. modelValue: makeNumericProp(""),
  4081. inputAlign: String,
  4082. placeholder: String,
  4083. autocomplete: String,
  4084. autocapitalize: String,
  4085. autocorrect: String,
  4086. errorMessage: String,
  4087. enterkeyhint: String,
  4088. clearTrigger: makeStringProp("focus"),
  4089. formatTrigger: makeStringProp("onChange"),
  4090. spellcheck: {
  4091. type: Boolean,
  4092. default: null
  4093. },
  4094. error: {
  4095. type: Boolean,
  4096. default: null
  4097. },
  4098. disabled: {
  4099. type: Boolean,
  4100. default: null
  4101. },
  4102. readonly: {
  4103. type: Boolean,
  4104. default: null
  4105. },
  4106. inputmode: String
  4107. };
  4108. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  4109. rows: numericProp,
  4110. type: makeStringProp("text"),
  4111. rules: Array,
  4112. autosize: [Boolean, Object],
  4113. labelWidth: numericProp,
  4114. labelClass: unknownProp,
  4115. labelAlign: String,
  4116. showWordLimit: Boolean,
  4117. errorMessageAlign: String,
  4118. colon: {
  4119. type: Boolean,
  4120. default: null
  4121. }
  4122. });
  4123. var stdin_default$1v = vue.defineComponent({
  4124. name: name$1l,
  4125. props: fieldProps,
  4126. emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  4127. setup(props2, {
  4128. emit,
  4129. slots
  4130. }) {
  4131. const id = useId();
  4132. const state = vue.reactive({
  4133. status: "unvalidated",
  4134. focused: false,
  4135. validateMessage: ""
  4136. });
  4137. const inputRef = vue.ref();
  4138. const clearIconRef = vue.ref();
  4139. const customValue = vue.ref();
  4140. const {
  4141. parent: form
  4142. } = use.useParent(FORM_KEY);
  4143. const getModelValue = () => {
  4144. var _a;
  4145. return String((_a = props2.modelValue) != null ? _a : "");
  4146. };
  4147. const getProp = (key) => {
  4148. if (isDef(props2[key])) {
  4149. return props2[key];
  4150. }
  4151. if (form && isDef(form.props[key])) {
  4152. return form.props[key];
  4153. }
  4154. };
  4155. const showClear = vue.computed(() => {
  4156. const readonly = getProp("readonly");
  4157. if (props2.clearable && !readonly) {
  4158. const hasValue = getModelValue() !== "";
  4159. const trigger = props2.clearTrigger === "always" || props2.clearTrigger === "focus" && state.focused;
  4160. return hasValue && trigger;
  4161. }
  4162. return false;
  4163. });
  4164. const formValue = vue.computed(() => {
  4165. if (customValue.value && slots.input) {
  4166. return customValue.value();
  4167. }
  4168. return props2.modelValue;
  4169. });
  4170. const showRequiredMark = vue.computed(() => {
  4171. var _a;
  4172. const required = getProp("required");
  4173. if (required === "auto") {
  4174. return (_a = props2.rules) == null ? void 0 : _a.some((rule) => rule.required);
  4175. }
  4176. return required;
  4177. });
  4178. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  4179. if (state.status === "failed") {
  4180. return;
  4181. }
  4182. let {
  4183. value
  4184. } = formValue;
  4185. if (rule.formatter) {
  4186. value = rule.formatter(value, rule);
  4187. }
  4188. if (!runSyncRule(value, rule)) {
  4189. state.status = "failed";
  4190. state.validateMessage = getRuleMessage(value, rule);
  4191. return;
  4192. }
  4193. if (rule.validator) {
  4194. if (isEmptyValue(value) && rule.validateEmpty === false) {
  4195. return;
  4196. }
  4197. return runRuleValidator(value, rule).then((result) => {
  4198. if (result && typeof result === "string") {
  4199. state.status = "failed";
  4200. state.validateMessage = result;
  4201. } else if (result === false) {
  4202. state.status = "failed";
  4203. state.validateMessage = getRuleMessage(value, rule);
  4204. }
  4205. });
  4206. }
  4207. }), Promise.resolve());
  4208. const resetValidation = () => {
  4209. state.status = "unvalidated";
  4210. state.validateMessage = "";
  4211. };
  4212. const endValidate = () => emit("endValidate", {
  4213. status: state.status,
  4214. message: state.validateMessage
  4215. });
  4216. const validate = (rules = props2.rules) => new Promise((resolve) => {
  4217. resetValidation();
  4218. if (rules) {
  4219. emit("startValidate");
  4220. runRules(rules).then(() => {
  4221. if (state.status === "failed") {
  4222. resolve({
  4223. name: props2.name,
  4224. message: state.validateMessage
  4225. });
  4226. endValidate();
  4227. } else {
  4228. state.status = "passed";
  4229. resolve();
  4230. endValidate();
  4231. }
  4232. });
  4233. } else {
  4234. resolve();
  4235. }
  4236. });
  4237. const validateWithTrigger = (trigger) => {
  4238. if (form && props2.rules) {
  4239. const {
  4240. validateTrigger
  4241. } = form.props;
  4242. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  4243. const rules = props2.rules.filter((rule) => {
  4244. if (rule.trigger) {
  4245. return toArray(rule.trigger).includes(trigger);
  4246. }
  4247. return defaultTrigger;
  4248. });
  4249. if (rules.length) {
  4250. validate(rules);
  4251. }
  4252. }
  4253. };
  4254. const limitValueLength = (value) => {
  4255. var _a;
  4256. const {
  4257. maxlength
  4258. } = props2;
  4259. if (isDef(maxlength) && getStringLength(value) > +maxlength) {
  4260. const modelValue = getModelValue();
  4261. if (modelValue && getStringLength(modelValue) === +maxlength) {
  4262. return modelValue;
  4263. }
  4264. const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
  4265. if (state.focused && selectionEnd) {
  4266. const valueArr = [...value];
  4267. const exceededLength = valueArr.length - +maxlength;
  4268. valueArr.splice(selectionEnd - exceededLength, exceededLength);
  4269. return valueArr.join("");
  4270. }
  4271. return cutString(value, +maxlength);
  4272. }
  4273. return value;
  4274. };
  4275. const updateValue = (value, trigger = "onChange") => {
  4276. var _a, _b;
  4277. const originalValue = value;
  4278. value = limitValueLength(value);
  4279. const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
  4280. if (props2.type === "number" || props2.type === "digit") {
  4281. const isNumber = props2.type === "number";
  4282. value = formatNumber(value, isNumber, isNumber);
  4283. if (trigger === "onBlur" && value !== "" && (props2.min !== void 0 || props2.max !== void 0)) {
  4284. const adjustedValue = clamp(+value, (_a = props2.min) != null ? _a : -Infinity, (_b = props2.max) != null ? _b : Infinity);
  4285. value = adjustedValue.toString();
  4286. }
  4287. }
  4288. let formatterDiffLen = 0;
  4289. if (props2.formatter && trigger === props2.formatTrigger) {
  4290. const {
  4291. formatter,
  4292. maxlength
  4293. } = props2;
  4294. value = formatter(value);
  4295. if (isDef(maxlength) && getStringLength(value) > +maxlength) {
  4296. value = cutString(value, +maxlength);
  4297. }
  4298. if (inputRef.value && state.focused) {
  4299. const {
  4300. selectionEnd
  4301. } = inputRef.value;
  4302. const bcoVal = cutString(originalValue, selectionEnd);
  4303. formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
  4304. }
  4305. }
  4306. if (inputRef.value && inputRef.value.value !== value) {
  4307. if (state.focused) {
  4308. let {
  4309. selectionStart,
  4310. selectionEnd
  4311. } = inputRef.value;
  4312. inputRef.value.value = value;
  4313. if (isDef(selectionStart) && isDef(selectionEnd)) {
  4314. const valueLen = getStringLength(value);
  4315. if (limitDiffLen) {
  4316. selectionStart -= limitDiffLen;
  4317. selectionEnd -= limitDiffLen;
  4318. } else if (formatterDiffLen) {
  4319. selectionStart += formatterDiffLen;
  4320. selectionEnd += formatterDiffLen;
  4321. }
  4322. inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
  4323. }
  4324. } else {
  4325. inputRef.value.value = value;
  4326. }
  4327. }
  4328. if (value !== props2.modelValue) {
  4329. emit("update:modelValue", value);
  4330. }
  4331. };
  4332. const onInput = (event) => {
  4333. if (!event.target.composing) {
  4334. updateValue(event.target.value);
  4335. }
  4336. };
  4337. const blur = () => {
  4338. var _a;
  4339. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  4340. };
  4341. const focus = () => {
  4342. var _a;
  4343. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  4344. };
  4345. const adjustTextareaSize = () => {
  4346. const input = inputRef.value;
  4347. if (props2.type === "textarea" && props2.autosize && input) {
  4348. resizeTextarea(input, props2.autosize);
  4349. }
  4350. };
  4351. const onFocus = (event) => {
  4352. state.focused = true;
  4353. emit("focus", event);
  4354. vue.nextTick(adjustTextareaSize);
  4355. if (getProp("readonly")) {
  4356. blur();
  4357. }
  4358. };
  4359. const onBlur = (event) => {
  4360. state.focused = false;
  4361. updateValue(getModelValue(), "onBlur");
  4362. emit("blur", event);
  4363. if (getProp("readonly")) {
  4364. return;
  4365. }
  4366. validateWithTrigger("onBlur");
  4367. vue.nextTick(adjustTextareaSize);
  4368. resetScroll();
  4369. };
  4370. const onClickInput = (event) => emit("clickInput", event);
  4371. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  4372. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  4373. const onClear = (event) => {
  4374. preventDefault(event);
  4375. emit("update:modelValue", "");
  4376. emit("clear", event);
  4377. };
  4378. const showError = vue.computed(() => {
  4379. if (typeof props2.error === "boolean") {
  4380. return props2.error;
  4381. }
  4382. if (form && form.props.showError && state.status === "failed") {
  4383. return true;
  4384. }
  4385. });
  4386. const labelStyle = vue.computed(() => {
  4387. const labelWidth = getProp("labelWidth");
  4388. const labelAlign = getProp("labelAlign");
  4389. if (labelWidth && labelAlign !== "top") {
  4390. return {
  4391. width: addUnit(labelWidth)
  4392. };
  4393. }
  4394. });
  4395. const onKeypress = (event) => {
  4396. const ENTER_CODE = 13;
  4397. if (event.keyCode === ENTER_CODE) {
  4398. const submitOnEnter = form && form.props.submitOnEnter;
  4399. if (!submitOnEnter && props2.type !== "textarea") {
  4400. preventDefault(event);
  4401. }
  4402. if (props2.type === "search") {
  4403. blur();
  4404. }
  4405. }
  4406. emit("keypress", event);
  4407. };
  4408. const getInputId = () => props2.id || `${id}-input`;
  4409. const getValidationStatus = () => state.status;
  4410. const renderInput = () => {
  4411. const controlClass = bem$1h("control", [getProp("inputAlign"), {
  4412. error: showError.value,
  4413. custom: !!slots.input,
  4414. "min-height": props2.type === "textarea" && !props2.autosize
  4415. }]);
  4416. if (slots.input) {
  4417. return vue.createVNode("div", {
  4418. "class": controlClass,
  4419. "onClick": onClickInput
  4420. }, [slots.input()]);
  4421. }
  4422. const inputAttrs = {
  4423. id: getInputId(),
  4424. ref: inputRef,
  4425. name: props2.name,
  4426. rows: props2.rows !== void 0 ? +props2.rows : void 0,
  4427. class: controlClass,
  4428. disabled: getProp("disabled"),
  4429. readonly: getProp("readonly"),
  4430. autofocus: props2.autofocus,
  4431. placeholder: props2.placeholder,
  4432. autocomplete: props2.autocomplete,
  4433. autocapitalize: props2.autocapitalize,
  4434. autocorrect: props2.autocorrect,
  4435. enterkeyhint: props2.enterkeyhint,
  4436. spellcheck: props2.spellcheck,
  4437. "aria-labelledby": props2.label ? `${id}-label` : void 0,
  4438. "data-allow-mismatch": "attribute",
  4439. onBlur,
  4440. onFocus,
  4441. onInput,
  4442. onClick: onClickInput,
  4443. onChange: endComposing,
  4444. onKeypress,
  4445. onCompositionend: endComposing,
  4446. onCompositionstart: startComposing
  4447. };
  4448. if (props2.type === "textarea") {
  4449. return vue.createVNode("textarea", vue.mergeProps(inputAttrs, {
  4450. "inputmode": props2.inputmode
  4451. }), null);
  4452. }
  4453. return vue.createVNode("input", vue.mergeProps(mapInputType(props2.type, props2.inputmode), inputAttrs), null);
  4454. };
  4455. const renderLeftIcon = () => {
  4456. const leftIconSlot = slots["left-icon"];
  4457. if (props2.leftIcon || leftIconSlot) {
  4458. return vue.createVNode("div", {
  4459. "class": bem$1h("left-icon"),
  4460. "onClick": onClickLeftIcon
  4461. }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
  4462. "name": props2.leftIcon,
  4463. "classPrefix": props2.iconPrefix
  4464. }, null)]);
  4465. }
  4466. };
  4467. const renderRightIcon = () => {
  4468. const rightIconSlot = slots["right-icon"];
  4469. if (props2.rightIcon || rightIconSlot) {
  4470. return vue.createVNode("div", {
  4471. "class": bem$1h("right-icon"),
  4472. "onClick": onClickRightIcon
  4473. }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
  4474. "name": props2.rightIcon,
  4475. "classPrefix": props2.iconPrefix
  4476. }, null)]);
  4477. }
  4478. };
  4479. const renderWordLimit = () => {
  4480. if (props2.showWordLimit && props2.maxlength) {
  4481. const count = getStringLength(getModelValue());
  4482. return vue.createVNode("div", {
  4483. "class": bem$1h("word-limit")
  4484. }, [vue.createVNode("span", {
  4485. "class": bem$1h("word-num")
  4486. }, [count]), vue.createTextVNode("/"), props2.maxlength]);
  4487. }
  4488. };
  4489. const renderMessage = () => {
  4490. if (form && form.props.showErrorMessage === false) {
  4491. return;
  4492. }
  4493. const message = props2.errorMessage || state.validateMessage;
  4494. if (message) {
  4495. const slot = slots["error-message"];
  4496. const errorMessageAlign = getProp("errorMessageAlign");
  4497. return vue.createVNode("div", {
  4498. "class": bem$1h("error-message", errorMessageAlign)
  4499. }, [slot ? slot({
  4500. message
  4501. }) : message]);
  4502. }
  4503. };
  4504. const renderLabel = () => {
  4505. const labelWidth = getProp("labelWidth");
  4506. const labelAlign = getProp("labelAlign");
  4507. const colon = getProp("colon") ? ":" : "";
  4508. if (slots.label) {
  4509. return [slots.label(), colon];
  4510. }
  4511. if (props2.label) {
  4512. return vue.createVNode("label", {
  4513. "id": `${id}-label`,
  4514. "for": slots.input ? void 0 : getInputId(),
  4515. "data-allow-mismatch": "attribute",
  4516. "onClick": (event) => {
  4517. preventDefault(event);
  4518. focus();
  4519. },
  4520. "style": labelAlign === "top" && labelWidth ? {
  4521. width: addUnit(labelWidth)
  4522. } : void 0
  4523. }, [props2.label + colon]);
  4524. }
  4525. };
  4526. const renderFieldBody = () => [vue.createVNode("div", {
  4527. "class": bem$1h("body")
  4528. }, [renderInput(), showClear.value && vue.createVNode(Icon, {
  4529. "ref": clearIconRef,
  4530. "name": props2.clearIcon,
  4531. "class": bem$1h("clear")
  4532. }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
  4533. "class": bem$1h("button")
  4534. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  4535. useExpose({
  4536. blur,
  4537. focus,
  4538. validate,
  4539. formValue,
  4540. resetValidation,
  4541. getValidationStatus
  4542. });
  4543. vue.provide(use.CUSTOM_FIELD_INJECTION_KEY, {
  4544. customValue,
  4545. resetValidation,
  4546. validateWithTrigger
  4547. });
  4548. vue.watch(() => props2.modelValue, () => {
  4549. updateValue(getModelValue());
  4550. resetValidation();
  4551. validateWithTrigger("onChange");
  4552. vue.nextTick(adjustTextareaSize);
  4553. });
  4554. vue.onMounted(() => {
  4555. updateValue(getModelValue(), props2.formatTrigger);
  4556. vue.nextTick(adjustTextareaSize);
  4557. });
  4558. use.useEventListener("touchstart", onClear, {
  4559. target: vue.computed(() => {
  4560. var _a;
  4561. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  4562. })
  4563. });
  4564. return () => {
  4565. const disabled = getProp("disabled");
  4566. const labelAlign = getProp("labelAlign");
  4567. const LeftIcon = renderLeftIcon();
  4568. const renderTitle = () => {
  4569. const Label = renderLabel();
  4570. if (labelAlign === "top") {
  4571. return [LeftIcon, Label].filter(Boolean);
  4572. }
  4573. return Label || [];
  4574. };
  4575. return vue.createVNode(Cell, {
  4576. "size": props2.size,
  4577. "class": bem$1h({
  4578. error: showError.value,
  4579. disabled,
  4580. [`label-${labelAlign}`]: labelAlign
  4581. }),
  4582. "center": props2.center,
  4583. "border": props2.border,
  4584. "isLink": props2.isLink,
  4585. "clickable": props2.clickable,
  4586. "titleStyle": labelStyle.value,
  4587. "valueClass": bem$1h("value"),
  4588. "titleClass": [bem$1h("label", [labelAlign, {
  4589. required: showRequiredMark.value
  4590. }]), props2.labelClass],
  4591. "arrowDirection": props2.arrowDirection
  4592. }, {
  4593. icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
  4594. title: renderTitle,
  4595. value: renderFieldBody,
  4596. extra: slots.extra
  4597. });
  4598. };
  4599. }
  4600. });
  4601. const Field = withInstall(stdin_default$1v);
  4602. let lockCount = 0;
  4603. function lockClick(lock) {
  4604. if (lock) {
  4605. if (!lockCount) {
  4606. document.body.classList.add("van-toast--unclickable");
  4607. }
  4608. lockCount++;
  4609. } else if (lockCount) {
  4610. lockCount--;
  4611. if (!lockCount) {
  4612. document.body.classList.remove("van-toast--unclickable");
  4613. }
  4614. }
  4615. }
  4616. const [name$1k, bem$1g] = createNamespace("toast");
  4617. const popupInheritProps$1 = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay", "zIndex"];
  4618. const toastProps = {
  4619. icon: String,
  4620. show: Boolean,
  4621. type: makeStringProp("text"),
  4622. overlay: Boolean,
  4623. message: numericProp,
  4624. iconSize: numericProp,
  4625. duration: makeNumberProp(2e3),
  4626. position: makeStringProp("middle"),
  4627. teleport: [String, Object],
  4628. wordBreak: String,
  4629. className: unknownProp,
  4630. iconPrefix: String,
  4631. transition: makeStringProp("van-fade"),
  4632. loadingType: String,
  4633. forbidClick: Boolean,
  4634. overlayClass: unknownProp,
  4635. overlayStyle: Object,
  4636. closeOnClick: Boolean,
  4637. closeOnClickOverlay: Boolean,
  4638. zIndex: numericProp
  4639. };
  4640. var stdin_default$1u = vue.defineComponent({
  4641. name: name$1k,
  4642. props: toastProps,
  4643. emits: ["update:show"],
  4644. setup(props2, {
  4645. emit,
  4646. slots
  4647. }) {
  4648. let timer2;
  4649. let clickable = false;
  4650. const toggleClickable = () => {
  4651. const newValue = props2.show && props2.forbidClick;
  4652. if (clickable !== newValue) {
  4653. clickable = newValue;
  4654. lockClick(clickable);
  4655. }
  4656. };
  4657. const updateShow = (show) => emit("update:show", show);
  4658. const onClick = () => {
  4659. if (props2.closeOnClick) {
  4660. updateShow(false);
  4661. }
  4662. };
  4663. const clearTimer = () => clearTimeout(timer2);
  4664. const renderIcon = () => {
  4665. const {
  4666. icon,
  4667. type,
  4668. iconSize,
  4669. iconPrefix,
  4670. loadingType
  4671. } = props2;
  4672. const hasIcon = icon || type === "success" || type === "fail";
  4673. if (hasIcon) {
  4674. return vue.createVNode(Icon, {
  4675. "name": icon || type,
  4676. "size": iconSize,
  4677. "class": bem$1g("icon"),
  4678. "classPrefix": iconPrefix
  4679. }, null);
  4680. }
  4681. if (type === "loading") {
  4682. return vue.createVNode(Loading, {
  4683. "class": bem$1g("loading"),
  4684. "size": iconSize,
  4685. "type": loadingType
  4686. }, null);
  4687. }
  4688. };
  4689. const renderMessage = () => {
  4690. const {
  4691. type,
  4692. message
  4693. } = props2;
  4694. if (slots.message) {
  4695. return vue.createVNode("div", {
  4696. "class": bem$1g("text")
  4697. }, [slots.message()]);
  4698. }
  4699. if (isDef(message) && message !== "") {
  4700. return type === "html" ? vue.createVNode("div", {
  4701. "key": 0,
  4702. "class": bem$1g("text"),
  4703. "innerHTML": String(message)
  4704. }, null) : vue.createVNode("div", {
  4705. "class": bem$1g("text")
  4706. }, [message]);
  4707. }
  4708. };
  4709. vue.watch(() => [props2.show, props2.forbidClick], toggleClickable);
  4710. vue.watch(() => [props2.show, props2.type, props2.message, props2.duration], () => {
  4711. clearTimer();
  4712. if (props2.show && props2.duration > 0) {
  4713. timer2 = setTimeout(() => {
  4714. updateShow(false);
  4715. }, props2.duration);
  4716. }
  4717. });
  4718. vue.onMounted(toggleClickable);
  4719. vue.onUnmounted(toggleClickable);
  4720. return () => vue.createVNode(Popup, vue.mergeProps({
  4721. "class": [bem$1g([props2.position, props2.wordBreak === "normal" ? "break-normal" : props2.wordBreak, {
  4722. [props2.type]: !props2.icon
  4723. }]), props2.className],
  4724. "lockScroll": false,
  4725. "onClick": onClick,
  4726. "onClosed": clearTimer,
  4727. "onUpdate:show": updateShow
  4728. }, pick(props2, popupInheritProps$1)), {
  4729. default: () => [renderIcon(), renderMessage()]
  4730. });
  4731. }
  4732. });
  4733. function usePopupState() {
  4734. const state = vue.reactive({
  4735. show: false
  4736. });
  4737. const toggle = (show) => {
  4738. state.show = show;
  4739. };
  4740. const open = (props2) => {
  4741. extend(state, props2, { transitionAppear: true });
  4742. toggle(true);
  4743. };
  4744. const close = () => toggle(false);
  4745. useExpose({ open, close, toggle });
  4746. return {
  4747. open,
  4748. close,
  4749. state,
  4750. toggle
  4751. };
  4752. }
  4753. function mountComponent(RootComponent) {
  4754. const app = vue.createApp(RootComponent);
  4755. const root = document.createElement("div");
  4756. document.body.appendChild(root);
  4757. return {
  4758. instance: app.mount(root),
  4759. unmount() {
  4760. app.unmount();
  4761. document.body.removeChild(root);
  4762. }
  4763. };
  4764. }
  4765. const defaultOptions$1 = {
  4766. icon: "",
  4767. type: "text",
  4768. message: "",
  4769. className: "",
  4770. overlay: false,
  4771. onClose: void 0,
  4772. onOpened: void 0,
  4773. duration: 2e3,
  4774. teleport: "body",
  4775. iconSize: void 0,
  4776. iconPrefix: void 0,
  4777. position: "middle",
  4778. transition: "van-fade",
  4779. forbidClick: false,
  4780. loadingType: void 0,
  4781. overlayClass: "",
  4782. overlayStyle: void 0,
  4783. closeOnClick: false,
  4784. closeOnClickOverlay: false
  4785. };
  4786. let queue = [];
  4787. let allowMultiple = false;
  4788. let currentOptions$2 = extend({}, defaultOptions$1);
  4789. const defaultOptionsMap = /* @__PURE__ */ new Map();
  4790. function parseOptions$1(message) {
  4791. if (isObject(message)) {
  4792. return message;
  4793. }
  4794. return {
  4795. message
  4796. };
  4797. }
  4798. function createInstance() {
  4799. const {
  4800. instance: instance2,
  4801. unmount
  4802. } = mountComponent({
  4803. setup() {
  4804. const message = vue.ref("");
  4805. const {
  4806. open,
  4807. state,
  4808. close,
  4809. toggle
  4810. } = usePopupState();
  4811. const onClosed = () => {
  4812. if (allowMultiple) {
  4813. queue = queue.filter((item) => item !== instance2);
  4814. unmount();
  4815. }
  4816. };
  4817. const render = () => {
  4818. const attrs = {
  4819. onClosed,
  4820. "onUpdate:show": toggle
  4821. };
  4822. return vue.createVNode(stdin_default$1u, vue.mergeProps(state, attrs), null);
  4823. };
  4824. vue.watch(message, (val) => {
  4825. state.message = val;
  4826. });
  4827. vue.getCurrentInstance().render = render;
  4828. return {
  4829. open,
  4830. close,
  4831. message
  4832. };
  4833. }
  4834. });
  4835. return instance2;
  4836. }
  4837. function getInstance() {
  4838. if (!queue.length || allowMultiple) {
  4839. const instance2 = createInstance();
  4840. queue.push(instance2);
  4841. }
  4842. return queue[queue.length - 1];
  4843. }
  4844. function showToast(options = {}) {
  4845. if (!inBrowser) {
  4846. return {};
  4847. }
  4848. const toast = getInstance();
  4849. const parsedOptions = parseOptions$1(options);
  4850. toast.open(extend({}, currentOptions$2, defaultOptionsMap.get(parsedOptions.type || currentOptions$2.type), parsedOptions));
  4851. return toast;
  4852. }
  4853. const createMethod = (type) => (options) => showToast(extend({
  4854. type
  4855. }, parseOptions$1(options)));
  4856. const showLoadingToast = createMethod("loading");
  4857. const showSuccessToast = createMethod("success");
  4858. const showFailToast = createMethod("fail");
  4859. const closeToast = (all) => {
  4860. var _a;
  4861. if (queue.length) {
  4862. if (all) {
  4863. queue.forEach((toast) => {
  4864. toast.close();
  4865. });
  4866. queue = [];
  4867. } else if (!allowMultiple) {
  4868. queue[0].close();
  4869. } else {
  4870. (_a = queue.shift()) == null ? void 0 : _a.close();
  4871. }
  4872. }
  4873. };
  4874. function setToastDefaultOptions(type, options) {
  4875. if (typeof type === "string") {
  4876. defaultOptionsMap.set(type, options);
  4877. } else {
  4878. extend(currentOptions$2, type);
  4879. }
  4880. }
  4881. const resetToastDefaultOptions = (type) => {
  4882. if (typeof type === "string") {
  4883. defaultOptionsMap.delete(type);
  4884. } else {
  4885. currentOptions$2 = extend({}, defaultOptions$1);
  4886. defaultOptionsMap.clear();
  4887. }
  4888. };
  4889. const allowMultipleToast = (value = true) => {
  4890. allowMultiple = value;
  4891. };
  4892. const Toast = withInstall(stdin_default$1u);
  4893. const [name$1j, bem$1f] = createNamespace("switch");
  4894. const switchProps = {
  4895. size: numericProp,
  4896. loading: Boolean,
  4897. disabled: Boolean,
  4898. modelValue: unknownProp,
  4899. activeColor: String,
  4900. inactiveColor: String,
  4901. activeValue: {
  4902. type: unknownProp,
  4903. default: true
  4904. },
  4905. inactiveValue: {
  4906. type: unknownProp,
  4907. default: false
  4908. }
  4909. };
  4910. var stdin_default$1t = vue.defineComponent({
  4911. name: name$1j,
  4912. props: switchProps,
  4913. emits: ["change", "update:modelValue"],
  4914. setup(props2, {
  4915. emit,
  4916. slots
  4917. }) {
  4918. const isChecked = () => props2.modelValue === props2.activeValue;
  4919. const onClick = () => {
  4920. if (!props2.disabled && !props2.loading) {
  4921. const newValue = isChecked() ? props2.inactiveValue : props2.activeValue;
  4922. emit("update:modelValue", newValue);
  4923. emit("change", newValue);
  4924. }
  4925. };
  4926. const renderLoading = () => {
  4927. if (props2.loading) {
  4928. const color = isChecked() ? props2.activeColor : props2.inactiveColor;
  4929. return vue.createVNode(Loading, {
  4930. "class": bem$1f("loading"),
  4931. "color": color
  4932. }, null);
  4933. }
  4934. if (slots.node) {
  4935. return slots.node();
  4936. }
  4937. };
  4938. use.useCustomFieldValue(() => props2.modelValue);
  4939. return () => {
  4940. var _a;
  4941. const {
  4942. size,
  4943. loading,
  4944. disabled,
  4945. activeColor,
  4946. inactiveColor
  4947. } = props2;
  4948. const checked = isChecked();
  4949. const style = {
  4950. fontSize: addUnit(size),
  4951. backgroundColor: checked ? activeColor : inactiveColor
  4952. };
  4953. return vue.createVNode("div", {
  4954. "role": "switch",
  4955. "class": bem$1f({
  4956. on: checked,
  4957. loading,
  4958. disabled
  4959. }),
  4960. "style": style,
  4961. "tabindex": disabled ? void 0 : 0,
  4962. "aria-checked": checked,
  4963. "onClick": onClick
  4964. }, [vue.createVNode("div", {
  4965. "class": bem$1f("node")
  4966. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  4967. };
  4968. }
  4969. });
  4970. const Switch = withInstall(stdin_default$1t);
  4971. const [name$1i, bem$1e] = createNamespace("address-edit-detail");
  4972. const t$j = createNamespace("address-edit")[2];
  4973. var stdin_default$1s = vue.defineComponent({
  4974. name: name$1i,
  4975. props: {
  4976. show: Boolean,
  4977. rows: numericProp,
  4978. value: String,
  4979. rules: Array,
  4980. focused: Boolean,
  4981. maxlength: numericProp,
  4982. searchResult: Array,
  4983. showSearchResult: Boolean
  4984. },
  4985. emits: ["blur", "focus", "input", "selectSearch"],
  4986. setup(props2, {
  4987. emit
  4988. }) {
  4989. const field = vue.ref();
  4990. const showSearchResult = () => props2.focused && props2.searchResult && props2.showSearchResult;
  4991. const onSelect = (express) => {
  4992. emit("selectSearch", express);
  4993. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  4994. };
  4995. const renderSearchResult = () => {
  4996. if (!showSearchResult()) {
  4997. return;
  4998. }
  4999. const {
  5000. searchResult
  5001. } = props2;
  5002. return searchResult.map((express) => vue.createVNode(Cell, {
  5003. "clickable": true,
  5004. "key": (express.name || "") + (express.address || ""),
  5005. "icon": "location-o",
  5006. "title": express.name,
  5007. "label": express.address,
  5008. "class": bem$1e("search-item"),
  5009. "border": false,
  5010. "onClick": () => onSelect(express)
  5011. }, null));
  5012. };
  5013. const onBlur = (event) => emit("blur", event);
  5014. const onFocus = (event) => emit("focus", event);
  5015. const onInput = (value) => emit("input", value);
  5016. return () => {
  5017. if (props2.show) {
  5018. return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
  5019. "autosize": true,
  5020. "clearable": true,
  5021. "ref": field,
  5022. "class": bem$1e(),
  5023. "rows": props2.rows,
  5024. "type": "textarea",
  5025. "rules": props2.rules,
  5026. "label": t$j("addressDetail"),
  5027. "border": !showSearchResult(),
  5028. "maxlength": props2.maxlength,
  5029. "modelValue": props2.value,
  5030. "placeholder": t$j("addressDetail"),
  5031. "onBlur": onBlur,
  5032. "onFocus": onFocus,
  5033. "onUpdate:modelValue": onInput
  5034. }, null), renderSearchResult()]);
  5035. }
  5036. };
  5037. }
  5038. });
  5039. const [name$1h, bem$1d, t$i] = createNamespace("address-edit");
  5040. const DEFAULT_DATA = {
  5041. name: "",
  5042. tel: "",
  5043. city: "",
  5044. county: "",
  5045. country: "",
  5046. province: "",
  5047. areaCode: "",
  5048. isDefault: false,
  5049. addressDetail: ""
  5050. };
  5051. const addressEditProps = {
  5052. areaList: Object,
  5053. isSaving: Boolean,
  5054. isDeleting: Boolean,
  5055. validator: Function,
  5056. showArea: truthProp,
  5057. showDetail: truthProp,
  5058. showDelete: Boolean,
  5059. disableArea: Boolean,
  5060. searchResult: Array,
  5061. telMaxlength: numericProp,
  5062. showSetDefault: Boolean,
  5063. saveButtonText: String,
  5064. areaPlaceholder: String,
  5065. deleteButtonText: String,
  5066. showSearchResult: Boolean,
  5067. detailRows: makeNumericProp(1),
  5068. detailMaxlength: makeNumericProp(200),
  5069. areaColumnsPlaceholder: makeArrayProp(),
  5070. addressInfo: {
  5071. type: Object,
  5072. default: () => extend({}, DEFAULT_DATA)
  5073. },
  5074. telValidator: {
  5075. type: Function,
  5076. default: isMobile
  5077. }
  5078. };
  5079. var stdin_default$1r = vue.defineComponent({
  5080. name: name$1h,
  5081. props: addressEditProps,
  5082. emits: ["save", "focus", "change", "delete", "clickArea", "changeArea", "changeDetail", "selectSearch", "changeDefault"],
  5083. setup(props2, {
  5084. emit,
  5085. slots
  5086. }) {
  5087. const areaRef = vue.ref();
  5088. const data = vue.reactive({});
  5089. const showAreaPopup = vue.ref(false);
  5090. const detailFocused = vue.ref(false);
  5091. const areaListLoaded = vue.computed(() => isObject(props2.areaList) && Object.keys(props2.areaList).length);
  5092. const areaText = vue.computed(() => {
  5093. const {
  5094. province,
  5095. city,
  5096. county,
  5097. areaCode
  5098. } = data;
  5099. if (areaCode) {
  5100. const arr = [province, city, county];
  5101. if (province && province === city) {
  5102. arr.splice(1, 1);
  5103. }
  5104. return arr.filter(Boolean).join("/");
  5105. }
  5106. return "";
  5107. });
  5108. const hideBottomFields = vue.computed(() => {
  5109. var _a;
  5110. return ((_a = props2.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  5111. });
  5112. const onFocus = (key) => {
  5113. detailFocused.value = key === "addressDetail";
  5114. emit("focus", key);
  5115. };
  5116. const onChange = (key, value) => {
  5117. emit("change", {
  5118. key,
  5119. value
  5120. });
  5121. };
  5122. const rules = vue.computed(() => {
  5123. const {
  5124. validator,
  5125. telValidator
  5126. } = props2;
  5127. const makeRule = (name2, emptyMessage) => ({
  5128. validator: (value) => {
  5129. if (validator) {
  5130. const message = validator(name2, value);
  5131. if (message) {
  5132. return message;
  5133. }
  5134. }
  5135. if (!value) {
  5136. return emptyMessage;
  5137. }
  5138. return true;
  5139. }
  5140. });
  5141. return {
  5142. name: [makeRule("name", t$i("nameEmpty"))],
  5143. tel: [makeRule("tel", t$i("telInvalid")), {
  5144. validator: telValidator,
  5145. message: t$i("telInvalid")
  5146. }],
  5147. areaCode: [makeRule("areaCode", t$i("areaEmpty"))],
  5148. addressDetail: [makeRule("addressDetail", t$i("addressEmpty"))]
  5149. };
  5150. });
  5151. const onSave = () => emit("save", data);
  5152. const onChangeDetail = (val) => {
  5153. data.addressDetail = val;
  5154. emit("changeDetail", val);
  5155. };
  5156. const assignAreaText = (options) => {
  5157. data.province = options[0].text;
  5158. data.city = options[1].text;
  5159. data.county = options[2].text;
  5160. };
  5161. const onAreaConfirm = ({
  5162. selectedValues,
  5163. selectedOptions
  5164. }) => {
  5165. if (selectedValues.some((value) => value === AREA_EMPTY_CODE)) {
  5166. showToast(t$i("areaEmpty"));
  5167. } else {
  5168. showAreaPopup.value = false;
  5169. assignAreaText(selectedOptions);
  5170. emit("changeArea", selectedOptions);
  5171. }
  5172. };
  5173. const onDelete = () => emit("delete", data);
  5174. const setAreaCode = (code) => {
  5175. data.areaCode = code || "";
  5176. };
  5177. const onDetailBlur = () => {
  5178. setTimeout(() => {
  5179. detailFocused.value = false;
  5180. });
  5181. };
  5182. const setAddressDetail = (value) => {
  5183. data.addressDetail = value;
  5184. };
  5185. const renderSetDefaultCell = () => {
  5186. if (props2.showSetDefault) {
  5187. const slots2 = {
  5188. "right-icon": () => vue.createVNode(Switch, {
  5189. "modelValue": data.isDefault,
  5190. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  5191. "onChange": (event) => emit("changeDefault", event)
  5192. }, null)
  5193. };
  5194. return vue.withDirectives(vue.createVNode(Cell, {
  5195. "center": true,
  5196. "border": false,
  5197. "title": t$i("defaultAddress"),
  5198. "class": bem$1d("default")
  5199. }, slots2), [[vue.vShow, !hideBottomFields.value]]);
  5200. }
  5201. };
  5202. useExpose({
  5203. setAreaCode,
  5204. setAddressDetail
  5205. });
  5206. vue.watch(() => props2.addressInfo, (value) => {
  5207. extend(data, DEFAULT_DATA, value);
  5208. vue.nextTick(() => {
  5209. var _a;
  5210. const options = (_a = areaRef.value) == null ? void 0 : _a.getSelectedOptions();
  5211. if (options && options.every((option) => option && option.value !== AREA_EMPTY_CODE)) {
  5212. assignAreaText(options);
  5213. }
  5214. });
  5215. }, {
  5216. deep: true,
  5217. immediate: true
  5218. });
  5219. return () => {
  5220. const {
  5221. disableArea
  5222. } = props2;
  5223. return vue.createVNode(Form, {
  5224. "class": bem$1d(),
  5225. "onSubmit": onSave
  5226. }, {
  5227. default: () => {
  5228. var _a;
  5229. return [vue.createVNode("div", {
  5230. "class": bem$1d("fields")
  5231. }, [vue.createVNode(Field, {
  5232. "modelValue": data.name,
  5233. "onUpdate:modelValue": [($event) => data.name = $event, (val) => onChange("name", val)],
  5234. "clearable": true,
  5235. "label": t$i("name"),
  5236. "rules": rules.value.name,
  5237. "placeholder": t$i("name"),
  5238. "onFocus": () => onFocus("name")
  5239. }, null), vue.createVNode(Field, {
  5240. "modelValue": data.tel,
  5241. "onUpdate:modelValue": [($event) => data.tel = $event, (val) => onChange("tel", val)],
  5242. "clearable": true,
  5243. "type": "tel",
  5244. "label": t$i("tel"),
  5245. "rules": rules.value.tel,
  5246. "maxlength": props2.telMaxlength,
  5247. "placeholder": t$i("tel"),
  5248. "onFocus": () => onFocus("tel")
  5249. }, null), vue.withDirectives(vue.createVNode(Field, {
  5250. "readonly": true,
  5251. "label": t$i("area"),
  5252. "is-link": !disableArea,
  5253. "modelValue": areaText.value,
  5254. "rules": props2.showArea ? rules.value.areaCode : void 0,
  5255. "placeholder": props2.areaPlaceholder || t$i("area"),
  5256. "onFocus": () => onFocus("areaCode"),
  5257. "onClick": () => {
  5258. emit("clickArea");
  5259. showAreaPopup.value = !disableArea;
  5260. }
  5261. }, null), [[vue.vShow, props2.showArea]]), vue.createVNode(stdin_default$1s, {
  5262. "show": props2.showDetail,
  5263. "rows": props2.detailRows,
  5264. "rules": rules.value.addressDetail,
  5265. "value": data.addressDetail,
  5266. "focused": detailFocused.value,
  5267. "maxlength": props2.detailMaxlength,
  5268. "searchResult": props2.searchResult,
  5269. "showSearchResult": props2.showSearchResult,
  5270. "onBlur": onDetailBlur,
  5271. "onFocus": () => onFocus("addressDetail"),
  5272. "onInput": onChangeDetail,
  5273. "onSelectSearch": (event) => emit("selectSearch", event)
  5274. }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
  5275. "class": bem$1d("buttons")
  5276. }, [vue.createVNode(Button, {
  5277. "block": true,
  5278. "round": true,
  5279. "type": "primary",
  5280. "text": props2.saveButtonText || t$i("save"),
  5281. "class": bem$1d("button"),
  5282. "loading": props2.isSaving,
  5283. "nativeType": "submit"
  5284. }, null), props2.showDelete && vue.createVNode(Button, {
  5285. "block": true,
  5286. "round": true,
  5287. "class": bem$1d("button"),
  5288. "loading": props2.isDeleting,
  5289. "text": props2.deleteButtonText || t$i("delete"),
  5290. "onClick": onDelete
  5291. }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
  5292. "show": showAreaPopup.value,
  5293. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  5294. "round": true,
  5295. "teleport": "body",
  5296. "position": "bottom",
  5297. "lazyRender": false
  5298. }, {
  5299. default: () => [vue.createVNode(Area, {
  5300. "modelValue": data.areaCode,
  5301. "onUpdate:modelValue": ($event) => data.areaCode = $event,
  5302. "ref": areaRef,
  5303. "loading": !areaListLoaded.value,
  5304. "areaList": props2.areaList,
  5305. "columnsPlaceholder": props2.areaColumnsPlaceholder,
  5306. "onConfirm": onAreaConfirm,
  5307. "onCancel": () => {
  5308. showAreaPopup.value = false;
  5309. }
  5310. }, null)]
  5311. })];
  5312. }
  5313. });
  5314. };
  5315. }
  5316. });
  5317. const AddressEdit = withInstall(stdin_default$1r);
  5318. const [name$1g, bem$1c] = createNamespace("radio-group");
  5319. const radioGroupProps = {
  5320. shape: String,
  5321. disabled: Boolean,
  5322. iconSize: numericProp,
  5323. direction: String,
  5324. modelValue: unknownProp,
  5325. checkedColor: String
  5326. };
  5327. const RADIO_KEY = Symbol(name$1g);
  5328. var stdin_default$1q = vue.defineComponent({
  5329. name: name$1g,
  5330. props: radioGroupProps,
  5331. emits: ["change", "update:modelValue"],
  5332. setup(props2, {
  5333. emit,
  5334. slots
  5335. }) {
  5336. const {
  5337. linkChildren
  5338. } = use.useChildren(RADIO_KEY);
  5339. const updateValue = (value) => emit("update:modelValue", value);
  5340. vue.watch(() => props2.modelValue, (value) => emit("change", value));
  5341. linkChildren({
  5342. props: props2,
  5343. updateValue
  5344. });
  5345. use.useCustomFieldValue(() => props2.modelValue);
  5346. return () => {
  5347. var _a;
  5348. return vue.createVNode("div", {
  5349. "class": bem$1c([props2.direction]),
  5350. "role": "radiogroup"
  5351. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5352. };
  5353. }
  5354. });
  5355. const RadioGroup = withInstall(stdin_default$1q);
  5356. const [name$1f, bem$1b] = createNamespace("checkbox-group");
  5357. const checkboxGroupProps = {
  5358. max: numericProp,
  5359. shape: makeStringProp("round"),
  5360. disabled: Boolean,
  5361. iconSize: numericProp,
  5362. direction: String,
  5363. modelValue: makeArrayProp(),
  5364. checkedColor: String
  5365. };
  5366. const CHECKBOX_GROUP_KEY = Symbol(name$1f);
  5367. var stdin_default$1p = vue.defineComponent({
  5368. name: name$1f,
  5369. props: checkboxGroupProps,
  5370. emits: ["change", "update:modelValue"],
  5371. setup(props2, {
  5372. emit,
  5373. slots
  5374. }) {
  5375. const {
  5376. children,
  5377. linkChildren
  5378. } = use.useChildren(CHECKBOX_GROUP_KEY);
  5379. const updateValue = (value) => emit("update:modelValue", value);
  5380. const toggleAll = (options = {}) => {
  5381. if (typeof options === "boolean") {
  5382. options = {
  5383. checked: options
  5384. };
  5385. }
  5386. const {
  5387. checked,
  5388. skipDisabled
  5389. } = options;
  5390. const checkedChildren = children.filter((item) => {
  5391. if (!item.props.bindGroup) {
  5392. return false;
  5393. }
  5394. if (item.props.disabled && skipDisabled) {
  5395. return item.checked.value;
  5396. }
  5397. return checked != null ? checked : !item.checked.value;
  5398. });
  5399. const names = checkedChildren.map((item) => item.name);
  5400. updateValue(names);
  5401. };
  5402. vue.watch(() => props2.modelValue, (value) => emit("change", value));
  5403. useExpose({
  5404. toggleAll
  5405. });
  5406. use.useCustomFieldValue(() => props2.modelValue);
  5407. linkChildren({
  5408. props: props2,
  5409. updateValue
  5410. });
  5411. return () => {
  5412. var _a;
  5413. return vue.createVNode("div", {
  5414. "class": bem$1b([props2.direction])
  5415. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5416. };
  5417. }
  5418. });
  5419. const CheckboxGroup = withInstall(stdin_default$1p);
  5420. const [name$1e, bem$1a] = createNamespace("tag");
  5421. const tagProps = {
  5422. size: String,
  5423. mark: Boolean,
  5424. show: truthProp,
  5425. type: makeStringProp("default"),
  5426. color: String,
  5427. plain: Boolean,
  5428. round: Boolean,
  5429. textColor: String,
  5430. closeable: Boolean
  5431. };
  5432. var stdin_default$1o = vue.defineComponent({
  5433. name: name$1e,
  5434. props: tagProps,
  5435. emits: ["close"],
  5436. setup(props2, {
  5437. slots,
  5438. emit
  5439. }) {
  5440. const onClose = (event) => {
  5441. event.stopPropagation();
  5442. emit("close", event);
  5443. };
  5444. const getStyle = () => {
  5445. if (props2.plain) {
  5446. return {
  5447. color: props2.textColor || props2.color,
  5448. borderColor: props2.color
  5449. };
  5450. }
  5451. return {
  5452. color: props2.textColor,
  5453. background: props2.color
  5454. };
  5455. };
  5456. const renderTag = () => {
  5457. var _a;
  5458. const {
  5459. type,
  5460. mark,
  5461. plain,
  5462. round,
  5463. size,
  5464. closeable
  5465. } = props2;
  5466. const classes = {
  5467. mark,
  5468. plain,
  5469. round
  5470. };
  5471. if (size) {
  5472. classes[size] = size;
  5473. }
  5474. const CloseIcon = closeable && vue.createVNode(Icon, {
  5475. "name": "cross",
  5476. "class": [bem$1a("close"), HAPTICS_FEEDBACK],
  5477. "onClick": onClose
  5478. }, null);
  5479. return vue.createVNode("span", {
  5480. "style": getStyle(),
  5481. "class": bem$1a([classes, type])
  5482. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  5483. };
  5484. return () => vue.createVNode(vue.Transition, {
  5485. "name": props2.closeable ? "van-fade" : void 0
  5486. }, {
  5487. default: () => [props2.show ? renderTag() : null]
  5488. });
  5489. }
  5490. });
  5491. const Tag = withInstall(stdin_default$1o);
  5492. const checkerProps = {
  5493. name: unknownProp,
  5494. disabled: Boolean,
  5495. iconSize: numericProp,
  5496. modelValue: unknownProp,
  5497. checkedColor: String,
  5498. labelPosition: String,
  5499. labelDisabled: Boolean
  5500. };
  5501. var stdin_default$1n = vue.defineComponent({
  5502. props: extend({}, checkerProps, {
  5503. bem: makeRequiredProp(Function),
  5504. role: String,
  5505. shape: String,
  5506. parent: Object,
  5507. checked: Boolean,
  5508. bindGroup: truthProp,
  5509. indeterminate: {
  5510. type: Boolean,
  5511. default: null
  5512. }
  5513. }),
  5514. emits: ["click", "toggle"],
  5515. setup(props2, {
  5516. emit,
  5517. slots
  5518. }) {
  5519. const iconRef = vue.ref();
  5520. const getParentProp = (name2) => {
  5521. if (props2.parent && props2.bindGroup) {
  5522. return props2.parent.props[name2];
  5523. }
  5524. };
  5525. const disabled = vue.computed(() => {
  5526. if (props2.parent && props2.bindGroup) {
  5527. const disabled2 = getParentProp("disabled") || props2.disabled;
  5528. if (props2.role === "checkbox") {
  5529. const checkedCount = getParentProp("modelValue").length;
  5530. const max = getParentProp("max");
  5531. const overlimit = max && checkedCount >= +max;
  5532. return disabled2 || overlimit && !props2.checked;
  5533. }
  5534. return disabled2;
  5535. }
  5536. return props2.disabled;
  5537. });
  5538. const direction = vue.computed(() => getParentProp("direction"));
  5539. const iconStyle = vue.computed(() => {
  5540. const checkedColor = props2.checkedColor || getParentProp("checkedColor");
  5541. if (checkedColor && props2.checked && !disabled.value) {
  5542. return {
  5543. borderColor: checkedColor,
  5544. backgroundColor: checkedColor
  5545. };
  5546. }
  5547. });
  5548. const shape = vue.computed(() => {
  5549. return props2.shape || getParentProp("shape") || "round";
  5550. });
  5551. const onClick = (event) => {
  5552. const {
  5553. target
  5554. } = event;
  5555. const icon = iconRef.value;
  5556. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  5557. if (!disabled.value && (iconClicked || !props2.labelDisabled)) {
  5558. emit("toggle");
  5559. }
  5560. emit("click", event);
  5561. };
  5562. const renderIcon = () => {
  5563. var _a, _b;
  5564. const {
  5565. bem: bem2,
  5566. checked,
  5567. indeterminate
  5568. } = props2;
  5569. const iconSize = props2.iconSize || getParentProp("iconSize");
  5570. return vue.createVNode("div", {
  5571. "ref": iconRef,
  5572. "class": bem2("icon", [shape.value, {
  5573. disabled: disabled.value,
  5574. checked,
  5575. indeterminate
  5576. }]),
  5577. "style": shape.value !== "dot" ? {
  5578. fontSize: addUnit(iconSize)
  5579. } : {
  5580. width: addUnit(iconSize),
  5581. height: addUnit(iconSize),
  5582. borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
  5583. }
  5584. }, [slots.icon ? slots.icon({
  5585. checked,
  5586. disabled: disabled.value
  5587. }) : shape.value !== "dot" ? vue.createVNode(Icon, {
  5588. "name": indeterminate ? "minus" : "success",
  5589. "style": iconStyle.value
  5590. }, null) : vue.createVNode("div", {
  5591. "class": bem2("icon--dot__icon"),
  5592. "style": {
  5593. backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
  5594. }
  5595. }, null)]);
  5596. };
  5597. const renderLabel = () => {
  5598. const {
  5599. checked
  5600. } = props2;
  5601. if (slots.default) {
  5602. return vue.createVNode("span", {
  5603. "class": props2.bem("label", [props2.labelPosition, {
  5604. disabled: disabled.value
  5605. }])
  5606. }, [slots.default({
  5607. checked,
  5608. disabled: disabled.value
  5609. })]);
  5610. }
  5611. };
  5612. return () => {
  5613. const nodes = props2.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  5614. return vue.createVNode("div", {
  5615. "role": props2.role,
  5616. "class": props2.bem([{
  5617. disabled: disabled.value,
  5618. "label-disabled": props2.labelDisabled
  5619. }, direction.value]),
  5620. "tabindex": disabled.value ? void 0 : 0,
  5621. "aria-checked": props2.checked,
  5622. "onClick": onClick
  5623. }, [nodes]);
  5624. };
  5625. }
  5626. });
  5627. const radioProps = extend({}, checkerProps, {
  5628. shape: String
  5629. });
  5630. const [name$1d, bem$19] = createNamespace("radio");
  5631. var stdin_default$1m = vue.defineComponent({
  5632. name: name$1d,
  5633. props: radioProps,
  5634. emits: ["update:modelValue"],
  5635. setup(props2, {
  5636. emit,
  5637. slots
  5638. }) {
  5639. const {
  5640. parent
  5641. } = use.useParent(RADIO_KEY);
  5642. const checked = () => {
  5643. const value = parent ? parent.props.modelValue : props2.modelValue;
  5644. return value === props2.name;
  5645. };
  5646. const toggle = () => {
  5647. if (parent) {
  5648. parent.updateValue(props2.name);
  5649. } else {
  5650. emit("update:modelValue", props2.name);
  5651. }
  5652. };
  5653. return () => vue.createVNode(stdin_default$1n, vue.mergeProps({
  5654. "bem": bem$19,
  5655. "role": "radio",
  5656. "parent": parent,
  5657. "checked": checked(),
  5658. "onToggle": toggle
  5659. }, props2), pick(slots, ["default", "icon"]));
  5660. }
  5661. });
  5662. const Radio = withInstall(stdin_default$1m);
  5663. const [name$1c, bem$18] = createNamespace("checkbox");
  5664. const checkboxProps = extend({}, checkerProps, {
  5665. shape: String,
  5666. bindGroup: truthProp,
  5667. indeterminate: {
  5668. type: Boolean,
  5669. default: null
  5670. }
  5671. });
  5672. var stdin_default$1l = vue.defineComponent({
  5673. name: name$1c,
  5674. props: checkboxProps,
  5675. emits: ["change", "update:modelValue"],
  5676. setup(props2, {
  5677. emit,
  5678. slots
  5679. }) {
  5680. const {
  5681. parent
  5682. } = use.useParent(CHECKBOX_GROUP_KEY);
  5683. const setParentValue = (checked2) => {
  5684. const {
  5685. name: name2
  5686. } = props2;
  5687. const {
  5688. max,
  5689. modelValue
  5690. } = parent.props;
  5691. const value = modelValue.slice();
  5692. if (checked2) {
  5693. const overlimit = max && value.length >= +max;
  5694. if (!overlimit && !value.includes(name2)) {
  5695. value.push(name2);
  5696. if (props2.bindGroup) {
  5697. parent.updateValue(value);
  5698. }
  5699. }
  5700. } else {
  5701. const index = value.indexOf(name2);
  5702. if (index !== -1) {
  5703. value.splice(index, 1);
  5704. if (props2.bindGroup) {
  5705. parent.updateValue(value);
  5706. }
  5707. }
  5708. }
  5709. };
  5710. const checked = vue.computed(() => {
  5711. if (parent && props2.bindGroup) {
  5712. return parent.props.modelValue.indexOf(props2.name) !== -1;
  5713. }
  5714. return !!props2.modelValue;
  5715. });
  5716. const toggle = (newValue = !checked.value) => {
  5717. if (parent && props2.bindGroup) {
  5718. setParentValue(newValue);
  5719. } else {
  5720. emit("update:modelValue", newValue);
  5721. }
  5722. if (props2.indeterminate !== null) emit("change", newValue);
  5723. };
  5724. vue.watch(() => props2.modelValue, (value) => {
  5725. if (props2.indeterminate === null) emit("change", value);
  5726. });
  5727. useExpose({
  5728. toggle,
  5729. props: props2,
  5730. checked
  5731. });
  5732. use.useCustomFieldValue(() => props2.modelValue);
  5733. return () => vue.createVNode(stdin_default$1n, vue.mergeProps({
  5734. "bem": bem$18,
  5735. "role": "checkbox",
  5736. "parent": parent,
  5737. "checked": checked.value,
  5738. "onToggle": toggle
  5739. }, props2), pick(slots, ["default", "icon"]));
  5740. }
  5741. });
  5742. const Checkbox = withInstall(stdin_default$1l);
  5743. const [name$1b, bem$17] = createNamespace("address-item");
  5744. var stdin_default$1k = vue.defineComponent({
  5745. name: name$1b,
  5746. props: {
  5747. address: makeRequiredProp(Object),
  5748. disabled: Boolean,
  5749. switchable: Boolean,
  5750. singleChoice: Boolean,
  5751. defaultTagText: String,
  5752. rightIcon: makeStringProp("edit")
  5753. },
  5754. emits: ["edit", "click", "select"],
  5755. setup(props2, {
  5756. slots,
  5757. emit
  5758. }) {
  5759. const onClick = (event) => {
  5760. if (props2.switchable) {
  5761. emit("select");
  5762. }
  5763. emit("click", event);
  5764. };
  5765. const renderRightIcon = () => vue.createVNode(Icon, {
  5766. "name": props2.rightIcon,
  5767. "class": bem$17("edit"),
  5768. "onClick": (event) => {
  5769. event.stopPropagation();
  5770. emit("edit");
  5771. emit("click", event);
  5772. }
  5773. }, null);
  5774. const renderTag = () => {
  5775. if (slots.tag) {
  5776. return slots.tag(props2.address);
  5777. }
  5778. if (props2.address.isDefault && props2.defaultTagText) {
  5779. return vue.createVNode(Tag, {
  5780. "type": "primary",
  5781. "round": true,
  5782. "class": bem$17("tag")
  5783. }, {
  5784. default: () => [props2.defaultTagText]
  5785. });
  5786. }
  5787. };
  5788. const renderContent = () => {
  5789. const {
  5790. address,
  5791. disabled,
  5792. switchable,
  5793. singleChoice
  5794. } = props2;
  5795. const Info = [vue.createVNode("div", {
  5796. "class": bem$17("name")
  5797. }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
  5798. "class": bem$17("address")
  5799. }, [address.address])];
  5800. if (switchable && !disabled) {
  5801. if (singleChoice) {
  5802. return vue.createVNode(Radio, {
  5803. "name": address.id,
  5804. "iconSize": 18
  5805. }, {
  5806. default: () => [Info]
  5807. });
  5808. } else {
  5809. return vue.createVNode(Checkbox, {
  5810. "name": address.id,
  5811. "iconSize": 18
  5812. }, {
  5813. default: () => [Info]
  5814. });
  5815. }
  5816. }
  5817. return Info;
  5818. };
  5819. return () => {
  5820. var _a;
  5821. const {
  5822. disabled
  5823. } = props2;
  5824. return vue.createVNode("div", {
  5825. "class": bem$17({
  5826. disabled
  5827. }),
  5828. "onClick": onClick
  5829. }, [vue.createVNode(Cell, {
  5830. "border": false,
  5831. "titleClass": bem$17("title")
  5832. }, {
  5833. title: renderContent,
  5834. "right-icon": renderRightIcon
  5835. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props2.address, {
  5836. disabled
  5837. }))]);
  5838. };
  5839. }
  5840. });
  5841. const [name$1a, bem$16, t$h] = createNamespace("address-list");
  5842. const addressListProps = {
  5843. list: makeArrayProp(),
  5844. modelValue: [...numericProp, Array],
  5845. switchable: truthProp,
  5846. disabledText: String,
  5847. disabledList: makeArrayProp(),
  5848. showAddButton: truthProp,
  5849. addButtonText: String,
  5850. defaultTagText: String,
  5851. rightIcon: makeStringProp("edit")
  5852. };
  5853. var stdin_default$1j = vue.defineComponent({
  5854. name: name$1a,
  5855. props: addressListProps,
  5856. emits: ["add", "edit", "select", "clickItem", "editDisabled", "selectDisabled", "update:modelValue"],
  5857. setup(props2, {
  5858. slots,
  5859. emit
  5860. }) {
  5861. const singleChoice = vue.computed(() => !Array.isArray(props2.modelValue));
  5862. const renderItem = (item, index, disabled) => {
  5863. const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
  5864. const onClick = (event) => emit("clickItem", item, index, {
  5865. event
  5866. });
  5867. const onSelect = () => {
  5868. emit(disabled ? "selectDisabled" : "select", item, index);
  5869. if (!disabled) {
  5870. if (singleChoice.value) {
  5871. emit("update:modelValue", item.id);
  5872. } else {
  5873. const value = props2.modelValue;
  5874. if (value.includes(item.id)) {
  5875. emit("update:modelValue", value.filter((id) => id !== item.id));
  5876. } else {
  5877. emit("update:modelValue", [...value, item.id]);
  5878. }
  5879. }
  5880. }
  5881. };
  5882. return vue.createVNode(stdin_default$1k, {
  5883. "key": item.id,
  5884. "address": item,
  5885. "disabled": disabled,
  5886. "switchable": props2.switchable,
  5887. "singleChoice": singleChoice.value,
  5888. "defaultTagText": props2.defaultTagText,
  5889. "rightIcon": props2.rightIcon,
  5890. "onEdit": onEdit,
  5891. "onClick": onClick,
  5892. "onSelect": onSelect
  5893. }, {
  5894. bottom: slots["item-bottom"],
  5895. tag: slots.tag
  5896. });
  5897. };
  5898. const renderList = (list, disabled) => {
  5899. if (list) {
  5900. return list.map((item, index) => renderItem(item, index, disabled));
  5901. }
  5902. };
  5903. const renderBottom = () => props2.showAddButton ? vue.createVNode("div", {
  5904. "class": [bem$16("bottom"), "van-safe-area-bottom"]
  5905. }, [vue.createVNode(Button, {
  5906. "round": true,
  5907. "block": true,
  5908. "type": "primary",
  5909. "text": props2.addButtonText || t$h("add"),
  5910. "class": bem$16("add"),
  5911. "onClick": () => emit("add")
  5912. }, null)]) : void 0;
  5913. return () => {
  5914. var _a, _b;
  5915. const List2 = renderList(props2.list);
  5916. const DisabledList = renderList(props2.disabledList, true);
  5917. const DisabledText = props2.disabledText && vue.createVNode("div", {
  5918. "class": bem$16("disabled-text")
  5919. }, [props2.disabledText]);
  5920. return vue.createVNode("div", {
  5921. "class": bem$16()
  5922. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), !singleChoice.value && Array.isArray(props2.modelValue) ? vue.createVNode(CheckboxGroup, {
  5923. "modelValue": props2.modelValue
  5924. }, {
  5925. default: () => [List2]
  5926. }) : vue.createVNode(RadioGroup, {
  5927. "modelValue": props2.modelValue
  5928. }, {
  5929. default: () => [List2]
  5930. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  5931. };
  5932. }
  5933. });
  5934. const AddressList = withInstall(stdin_default$1j);
  5935. const hasIntersectionObserver = use.inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  5936. const modeType = {
  5937. event: "event",
  5938. observer: "observer"
  5939. };
  5940. function remove(arr, item) {
  5941. if (!arr.length) return;
  5942. const index = arr.indexOf(item);
  5943. if (index > -1) return arr.splice(index, 1);
  5944. }
  5945. function getBestSelectionFromSrcset(el, scale) {
  5946. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset")) return;
  5947. let options = el.getAttribute("data-srcset");
  5948. const container = el.parentNode;
  5949. const containerWidth = container.offsetWidth * scale;
  5950. let spaceIndex;
  5951. let tmpSrc;
  5952. let tmpWidth;
  5953. options = options.trim().split(",");
  5954. const result = options.map((item) => {
  5955. item = item.trim();
  5956. spaceIndex = item.lastIndexOf(" ");
  5957. if (spaceIndex === -1) {
  5958. tmpSrc = item;
  5959. tmpWidth = 999998;
  5960. } else {
  5961. tmpSrc = item.substr(0, spaceIndex);
  5962. tmpWidth = parseInt(
  5963. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  5964. 10
  5965. );
  5966. }
  5967. return [tmpWidth, tmpSrc];
  5968. });
  5969. result.sort((a, b) => {
  5970. if (a[0] < b[0]) {
  5971. return 1;
  5972. }
  5973. if (a[0] > b[0]) {
  5974. return -1;
  5975. }
  5976. if (a[0] === b[0]) {
  5977. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  5978. return 1;
  5979. }
  5980. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  5981. return -1;
  5982. }
  5983. }
  5984. return 0;
  5985. });
  5986. let bestSelectedSrc = "";
  5987. let tmpOption;
  5988. for (let i = 0; i < result.length; i++) {
  5989. tmpOption = result[i];
  5990. bestSelectedSrc = tmpOption[1];
  5991. const next = result[i + 1];
  5992. if (next && next[0] < containerWidth) {
  5993. bestSelectedSrc = tmpOption[1];
  5994. break;
  5995. } else if (!next) {
  5996. bestSelectedSrc = tmpOption[1];
  5997. break;
  5998. }
  5999. }
  6000. return bestSelectedSrc;
  6001. }
  6002. const getDPR = (scale = 1) => use.inBrowser ? window.devicePixelRatio || scale : scale;
  6003. function supportWebp() {
  6004. if (!use.inBrowser) return false;
  6005. let support = true;
  6006. try {
  6007. const elem = document.createElement("canvas");
  6008. if (elem.getContext && elem.getContext("2d")) {
  6009. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  6010. }
  6011. } catch (err) {
  6012. support = false;
  6013. }
  6014. return support;
  6015. }
  6016. function throttle(action, delay) {
  6017. let timeout = null;
  6018. let lastRun = 0;
  6019. return function(...args) {
  6020. if (timeout) {
  6021. return;
  6022. }
  6023. const elapsed = Date.now() - lastRun;
  6024. const runCallback = () => {
  6025. lastRun = Date.now();
  6026. timeout = false;
  6027. action.apply(this, args);
  6028. };
  6029. if (elapsed >= delay) {
  6030. runCallback();
  6031. } else {
  6032. timeout = setTimeout(runCallback, delay);
  6033. }
  6034. };
  6035. }
  6036. function on(el, type, func) {
  6037. el.addEventListener(type, func, {
  6038. capture: false,
  6039. passive: true
  6040. });
  6041. }
  6042. function off(el, type, func) {
  6043. el.removeEventListener(type, func, false);
  6044. }
  6045. const loadImageAsync = (item, resolve, reject) => {
  6046. const image = new Image();
  6047. if (!item || !item.src) {
  6048. return reject(new Error("image src is required"));
  6049. }
  6050. image.src = item.src;
  6051. if (item.cors) {
  6052. image.crossOrigin = item.cors;
  6053. }
  6054. image.onload = () => resolve({
  6055. naturalHeight: image.naturalHeight,
  6056. naturalWidth: image.naturalWidth,
  6057. src: image.src
  6058. });
  6059. image.onerror = (e) => reject(e);
  6060. };
  6061. class ImageCache {
  6062. constructor({ max }) {
  6063. this.options = {
  6064. max: max || 100
  6065. };
  6066. this.caches = [];
  6067. }
  6068. has(key) {
  6069. return this.caches.indexOf(key) > -1;
  6070. }
  6071. add(key) {
  6072. if (this.has(key)) return;
  6073. this.caches.push(key);
  6074. if (this.caches.length > this.options.max) {
  6075. this.free();
  6076. }
  6077. }
  6078. free() {
  6079. this.caches.shift();
  6080. }
  6081. }
  6082. const [name$19, bem$15] = createNamespace("back-top");
  6083. const backTopProps = {
  6084. right: numericProp,
  6085. bottom: numericProp,
  6086. zIndex: numericProp,
  6087. target: [String, Object],
  6088. offset: makeNumericProp(200),
  6089. immediate: Boolean,
  6090. teleport: {
  6091. type: [String, Object],
  6092. default: "body"
  6093. }
  6094. };
  6095. var stdin_default$1i = vue.defineComponent({
  6096. name: name$19,
  6097. inheritAttrs: false,
  6098. props: backTopProps,
  6099. emits: ["click"],
  6100. setup(props2, {
  6101. emit,
  6102. slots,
  6103. attrs
  6104. }) {
  6105. let shouldReshow = false;
  6106. const show = vue.ref(false);
  6107. const root = vue.ref();
  6108. const scrollParent = vue.ref();
  6109. const style = vue.computed(() => extend(getZIndexStyle(props2.zIndex), {
  6110. right: addUnit(props2.right),
  6111. bottom: addUnit(props2.bottom)
  6112. }));
  6113. const onClick = (event) => {
  6114. var _a;
  6115. emit("click", event);
  6116. (_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
  6117. top: 0,
  6118. behavior: props2.immediate ? "auto" : "smooth"
  6119. });
  6120. };
  6121. const scroll = () => {
  6122. show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= +props2.offset : false;
  6123. };
  6124. const getTarget = () => {
  6125. const {
  6126. target
  6127. } = props2;
  6128. if (typeof target === "string") {
  6129. const el = document.querySelector(target);
  6130. if (el) {
  6131. return el;
  6132. }
  6133. if (process.env.NODE_ENV !== "production") {
  6134. console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
  6135. }
  6136. } else {
  6137. return target;
  6138. }
  6139. };
  6140. const updateTarget = () => {
  6141. if (inBrowser) {
  6142. vue.nextTick(() => {
  6143. scrollParent.value = props2.target ? getTarget() : use.getScrollParent(root.value);
  6144. scroll();
  6145. });
  6146. }
  6147. };
  6148. use.useEventListener("scroll", throttle(scroll, 100), {
  6149. target: scrollParent
  6150. });
  6151. vue.onMounted(updateTarget);
  6152. vue.onActivated(() => {
  6153. if (shouldReshow) {
  6154. show.value = true;
  6155. shouldReshow = false;
  6156. }
  6157. });
  6158. vue.onDeactivated(() => {
  6159. if (show.value && props2.teleport) {
  6160. show.value = false;
  6161. shouldReshow = true;
  6162. }
  6163. });
  6164. vue.watch(() => props2.target, updateTarget);
  6165. return () => {
  6166. const Content = vue.createVNode("div", vue.mergeProps({
  6167. "ref": !props2.teleport ? root : void 0,
  6168. "class": bem$15({
  6169. active: show.value
  6170. }),
  6171. "style": style.value,
  6172. "onClick": onClick
  6173. }, attrs), [slots.default ? slots.default() : vue.createVNode(Icon, {
  6174. "name": "back-top",
  6175. "class": bem$15("icon")
  6176. }, null)]);
  6177. if (props2.teleport) {
  6178. return [vue.createVNode("div", {
  6179. "ref": root,
  6180. "class": bem$15("placeholder")
  6181. }, null), vue.createVNode(vue.Teleport, {
  6182. "to": props2.teleport
  6183. }, {
  6184. default: () => [Content]
  6185. })];
  6186. }
  6187. return Content;
  6188. };
  6189. }
  6190. });
  6191. const BackTop = withInstall(stdin_default$1i);
  6192. var __async = (__this, __arguments, generator) => {
  6193. return new Promise((resolve, reject) => {
  6194. var fulfilled = (value) => {
  6195. try {
  6196. step(generator.next(value));
  6197. } catch (e) {
  6198. reject(e);
  6199. }
  6200. };
  6201. var rejected = (value) => {
  6202. try {
  6203. step(generator.throw(value));
  6204. } catch (e) {
  6205. reject(e);
  6206. }
  6207. };
  6208. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  6209. step((generator = generator.apply(__this, __arguments)).next());
  6210. });
  6211. };
  6212. const barrageProps = {
  6213. top: makeNumericProp(10),
  6214. rows: makeNumericProp(4),
  6215. duration: makeNumericProp(4e3),
  6216. autoPlay: truthProp,
  6217. delay: makeNumberProp(300),
  6218. modelValue: makeArrayProp()
  6219. };
  6220. const [name$18, bem$14] = createNamespace("barrage");
  6221. var stdin_default$1h = vue.defineComponent({
  6222. name: name$18,
  6223. props: barrageProps,
  6224. emits: ["update:modelValue"],
  6225. setup(props2, {
  6226. emit,
  6227. slots
  6228. }) {
  6229. const barrageWrapper = vue.ref();
  6230. const className = bem$14("item");
  6231. const total = vue.ref(0);
  6232. const barrageItems = [];
  6233. const createBarrageItem = (text, delay = props2.delay) => {
  6234. const item = document.createElement("span");
  6235. item.className = className;
  6236. item.innerText = String(text);
  6237. item.style.animationDuration = `${props2.duration}ms`;
  6238. item.style.animationDelay = `${delay}ms`;
  6239. item.style.animationName = "van-barrage";
  6240. item.style.animationTimingFunction = "linear";
  6241. return item;
  6242. };
  6243. const isInitBarrage = vue.ref(true);
  6244. const isPlay = vue.ref(props2.autoPlay);
  6245. const appendBarrageItem = ({
  6246. id,
  6247. text
  6248. }, i) => {
  6249. var _a;
  6250. const item = createBarrageItem(text, isInitBarrage.value ? i * props2.delay : void 0);
  6251. if (!props2.autoPlay && isPlay.value === false) {
  6252. item.style.animationPlayState = "paused";
  6253. }
  6254. (_a = barrageWrapper.value) == null ? void 0 : _a.append(item);
  6255. total.value++;
  6256. const top = (total.value - 1) % +props2.rows * item.offsetHeight + +props2.top;
  6257. item.style.top = `${top}px`;
  6258. item.dataset.id = String(id);
  6259. barrageItems.push(item);
  6260. item.addEventListener("animationend", () => {
  6261. emit("update:modelValue", [...props2.modelValue].filter((v) => String(v.id) !== item.dataset.id));
  6262. });
  6263. };
  6264. const updateBarrages = (newValue, oldValue) => {
  6265. const map = new Map(oldValue.map((item) => [item.id, item]));
  6266. newValue.forEach((item, i) => {
  6267. if (map.has(item.id)) {
  6268. map.delete(item.id);
  6269. } else {
  6270. appendBarrageItem(item, i);
  6271. }
  6272. });
  6273. map.forEach((item) => {
  6274. const index = barrageItems.findIndex((span) => span.dataset.id === String(item.id));
  6275. if (index > -1) {
  6276. barrageItems[index].remove();
  6277. barrageItems.splice(index, 1);
  6278. }
  6279. });
  6280. isInitBarrage.value = false;
  6281. };
  6282. vue.watch(() => props2.modelValue.slice(), (newValue, oldValue) => updateBarrages(newValue != null ? newValue : [], oldValue != null ? oldValue : []), {
  6283. deep: true
  6284. });
  6285. const rootStyle = vue.ref({});
  6286. vue.onMounted(() => __async(this, null, function* () {
  6287. var _a;
  6288. rootStyle.value["--move-distance"] = `-${(_a = barrageWrapper.value) == null ? void 0 : _a.offsetWidth}px`;
  6289. yield vue.nextTick();
  6290. updateBarrages(props2.modelValue, []);
  6291. }));
  6292. const play = () => {
  6293. isPlay.value = true;
  6294. barrageItems.forEach((item) => {
  6295. item.style.animationPlayState = "running";
  6296. });
  6297. };
  6298. const pause = () => {
  6299. isPlay.value = false;
  6300. barrageItems.forEach((item) => {
  6301. item.style.animationPlayState = "paused";
  6302. });
  6303. };
  6304. useExpose({
  6305. play,
  6306. pause
  6307. });
  6308. return () => {
  6309. var _a;
  6310. return vue.createVNode("div", {
  6311. "class": bem$14(),
  6312. "ref": barrageWrapper,
  6313. "style": rootStyle.value
  6314. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6315. };
  6316. }
  6317. });
  6318. const Barrage = withInstall(stdin_default$1h);
  6319. const [name$17, bem$13, t$g] = createNamespace("calendar");
  6320. const formatMonthTitle = (date) => t$g("monthTitle", date.getFullYear(), date.getMonth() + 1);
  6321. function compareMonth(date1, date2) {
  6322. const year1 = date1.getFullYear();
  6323. const year2 = date2.getFullYear();
  6324. if (year1 === year2) {
  6325. const month1 = date1.getMonth();
  6326. const month2 = date2.getMonth();
  6327. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  6328. }
  6329. return year1 > year2 ? 1 : -1;
  6330. }
  6331. function compareDay(day1, day2) {
  6332. const compareMonthResult = compareMonth(day1, day2);
  6333. if (compareMonthResult === 0) {
  6334. const date1 = day1.getDate();
  6335. const date2 = day2.getDate();
  6336. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  6337. }
  6338. return compareMonthResult;
  6339. }
  6340. const cloneDate = (date) => new Date(date);
  6341. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  6342. function getDayByOffset(date, offset) {
  6343. const cloned = cloneDate(date);
  6344. cloned.setDate(cloned.getDate() + offset);
  6345. return cloned;
  6346. }
  6347. function getMonthByOffset(date, offset) {
  6348. const cloned = cloneDate(date);
  6349. cloned.setMonth(cloned.getMonth() + offset);
  6350. if (cloned.getDate() !== date.getDate()) {
  6351. cloned.setDate(0);
  6352. }
  6353. return cloned;
  6354. }
  6355. function getYearByOffset(date, offset) {
  6356. const cloned = cloneDate(date);
  6357. cloned.setFullYear(cloned.getFullYear() + offset);
  6358. if (cloned.getDate() !== date.getDate()) {
  6359. cloned.setDate(0);
  6360. }
  6361. return cloned;
  6362. }
  6363. const getPrevDay = (date) => getDayByOffset(date, -1);
  6364. const getNextDay = (date) => getDayByOffset(date, 1);
  6365. const getPrevMonth = (date) => getMonthByOffset(date, -1);
  6366. const getNextMonth = (date) => getMonthByOffset(date, 1);
  6367. const getPrevYear = (date) => getYearByOffset(date, -1);
  6368. const getNextYear = (date) => getYearByOffset(date, 1);
  6369. const getToday = () => {
  6370. const today = /* @__PURE__ */ new Date();
  6371. today.setHours(0, 0, 0, 0);
  6372. return today;
  6373. };
  6374. function calcDateNum(date) {
  6375. const day1 = date[0].getTime();
  6376. const day2 = date[1].getTime();
  6377. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  6378. }
  6379. const sharedProps = extend({}, pickerSharedProps, {
  6380. modelValue: makeArrayProp(),
  6381. filter: Function,
  6382. formatter: {
  6383. type: Function,
  6384. default: (type, option) => option
  6385. }
  6386. });
  6387. const pickerInheritKeys = Object.keys(pickerSharedProps);
  6388. function times(n, iteratee) {
  6389. if (n < 0) {
  6390. return [];
  6391. }
  6392. const result = Array(n);
  6393. let index = -1;
  6394. while (++index < n) {
  6395. result[index] = iteratee(index);
  6396. }
  6397. return result;
  6398. }
  6399. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  6400. const genOptions = (min, max, type, formatter, filter, values) => {
  6401. const options = times(max - min + 1, (index) => {
  6402. const value = padZero(min + index);
  6403. return formatter(type, {
  6404. text: value,
  6405. value
  6406. });
  6407. });
  6408. return filter ? filter(type, options, values) : options;
  6409. };
  6410. const formatValueRange = (values, columns) => values.map((value, index) => {
  6411. const column = columns[index];
  6412. if (column.length) {
  6413. const minValue = +column[0].value;
  6414. const maxValue = +column[column.length - 1].value;
  6415. return padZero(clamp(+value, minValue, maxValue));
  6416. }
  6417. return value;
  6418. });
  6419. const [name$16] = createNamespace("calendar-day");
  6420. var stdin_default$1g = vue.defineComponent({
  6421. name: name$16,
  6422. props: {
  6423. item: makeRequiredProp(Object),
  6424. color: String,
  6425. index: Number,
  6426. offset: makeNumberProp(0),
  6427. rowHeight: String
  6428. },
  6429. emits: ["click", "clickDisabledDate"],
  6430. setup(props2, {
  6431. emit,
  6432. slots
  6433. }) {
  6434. const style = vue.computed(() => {
  6435. var _a;
  6436. const {
  6437. item,
  6438. index,
  6439. color,
  6440. offset,
  6441. rowHeight
  6442. } = props2;
  6443. const style2 = {
  6444. height: rowHeight
  6445. };
  6446. if (item.type === "placeholder") {
  6447. style2.width = "100%";
  6448. return style2;
  6449. }
  6450. if (index === 0) {
  6451. style2.marginLeft = `${100 * offset / 7}%`;
  6452. }
  6453. if (color) {
  6454. switch (item.type) {
  6455. case "end":
  6456. case "start":
  6457. case "start-end":
  6458. case "multiple-middle":
  6459. case "multiple-selected":
  6460. style2.background = color;
  6461. break;
  6462. case "middle":
  6463. style2.color = color;
  6464. break;
  6465. }
  6466. }
  6467. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  6468. style2.marginBottom = 0;
  6469. }
  6470. return style2;
  6471. });
  6472. const onClick = () => {
  6473. if (props2.item.type !== "disabled") {
  6474. emit("click", props2.item);
  6475. } else {
  6476. emit("clickDisabledDate", props2.item);
  6477. }
  6478. };
  6479. const renderTopInfo = () => {
  6480. const {
  6481. topInfo
  6482. } = props2.item;
  6483. if (topInfo || slots["top-info"]) {
  6484. return vue.createVNode("div", {
  6485. "class": bem$13("top-info")
  6486. }, [slots["top-info"] ? slots["top-info"](props2.item) : topInfo]);
  6487. }
  6488. };
  6489. const renderBottomInfo = () => {
  6490. const {
  6491. bottomInfo
  6492. } = props2.item;
  6493. if (bottomInfo || slots["bottom-info"]) {
  6494. return vue.createVNode("div", {
  6495. "class": bem$13("bottom-info")
  6496. }, [slots["bottom-info"] ? slots["bottom-info"](props2.item) : bottomInfo]);
  6497. }
  6498. };
  6499. const renderText = () => {
  6500. return slots.text ? slots.text(props2.item) : props2.item.text;
  6501. };
  6502. const renderContent = () => {
  6503. const {
  6504. item,
  6505. color,
  6506. rowHeight
  6507. } = props2;
  6508. const {
  6509. type
  6510. } = item;
  6511. const Nodes = [renderTopInfo(), renderText(), renderBottomInfo()];
  6512. if (type === "selected") {
  6513. return vue.createVNode("div", {
  6514. "class": bem$13("selected-day"),
  6515. "style": {
  6516. width: rowHeight,
  6517. height: rowHeight,
  6518. background: color
  6519. }
  6520. }, [Nodes]);
  6521. }
  6522. return Nodes;
  6523. };
  6524. return () => {
  6525. const {
  6526. type,
  6527. className
  6528. } = props2.item;
  6529. if (type === "placeholder") {
  6530. return vue.createVNode("div", {
  6531. "class": bem$13("day"),
  6532. "style": style.value
  6533. }, null);
  6534. }
  6535. return vue.createVNode("div", {
  6536. "role": "gridcell",
  6537. "style": style.value,
  6538. "class": [bem$13("day", type), className],
  6539. "tabindex": type === "disabled" ? void 0 : -1,
  6540. "onClick": onClick
  6541. }, [renderContent()]);
  6542. };
  6543. }
  6544. });
  6545. const [name$15] = createNamespace("calendar-month");
  6546. const calendarMonthProps = {
  6547. date: makeRequiredProp(Date),
  6548. type: String,
  6549. color: String,
  6550. minDate: Date,
  6551. maxDate: Date,
  6552. showMark: Boolean,
  6553. rowHeight: numericProp,
  6554. formatter: Function,
  6555. lazyRender: Boolean,
  6556. currentDate: [Date, Array],
  6557. allowSameDay: Boolean,
  6558. showSubtitle: Boolean,
  6559. showMonthTitle: Boolean,
  6560. firstDayOfWeek: Number
  6561. };
  6562. var stdin_default$1f = vue.defineComponent({
  6563. name: name$15,
  6564. props: calendarMonthProps,
  6565. emits: ["click", "clickDisabledDate"],
  6566. setup(props2, {
  6567. emit,
  6568. slots
  6569. }) {
  6570. const [visible, setVisible] = use.useToggle();
  6571. const daysRef = vue.ref();
  6572. const monthRef = vue.ref();
  6573. const height = useHeight(monthRef);
  6574. const title = vue.computed(() => formatMonthTitle(props2.date));
  6575. const rowHeight = vue.computed(() => addUnit(props2.rowHeight));
  6576. const offset = vue.computed(() => {
  6577. const date = props2.date.getDate();
  6578. const day = props2.date.getDay();
  6579. const realDay = (day - date % 7 + 8) % 7;
  6580. if (props2.firstDayOfWeek) {
  6581. return (realDay + 7 - props2.firstDayOfWeek) % 7;
  6582. }
  6583. return realDay;
  6584. });
  6585. const totalDay = vue.computed(() => getMonthEndDay(props2.date.getFullYear(), props2.date.getMonth() + 1));
  6586. const shouldRender = vue.computed(() => visible.value || !props2.lazyRender);
  6587. const getTitle = () => title.value;
  6588. const getMultipleDayType = (day) => {
  6589. const isSelected = (date) => props2.currentDate.some((item) => compareDay(item, date) === 0);
  6590. if (isSelected(day)) {
  6591. const prevDay = getPrevDay(day);
  6592. const nextDay = getNextDay(day);
  6593. const prevSelected = isSelected(prevDay);
  6594. const nextSelected = isSelected(nextDay);
  6595. if (prevSelected && nextSelected) {
  6596. return "multiple-middle";
  6597. }
  6598. if (prevSelected) {
  6599. return "end";
  6600. }
  6601. if (nextSelected) {
  6602. return "start";
  6603. }
  6604. return "multiple-selected";
  6605. }
  6606. return "";
  6607. };
  6608. const getRangeDayType = (day) => {
  6609. const [startDay, endDay] = props2.currentDate;
  6610. if (!startDay) {
  6611. return "";
  6612. }
  6613. const compareToStart = compareDay(day, startDay);
  6614. if (!endDay) {
  6615. return compareToStart === 0 ? "start" : "";
  6616. }
  6617. const compareToEnd = compareDay(day, endDay);
  6618. if (props2.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  6619. return "start-end";
  6620. }
  6621. if (compareToStart === 0) {
  6622. return "start";
  6623. }
  6624. if (compareToEnd === 0) {
  6625. return "end";
  6626. }
  6627. if (compareToStart > 0 && compareToEnd < 0) {
  6628. return "middle";
  6629. }
  6630. return "";
  6631. };
  6632. const getDayType = (day) => {
  6633. const {
  6634. type,
  6635. minDate,
  6636. maxDate,
  6637. currentDate
  6638. } = props2;
  6639. if (minDate && compareDay(day, minDate) < 0 || maxDate && compareDay(day, maxDate) > 0) {
  6640. return "disabled";
  6641. }
  6642. if (currentDate === null) {
  6643. return "";
  6644. }
  6645. if (Array.isArray(currentDate)) {
  6646. if (type === "multiple") {
  6647. return getMultipleDayType(day);
  6648. }
  6649. if (type === "range") {
  6650. return getRangeDayType(day);
  6651. }
  6652. } else if (type === "single") {
  6653. return compareDay(day, currentDate) === 0 ? "selected" : "";
  6654. }
  6655. return "";
  6656. };
  6657. const getBottomInfo = (dayType) => {
  6658. if (props2.type === "range") {
  6659. if (dayType === "start" || dayType === "end") {
  6660. return t$g(dayType);
  6661. }
  6662. if (dayType === "start-end") {
  6663. return `${t$g("start")}/${t$g("end")}`;
  6664. }
  6665. }
  6666. };
  6667. const renderTitle = () => {
  6668. if (props2.showMonthTitle) {
  6669. return vue.createVNode("div", {
  6670. "class": bem$13("month-title")
  6671. }, [slots["month-title"] ? slots["month-title"]({
  6672. date: props2.date,
  6673. text: title.value
  6674. }) : title.value]);
  6675. }
  6676. };
  6677. const renderMark = () => {
  6678. if (props2.showMark && shouldRender.value) {
  6679. return vue.createVNode("div", {
  6680. "class": bem$13("month-mark")
  6681. }, [props2.date.getMonth() + 1]);
  6682. }
  6683. };
  6684. const placeholders = vue.computed(() => {
  6685. const count = Math.ceil((totalDay.value + offset.value) / 7);
  6686. return Array(count).fill({
  6687. type: "placeholder"
  6688. });
  6689. });
  6690. const days = vue.computed(() => {
  6691. const days2 = [];
  6692. const year = props2.date.getFullYear();
  6693. const month = props2.date.getMonth();
  6694. for (let day = 1; day <= totalDay.value; day++) {
  6695. const date = new Date(year, month, day);
  6696. const type = getDayType(date);
  6697. let config = {
  6698. date,
  6699. type,
  6700. text: day,
  6701. bottomInfo: getBottomInfo(type)
  6702. };
  6703. if (props2.formatter) {
  6704. config = props2.formatter(config);
  6705. }
  6706. days2.push(config);
  6707. }
  6708. return days2;
  6709. });
  6710. const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
  6711. const scrollToDate = (body, targetDate) => {
  6712. if (daysRef.value) {
  6713. const daysRect = use.useRect(daysRef.value);
  6714. const totalRows = placeholders.value.length;
  6715. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  6716. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  6717. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - use.useRect(body).top);
  6718. }
  6719. };
  6720. const renderDay = (item, index) => vue.createVNode(stdin_default$1g, {
  6721. "item": item,
  6722. "index": index,
  6723. "color": props2.color,
  6724. "offset": offset.value,
  6725. "rowHeight": rowHeight.value,
  6726. "onClick": (item2) => emit("click", item2),
  6727. "onClickDisabledDate": (item2) => emit("clickDisabledDate", item2)
  6728. }, pick(slots, ["top-info", "bottom-info", "text"]));
  6729. const renderDays = () => vue.createVNode("div", {
  6730. "ref": daysRef,
  6731. "role": "grid",
  6732. "class": bem$13("days")
  6733. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  6734. useExpose({
  6735. getTitle,
  6736. getHeight: () => height.value,
  6737. setVisible,
  6738. scrollToDate,
  6739. disabledDays
  6740. });
  6741. return () => vue.createVNode("div", {
  6742. "class": bem$13("month"),
  6743. "ref": monthRef
  6744. }, [renderTitle(), renderDays()]);
  6745. }
  6746. });
  6747. const [name$14] = createNamespace("calendar-header");
  6748. var stdin_default$1e = vue.defineComponent({
  6749. name: name$14,
  6750. props: {
  6751. date: Date,
  6752. minDate: Date,
  6753. maxDate: Date,
  6754. title: String,
  6755. subtitle: String,
  6756. showTitle: Boolean,
  6757. showSubtitle: Boolean,
  6758. firstDayOfWeek: Number,
  6759. switchMode: makeStringProp("none")
  6760. },
  6761. emits: ["clickSubtitle", "panelChange"],
  6762. setup(props2, {
  6763. slots,
  6764. emit
  6765. }) {
  6766. const prevMonthDisabled = vue.computed(() => props2.date && props2.minDate && compareMonth(getPrevMonth(props2.date), props2.minDate) < 0);
  6767. const prevYearDisabled = vue.computed(() => props2.date && props2.minDate && compareMonth(getPrevYear(props2.date), props2.minDate) < 0);
  6768. const nextMonthDisabled = vue.computed(() => props2.date && props2.maxDate && compareMonth(getNextMonth(props2.date), props2.maxDate) > 0);
  6769. const nextYearDisabled = vue.computed(() => props2.date && props2.maxDate && compareMonth(getNextYear(props2.date), props2.maxDate) > 0);
  6770. const renderTitle = () => {
  6771. if (props2.showTitle) {
  6772. const text = props2.title || t$g("title");
  6773. const title = slots.title ? slots.title() : text;
  6774. return vue.createVNode("div", {
  6775. "class": bem$13("header-title")
  6776. }, [title]);
  6777. }
  6778. };
  6779. const onClickSubtitle = (event) => emit("clickSubtitle", event);
  6780. const onPanelChange = (date) => emit("panelChange", date);
  6781. const renderAction = (isNext) => {
  6782. const showYearAction = props2.switchMode === "year-month";
  6783. const monthSlot = slots[isNext ? "next-month" : "prev-month"];
  6784. const yearSlot = slots[isNext ? "next-year" : "prev-year"];
  6785. const monthDisabled = isNext ? nextMonthDisabled.value : prevMonthDisabled.value;
  6786. const yearDisabled = isNext ? nextYearDisabled.value : prevYearDisabled.value;
  6787. const monthIconName = isNext ? "arrow" : "arrow-left";
  6788. const yearIconName = isNext ? "arrow-double-right" : "arrow-double-left";
  6789. const onMonthChange = () => onPanelChange((isNext ? getNextMonth : getPrevMonth)(props2.date));
  6790. const onYearChange = () => onPanelChange((isNext ? getNextYear : getPrevYear)(props2.date));
  6791. const MonthAction = vue.createVNode("view", {
  6792. "class": bem$13("header-action", {
  6793. disabled: monthDisabled
  6794. }),
  6795. "onClick": monthDisabled ? void 0 : onMonthChange
  6796. }, [monthSlot ? monthSlot({
  6797. disabled: monthDisabled
  6798. }) : vue.createVNode(Icon, {
  6799. "class": {
  6800. [HAPTICS_FEEDBACK]: !monthDisabled
  6801. },
  6802. "name": monthIconName
  6803. }, null)]);
  6804. const YearAction = showYearAction && vue.createVNode("view", {
  6805. "class": bem$13("header-action", {
  6806. disabled: yearDisabled
  6807. }),
  6808. "onClick": yearDisabled ? void 0 : onYearChange
  6809. }, [yearSlot ? yearSlot({
  6810. disabled: yearDisabled
  6811. }) : vue.createVNode(Icon, {
  6812. "class": {
  6813. [HAPTICS_FEEDBACK]: !yearDisabled
  6814. },
  6815. "name": yearIconName
  6816. }, null)]);
  6817. return isNext ? [MonthAction, YearAction] : [YearAction, MonthAction];
  6818. };
  6819. const renderSubtitle = () => {
  6820. if (props2.showSubtitle) {
  6821. const title = slots.subtitle ? slots.subtitle({
  6822. date: props2.date,
  6823. text: props2.subtitle
  6824. }) : props2.subtitle;
  6825. const canSwitch = props2.switchMode !== "none";
  6826. return vue.createVNode("div", {
  6827. "class": bem$13("header-subtitle", {
  6828. "with-switch": canSwitch
  6829. }),
  6830. "onClick": onClickSubtitle
  6831. }, [canSwitch ? [renderAction(), vue.createVNode("div", {
  6832. "class": bem$13("header-subtitle-text")
  6833. }, [title]), renderAction(true)] : title]);
  6834. }
  6835. };
  6836. const renderWeekDays = () => {
  6837. const {
  6838. firstDayOfWeek
  6839. } = props2;
  6840. const weekdays = t$g("weekdays");
  6841. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  6842. return vue.createVNode("div", {
  6843. "class": bem$13("weekdays")
  6844. }, [renderWeekDays2.map((text) => vue.createVNode("span", {
  6845. "class": bem$13("weekday")
  6846. }, [text]))]);
  6847. };
  6848. return () => vue.createVNode("div", {
  6849. "class": bem$13("header")
  6850. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  6851. }
  6852. });
  6853. const calendarProps = {
  6854. show: Boolean,
  6855. type: makeStringProp("single"),
  6856. switchMode: makeStringProp("none"),
  6857. title: String,
  6858. color: String,
  6859. round: truthProp,
  6860. readonly: Boolean,
  6861. poppable: truthProp,
  6862. maxRange: makeNumericProp(null),
  6863. position: makeStringProp("bottom"),
  6864. teleport: [String, Object],
  6865. showMark: truthProp,
  6866. showTitle: truthProp,
  6867. formatter: Function,
  6868. rowHeight: numericProp,
  6869. confirmText: String,
  6870. rangePrompt: String,
  6871. lazyRender: truthProp,
  6872. showConfirm: truthProp,
  6873. defaultDate: [Date, Array],
  6874. allowSameDay: Boolean,
  6875. showSubtitle: truthProp,
  6876. closeOnPopstate: truthProp,
  6877. showRangePrompt: truthProp,
  6878. confirmDisabledText: String,
  6879. closeOnClickOverlay: truthProp,
  6880. safeAreaInsetTop: Boolean,
  6881. safeAreaInsetBottom: truthProp,
  6882. minDate: {
  6883. type: Date,
  6884. validator: isDate
  6885. },
  6886. maxDate: {
  6887. type: Date,
  6888. validator: isDate
  6889. },
  6890. firstDayOfWeek: {
  6891. type: numericProp,
  6892. default: 0,
  6893. validator: (val) => val >= 0 && val <= 6
  6894. }
  6895. };
  6896. var stdin_default$1d = vue.defineComponent({
  6897. name: name$17,
  6898. props: calendarProps,
  6899. emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle", "clickDisabledDate", "panelChange"],
  6900. setup(props2, {
  6901. emit,
  6902. slots
  6903. }) {
  6904. const canSwitch = vue.computed(() => props2.switchMode !== "none");
  6905. const minDate = vue.computed(() => {
  6906. if (!props2.minDate && !canSwitch.value) {
  6907. return getToday();
  6908. }
  6909. return props2.minDate;
  6910. });
  6911. const maxDate = vue.computed(() => {
  6912. if (!props2.maxDate && !canSwitch.value) {
  6913. return getMonthByOffset(getToday(), 6);
  6914. }
  6915. return props2.maxDate;
  6916. });
  6917. const limitDateRange = (date, min = minDate.value, max = maxDate.value) => {
  6918. if (min && compareDay(date, min) === -1) {
  6919. return min;
  6920. }
  6921. if (max && compareDay(date, max) === 1) {
  6922. return max;
  6923. }
  6924. return date;
  6925. };
  6926. const getInitialDate = (defaultDate = props2.defaultDate) => {
  6927. const {
  6928. type,
  6929. allowSameDay
  6930. } = props2;
  6931. if (defaultDate === null) {
  6932. return defaultDate;
  6933. }
  6934. const now = getToday();
  6935. if (type === "range") {
  6936. if (!Array.isArray(defaultDate)) {
  6937. defaultDate = [];
  6938. }
  6939. if (defaultDate.length === 1 && compareDay(defaultDate[0], now) === 1) {
  6940. defaultDate = [];
  6941. }
  6942. const min = minDate.value;
  6943. const max = maxDate.value;
  6944. const start = limitDateRange(defaultDate[0] || now, min, max ? allowSameDay ? max : getPrevDay(max) : void 0);
  6945. const end = limitDateRange(defaultDate[1] || (allowSameDay ? now : getNextDay(now)), min ? allowSameDay ? min : getNextDay(min) : void 0);
  6946. return [start, end];
  6947. }
  6948. if (type === "multiple") {
  6949. if (Array.isArray(defaultDate)) {
  6950. return defaultDate.map((date) => limitDateRange(date));
  6951. }
  6952. return [limitDateRange(now)];
  6953. }
  6954. if (!defaultDate || Array.isArray(defaultDate)) {
  6955. defaultDate = now;
  6956. }
  6957. return limitDateRange(defaultDate);
  6958. };
  6959. const getInitialPanelDate = () => {
  6960. const date = Array.isArray(currentDate.value) ? currentDate.value[0] : currentDate.value;
  6961. return date ? date : limitDateRange(getToday());
  6962. };
  6963. let bodyHeight;
  6964. const bodyRef = vue.ref();
  6965. const currentDate = vue.ref(getInitialDate());
  6966. const currentPanelDate = vue.ref(getInitialPanelDate());
  6967. const currentMonthRef = vue.ref();
  6968. const [monthRefs, setMonthRefs] = useRefs();
  6969. const dayOffset = vue.computed(() => props2.firstDayOfWeek ? +props2.firstDayOfWeek % 7 : 0);
  6970. const months = vue.computed(() => {
  6971. const months2 = [];
  6972. if (!minDate.value || !maxDate.value) {
  6973. return months2;
  6974. }
  6975. const cursor = new Date(minDate.value);
  6976. cursor.setDate(1);
  6977. do {
  6978. months2.push(new Date(cursor));
  6979. cursor.setMonth(cursor.getMonth() + 1);
  6980. } while (compareMonth(cursor, maxDate.value) !== 1);
  6981. return months2;
  6982. });
  6983. const buttonDisabled = vue.computed(() => {
  6984. if (currentDate.value) {
  6985. if (props2.type === "range") {
  6986. return !currentDate.value[0] || !currentDate.value[1];
  6987. }
  6988. if (props2.type === "multiple") {
  6989. return !currentDate.value.length;
  6990. }
  6991. }
  6992. return !currentDate.value;
  6993. });
  6994. const getSelectedDate = () => currentDate.value;
  6995. const onScroll = () => {
  6996. const top = getScrollTop(bodyRef.value);
  6997. const bottom = top + bodyHeight;
  6998. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  6999. const heightSum = heights.reduce((a, b) => a + b, 0);
  7000. if (bottom > heightSum && top > 0) {
  7001. return;
  7002. }
  7003. let height = 0;
  7004. let currentMonth;
  7005. const visibleRange = [-1, -1];
  7006. for (let i = 0; i < months.value.length; i++) {
  7007. const month = monthRefs.value[i];
  7008. const visible = height <= bottom && height + heights[i] >= top;
  7009. if (visible) {
  7010. visibleRange[1] = i;
  7011. if (!currentMonth) {
  7012. currentMonth = month;
  7013. visibleRange[0] = i;
  7014. }
  7015. if (!monthRefs.value[i].showed) {
  7016. monthRefs.value[i].showed = true;
  7017. emit("monthShow", {
  7018. date: month.date,
  7019. title: month.getTitle()
  7020. });
  7021. }
  7022. }
  7023. height += heights[i];
  7024. }
  7025. months.value.forEach((month, index) => {
  7026. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  7027. monthRefs.value[index].setVisible(visible);
  7028. });
  7029. if (currentMonth) {
  7030. currentMonthRef.value = currentMonth;
  7031. }
  7032. };
  7033. const scrollToDate = (targetDate) => {
  7034. if (canSwitch.value) {
  7035. currentPanelDate.value = targetDate;
  7036. } else {
  7037. use.raf(() => {
  7038. months.value.some((month, index) => {
  7039. if (compareMonth(month, targetDate) === 0) {
  7040. if (bodyRef.value) {
  7041. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  7042. }
  7043. return true;
  7044. }
  7045. return false;
  7046. });
  7047. onScroll();
  7048. });
  7049. }
  7050. };
  7051. const scrollToCurrentDate = () => {
  7052. if (props2.poppable && !props2.show) {
  7053. return;
  7054. }
  7055. if (currentDate.value) {
  7056. const targetDate = props2.type === "single" ? currentDate.value : currentDate.value[0];
  7057. if (isDate(targetDate)) {
  7058. scrollToDate(targetDate);
  7059. }
  7060. } else if (!canSwitch.value) {
  7061. use.raf(onScroll);
  7062. }
  7063. };
  7064. const init = () => {
  7065. if (props2.poppable && !props2.show) {
  7066. return;
  7067. }
  7068. if (!canSwitch.value) {
  7069. use.raf(() => {
  7070. bodyHeight = Math.floor(use.useRect(bodyRef).height);
  7071. });
  7072. }
  7073. scrollToCurrentDate();
  7074. };
  7075. const reset = (date = getInitialDate()) => {
  7076. currentDate.value = date;
  7077. scrollToCurrentDate();
  7078. };
  7079. const checkRange = (date) => {
  7080. const {
  7081. maxRange,
  7082. rangePrompt,
  7083. showRangePrompt
  7084. } = props2;
  7085. if (maxRange && calcDateNum(date) > +maxRange) {
  7086. if (showRangePrompt) {
  7087. showToast(rangePrompt || t$g("rangePrompt", maxRange));
  7088. }
  7089. emit("overRange");
  7090. return false;
  7091. }
  7092. return true;
  7093. };
  7094. const onPanelChange = (date) => {
  7095. currentPanelDate.value = date;
  7096. emit("panelChange", {
  7097. date
  7098. });
  7099. };
  7100. const onConfirm = () => {
  7101. var _a;
  7102. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  7103. };
  7104. const select = (date, complete) => {
  7105. const setCurrentDate = (date2) => {
  7106. currentDate.value = date2;
  7107. emit("select", cloneDates(date2));
  7108. };
  7109. if (complete && props2.type === "range") {
  7110. const valid = checkRange(date);
  7111. if (!valid) {
  7112. setCurrentDate([date[0], getDayByOffset(date[0], +props2.maxRange - 1)]);
  7113. return;
  7114. }
  7115. }
  7116. setCurrentDate(date);
  7117. if (complete && !props2.showConfirm) {
  7118. onConfirm();
  7119. }
  7120. };
  7121. const getDisabledDate = (disabledDays2, startDay, date) => {
  7122. var _a;
  7123. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  7124. };
  7125. const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
  7126. var _a, _b;
  7127. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  7128. return arr;
  7129. }, []));
  7130. const onClickDay = (item) => {
  7131. if (props2.readonly || !item.date) {
  7132. return;
  7133. }
  7134. const {
  7135. date
  7136. } = item;
  7137. const {
  7138. type
  7139. } = props2;
  7140. if (type === "range") {
  7141. if (!currentDate.value) {
  7142. select([date]);
  7143. return;
  7144. }
  7145. const [startDay, endDay] = currentDate.value;
  7146. if (startDay && !endDay) {
  7147. const compareToStart = compareDay(date, startDay);
  7148. if (compareToStart === 1) {
  7149. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  7150. if (disabledDay) {
  7151. const endDay2 = getPrevDay(disabledDay);
  7152. if (compareDay(startDay, endDay2) === -1) {
  7153. select([startDay, endDay2]);
  7154. } else {
  7155. select([date]);
  7156. }
  7157. } else {
  7158. select([startDay, date], true);
  7159. }
  7160. } else if (compareToStart === -1) {
  7161. select([date]);
  7162. } else if (props2.allowSameDay) {
  7163. select([date, date], true);
  7164. }
  7165. } else {
  7166. select([date]);
  7167. }
  7168. } else if (type === "multiple") {
  7169. if (!currentDate.value) {
  7170. select([date]);
  7171. return;
  7172. }
  7173. const dates = currentDate.value;
  7174. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  7175. if (selectedIndex !== -1) {
  7176. const [unselectedDate] = dates.splice(selectedIndex, 1);
  7177. emit("unselect", cloneDate(unselectedDate));
  7178. } else if (props2.maxRange && dates.length >= +props2.maxRange) {
  7179. showToast(props2.rangePrompt || t$g("rangePrompt", props2.maxRange));
  7180. } else {
  7181. select([...dates, date]);
  7182. }
  7183. } else {
  7184. select(date, true);
  7185. }
  7186. };
  7187. const updateShow = (value) => emit("update:show", value);
  7188. const renderMonth = (date, index) => {
  7189. const showMonthTitle = index !== 0 || !props2.showSubtitle;
  7190. return vue.createVNode(stdin_default$1f, vue.mergeProps({
  7191. "ref": canSwitch.value ? currentMonthRef : setMonthRefs(index),
  7192. "date": date,
  7193. "currentDate": currentDate.value,
  7194. "showMonthTitle": showMonthTitle,
  7195. "firstDayOfWeek": dayOffset.value,
  7196. "lazyRender": canSwitch.value ? false : props2.lazyRender,
  7197. "maxDate": maxDate.value,
  7198. "minDate": minDate.value
  7199. }, pick(props2, ["type", "color", "showMark", "formatter", "rowHeight", "showSubtitle", "allowSameDay"]), {
  7200. "onClick": onClickDay,
  7201. "onClickDisabledDate": (item) => emit("clickDisabledDate", item)
  7202. }), pick(slots, ["top-info", "bottom-info", "month-title", "text"]));
  7203. };
  7204. const renderFooterButton = () => {
  7205. if (slots.footer) {
  7206. return slots.footer();
  7207. }
  7208. if (props2.showConfirm) {
  7209. const slot = slots["confirm-text"];
  7210. const disabled = buttonDisabled.value;
  7211. const text = disabled ? props2.confirmDisabledText : props2.confirmText;
  7212. return vue.createVNode(Button, {
  7213. "round": true,
  7214. "block": true,
  7215. "type": "primary",
  7216. "color": props2.color,
  7217. "class": bem$13("confirm"),
  7218. "disabled": disabled,
  7219. "nativeType": "button",
  7220. "onClick": onConfirm
  7221. }, {
  7222. default: () => [slot ? slot({
  7223. disabled
  7224. }) : text || t$g("confirm")]
  7225. });
  7226. }
  7227. };
  7228. const renderFooter = () => vue.createVNode("div", {
  7229. "class": [bem$13("footer"), {
  7230. "van-safe-area-bottom": props2.safeAreaInsetBottom
  7231. }]
  7232. }, [renderFooterButton()]);
  7233. const renderCalendar = () => {
  7234. var _a, _b;
  7235. return vue.createVNode("div", {
  7236. "class": bem$13()
  7237. }, [vue.createVNode(stdin_default$1e, {
  7238. "date": (_a = currentMonthRef.value) == null ? void 0 : _a.date,
  7239. "maxDate": maxDate.value,
  7240. "minDate": minDate.value,
  7241. "title": props2.title,
  7242. "subtitle": (_b = currentMonthRef.value) == null ? void 0 : _b.getTitle(),
  7243. "showTitle": props2.showTitle,
  7244. "showSubtitle": props2.showSubtitle,
  7245. "switchMode": props2.switchMode,
  7246. "firstDayOfWeek": dayOffset.value,
  7247. "onClickSubtitle": (event) => emit("clickSubtitle", event),
  7248. "onPanelChange": onPanelChange
  7249. }, pick(slots, ["title", "subtitle", "prev-month", "prev-year", "next-month", "next-year"])), vue.createVNode("div", {
  7250. "ref": bodyRef,
  7251. "class": bem$13("body"),
  7252. "onScroll": canSwitch.value ? void 0 : onScroll
  7253. }, [canSwitch.value ? renderMonth(currentPanelDate.value, 0) : months.value.map(renderMonth)]), renderFooter()]);
  7254. };
  7255. vue.watch(() => props2.show, init);
  7256. vue.watch(() => [props2.type, props2.minDate, props2.maxDate, props2.switchMode], () => reset(getInitialDate(currentDate.value)));
  7257. vue.watch(() => props2.defaultDate, (value) => {
  7258. reset(value);
  7259. });
  7260. useExpose({
  7261. reset,
  7262. scrollToDate,
  7263. getSelectedDate
  7264. });
  7265. use.onMountedOrActivated(init);
  7266. return () => {
  7267. if (props2.poppable) {
  7268. return vue.createVNode(Popup, {
  7269. "show": props2.show,
  7270. "class": bem$13("popup"),
  7271. "round": props2.round,
  7272. "position": props2.position,
  7273. "closeable": props2.showTitle || props2.showSubtitle,
  7274. "teleport": props2.teleport,
  7275. "closeOnPopstate": props2.closeOnPopstate,
  7276. "safeAreaInsetTop": props2.safeAreaInsetTop,
  7277. "closeOnClickOverlay": props2.closeOnClickOverlay,
  7278. "onUpdate:show": updateShow
  7279. }, {
  7280. default: renderCalendar
  7281. });
  7282. }
  7283. return renderCalendar();
  7284. };
  7285. }
  7286. });
  7287. const Calendar = withInstall(stdin_default$1d);
  7288. const [name$13, bem$12] = createNamespace("image");
  7289. const imageProps = {
  7290. src: String,
  7291. alt: String,
  7292. fit: String,
  7293. position: String,
  7294. round: Boolean,
  7295. block: Boolean,
  7296. width: numericProp,
  7297. height: numericProp,
  7298. radius: numericProp,
  7299. lazyLoad: Boolean,
  7300. iconSize: numericProp,
  7301. showError: truthProp,
  7302. errorIcon: makeStringProp("photo-fail"),
  7303. iconPrefix: String,
  7304. showLoading: truthProp,
  7305. loadingIcon: makeStringProp("photo"),
  7306. crossorigin: String,
  7307. referrerpolicy: String
  7308. };
  7309. var stdin_default$1c = vue.defineComponent({
  7310. name: name$13,
  7311. props: imageProps,
  7312. emits: ["load", "error"],
  7313. setup(props2, {
  7314. emit,
  7315. slots
  7316. }) {
  7317. const error = vue.ref(false);
  7318. const loading = vue.ref(true);
  7319. const imageRef = vue.ref();
  7320. const {
  7321. $Lazyload
  7322. } = vue.getCurrentInstance().proxy;
  7323. const style = vue.computed(() => {
  7324. const style2 = {
  7325. width: addUnit(props2.width),
  7326. height: addUnit(props2.height)
  7327. };
  7328. if (isDef(props2.radius)) {
  7329. style2.overflow = "hidden";
  7330. style2.borderRadius = addUnit(props2.radius);
  7331. }
  7332. return style2;
  7333. });
  7334. vue.watch(() => props2.src, () => {
  7335. error.value = false;
  7336. loading.value = true;
  7337. });
  7338. const onLoad = (event) => {
  7339. if (loading.value) {
  7340. loading.value = false;
  7341. emit("load", event);
  7342. }
  7343. };
  7344. const triggerLoad = () => {
  7345. const loadEvent = new Event("load");
  7346. Object.defineProperty(loadEvent, "target", {
  7347. value: imageRef.value,
  7348. enumerable: true
  7349. });
  7350. onLoad(loadEvent);
  7351. };
  7352. const onError = (event) => {
  7353. error.value = true;
  7354. loading.value = false;
  7355. emit("error", event);
  7356. };
  7357. const renderIcon = (name2, className, slot) => {
  7358. if (slot) {
  7359. return slot();
  7360. }
  7361. return vue.createVNode(Icon, {
  7362. "name": name2,
  7363. "size": props2.iconSize,
  7364. "class": className,
  7365. "classPrefix": props2.iconPrefix
  7366. }, null);
  7367. };
  7368. const renderPlaceholder = () => {
  7369. if (loading.value && props2.showLoading) {
  7370. return vue.createVNode("div", {
  7371. "class": bem$12("loading")
  7372. }, [renderIcon(props2.loadingIcon, bem$12("loading-icon"), slots.loading)]);
  7373. }
  7374. if (error.value && props2.showError) {
  7375. return vue.createVNode("div", {
  7376. "class": bem$12("error")
  7377. }, [renderIcon(props2.errorIcon, bem$12("error-icon"), slots.error)]);
  7378. }
  7379. };
  7380. const renderImage = () => {
  7381. if (error.value || !props2.src) {
  7382. return;
  7383. }
  7384. const attrs = {
  7385. alt: props2.alt,
  7386. class: bem$12("img"),
  7387. style: {
  7388. objectFit: props2.fit,
  7389. objectPosition: props2.position
  7390. },
  7391. crossorigin: props2.crossorigin,
  7392. referrerpolicy: props2.referrerpolicy
  7393. };
  7394. if (props2.lazyLoad) {
  7395. return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
  7396. "ref": imageRef
  7397. }, attrs), null), [[vue.resolveDirective("lazy"), props2.src]]);
  7398. }
  7399. return vue.createVNode("img", vue.mergeProps({
  7400. "ref": imageRef,
  7401. "src": props2.src,
  7402. "onLoad": onLoad,
  7403. "onError": onError
  7404. }, attrs), null);
  7405. };
  7406. const onLazyLoaded = ({
  7407. el
  7408. }) => {
  7409. const check = () => {
  7410. if (el === imageRef.value && loading.value) {
  7411. triggerLoad();
  7412. }
  7413. };
  7414. if (imageRef.value) {
  7415. check();
  7416. } else {
  7417. vue.nextTick(check);
  7418. }
  7419. };
  7420. const onLazyLoadError = ({
  7421. el
  7422. }) => {
  7423. if (el === imageRef.value && !error.value) {
  7424. onError();
  7425. }
  7426. };
  7427. if ($Lazyload && inBrowser) {
  7428. $Lazyload.$on("loaded", onLazyLoaded);
  7429. $Lazyload.$on("error", onLazyLoadError);
  7430. vue.onBeforeUnmount(() => {
  7431. $Lazyload.$off("loaded", onLazyLoaded);
  7432. $Lazyload.$off("error", onLazyLoadError);
  7433. });
  7434. }
  7435. vue.onMounted(() => {
  7436. vue.nextTick(() => {
  7437. var _a;
  7438. if (((_a = imageRef.value) == null ? void 0 : _a.complete) && !props2.lazyLoad) {
  7439. triggerLoad();
  7440. }
  7441. });
  7442. });
  7443. return () => {
  7444. var _a;
  7445. return vue.createVNode("div", {
  7446. "class": bem$12({
  7447. round: props2.round,
  7448. block: props2.block
  7449. }),
  7450. "style": style.value
  7451. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7452. };
  7453. }
  7454. });
  7455. const Image$1 = withInstall(stdin_default$1c);
  7456. const [name$12, bem$11] = createNamespace("card");
  7457. const cardProps = {
  7458. tag: String,
  7459. num: numericProp,
  7460. desc: String,
  7461. thumb: String,
  7462. title: String,
  7463. price: numericProp,
  7464. centered: Boolean,
  7465. lazyLoad: Boolean,
  7466. currency: makeStringProp("¥"),
  7467. thumbLink: String,
  7468. originPrice: numericProp
  7469. };
  7470. var stdin_default$1b = vue.defineComponent({
  7471. name: name$12,
  7472. props: cardProps,
  7473. emits: ["clickThumb"],
  7474. setup(props2, {
  7475. slots,
  7476. emit
  7477. }) {
  7478. const renderTitle = () => {
  7479. if (slots.title) {
  7480. return slots.title();
  7481. }
  7482. if (props2.title) {
  7483. return vue.createVNode("div", {
  7484. "class": [bem$11("title"), "van-multi-ellipsis--l2"]
  7485. }, [props2.title]);
  7486. }
  7487. };
  7488. const renderThumbTag = () => {
  7489. if (slots.tag || props2.tag) {
  7490. return vue.createVNode("div", {
  7491. "class": bem$11("tag")
  7492. }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
  7493. "mark": true,
  7494. "type": "primary"
  7495. }, {
  7496. default: () => [props2.tag]
  7497. })]);
  7498. }
  7499. };
  7500. const renderThumbImage = () => {
  7501. if (slots.thumb) {
  7502. return slots.thumb();
  7503. }
  7504. return vue.createVNode(Image$1, {
  7505. "src": props2.thumb,
  7506. "fit": "cover",
  7507. "width": "100%",
  7508. "height": "100%",
  7509. "lazyLoad": props2.lazyLoad
  7510. }, null);
  7511. };
  7512. const renderThumb = () => {
  7513. if (slots.thumb || props2.thumb) {
  7514. return vue.createVNode("a", {
  7515. "href": props2.thumbLink,
  7516. "class": bem$11("thumb"),
  7517. "onClick": (event) => emit("clickThumb", event)
  7518. }, [renderThumbImage(), renderThumbTag()]);
  7519. }
  7520. };
  7521. const renderDesc = () => {
  7522. if (slots.desc) {
  7523. return slots.desc();
  7524. }
  7525. if (props2.desc) {
  7526. return vue.createVNode("div", {
  7527. "class": [bem$11("desc"), "van-ellipsis"]
  7528. }, [props2.desc]);
  7529. }
  7530. };
  7531. const renderPriceText = () => {
  7532. const priceArr = props2.price.toString().split(".");
  7533. return vue.createVNode("div", null, [vue.createVNode("span", {
  7534. "class": bem$11("price-currency")
  7535. }, [props2.currency]), vue.createVNode("span", {
  7536. "class": bem$11("price-integer")
  7537. }, [priceArr[0]]), priceArr.length > 1 && vue.createVNode(vue.Fragment, null, [vue.createTextVNode("."), vue.createVNode("span", {
  7538. "class": bem$11("price-decimal")
  7539. }, [priceArr[1]])])]);
  7540. };
  7541. return () => {
  7542. var _a, _b, _c;
  7543. const showNum = slots.num || isDef(props2.num);
  7544. const showPrice = slots.price || isDef(props2.price);
  7545. const showOriginPrice = slots["origin-price"] || isDef(props2.originPrice);
  7546. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  7547. const Price = showPrice && vue.createVNode("div", {
  7548. "class": bem$11("price")
  7549. }, [slots.price ? slots.price() : renderPriceText()]);
  7550. const OriginPrice = showOriginPrice && vue.createVNode("div", {
  7551. "class": bem$11("origin-price")
  7552. }, [slots["origin-price"] ? slots["origin-price"]() : `${props2.currency} ${props2.originPrice}`]);
  7553. const Num = showNum && vue.createVNode("div", {
  7554. "class": bem$11("num")
  7555. }, [slots.num ? slots.num() : `x${props2.num}`]);
  7556. const Footer = slots.footer && vue.createVNode("div", {
  7557. "class": bem$11("footer")
  7558. }, [slots.footer()]);
  7559. const Bottom = showBottom && vue.createVNode("div", {
  7560. "class": bem$11("bottom")
  7561. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  7562. return vue.createVNode("div", {
  7563. "class": bem$11()
  7564. }, [vue.createVNode("div", {
  7565. "class": bem$11("header")
  7566. }, [renderThumb(), vue.createVNode("div", {
  7567. "class": bem$11("content", {
  7568. centered: props2.centered
  7569. })
  7570. }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  7571. };
  7572. }
  7573. });
  7574. const Card = withInstall(stdin_default$1b);
  7575. const [name$11, bem$10, t$f] = createNamespace("cascader");
  7576. const cascaderProps = {
  7577. title: String,
  7578. options: makeArrayProp(),
  7579. closeable: truthProp,
  7580. swipeable: truthProp,
  7581. closeIcon: makeStringProp("cross"),
  7582. showHeader: truthProp,
  7583. modelValue: numericProp,
  7584. fieldNames: Object,
  7585. placeholder: String,
  7586. activeColor: String
  7587. };
  7588. var stdin_default$1a = vue.defineComponent({
  7589. name: name$11,
  7590. props: cascaderProps,
  7591. emits: ["close", "change", "finish", "clickTab", "update:modelValue"],
  7592. setup(props2, {
  7593. slots,
  7594. emit
  7595. }) {
  7596. const tabs = vue.ref([]);
  7597. const activeTab = vue.ref(0);
  7598. const [selectedElementRefs, setSelectedElementRefs] = useRefs();
  7599. const {
  7600. text: textKey,
  7601. value: valueKey,
  7602. children: childrenKey
  7603. } = extend({
  7604. text: "text",
  7605. value: "value",
  7606. children: "children"
  7607. }, props2.fieldNames);
  7608. const getSelectedOptionsByValue = (options, value) => {
  7609. for (const option of options) {
  7610. if (option[valueKey] === value) {
  7611. return [option];
  7612. }
  7613. if (option[childrenKey]) {
  7614. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  7615. if (selectedOptions) {
  7616. return [option, ...selectedOptions];
  7617. }
  7618. }
  7619. }
  7620. };
  7621. const updateTabs = () => {
  7622. const {
  7623. options,
  7624. modelValue
  7625. } = props2;
  7626. if (modelValue !== void 0) {
  7627. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  7628. if (selectedOptions) {
  7629. let optionsCursor = options;
  7630. tabs.value = selectedOptions.map((option) => {
  7631. const tab = {
  7632. options: optionsCursor,
  7633. selected: option
  7634. };
  7635. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  7636. if (next) {
  7637. optionsCursor = next[childrenKey];
  7638. }
  7639. return tab;
  7640. });
  7641. if (optionsCursor) {
  7642. tabs.value.push({
  7643. options: optionsCursor,
  7644. selected: null
  7645. });
  7646. }
  7647. vue.nextTick(() => {
  7648. activeTab.value = tabs.value.length - 1;
  7649. });
  7650. return;
  7651. }
  7652. }
  7653. tabs.value = [{
  7654. options,
  7655. selected: null
  7656. }];
  7657. };
  7658. const onSelect = (option, tabIndex) => {
  7659. if (option.disabled) {
  7660. return;
  7661. }
  7662. tabs.value[tabIndex].selected = option;
  7663. if (tabs.value.length > tabIndex + 1) {
  7664. tabs.value = tabs.value.slice(0, tabIndex + 1);
  7665. }
  7666. if (option[childrenKey]) {
  7667. const nextTab = {
  7668. options: option[childrenKey],
  7669. selected: null
  7670. };
  7671. if (tabs.value[tabIndex + 1]) {
  7672. tabs.value[tabIndex + 1] = nextTab;
  7673. } else {
  7674. tabs.value.push(nextTab);
  7675. }
  7676. vue.nextTick(() => {
  7677. activeTab.value++;
  7678. });
  7679. }
  7680. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  7681. emit("update:modelValue", option[valueKey]);
  7682. const params = {
  7683. value: option[valueKey],
  7684. tabIndex,
  7685. selectedOptions
  7686. };
  7687. emit("change", params);
  7688. if (!option[childrenKey]) {
  7689. emit("finish", params);
  7690. }
  7691. };
  7692. const onClose = () => emit("close");
  7693. const onClickTab = ({
  7694. name: name2,
  7695. title
  7696. }) => emit("clickTab", name2, title);
  7697. const renderHeader = () => props2.showHeader ? vue.createVNode("div", {
  7698. "class": bem$10("header")
  7699. }, [vue.createVNode("h2", {
  7700. "class": bem$10("title")
  7701. }, [slots.title ? slots.title() : props2.title]), props2.closeable ? vue.createVNode(Icon, {
  7702. "name": props2.closeIcon,
  7703. "class": [bem$10("close-icon"), HAPTICS_FEEDBACK],
  7704. "onClick": onClose
  7705. }, null) : null]) : null;
  7706. const renderOption = (option, selectedOption, tabIndex) => {
  7707. const {
  7708. disabled
  7709. } = option;
  7710. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  7711. const color = option.color || (selected ? props2.activeColor : void 0);
  7712. const Text = slots.option ? slots.option({
  7713. option,
  7714. selected
  7715. }) : vue.createVNode("span", null, [option[textKey]]);
  7716. return vue.createVNode("li", {
  7717. "ref": selected ? setSelectedElementRefs(tabIndex) : void 0,
  7718. "role": "menuitemradio",
  7719. "class": [bem$10("option", {
  7720. selected,
  7721. disabled
  7722. }), option.className],
  7723. "style": {
  7724. color
  7725. },
  7726. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  7727. "aria-checked": selected,
  7728. "aria-disabled": disabled || void 0,
  7729. "onClick": () => onSelect(option, tabIndex)
  7730. }, [Text, selected ? vue.createVNode(Icon, {
  7731. "name": "success",
  7732. "class": bem$10("selected-icon")
  7733. }, null) : null]);
  7734. };
  7735. const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
  7736. "role": "menu",
  7737. "class": bem$10("options")
  7738. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  7739. const renderTab = (tab, tabIndex) => {
  7740. const {
  7741. options,
  7742. selected
  7743. } = tab;
  7744. const placeholder = props2.placeholder || t$f("select");
  7745. const title = selected ? selected[textKey] : placeholder;
  7746. return vue.createVNode(Tab, {
  7747. "title": title,
  7748. "titleClass": bem$10("tab", {
  7749. unselected: !selected
  7750. })
  7751. }, {
  7752. default: () => {
  7753. var _a, _b;
  7754. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  7755. tabIndex
  7756. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  7757. tabIndex
  7758. })];
  7759. }
  7760. });
  7761. };
  7762. const renderTabs = () => vue.createVNode(Tabs, {
  7763. "active": activeTab.value,
  7764. "onUpdate:active": ($event) => activeTab.value = $event,
  7765. "shrink": true,
  7766. "animated": true,
  7767. "class": bem$10("tabs"),
  7768. "color": props2.activeColor,
  7769. "swipeable": props2.swipeable,
  7770. "onClickTab": onClickTab
  7771. }, {
  7772. default: () => [tabs.value.map(renderTab)]
  7773. });
  7774. const scrollIntoView = (el) => {
  7775. const scrollParent = el.parentElement;
  7776. if (scrollParent) {
  7777. scrollParent.scrollTop = el.offsetTop - (scrollParent.offsetHeight - el.offsetHeight) / 2;
  7778. }
  7779. };
  7780. updateTabs();
  7781. vue.watch(activeTab, (value) => {
  7782. const el = selectedElementRefs.value[value];
  7783. if (el) scrollIntoView(el);
  7784. });
  7785. vue.watch(() => props2.options, updateTabs, {
  7786. deep: true
  7787. });
  7788. vue.watch(() => props2.modelValue, (value) => {
  7789. if (value !== void 0) {
  7790. const values = tabs.value.map((tab) => {
  7791. var _a;
  7792. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  7793. });
  7794. if (values.includes(value)) {
  7795. return;
  7796. }
  7797. }
  7798. updateTabs();
  7799. });
  7800. return () => vue.createVNode("div", {
  7801. "class": bem$10()
  7802. }, [renderHeader(), renderTabs()]);
  7803. }
  7804. });
  7805. const Cascader = withInstall(stdin_default$1a);
  7806. const [name$10, bem$$] = createNamespace("cell-group");
  7807. const cellGroupProps = {
  7808. title: String,
  7809. inset: Boolean,
  7810. border: truthProp
  7811. };
  7812. var stdin_default$19 = vue.defineComponent({
  7813. name: name$10,
  7814. inheritAttrs: false,
  7815. props: cellGroupProps,
  7816. setup(props2, {
  7817. slots,
  7818. attrs
  7819. }) {
  7820. const renderGroup = () => {
  7821. var _a;
  7822. return vue.createVNode("div", vue.mergeProps({
  7823. "class": [bem$$({
  7824. inset: props2.inset
  7825. }), {
  7826. [BORDER_TOP_BOTTOM]: props2.border && !props2.inset
  7827. }]
  7828. }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7829. };
  7830. const renderTitle = () => vue.createVNode("div", {
  7831. "class": bem$$("title", {
  7832. inset: props2.inset
  7833. })
  7834. }, [slots.title ? slots.title() : props2.title]);
  7835. return () => {
  7836. if (props2.title || slots.title) {
  7837. return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
  7838. }
  7839. return renderGroup();
  7840. };
  7841. }
  7842. });
  7843. const CellGroup = withInstall(stdin_default$19);
  7844. const [name$$, bem$_] = createNamespace("circle");
  7845. let uid = 0;
  7846. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  7847. function getPath(clockwise, viewBoxSize) {
  7848. const sweepFlag = clockwise ? 1 : 0;
  7849. 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`;
  7850. }
  7851. const circleProps = {
  7852. text: String,
  7853. size: numericProp,
  7854. fill: makeStringProp("none"),
  7855. rate: makeNumericProp(100),
  7856. speed: makeNumericProp(0),
  7857. color: [String, Object],
  7858. clockwise: truthProp,
  7859. layerColor: String,
  7860. currentRate: makeNumberProp(0),
  7861. strokeWidth: makeNumericProp(40),
  7862. strokeLinecap: String,
  7863. startPosition: makeStringProp("top")
  7864. };
  7865. var stdin_default$18 = vue.defineComponent({
  7866. name: name$$,
  7867. props: circleProps,
  7868. emits: ["update:currentRate"],
  7869. setup(props2, {
  7870. emit,
  7871. slots
  7872. }) {
  7873. const id = `van-circle-${uid++}`;
  7874. const viewBoxSize = vue.computed(() => +props2.strokeWidth + 1e3);
  7875. const path = vue.computed(() => getPath(props2.clockwise, viewBoxSize.value));
  7876. const svgStyle = vue.computed(() => {
  7877. const ROTATE_ANGLE_MAP = {
  7878. top: 0,
  7879. right: 90,
  7880. bottom: 180,
  7881. left: 270
  7882. };
  7883. const angleValue = ROTATE_ANGLE_MAP[props2.startPosition];
  7884. if (angleValue) {
  7885. return {
  7886. transform: `rotate(${angleValue}deg)`
  7887. };
  7888. }
  7889. });
  7890. vue.watch(() => props2.rate, (rate) => {
  7891. let rafId;
  7892. const startTime = Date.now();
  7893. const startRate = props2.currentRate;
  7894. const endRate = format(rate);
  7895. const duration = Math.abs((startRate - endRate) * 1e3 / +props2.speed);
  7896. const animate = () => {
  7897. const now = Date.now();
  7898. const progress = Math.min((now - startTime) / duration, 1);
  7899. const rate2 = progress * (endRate - startRate) + startRate;
  7900. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7901. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7902. rafId = use.raf(animate);
  7903. }
  7904. };
  7905. if (props2.speed) {
  7906. if (rafId) {
  7907. use.cancelRaf(rafId);
  7908. }
  7909. rafId = use.raf(animate);
  7910. } else {
  7911. emit("update:currentRate", endRate);
  7912. }
  7913. }, {
  7914. immediate: true
  7915. });
  7916. const renderHover = () => {
  7917. const PERIMETER = 3140;
  7918. const {
  7919. strokeWidth,
  7920. currentRate,
  7921. strokeLinecap
  7922. } = props2;
  7923. const offset = PERIMETER * currentRate / 100;
  7924. const color = isObject(props2.color) ? `url(#${id})` : props2.color;
  7925. const style = {
  7926. stroke: color,
  7927. strokeWidth: `${+strokeWidth + 1}px`,
  7928. strokeLinecap,
  7929. strokeDasharray: `${offset}px ${PERIMETER}px`
  7930. };
  7931. return vue.createVNode("path", {
  7932. "d": path.value,
  7933. "style": style,
  7934. "class": bem$_("hover"),
  7935. "stroke": color
  7936. }, null);
  7937. };
  7938. const renderLayer = () => {
  7939. const style = {
  7940. fill: props2.fill,
  7941. stroke: props2.layerColor,
  7942. strokeWidth: `${props2.strokeWidth}px`
  7943. };
  7944. return vue.createVNode("path", {
  7945. "class": bem$_("layer"),
  7946. "style": style,
  7947. "d": path.value
  7948. }, null);
  7949. };
  7950. const renderGradient = () => {
  7951. const {
  7952. color
  7953. } = props2;
  7954. if (!isObject(color)) {
  7955. return;
  7956. }
  7957. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
  7958. "key": index,
  7959. "offset": key,
  7960. "stop-color": color[key]
  7961. }, null));
  7962. return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  7963. "id": id,
  7964. "x1": "100%",
  7965. "y1": "0%",
  7966. "x2": "0%",
  7967. "y2": "0%"
  7968. }, [Stops])]);
  7969. };
  7970. const renderText = () => {
  7971. if (slots.default) {
  7972. return slots.default();
  7973. }
  7974. if (props2.text) {
  7975. return vue.createVNode("div", {
  7976. "class": bem$_("text")
  7977. }, [props2.text]);
  7978. }
  7979. };
  7980. return () => vue.createVNode("div", {
  7981. "class": bem$_(),
  7982. "style": getSizeStyle(props2.size)
  7983. }, [vue.createVNode("svg", {
  7984. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7985. "style": svgStyle.value
  7986. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7987. }
  7988. });
  7989. const Circle = withInstall(stdin_default$18);
  7990. const [name$_, bem$Z] = createNamespace("row");
  7991. const ROW_KEY = Symbol(name$_);
  7992. const rowProps = {
  7993. tag: makeStringProp("div"),
  7994. wrap: truthProp,
  7995. align: String,
  7996. gutter: {
  7997. type: [String, Number, Array],
  7998. default: 0
  7999. },
  8000. justify: String
  8001. };
  8002. var stdin_default$17 = vue.defineComponent({
  8003. name: name$_,
  8004. props: rowProps,
  8005. setup(props2, {
  8006. slots
  8007. }) {
  8008. const {
  8009. children,
  8010. linkChildren
  8011. } = use.useChildren(ROW_KEY);
  8012. const groups = vue.computed(() => {
  8013. const groups2 = [[]];
  8014. let totalSpan = 0;
  8015. children.forEach((child, index) => {
  8016. totalSpan += Number(child.span);
  8017. if (totalSpan > 24) {
  8018. groups2.push([index]);
  8019. totalSpan -= 24;
  8020. } else {
  8021. groups2[groups2.length - 1].push(index);
  8022. }
  8023. });
  8024. return groups2;
  8025. });
  8026. const spaces = vue.computed(() => {
  8027. let gutter = 0;
  8028. if (Array.isArray(props2.gutter)) {
  8029. gutter = Number(props2.gutter[0]) || 0;
  8030. } else {
  8031. gutter = Number(props2.gutter);
  8032. }
  8033. const spaces2 = [];
  8034. if (!gutter) {
  8035. return spaces2;
  8036. }
  8037. groups.value.forEach((group) => {
  8038. const averagePadding = gutter * (group.length - 1) / group.length;
  8039. group.forEach((item, index) => {
  8040. if (index === 0) {
  8041. spaces2.push({
  8042. right: averagePadding
  8043. });
  8044. } else {
  8045. const left = gutter - spaces2[item - 1].right;
  8046. const right = averagePadding - left;
  8047. spaces2.push({
  8048. left,
  8049. right
  8050. });
  8051. }
  8052. });
  8053. });
  8054. return spaces2;
  8055. });
  8056. const verticalSpaces = vue.computed(() => {
  8057. const {
  8058. gutter
  8059. } = props2;
  8060. const spaces2 = [];
  8061. if (Array.isArray(gutter) && gutter.length > 1) {
  8062. const bottom = Number(gutter[1]) || 0;
  8063. if (bottom <= 0) {
  8064. return spaces2;
  8065. }
  8066. groups.value.forEach((group, index) => {
  8067. if (index === groups.value.length - 1) return;
  8068. group.forEach(() => {
  8069. spaces2.push({
  8070. bottom
  8071. });
  8072. });
  8073. });
  8074. }
  8075. return spaces2;
  8076. });
  8077. linkChildren({
  8078. spaces,
  8079. verticalSpaces
  8080. });
  8081. return () => {
  8082. const {
  8083. tag,
  8084. wrap,
  8085. align,
  8086. justify
  8087. } = props2;
  8088. return vue.createVNode(tag, {
  8089. "class": bem$Z({
  8090. [`align-${align}`]: align,
  8091. [`justify-${justify}`]: justify,
  8092. nowrap: !wrap
  8093. })
  8094. }, {
  8095. default: () => {
  8096. var _a;
  8097. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  8098. }
  8099. });
  8100. };
  8101. }
  8102. });
  8103. const [name$Z, bem$Y] = createNamespace("col");
  8104. const colProps = {
  8105. tag: makeStringProp("div"),
  8106. span: makeNumericProp(0),
  8107. offset: numericProp
  8108. };
  8109. var stdin_default$16 = vue.defineComponent({
  8110. name: name$Z,
  8111. props: colProps,
  8112. setup(props2, {
  8113. slots
  8114. }) {
  8115. const {
  8116. parent,
  8117. index
  8118. } = use.useParent(ROW_KEY);
  8119. const style = vue.computed(() => {
  8120. if (!parent) {
  8121. return;
  8122. }
  8123. const {
  8124. spaces,
  8125. verticalSpaces
  8126. } = parent;
  8127. let styles = {};
  8128. if (spaces && spaces.value && spaces.value[index.value]) {
  8129. const {
  8130. left,
  8131. right
  8132. } = spaces.value[index.value];
  8133. styles = {
  8134. paddingLeft: left ? `${left}px` : null,
  8135. paddingRight: right ? `${right}px` : null
  8136. };
  8137. }
  8138. const {
  8139. bottom
  8140. } = verticalSpaces.value[index.value] || {};
  8141. return extend(styles, {
  8142. marginBottom: bottom ? `${bottom}px` : null
  8143. });
  8144. });
  8145. return () => {
  8146. const {
  8147. tag,
  8148. span,
  8149. offset
  8150. } = props2;
  8151. return vue.createVNode(tag, {
  8152. "style": style.value,
  8153. "class": bem$Y({
  8154. [span]: span,
  8155. [`offset-${offset}`]: offset
  8156. })
  8157. }, {
  8158. default: () => {
  8159. var _a;
  8160. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  8161. }
  8162. });
  8163. };
  8164. }
  8165. });
  8166. const Col = withInstall(stdin_default$16);
  8167. const [name$Y, bem$X] = createNamespace("collapse");
  8168. const COLLAPSE_KEY = Symbol(name$Y);
  8169. const collapseProps = {
  8170. border: truthProp,
  8171. accordion: Boolean,
  8172. modelValue: {
  8173. type: [String, Number, Array],
  8174. default: ""
  8175. }
  8176. };
  8177. function validateModelValue(modelValue, accordion) {
  8178. if (accordion && Array.isArray(modelValue)) {
  8179. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  8180. return false;
  8181. }
  8182. if (!accordion && !Array.isArray(modelValue)) {
  8183. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  8184. return false;
  8185. }
  8186. return true;
  8187. }
  8188. var stdin_default$15 = vue.defineComponent({
  8189. name: name$Y,
  8190. props: collapseProps,
  8191. emits: ["change", "update:modelValue"],
  8192. setup(props2, {
  8193. emit,
  8194. slots
  8195. }) {
  8196. const {
  8197. linkChildren,
  8198. children
  8199. } = use.useChildren(COLLAPSE_KEY);
  8200. const updateName = (name2) => {
  8201. emit("change", name2);
  8202. emit("update:modelValue", name2);
  8203. };
  8204. const toggle = (name2, expanded) => {
  8205. const {
  8206. accordion,
  8207. modelValue
  8208. } = props2;
  8209. if (accordion) {
  8210. updateName(name2 === modelValue ? "" : name2);
  8211. } else if (expanded) {
  8212. updateName(modelValue.concat(name2));
  8213. } else {
  8214. updateName(modelValue.filter((activeName) => activeName !== name2));
  8215. }
  8216. };
  8217. const toggleAll = (options = {}) => {
  8218. if (props2.accordion) {
  8219. return;
  8220. }
  8221. if (typeof options === "boolean") {
  8222. options = {
  8223. expanded: options
  8224. };
  8225. }
  8226. const {
  8227. expanded,
  8228. skipDisabled
  8229. } = options;
  8230. const expandedChildren = children.filter((item) => {
  8231. if (item.disabled && skipDisabled) {
  8232. return item.expanded.value;
  8233. }
  8234. return expanded != null ? expanded : !item.expanded.value;
  8235. });
  8236. const names = expandedChildren.map((item) => item.itemName.value);
  8237. updateName(names);
  8238. };
  8239. const isExpanded = (name2) => {
  8240. const {
  8241. accordion,
  8242. modelValue
  8243. } = props2;
  8244. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  8245. return false;
  8246. }
  8247. return accordion ? modelValue === name2 : modelValue.includes(name2);
  8248. };
  8249. useExpose({
  8250. toggleAll
  8251. });
  8252. linkChildren({
  8253. toggle,
  8254. isExpanded
  8255. });
  8256. return () => {
  8257. var _a;
  8258. return vue.createVNode("div", {
  8259. "class": [bem$X(), {
  8260. [BORDER_TOP_BOTTOM]: props2.border
  8261. }]
  8262. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  8263. };
  8264. }
  8265. });
  8266. const Collapse = withInstall(stdin_default$15);
  8267. const [name$X, bem$W] = createNamespace("collapse-item");
  8268. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  8269. const collapseItemProps = extend({}, cellSharedProps, {
  8270. name: numericProp,
  8271. isLink: truthProp,
  8272. disabled: Boolean,
  8273. readonly: Boolean,
  8274. lazyRender: truthProp
  8275. });
  8276. var stdin_default$14 = vue.defineComponent({
  8277. name: name$X,
  8278. props: collapseItemProps,
  8279. setup(props2, {
  8280. slots
  8281. }) {
  8282. const wrapperRef = vue.ref();
  8283. const contentRef = vue.ref();
  8284. const {
  8285. parent,
  8286. index
  8287. } = use.useParent(COLLAPSE_KEY);
  8288. if (!parent) {
  8289. if (process.env.NODE_ENV !== "production") {
  8290. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  8291. }
  8292. return;
  8293. }
  8294. const name2 = vue.computed(() => {
  8295. var _a;
  8296. return (_a = props2.name) != null ? _a : index.value;
  8297. });
  8298. const expanded = vue.computed(() => parent.isExpanded(name2.value));
  8299. const show = vue.ref(expanded.value);
  8300. const lazyRender = useLazyRender(() => show.value || !props2.lazyRender);
  8301. const onTransitionEnd = () => {
  8302. if (!expanded.value) {
  8303. show.value = false;
  8304. } else if (wrapperRef.value) {
  8305. wrapperRef.value.style.height = "";
  8306. }
  8307. };
  8308. vue.watch(expanded, (value, oldValue) => {
  8309. if (oldValue === null) {
  8310. return;
  8311. }
  8312. if (value) {
  8313. show.value = true;
  8314. }
  8315. const tick = value ? vue.nextTick : use.raf;
  8316. tick(() => {
  8317. if (!contentRef.value || !wrapperRef.value) {
  8318. return;
  8319. }
  8320. const {
  8321. offsetHeight
  8322. } = contentRef.value;
  8323. if (offsetHeight) {
  8324. const contentHeight = `${offsetHeight}px`;
  8325. wrapperRef.value.style.height = value ? "0" : contentHeight;
  8326. use.doubleRaf(() => {
  8327. if (wrapperRef.value) {
  8328. wrapperRef.value.style.height = value ? contentHeight : "0";
  8329. }
  8330. });
  8331. } else {
  8332. onTransitionEnd();
  8333. }
  8334. });
  8335. });
  8336. const toggle = (newValue = !expanded.value) => {
  8337. parent.toggle(name2.value, newValue);
  8338. };
  8339. const onClickTitle = () => {
  8340. if (!props2.disabled && !props2.readonly) {
  8341. toggle();
  8342. }
  8343. };
  8344. const renderTitle = () => {
  8345. const {
  8346. border,
  8347. disabled,
  8348. readonly
  8349. } = props2;
  8350. const attrs = pick(props2, Object.keys(cellSharedProps));
  8351. if (readonly) {
  8352. attrs.isLink = false;
  8353. }
  8354. if (disabled || readonly) {
  8355. attrs.clickable = false;
  8356. }
  8357. return vue.createVNode(Cell, vue.mergeProps({
  8358. "role": "button",
  8359. "class": bem$W("title", {
  8360. disabled,
  8361. expanded: expanded.value,
  8362. borderless: !border
  8363. }),
  8364. "aria-expanded": String(expanded.value),
  8365. "onClick": onClickTitle
  8366. }, attrs), pick(slots, CELL_SLOTS));
  8367. };
  8368. const renderContent = lazyRender(() => {
  8369. var _a;
  8370. return vue.withDirectives(vue.createVNode("div", {
  8371. "ref": wrapperRef,
  8372. "class": bem$W("wrapper"),
  8373. "onTransitionend": onTransitionEnd
  8374. }, [vue.createVNode("div", {
  8375. "ref": contentRef,
  8376. "class": bem$W("content")
  8377. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
  8378. });
  8379. useExpose({
  8380. toggle,
  8381. expanded,
  8382. itemName: name2
  8383. });
  8384. return () => vue.createVNode("div", {
  8385. "class": [bem$W({
  8386. border: index.value && props2.border
  8387. })]
  8388. }, [renderTitle(), renderContent()]);
  8389. }
  8390. });
  8391. const CollapseItem = withInstall(stdin_default$14);
  8392. const ConfigProvider = withInstall(stdin_default$1S);
  8393. const [name$W, bem$V, t$e] = createNamespace("contact-card");
  8394. const contactCardProps = {
  8395. tel: String,
  8396. name: String,
  8397. type: makeStringProp("add"),
  8398. addText: String,
  8399. editable: truthProp
  8400. };
  8401. var stdin_default$13 = vue.defineComponent({
  8402. name: name$W,
  8403. props: contactCardProps,
  8404. emits: ["click"],
  8405. setup(props2, {
  8406. emit
  8407. }) {
  8408. const onClick = (event) => {
  8409. if (props2.editable) {
  8410. emit("click", event);
  8411. }
  8412. };
  8413. const renderContent = () => {
  8414. if (props2.type === "add") {
  8415. return props2.addText || t$e("addContact");
  8416. }
  8417. return [vue.createVNode("div", null, [`${t$e("name")}:${props2.name}`]), vue.createVNode("div", null, [`${t$e("tel")}:${props2.tel}`])];
  8418. };
  8419. return () => vue.createVNode(Cell, {
  8420. "center": true,
  8421. "icon": props2.type === "edit" ? "contact" : "add-square",
  8422. "class": bem$V([props2.type]),
  8423. "border": false,
  8424. "isLink": props2.editable,
  8425. "titleClass": bem$V("title"),
  8426. "onClick": onClick
  8427. }, {
  8428. title: renderContent
  8429. });
  8430. }
  8431. });
  8432. const ContactCard = withInstall(stdin_default$13);
  8433. const [name$V, bem$U, t$d] = createNamespace("contact-edit");
  8434. const DEFAULT_CONTACT = {
  8435. tel: "",
  8436. name: ""
  8437. };
  8438. const contactEditProps = {
  8439. isEdit: Boolean,
  8440. isSaving: Boolean,
  8441. isDeleting: Boolean,
  8442. showSetDefault: Boolean,
  8443. setDefaultLabel: String,
  8444. contactInfo: {
  8445. type: Object,
  8446. default: () => extend({}, DEFAULT_CONTACT)
  8447. },
  8448. telValidator: {
  8449. type: Function,
  8450. default: isMobile
  8451. }
  8452. };
  8453. var stdin_default$12 = vue.defineComponent({
  8454. name: name$V,
  8455. props: contactEditProps,
  8456. emits: ["save", "delete", "changeDefault"],
  8457. setup(props2, {
  8458. emit
  8459. }) {
  8460. const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props2.contactInfo));
  8461. const onSave = () => {
  8462. if (!props2.isSaving) {
  8463. emit("save", contact);
  8464. }
  8465. };
  8466. const onDelete = () => emit("delete", contact);
  8467. const renderButtons = () => vue.createVNode("div", {
  8468. "class": bem$U("buttons")
  8469. }, [vue.createVNode(Button, {
  8470. "block": true,
  8471. "round": true,
  8472. "type": "primary",
  8473. "text": t$d("save"),
  8474. "class": bem$U("button"),
  8475. "loading": props2.isSaving,
  8476. "nativeType": "submit"
  8477. }, null), props2.isEdit && vue.createVNode(Button, {
  8478. "block": true,
  8479. "round": true,
  8480. "text": t$d("delete"),
  8481. "class": bem$U("button"),
  8482. "loading": props2.isDeleting,
  8483. "onClick": onDelete
  8484. }, null)]);
  8485. const renderSwitch = () => vue.createVNode(Switch, {
  8486. "modelValue": contact.isDefault,
  8487. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  8488. "onChange": (checked) => emit("changeDefault", checked)
  8489. }, null);
  8490. const renderSetDefault = () => {
  8491. if (props2.showSetDefault) {
  8492. return vue.createVNode(Cell, {
  8493. "title": props2.setDefaultLabel,
  8494. "class": bem$U("switch-cell"),
  8495. "border": false
  8496. }, {
  8497. "right-icon": renderSwitch
  8498. });
  8499. }
  8500. };
  8501. vue.watch(() => props2.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  8502. return () => vue.createVNode(Form, {
  8503. "class": bem$U(),
  8504. "onSubmit": onSave
  8505. }, {
  8506. default: () => [vue.createVNode("div", {
  8507. "class": bem$U("fields")
  8508. }, [vue.createVNode(Field, {
  8509. "modelValue": contact.name,
  8510. "onUpdate:modelValue": ($event) => contact.name = $event,
  8511. "clearable": true,
  8512. "label": t$d("name"),
  8513. "rules": [{
  8514. required: true,
  8515. message: t$d("nameEmpty")
  8516. }],
  8517. "maxlength": "30",
  8518. "placeholder": t$d("name")
  8519. }, null), vue.createVNode(Field, {
  8520. "modelValue": contact.tel,
  8521. "onUpdate:modelValue": ($event) => contact.tel = $event,
  8522. "clearable": true,
  8523. "type": "tel",
  8524. "label": t$d("tel"),
  8525. "rules": [{
  8526. validator: props2.telValidator,
  8527. message: t$d("telInvalid")
  8528. }],
  8529. "placeholder": t$d("tel")
  8530. }, null)]), renderSetDefault(), renderButtons()]
  8531. });
  8532. }
  8533. });
  8534. const ContactEdit = withInstall(stdin_default$12);
  8535. const [name$U, bem$T, t$c] = createNamespace("contact-list");
  8536. const contactListProps = {
  8537. list: Array,
  8538. addText: String,
  8539. modelValue: unknownProp,
  8540. defaultTagText: String
  8541. };
  8542. var stdin_default$11 = vue.defineComponent({
  8543. name: name$U,
  8544. props: contactListProps,
  8545. emits: ["add", "edit", "select", "update:modelValue"],
  8546. setup(props2, {
  8547. emit
  8548. }) {
  8549. const renderItem = (item, index) => {
  8550. const onClick = () => {
  8551. emit("update:modelValue", item.id);
  8552. emit("select", item, index);
  8553. };
  8554. const renderRightIcon = () => vue.createVNode(Radio, {
  8555. "class": bem$T("radio"),
  8556. "name": item.id,
  8557. "iconSize": 18
  8558. }, null);
  8559. const renderEditIcon = () => vue.createVNode(Icon, {
  8560. "name": "edit",
  8561. "class": bem$T("edit"),
  8562. "onClick": (event) => {
  8563. event.stopPropagation();
  8564. emit("edit", item, index);
  8565. }
  8566. }, null);
  8567. const renderContent = () => {
  8568. const nodes = [`${item.name},${item.tel}`];
  8569. if (item.isDefault && props2.defaultTagText) {
  8570. nodes.push(vue.createVNode(Tag, {
  8571. "type": "primary",
  8572. "round": true,
  8573. "class": bem$T("item-tag")
  8574. }, {
  8575. default: () => [props2.defaultTagText]
  8576. }));
  8577. }
  8578. return nodes;
  8579. };
  8580. return vue.createVNode(Cell, {
  8581. "key": item.id,
  8582. "isLink": true,
  8583. "center": true,
  8584. "class": bem$T("item"),
  8585. "titleClass": bem$T("item-title"),
  8586. "onClick": onClick
  8587. }, {
  8588. icon: renderEditIcon,
  8589. title: renderContent,
  8590. "right-icon": renderRightIcon
  8591. });
  8592. };
  8593. return () => vue.createVNode("div", {
  8594. "class": bem$T()
  8595. }, [vue.createVNode(RadioGroup, {
  8596. "modelValue": props2.modelValue,
  8597. "class": bem$T("group")
  8598. }, {
  8599. default: () => [props2.list && props2.list.map(renderItem)]
  8600. }), vue.createVNode("div", {
  8601. "class": [bem$T("bottom"), "van-safe-area-bottom"]
  8602. }, [vue.createVNode(Button, {
  8603. "round": true,
  8604. "block": true,
  8605. "type": "primary",
  8606. "class": bem$T("add"),
  8607. "text": props2.addText || t$c("addContact"),
  8608. "onClick": () => emit("add")
  8609. }, null)])]);
  8610. }
  8611. });
  8612. const ContactList = withInstall(stdin_default$11);
  8613. function parseFormat(format2, currentTime) {
  8614. const { days } = currentTime;
  8615. let { hours, minutes, seconds, milliseconds } = currentTime;
  8616. if (format2.includes("DD")) {
  8617. format2 = format2.replace("DD", padZero(days));
  8618. } else {
  8619. hours += days * 24;
  8620. }
  8621. if (format2.includes("HH")) {
  8622. format2 = format2.replace("HH", padZero(hours));
  8623. } else {
  8624. minutes += hours * 60;
  8625. }
  8626. if (format2.includes("mm")) {
  8627. format2 = format2.replace("mm", padZero(minutes));
  8628. } else {
  8629. seconds += minutes * 60;
  8630. }
  8631. if (format2.includes("ss")) {
  8632. format2 = format2.replace("ss", padZero(seconds));
  8633. } else {
  8634. milliseconds += seconds * 1e3;
  8635. }
  8636. if (format2.includes("S")) {
  8637. const ms = padZero(milliseconds, 3);
  8638. if (format2.includes("SSS")) {
  8639. format2 = format2.replace("SSS", ms);
  8640. } else if (format2.includes("SS")) {
  8641. format2 = format2.replace("SS", ms.slice(0, 2));
  8642. } else {
  8643. format2 = format2.replace("S", ms.charAt(0));
  8644. }
  8645. }
  8646. return format2;
  8647. }
  8648. const [name$T, bem$S] = createNamespace("count-down");
  8649. const countDownProps = {
  8650. time: makeNumericProp(0),
  8651. format: makeStringProp("HH:mm:ss"),
  8652. autoStart: truthProp,
  8653. millisecond: Boolean
  8654. };
  8655. var stdin_default$10 = vue.defineComponent({
  8656. name: name$T,
  8657. props: countDownProps,
  8658. emits: ["change", "finish"],
  8659. setup(props2, {
  8660. emit,
  8661. slots
  8662. }) {
  8663. const {
  8664. start,
  8665. pause,
  8666. reset,
  8667. current: current2
  8668. } = use.useCountDown({
  8669. time: +props2.time,
  8670. millisecond: props2.millisecond,
  8671. onChange: (current22) => emit("change", current22),
  8672. onFinish: () => emit("finish")
  8673. });
  8674. const timeText = vue.computed(() => parseFormat(props2.format, current2.value));
  8675. const resetTime = () => {
  8676. reset(+props2.time);
  8677. if (props2.autoStart) {
  8678. start();
  8679. }
  8680. };
  8681. vue.watch(() => props2.time, resetTime, {
  8682. immediate: true
  8683. });
  8684. useExpose({
  8685. start,
  8686. pause,
  8687. reset: resetTime
  8688. });
  8689. return () => vue.createVNode("div", {
  8690. "role": "timer",
  8691. "class": bem$S()
  8692. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  8693. }
  8694. });
  8695. const CountDown = withInstall(stdin_default$10);
  8696. function getDate(timeStamp) {
  8697. const date = new Date(timeStamp * 1e3);
  8698. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  8699. date.getDate()
  8700. )}`;
  8701. }
  8702. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  8703. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  8704. const [name$S, bem$R, t$b] = createNamespace("coupon");
  8705. var stdin_default$$ = vue.defineComponent({
  8706. name: name$S,
  8707. props: {
  8708. chosen: Boolean,
  8709. coupon: makeRequiredProp(Object),
  8710. disabled: Boolean,
  8711. currency: makeStringProp("¥")
  8712. },
  8713. setup(props2) {
  8714. const validPeriod = vue.computed(() => {
  8715. const {
  8716. startAt,
  8717. endAt
  8718. } = props2.coupon;
  8719. return `${getDate(startAt)} - ${getDate(endAt)}`;
  8720. });
  8721. const faceAmount = vue.computed(() => {
  8722. const {
  8723. coupon,
  8724. currency
  8725. } = props2;
  8726. if (coupon.valueDesc) {
  8727. return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
  8728. }
  8729. if (coupon.denominations) {
  8730. const denominations = formatAmount(coupon.denominations);
  8731. return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
  8732. }
  8733. if (coupon.discount) {
  8734. return t$b("discount", formatDiscount(coupon.discount));
  8735. }
  8736. return "";
  8737. });
  8738. const conditionMessage = vue.computed(() => {
  8739. const condition = formatAmount(props2.coupon.originCondition || 0);
  8740. return condition === "0" ? t$b("unlimited") : t$b("condition", condition);
  8741. });
  8742. return () => {
  8743. const {
  8744. chosen,
  8745. coupon,
  8746. disabled
  8747. } = props2;
  8748. const description = disabled && coupon.reason || coupon.description;
  8749. return vue.createVNode("div", {
  8750. "class": bem$R({
  8751. disabled
  8752. })
  8753. }, [vue.createVNode("div", {
  8754. "class": bem$R("content")
  8755. }, [vue.createVNode("div", {
  8756. "class": bem$R("head")
  8757. }, [vue.createVNode("h2", {
  8758. "class": bem$R("amount")
  8759. }, [faceAmount.value]), vue.createVNode("p", {
  8760. "class": bem$R("condition")
  8761. }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
  8762. "class": bem$R("body")
  8763. }, [vue.createVNode("p", {
  8764. "class": bem$R("name")
  8765. }, [coupon.name]), vue.createVNode("p", {
  8766. "class": bem$R("valid")
  8767. }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
  8768. "class": bem$R("corner"),
  8769. "modelValue": chosen
  8770. }, null)])]), description && vue.createVNode("p", {
  8771. "class": bem$R("description")
  8772. }, [description])]);
  8773. };
  8774. }
  8775. });
  8776. const Coupon = withInstall(stdin_default$$);
  8777. const [name$R, bem$Q, t$a] = createNamespace("coupon-cell");
  8778. const couponCellProps = {
  8779. title: String,
  8780. border: truthProp,
  8781. editable: truthProp,
  8782. coupons: makeArrayProp(),
  8783. currency: makeStringProp("¥"),
  8784. chosenCoupon: {
  8785. type: [Number, Array],
  8786. default: -1
  8787. }
  8788. };
  8789. const getValue = (coupon) => {
  8790. const {
  8791. value,
  8792. denominations
  8793. } = coupon;
  8794. if (isDef(value)) {
  8795. return value;
  8796. }
  8797. if (isDef(denominations)) {
  8798. return denominations;
  8799. }
  8800. return 0;
  8801. };
  8802. function formatValue({
  8803. coupons,
  8804. chosenCoupon,
  8805. currency
  8806. }) {
  8807. let value = 0;
  8808. let isExist = false;
  8809. (Array.isArray(chosenCoupon) ? chosenCoupon : [chosenCoupon]).forEach((i) => {
  8810. const coupon = coupons[+i];
  8811. if (coupon) {
  8812. isExist = true;
  8813. value += getValue(coupon);
  8814. }
  8815. });
  8816. if (isExist) {
  8817. return `-${currency} ${(value / 100).toFixed(2)}`;
  8818. }
  8819. return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
  8820. }
  8821. var stdin_default$_ = vue.defineComponent({
  8822. name: name$R,
  8823. props: couponCellProps,
  8824. setup(props2) {
  8825. return () => {
  8826. const selected = Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.length : props2.coupons[+props2.chosenCoupon];
  8827. return vue.createVNode(Cell, {
  8828. "class": bem$Q(),
  8829. "value": formatValue(props2),
  8830. "title": props2.title || t$a("title"),
  8831. "border": props2.border,
  8832. "isLink": props2.editable,
  8833. "valueClass": bem$Q("value", {
  8834. selected
  8835. })
  8836. }, null);
  8837. };
  8838. }
  8839. });
  8840. const CouponCell = withInstall(stdin_default$_);
  8841. const [name$Q, bem$P] = createNamespace("empty");
  8842. const emptyProps = {
  8843. image: makeStringProp("default"),
  8844. imageSize: [Number, String, Array],
  8845. description: String
  8846. };
  8847. var stdin_default$Z = vue.defineComponent({
  8848. name: name$Q,
  8849. props: emptyProps,
  8850. setup(props2, {
  8851. slots
  8852. }) {
  8853. const renderDescription = () => {
  8854. const description = slots.description ? slots.description() : props2.description;
  8855. if (description) {
  8856. return vue.createVNode("p", {
  8857. "class": bem$P("description")
  8858. }, [description]);
  8859. }
  8860. };
  8861. const renderBottom = () => {
  8862. if (slots.default) {
  8863. return vue.createVNode("div", {
  8864. "class": bem$P("bottom")
  8865. }, [slots.default()]);
  8866. }
  8867. };
  8868. const baseId = useId();
  8869. const getId = (num) => `${baseId}-${num}`;
  8870. const getUrlById = (num) => `url(#${getId(num)})`;
  8871. const renderStop = (color, offset, opacity) => vue.createVNode("stop", {
  8872. "stop-color": color,
  8873. "offset": `${offset}%`,
  8874. "stop-opacity": opacity
  8875. }, null);
  8876. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  8877. const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
  8878. "id": getId(id),
  8879. "cx": "50%",
  8880. "cy": "54%",
  8881. "fx": "50%",
  8882. "fy": "54%",
  8883. "r": "297%",
  8884. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)",
  8885. "data-allow-mismatch": "attribute"
  8886. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
  8887. "fill": getUrlById(id),
  8888. "opacity": ".8",
  8889. "cx": "80",
  8890. "cy": "140",
  8891. "rx": "46",
  8892. "ry": "8",
  8893. "data-allow-mismatch": "attribute"
  8894. }, null)];
  8895. const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8896. "id": getId("a"),
  8897. "x1": "64%",
  8898. "y1": "100%",
  8899. "x2": "64%",
  8900. "data-allow-mismatch": "attribute"
  8901. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8902. "opacity": ".8",
  8903. "data-allow-mismatch": "children"
  8904. }, [vue.createVNode("path", {
  8905. "d": "M36 131V53H16v20H2v58h34z",
  8906. "fill": getUrlById("a")
  8907. }, null), vue.createVNode("path", {
  8908. "d": "M123 15h22v14h9v77h-31V15z",
  8909. "fill": getUrlById("a")
  8910. }, null)])];
  8911. const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  8912. "id": getId("b"),
  8913. "x1": "64%",
  8914. "y1": "97%",
  8915. "x2": "64%",
  8916. "y2": "0%",
  8917. "data-allow-mismatch": "attribute"
  8918. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
  8919. "opacity": ".8",
  8920. "data-allow-mismatch": "children"
  8921. }, [vue.createVNode("path", {
  8922. "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",
  8923. "fill": getUrlById("b")
  8924. }, null), vue.createVNode("path", {
  8925. "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",
  8926. "fill": getUrlById("b")
  8927. }, null)])];
  8928. const renderNetwork = () => vue.createVNode("svg", {
  8929. "viewBox": "0 0 160 160"
  8930. }, [vue.createVNode("defs", {
  8931. "data-allow-mismatch": "children"
  8932. }, [vue.createVNode("linearGradient", {
  8933. "id": getId(1),
  8934. "x1": "64%",
  8935. "y1": "100%",
  8936. "x2": "64%"
  8937. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
  8938. "id": getId(2),
  8939. "x1": "50%",
  8940. "x2": "50%",
  8941. "y2": "84%"
  8942. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
  8943. "id": getId(3),
  8944. "x1": "100%",
  8945. "x2": "100%",
  8946. "y2": "100%"
  8947. }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
  8948. "id": getId(4),
  8949. "cx": "50%",
  8950. "cy": "0%",
  8951. "fx": "50%",
  8952. "fy": "0%",
  8953. "r": "100%",
  8954. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8955. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
  8956. "fill": "none"
  8957. }, [renderBuilding(), vue.createVNode("path", {
  8958. "fill": getUrlById(4),
  8959. "d": "M0 139h160v21H0z",
  8960. "data-allow-mismatch": "attribute"
  8961. }, null), vue.createVNode("path", {
  8962. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8963. "fill": getUrlById(2),
  8964. "data-allow-mismatch": "attribute"
  8965. }, null), vue.createVNode("g", {
  8966. "opacity": ".6",
  8967. "stroke-linecap": "round",
  8968. "stroke-width": "7",
  8969. "data-allow-mismatch": "children"
  8970. }, [vue.createVNode("path", {
  8971. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8972. "stroke": getUrlById(3)
  8973. }, null), vue.createVNode("path", {
  8974. "d": "M53 36a34 34 0 0 0 0 48",
  8975. "stroke": getUrlById(3)
  8976. }, null), vue.createVNode("path", {
  8977. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8978. "stroke": getUrlById(3)
  8979. }, null), vue.createVNode("path", {
  8980. "d": "M106 84a34 34 0 0 0 0-48",
  8981. "stroke": getUrlById(3)
  8982. }, null)]), vue.createVNode("g", {
  8983. "transform": "translate(31 105)"
  8984. }, [vue.createVNode("rect", {
  8985. "fill": "#EBEDF0",
  8986. "width": "98",
  8987. "height": "34",
  8988. "rx": "2"
  8989. }, null), vue.createVNode("rect", {
  8990. "fill": "#FFF",
  8991. "x": "9",
  8992. "y": "8",
  8993. "width": "80",
  8994. "height": "18",
  8995. "rx": "1.1"
  8996. }, null), vue.createVNode("rect", {
  8997. "fill": "#EBEDF0",
  8998. "x": "15",
  8999. "y": "12",
  9000. "width": "18",
  9001. "height": "6",
  9002. "rx": "1.1"
  9003. }, null)])])]);
  9004. const renderMaterial = () => vue.createVNode("svg", {
  9005. "viewBox": "0 0 160 160"
  9006. }, [vue.createVNode("defs", {
  9007. "data-allow-mismatch": "children"
  9008. }, [vue.createVNode("linearGradient", {
  9009. "x1": "50%",
  9010. "x2": "50%",
  9011. "y2": "100%",
  9012. "id": getId(5)
  9013. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  9014. "x1": "95%",
  9015. "y1": "48%",
  9016. "x2": "5.5%",
  9017. "y2": "51%",
  9018. "id": getId(6)
  9019. }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
  9020. "y1": "45%",
  9021. "x2": "100%",
  9022. "y2": "54%",
  9023. "id": getId(7)
  9024. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
  9025. "transform": "translate(36 50)",
  9026. "fill": "none"
  9027. }, [vue.createVNode("g", {
  9028. "transform": "translate(8)"
  9029. }, [vue.createVNode("rect", {
  9030. "fill": "#EBEDF0",
  9031. "opacity": ".6",
  9032. "x": "38",
  9033. "y": "13",
  9034. "width": "36",
  9035. "height": "53",
  9036. "rx": "2"
  9037. }, null), vue.createVNode("rect", {
  9038. "fill": getUrlById(5),
  9039. "width": "64",
  9040. "height": "66",
  9041. "rx": "2",
  9042. "data-allow-mismatch": "attribute"
  9043. }, null), vue.createVNode("rect", {
  9044. "fill": "#FFF",
  9045. "x": "6",
  9046. "y": "6",
  9047. "width": "52",
  9048. "height": "55",
  9049. "rx": "1"
  9050. }, null), vue.createVNode("g", {
  9051. "transform": "translate(15 17)",
  9052. "fill": getUrlById(6),
  9053. "data-allow-mismatch": "attribute"
  9054. }, [vue.createVNode("rect", {
  9055. "width": "34",
  9056. "height": "6",
  9057. "rx": "1"
  9058. }, null), vue.createVNode("path", {
  9059. "d": "M0 14h34v6H0z"
  9060. }, null), vue.createVNode("rect", {
  9061. "y": "28",
  9062. "width": "34",
  9063. "height": "6",
  9064. "rx": "1"
  9065. }, null)])]), vue.createVNode("rect", {
  9066. "fill": getUrlById(7),
  9067. "y": "61",
  9068. "width": "88",
  9069. "height": "28",
  9070. "rx": "1",
  9071. "data-allow-mismatch": "attribute"
  9072. }, null), vue.createVNode("rect", {
  9073. "fill": "#F7F8FA",
  9074. "x": "29",
  9075. "y": "72",
  9076. "width": "30",
  9077. "height": "6",
  9078. "rx": "1"
  9079. }, null)])]);
  9080. const renderError = () => vue.createVNode("svg", {
  9081. "viewBox": "0 0 160 160"
  9082. }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
  9083. "x1": "50%",
  9084. "x2": "50%",
  9085. "y2": "100%",
  9086. "id": getId(8),
  9087. "data-allow-mismatch": "attribute"
  9088. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
  9089. "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",
  9090. "fill": getUrlById(8),
  9091. "data-allow-mismatch": "attribute"
  9092. }, null)]);
  9093. const renderSearch = () => vue.createVNode("svg", {
  9094. "viewBox": "0 0 160 160"
  9095. }, [vue.createVNode("defs", {
  9096. "data-allow-mismatch": "children"
  9097. }, [vue.createVNode("linearGradient", {
  9098. "x1": "50%",
  9099. "y1": "100%",
  9100. "x2": "50%",
  9101. "id": getId(9)
  9102. }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
  9103. "x1": "100%",
  9104. "y1": "50%",
  9105. "y2": "50%",
  9106. "id": getId(10)
  9107. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  9108. "x1": "50%",
  9109. "x2": "50%",
  9110. "y2": "100%",
  9111. "id": getId(11)
  9112. }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
  9113. "x1": "50%",
  9114. "x2": "50%",
  9115. "y2": "100%",
  9116. "id": getId(12)
  9117. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
  9118. "transform": "rotate(-45 113 -4)",
  9119. "fill": "none",
  9120. "data-allow-mismatch": "children"
  9121. }, [vue.createVNode("rect", {
  9122. "fill": getUrlById(9),
  9123. "x": "24",
  9124. "y": "52.8",
  9125. "width": "5.8",
  9126. "height": "19",
  9127. "rx": "1"
  9128. }, null), vue.createVNode("rect", {
  9129. "fill": getUrlById(10),
  9130. "x": "22.1",
  9131. "y": "67.3",
  9132. "width": "9.9",
  9133. "height": "28",
  9134. "rx": "1"
  9135. }, null), vue.createVNode("circle", {
  9136. "stroke": getUrlById(11),
  9137. "stroke-width": "8",
  9138. "cx": "27",
  9139. "cy": "27",
  9140. "r": "27"
  9141. }, null), vue.createVNode("circle", {
  9142. "fill": getUrlById(12),
  9143. "cx": "27",
  9144. "cy": "27",
  9145. "r": "16"
  9146. }, null), vue.createVNode("path", {
  9147. "d": "M37 7c-8 0-15 5-16 12",
  9148. "stroke": getUrlById(11),
  9149. "stroke-width": "3",
  9150. "opacity": ".5",
  9151. "stroke-linecap": "round",
  9152. "transform": "rotate(45 29 13)"
  9153. }, null)])]);
  9154. const renderImage = () => {
  9155. var _a;
  9156. if (slots.image) {
  9157. return slots.image();
  9158. }
  9159. const PRESET_IMAGES = {
  9160. error: renderError,
  9161. search: renderSearch,
  9162. network: renderNetwork,
  9163. default: renderMaterial
  9164. };
  9165. return ((_a = PRESET_IMAGES[props2.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
  9166. "src": props2.image
  9167. }, null);
  9168. };
  9169. return () => vue.createVNode("div", {
  9170. "class": bem$P()
  9171. }, [vue.createVNode("div", {
  9172. "class": bem$P("image"),
  9173. "style": getSizeStyle(props2.imageSize)
  9174. }, [renderImage()]), renderDescription(), renderBottom()]);
  9175. }
  9176. });
  9177. const Empty = withInstall(stdin_default$Z);
  9178. const [name$P, bem$O, t$9] = createNamespace("coupon-list");
  9179. const couponListProps = {
  9180. code: makeStringProp(""),
  9181. coupons: makeArrayProp(),
  9182. currency: makeStringProp("¥"),
  9183. showCount: truthProp,
  9184. emptyImage: String,
  9185. enabledTitle: String,
  9186. disabledTitle: String,
  9187. disabledCoupons: makeArrayProp(),
  9188. showExchangeBar: truthProp,
  9189. showCloseButton: truthProp,
  9190. closeButtonText: String,
  9191. inputPlaceholder: String,
  9192. exchangeMinLength: makeNumberProp(1),
  9193. exchangeButtonText: String,
  9194. displayedCouponIndex: makeNumberProp(-1),
  9195. exchangeButtonLoading: Boolean,
  9196. exchangeButtonDisabled: Boolean,
  9197. chosenCoupon: {
  9198. type: [Number, Array],
  9199. default: -1
  9200. }
  9201. };
  9202. var stdin_default$Y = vue.defineComponent({
  9203. name: name$P,
  9204. props: couponListProps,
  9205. emits: ["change", "exchange", "update:code"],
  9206. setup(props2, {
  9207. emit,
  9208. slots
  9209. }) {
  9210. const [couponRefs, setCouponRefs] = useRefs();
  9211. const root = vue.ref();
  9212. const barRef = vue.ref();
  9213. const activeTab = vue.ref(0);
  9214. const listHeight = vue.ref(0);
  9215. const currentCode = vue.ref(props2.code);
  9216. const buttonDisabled = vue.computed(() => !props2.exchangeButtonLoading && (props2.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props2.exchangeMinLength));
  9217. const updateListHeight = () => {
  9218. const TABS_HEIGHT = 44;
  9219. const rootHeight = use.useRect(root).height;
  9220. const headerHeight = use.useRect(barRef).height + TABS_HEIGHT;
  9221. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  9222. };
  9223. const onExchange = () => {
  9224. emit("exchange", currentCode.value);
  9225. if (!props2.code) {
  9226. currentCode.value = "";
  9227. }
  9228. };
  9229. const scrollToCoupon = (index) => {
  9230. vue.nextTick(() => {
  9231. var _a;
  9232. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  9233. });
  9234. };
  9235. const renderEmpty = () => vue.createVNode(Empty, {
  9236. "image": props2.emptyImage
  9237. }, {
  9238. default: () => [vue.createVNode("p", {
  9239. "class": bem$O("empty-tip")
  9240. }, [t$9("noCoupon")])]
  9241. });
  9242. const renderExchangeBar = () => {
  9243. if (props2.showExchangeBar) {
  9244. return vue.createVNode("div", {
  9245. "ref": barRef,
  9246. "class": bem$O("exchange-bar")
  9247. }, [vue.createVNode(Field, {
  9248. "modelValue": currentCode.value,
  9249. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  9250. "clearable": true,
  9251. "border": false,
  9252. "class": bem$O("field"),
  9253. "placeholder": props2.inputPlaceholder || t$9("placeholder"),
  9254. "maxlength": "20"
  9255. }, null), vue.createVNode(Button, {
  9256. "plain": true,
  9257. "type": "primary",
  9258. "class": bem$O("exchange"),
  9259. "text": props2.exchangeButtonText || t$9("exchange"),
  9260. "loading": props2.exchangeButtonLoading,
  9261. "disabled": buttonDisabled.value,
  9262. "onClick": onExchange
  9263. }, null)]);
  9264. }
  9265. };
  9266. const renderCouponTab = () => {
  9267. const {
  9268. coupons,
  9269. chosenCoupon
  9270. } = props2;
  9271. const count = props2.showCount ? ` (${coupons.length})` : "";
  9272. const title = (props2.enabledTitle || t$9("enable")) + count;
  9273. const updateChosenCoupon = (currentValues = [], value = 0) => {
  9274. if (currentValues.includes(value)) {
  9275. return currentValues.filter((item) => item !== value);
  9276. }
  9277. return [...currentValues, value];
  9278. };
  9279. return vue.createVNode(Tab, {
  9280. "title": title
  9281. }, {
  9282. default: () => {
  9283. var _a;
  9284. return [vue.createVNode("div", {
  9285. "class": bem$O("list", {
  9286. "with-bottom": props2.showCloseButton
  9287. }),
  9288. "style": {
  9289. height: `${listHeight.value}px`
  9290. }
  9291. }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
  9292. "key": coupon.id,
  9293. "ref": setCouponRefs(index),
  9294. "coupon": coupon,
  9295. "chosen": Array.isArray(chosenCoupon) ? chosenCoupon.includes(index) : index === chosenCoupon,
  9296. "currency": props2.currency,
  9297. "onClick": () => emit("change", Array.isArray(chosenCoupon) ? updateChosenCoupon(chosenCoupon, index) : index)
  9298. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  9299. }
  9300. });
  9301. };
  9302. const renderDisabledTab = () => {
  9303. const {
  9304. disabledCoupons
  9305. } = props2;
  9306. const count = props2.showCount ? ` (${disabledCoupons.length})` : "";
  9307. const title = (props2.disabledTitle || t$9("disabled")) + count;
  9308. return vue.createVNode(Tab, {
  9309. "title": title
  9310. }, {
  9311. default: () => {
  9312. var _a;
  9313. return [vue.createVNode("div", {
  9314. "class": bem$O("list", {
  9315. "with-bottom": props2.showCloseButton
  9316. }),
  9317. "style": {
  9318. height: `${listHeight.value}px`
  9319. }
  9320. }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
  9321. "disabled": true,
  9322. "key": coupon.id,
  9323. "coupon": coupon,
  9324. "currency": props2.currency
  9325. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  9326. }
  9327. });
  9328. };
  9329. vue.watch(() => props2.code, (value) => {
  9330. currentCode.value = value;
  9331. });
  9332. vue.watch(windowHeight, updateListHeight);
  9333. vue.watch(currentCode, (value) => emit("update:code", value));
  9334. vue.watch(() => props2.displayedCouponIndex, scrollToCoupon);
  9335. vue.onMounted(() => {
  9336. updateListHeight();
  9337. scrollToCoupon(props2.displayedCouponIndex);
  9338. });
  9339. return () => vue.createVNode("div", {
  9340. "ref": root,
  9341. "class": bem$O()
  9342. }, [renderExchangeBar(), vue.createVNode(Tabs, {
  9343. "active": activeTab.value,
  9344. "onUpdate:active": ($event) => activeTab.value = $event,
  9345. "class": bem$O("tab")
  9346. }, {
  9347. default: () => [renderCouponTab(), renderDisabledTab()]
  9348. }), vue.createVNode("div", {
  9349. "class": bem$O("bottom")
  9350. }, [slots["list-button"] ? slots["list-button"]() : vue.withDirectives(vue.createVNode(Button, {
  9351. "round": true,
  9352. "block": true,
  9353. "type": "primary",
  9354. "class": bem$O("close"),
  9355. "text": props2.closeButtonText || t$9("close"),
  9356. "onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? [] : -1)
  9357. }, null), [[vue.vShow, props2.showCloseButton]])])]);
  9358. }
  9359. });
  9360. const CouponList = withInstall(stdin_default$Y);
  9361. const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
  9362. const [name$O] = createNamespace("date-picker");
  9363. const datePickerProps = extend({}, sharedProps, {
  9364. columnsType: {
  9365. type: Array,
  9366. default: () => ["year", "month", "day"]
  9367. },
  9368. minDate: {
  9369. type: Date,
  9370. default: () => new Date(currentYear - 10, 0, 1),
  9371. validator: isDate
  9372. },
  9373. maxDate: {
  9374. type: Date,
  9375. default: () => new Date(currentYear + 10, 11, 31),
  9376. validator: isDate
  9377. }
  9378. });
  9379. var stdin_default$X = vue.defineComponent({
  9380. name: name$O,
  9381. props: datePickerProps,
  9382. emits: ["confirm", "cancel", "change", "update:modelValue"],
  9383. setup(props2, {
  9384. emit,
  9385. slots
  9386. }) {
  9387. const currentValues = vue.ref(props2.modelValue);
  9388. const updatedByExternalSources = vue.ref(false);
  9389. const pickerRef = vue.ref();
  9390. const computedValues = vue.computed(() => updatedByExternalSources.value ? props2.modelValue : currentValues.value);
  9391. const isMinYear = (year) => year === props2.minDate.getFullYear();
  9392. const isMaxYear = (year) => year === props2.maxDate.getFullYear();
  9393. const isMinMonth = (month) => month === props2.minDate.getMonth() + 1;
  9394. const isMaxMonth = (month) => month === props2.maxDate.getMonth() + 1;
  9395. const getValue2 = (type) => {
  9396. const {
  9397. minDate,
  9398. columnsType
  9399. } = props2;
  9400. const index = columnsType.indexOf(type);
  9401. const value = computedValues.value[index];
  9402. if (value) {
  9403. return +value;
  9404. }
  9405. switch (type) {
  9406. case "year":
  9407. return minDate.getFullYear();
  9408. case "month":
  9409. return minDate.getMonth() + 1;
  9410. case "day":
  9411. return minDate.getDate();
  9412. }
  9413. };
  9414. const genYearOptions = () => {
  9415. const minYear = props2.minDate.getFullYear();
  9416. const maxYear = props2.maxDate.getFullYear();
  9417. return genOptions(minYear, maxYear, "year", props2.formatter, props2.filter, computedValues.value);
  9418. };
  9419. const genMonthOptions = () => {
  9420. const year = getValue2("year");
  9421. const minMonth = isMinYear(year) ? props2.minDate.getMonth() + 1 : 1;
  9422. const maxMonth = isMaxYear(year) ? props2.maxDate.getMonth() + 1 : 12;
  9423. return genOptions(minMonth, maxMonth, "month", props2.formatter, props2.filter, computedValues.value);
  9424. };
  9425. const genDayOptions = () => {
  9426. const year = getValue2("year");
  9427. const month = getValue2("month");
  9428. const minDate = isMinYear(year) && isMinMonth(month) ? props2.minDate.getDate() : 1;
  9429. const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
  9430. return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter, computedValues.value);
  9431. };
  9432. const confirm = () => {
  9433. var _a;
  9434. return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
  9435. };
  9436. const getSelectedDate = () => currentValues.value;
  9437. const columns = vue.computed(() => props2.columnsType.map((type) => {
  9438. switch (type) {
  9439. case "year":
  9440. return genYearOptions();
  9441. case "month":
  9442. return genMonthOptions();
  9443. case "day":
  9444. return genDayOptions();
  9445. default:
  9446. if (process.env.NODE_ENV !== "production") {
  9447. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  9448. }
  9449. return [];
  9450. }
  9451. }));
  9452. vue.watch(currentValues, (newValues) => {
  9453. if (!isSameValue(newValues, props2.modelValue)) {
  9454. emit("update:modelValue", newValues);
  9455. }
  9456. });
  9457. vue.watch(() => props2.modelValue, (newValues, oldValues) => {
  9458. updatedByExternalSources.value = isSameValue(oldValues, currentValues.value);
  9459. newValues = formatValueRange(newValues, columns.value);
  9460. if (!isSameValue(newValues, currentValues.value)) {
  9461. currentValues.value = newValues;
  9462. }
  9463. updatedByExternalSources.value = false;
  9464. }, {
  9465. immediate: true
  9466. });
  9467. const onChange = (...args) => emit("change", ...args);
  9468. const onCancel = (...args) => emit("cancel", ...args);
  9469. const onConfirm = (...args) => emit("confirm", ...args);
  9470. useExpose({
  9471. confirm,
  9472. getSelectedDate
  9473. });
  9474. return () => vue.createVNode(Picker, vue.mergeProps({
  9475. "ref": pickerRef,
  9476. "modelValue": currentValues.value,
  9477. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  9478. "columns": columns.value,
  9479. "onChange": onChange,
  9480. "onCancel": onCancel,
  9481. "onConfirm": onConfirm
  9482. }, pick(props2, pickerInheritKeys)), slots);
  9483. }
  9484. });
  9485. const DatePicker = withInstall(stdin_default$X);
  9486. const [name$N, bem$N, t$8] = createNamespace("dialog");
  9487. const dialogProps = extend({}, popupSharedProps, {
  9488. title: String,
  9489. theme: String,
  9490. width: numericProp,
  9491. message: [String, Function],
  9492. callback: Function,
  9493. allowHtml: Boolean,
  9494. className: unknownProp,
  9495. transition: makeStringProp("van-dialog-bounce"),
  9496. messageAlign: String,
  9497. closeOnPopstate: truthProp,
  9498. showCancelButton: Boolean,
  9499. cancelButtonText: String,
  9500. cancelButtonColor: String,
  9501. cancelButtonDisabled: Boolean,
  9502. confirmButtonText: String,
  9503. confirmButtonColor: String,
  9504. confirmButtonDisabled: Boolean,
  9505. showConfirmButton: truthProp,
  9506. closeOnClickOverlay: Boolean,
  9507. keyboardEnabled: truthProp
  9508. });
  9509. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  9510. var stdin_default$W = vue.defineComponent({
  9511. name: name$N,
  9512. props: dialogProps,
  9513. emits: ["confirm", "cancel", "keydown", "update:show"],
  9514. setup(props2, {
  9515. emit,
  9516. slots
  9517. }) {
  9518. const root = vue.ref();
  9519. const loading = vue.reactive({
  9520. confirm: false,
  9521. cancel: false
  9522. });
  9523. const updateShow = (value) => emit("update:show", value);
  9524. const close = (action) => {
  9525. var _a;
  9526. updateShow(false);
  9527. (_a = props2.callback) == null ? void 0 : _a.call(props2, action);
  9528. };
  9529. const getActionHandler = (action) => () => {
  9530. if (!props2.show) {
  9531. return;
  9532. }
  9533. emit(action);
  9534. if (props2.beforeClose) {
  9535. loading[action] = true;
  9536. callInterceptor(props2.beforeClose, {
  9537. args: [action],
  9538. done() {
  9539. close(action);
  9540. loading[action] = false;
  9541. },
  9542. canceled() {
  9543. loading[action] = false;
  9544. }
  9545. });
  9546. } else {
  9547. close(action);
  9548. }
  9549. };
  9550. const onCancel = getActionHandler("cancel");
  9551. const onConfirm = getActionHandler("confirm");
  9552. const onKeydown = vue.withKeys((event) => {
  9553. var _a, _b;
  9554. if (!props2.keyboardEnabled) {
  9555. return;
  9556. }
  9557. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  9558. return;
  9559. }
  9560. const onEventType = {
  9561. Enter: props2.showConfirmButton ? onConfirm : noop,
  9562. Escape: props2.showCancelButton ? onCancel : noop
  9563. };
  9564. onEventType[event.key]();
  9565. emit("keydown", event);
  9566. }, ["enter", "esc"]);
  9567. const renderTitle = () => {
  9568. const title = slots.title ? slots.title() : props2.title;
  9569. if (title) {
  9570. return vue.createVNode("div", {
  9571. "class": bem$N("header", {
  9572. isolated: !props2.message && !slots.default
  9573. })
  9574. }, [title]);
  9575. }
  9576. };
  9577. const renderMessage = (hasTitle) => {
  9578. const {
  9579. message,
  9580. allowHtml,
  9581. messageAlign
  9582. } = props2;
  9583. const classNames = bem$N("message", {
  9584. "has-title": hasTitle,
  9585. [messageAlign]: messageAlign
  9586. });
  9587. const content = isFunction(message) ? message() : message;
  9588. if (allowHtml && typeof content === "string") {
  9589. return vue.createVNode("div", {
  9590. "class": classNames,
  9591. "innerHTML": content
  9592. }, null);
  9593. }
  9594. return vue.createVNode("div", {
  9595. "class": classNames
  9596. }, [content]);
  9597. };
  9598. const renderContent = () => {
  9599. if (slots.default) {
  9600. return vue.createVNode("div", {
  9601. "class": bem$N("content")
  9602. }, [slots.default()]);
  9603. }
  9604. const {
  9605. title,
  9606. message,
  9607. allowHtml
  9608. } = props2;
  9609. if (message) {
  9610. const hasTitle = !!(title || slots.title);
  9611. return vue.createVNode("div", {
  9612. "key": allowHtml ? 1 : 0,
  9613. "class": bem$N("content", {
  9614. isolated: !hasTitle
  9615. })
  9616. }, [renderMessage(hasTitle)]);
  9617. }
  9618. };
  9619. const renderButtons = () => vue.createVNode("div", {
  9620. "class": [BORDER_TOP, bem$N("footer")]
  9621. }, [props2.showCancelButton && vue.createVNode(Button, {
  9622. "size": "large",
  9623. "text": props2.cancelButtonText || t$8("cancel"),
  9624. "class": bem$N("cancel"),
  9625. "style": {
  9626. color: props2.cancelButtonColor
  9627. },
  9628. "loading": loading.cancel,
  9629. "disabled": props2.cancelButtonDisabled,
  9630. "onClick": onCancel
  9631. }, null), props2.showConfirmButton && vue.createVNode(Button, {
  9632. "size": "large",
  9633. "text": props2.confirmButtonText || t$8("confirm"),
  9634. "class": [bem$N("confirm"), {
  9635. [BORDER_LEFT]: props2.showCancelButton
  9636. }],
  9637. "style": {
  9638. color: props2.confirmButtonColor
  9639. },
  9640. "loading": loading.confirm,
  9641. "disabled": props2.confirmButtonDisabled,
  9642. "onClick": onConfirm
  9643. }, null)]);
  9644. const renderRoundButtons = () => vue.createVNode(ActionBar, {
  9645. "class": bem$N("footer")
  9646. }, {
  9647. default: () => [props2.showCancelButton && vue.createVNode(ActionBarButton, {
  9648. "type": "warning",
  9649. "text": props2.cancelButtonText || t$8("cancel"),
  9650. "class": bem$N("cancel"),
  9651. "color": props2.cancelButtonColor,
  9652. "loading": loading.cancel,
  9653. "disabled": props2.cancelButtonDisabled,
  9654. "onClick": onCancel
  9655. }, null), props2.showConfirmButton && vue.createVNode(ActionBarButton, {
  9656. "type": "danger",
  9657. "text": props2.confirmButtonText || t$8("confirm"),
  9658. "class": bem$N("confirm"),
  9659. "color": props2.confirmButtonColor,
  9660. "loading": loading.confirm,
  9661. "disabled": props2.confirmButtonDisabled,
  9662. "onClick": onConfirm
  9663. }, null)]
  9664. });
  9665. const renderFooter = () => {
  9666. if (slots.footer) {
  9667. return slots.footer();
  9668. }
  9669. return props2.theme === "round-button" ? renderRoundButtons() : renderButtons();
  9670. };
  9671. return () => {
  9672. const {
  9673. width,
  9674. title,
  9675. theme,
  9676. message,
  9677. className
  9678. } = props2;
  9679. return vue.createVNode(Popup, vue.mergeProps({
  9680. "ref": root,
  9681. "role": "dialog",
  9682. "class": [bem$N([theme]), className],
  9683. "style": {
  9684. width: addUnit(width)
  9685. },
  9686. "tabindex": 0,
  9687. "aria-labelledby": title || message,
  9688. "onKeydown": onKeydown,
  9689. "onUpdate:show": updateShow
  9690. }, pick(props2, popupInheritKeys$1)), {
  9691. default: () => [renderTitle(), renderContent(), renderFooter()]
  9692. });
  9693. };
  9694. }
  9695. });
  9696. let instance$2;
  9697. const DEFAULT_OPTIONS = {
  9698. title: "",
  9699. width: "",
  9700. theme: null,
  9701. message: "",
  9702. overlay: true,
  9703. callback: null,
  9704. teleport: "body",
  9705. className: "",
  9706. allowHtml: false,
  9707. lockScroll: true,
  9708. transition: void 0,
  9709. beforeClose: null,
  9710. overlayClass: "",
  9711. overlayStyle: void 0,
  9712. messageAlign: "",
  9713. cancelButtonText: "",
  9714. cancelButtonColor: null,
  9715. cancelButtonDisabled: false,
  9716. confirmButtonText: "",
  9717. confirmButtonColor: null,
  9718. confirmButtonDisabled: false,
  9719. showConfirmButton: true,
  9720. showCancelButton: false,
  9721. closeOnPopstate: true,
  9722. closeOnClickOverlay: false
  9723. };
  9724. let currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  9725. function initInstance$2() {
  9726. const Wrapper = {
  9727. setup() {
  9728. const {
  9729. state,
  9730. toggle
  9731. } = usePopupState();
  9732. return () => vue.createVNode(stdin_default$W, vue.mergeProps(state, {
  9733. "onUpdate:show": toggle
  9734. }), null);
  9735. }
  9736. };
  9737. ({
  9738. instance: instance$2
  9739. } = mountComponent(Wrapper));
  9740. }
  9741. function showDialog(options) {
  9742. if (!inBrowser) {
  9743. return Promise.resolve(void 0);
  9744. }
  9745. return new Promise((resolve, reject) => {
  9746. if (!instance$2) {
  9747. initInstance$2();
  9748. }
  9749. instance$2.open(extend({}, currentOptions$1, options, {
  9750. callback: (action) => {
  9751. (action === "confirm" ? resolve : reject)(action);
  9752. }
  9753. }));
  9754. });
  9755. }
  9756. const setDialogDefaultOptions = (options) => {
  9757. extend(currentOptions$1, options);
  9758. };
  9759. const resetDialogDefaultOptions = () => {
  9760. currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  9761. };
  9762. const showConfirmDialog = (options) => showDialog(extend({
  9763. showCancelButton: true
  9764. }, options));
  9765. const closeDialog = () => {
  9766. if (instance$2) {
  9767. instance$2.toggle(false);
  9768. }
  9769. };
  9770. const Dialog = withInstall(stdin_default$W);
  9771. const [name$M, bem$M] = createNamespace("divider");
  9772. const dividerProps = {
  9773. dashed: Boolean,
  9774. hairline: truthProp,
  9775. vertical: Boolean,
  9776. contentPosition: makeStringProp("center")
  9777. };
  9778. var stdin_default$V = vue.defineComponent({
  9779. name: name$M,
  9780. props: dividerProps,
  9781. setup(props2, {
  9782. slots
  9783. }) {
  9784. return () => {
  9785. var _a;
  9786. return vue.createVNode("div", {
  9787. "role": "separator",
  9788. "class": bem$M({
  9789. dashed: props2.dashed,
  9790. hairline: props2.hairline,
  9791. vertical: props2.vertical,
  9792. [`content-${props2.contentPosition}`]: !!slots.default && !props2.vertical
  9793. })
  9794. }, [!props2.vertical && ((_a = slots.default) == null ? void 0 : _a.call(slots))]);
  9795. };
  9796. }
  9797. });
  9798. const Divider = withInstall(stdin_default$V);
  9799. const [name$L, bem$L] = createNamespace("dropdown-menu");
  9800. const dropdownMenuProps = {
  9801. overlay: truthProp,
  9802. zIndex: numericProp,
  9803. duration: makeNumericProp(0.2),
  9804. direction: makeStringProp("down"),
  9805. activeColor: String,
  9806. autoLocate: Boolean,
  9807. closeOnClickOutside: truthProp,
  9808. closeOnClickOverlay: truthProp,
  9809. swipeThreshold: numericProp
  9810. };
  9811. const DROPDOWN_KEY = Symbol(name$L);
  9812. var stdin_default$U = vue.defineComponent({
  9813. name: name$L,
  9814. props: dropdownMenuProps,
  9815. setup(props2, {
  9816. slots
  9817. }) {
  9818. const id = useId();
  9819. const root = vue.ref();
  9820. const barRef = vue.ref();
  9821. const offset = vue.ref(0);
  9822. const {
  9823. children,
  9824. linkChildren
  9825. } = use.useChildren(DROPDOWN_KEY);
  9826. const scrollParent = use.useScrollParent(root);
  9827. const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
  9828. const scrollable = vue.computed(() => props2.swipeThreshold && children.length > +props2.swipeThreshold);
  9829. const barStyle = vue.computed(() => {
  9830. if (opened.value && isDef(props2.zIndex)) {
  9831. return {
  9832. zIndex: +props2.zIndex + 1
  9833. };
  9834. }
  9835. });
  9836. const close = () => {
  9837. children.forEach((item) => {
  9838. item.toggle(false);
  9839. });
  9840. };
  9841. const onClickAway = () => {
  9842. if (props2.closeOnClickOutside) {
  9843. close();
  9844. }
  9845. };
  9846. const updateOffset = () => {
  9847. if (barRef.value) {
  9848. const rect = use.useRect(barRef);
  9849. if (props2.direction === "down") {
  9850. offset.value = rect.bottom;
  9851. } else {
  9852. offset.value = windowHeight.value - rect.top;
  9853. }
  9854. }
  9855. };
  9856. const onScroll = () => {
  9857. if (opened.value) {
  9858. updateOffset();
  9859. }
  9860. };
  9861. const toggleItem = (active) => {
  9862. children.forEach((item, index) => {
  9863. if (index === active) {
  9864. item.toggle();
  9865. } else if (item.state.showPopup) {
  9866. item.toggle(false, {
  9867. immediate: true
  9868. });
  9869. }
  9870. });
  9871. };
  9872. const renderTitle = (item, index) => {
  9873. const {
  9874. showPopup
  9875. } = item.state;
  9876. const {
  9877. disabled,
  9878. titleClass
  9879. } = item;
  9880. return vue.createVNode("div", {
  9881. "id": `${id}-${index}`,
  9882. "role": "button",
  9883. "tabindex": disabled ? void 0 : 0,
  9884. "data-allow-mismatch": "attribute",
  9885. "class": [bem$L("item", {
  9886. disabled,
  9887. grow: scrollable.value
  9888. }), {
  9889. [HAPTICS_FEEDBACK]: !disabled
  9890. }],
  9891. "onClick": () => {
  9892. if (!disabled) {
  9893. toggleItem(index);
  9894. }
  9895. }
  9896. }, [vue.createVNode("span", {
  9897. "class": [bem$L("title", {
  9898. down: showPopup === (props2.direction === "down"),
  9899. active: showPopup
  9900. }), titleClass],
  9901. "style": {
  9902. color: showPopup ? props2.activeColor : ""
  9903. }
  9904. }, [vue.createVNode("div", {
  9905. "class": "van-ellipsis"
  9906. }, [item.renderTitle()])])]);
  9907. };
  9908. useExpose({
  9909. close
  9910. });
  9911. linkChildren({
  9912. id,
  9913. props: props2,
  9914. offset,
  9915. updateOffset
  9916. });
  9917. use.useClickAway(root, onClickAway);
  9918. use.useEventListener("scroll", onScroll, {
  9919. target: scrollParent,
  9920. passive: true
  9921. });
  9922. return () => {
  9923. var _a;
  9924. return vue.createVNode("div", {
  9925. "ref": root,
  9926. "class": bem$L()
  9927. }, [vue.createVNode("div", {
  9928. "ref": barRef,
  9929. "style": barStyle.value,
  9930. "class": bem$L("bar", {
  9931. opened: opened.value,
  9932. scrollable: scrollable.value
  9933. })
  9934. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9935. };
  9936. }
  9937. });
  9938. const [name$K, bem$K] = createNamespace("dropdown-item");
  9939. const dropdownItemProps = {
  9940. title: String,
  9941. options: makeArrayProp(),
  9942. disabled: Boolean,
  9943. teleport: [String, Object],
  9944. lazyRender: truthProp,
  9945. modelValue: unknownProp,
  9946. titleClass: unknownProp
  9947. };
  9948. var stdin_default$T = vue.defineComponent({
  9949. name: name$K,
  9950. inheritAttrs: false,
  9951. props: dropdownItemProps,
  9952. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9953. setup(props2, {
  9954. emit,
  9955. slots,
  9956. attrs
  9957. }) {
  9958. const state = vue.reactive({
  9959. showPopup: false,
  9960. transition: true,
  9961. showWrapper: false
  9962. });
  9963. const wrapperRef = vue.ref();
  9964. const {
  9965. parent,
  9966. index
  9967. } = use.useParent(DROPDOWN_KEY);
  9968. if (!parent) {
  9969. if (process.env.NODE_ENV !== "production") {
  9970. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9971. }
  9972. return;
  9973. }
  9974. const getEmitter = (name2) => () => emit(name2);
  9975. const onOpen = getEmitter("open");
  9976. const onClose = getEmitter("close");
  9977. const onOpened = getEmitter("opened");
  9978. const onClosed = () => {
  9979. state.showWrapper = false;
  9980. emit("closed");
  9981. };
  9982. const onClickWrapper = (event) => {
  9983. if (props2.teleport) {
  9984. event.stopPropagation();
  9985. }
  9986. };
  9987. const toggle = (show = !state.showPopup, options = {}) => {
  9988. if (show === state.showPopup) {
  9989. return;
  9990. }
  9991. state.showPopup = show;
  9992. state.transition = !options.immediate;
  9993. if (show) {
  9994. parent.updateOffset();
  9995. state.showWrapper = true;
  9996. }
  9997. };
  9998. const renderTitle = () => {
  9999. if (slots.title) {
  10000. return slots.title();
  10001. }
  10002. if (props2.title) {
  10003. return props2.title;
  10004. }
  10005. const match = props2.options.find((option) => option.value === props2.modelValue);
  10006. return match ? match.text : "";
  10007. };
  10008. const renderOption = (option) => {
  10009. const {
  10010. activeColor
  10011. } = parent.props;
  10012. const {
  10013. disabled
  10014. } = option;
  10015. const active = option.value === props2.modelValue;
  10016. const onClick = () => {
  10017. if (disabled) {
  10018. return;
  10019. }
  10020. state.showPopup = false;
  10021. if (option.value !== props2.modelValue) {
  10022. emit("update:modelValue", option.value);
  10023. emit("change", option.value);
  10024. }
  10025. };
  10026. const renderIcon = () => {
  10027. if (active) {
  10028. return vue.createVNode(Icon, {
  10029. "class": bem$K("icon"),
  10030. "color": disabled ? void 0 : activeColor,
  10031. "name": "success"
  10032. }, null);
  10033. }
  10034. };
  10035. return vue.createVNode(Cell, {
  10036. "role": "menuitem",
  10037. "key": String(option.value),
  10038. "icon": option.icon,
  10039. "title": option.text,
  10040. "class": bem$K("option", {
  10041. active,
  10042. disabled
  10043. }),
  10044. "style": {
  10045. color: active ? activeColor : ""
  10046. },
  10047. "tabindex": active ? 0 : -1,
  10048. "clickable": !disabled,
  10049. "onClick": onClick
  10050. }, {
  10051. value: renderIcon
  10052. });
  10053. };
  10054. const renderContent = () => {
  10055. const {
  10056. offset
  10057. } = parent;
  10058. const {
  10059. autoLocate,
  10060. zIndex,
  10061. overlay,
  10062. duration,
  10063. direction,
  10064. closeOnClickOverlay
  10065. } = parent.props;
  10066. const style = getZIndexStyle(zIndex);
  10067. let offsetValue = offset.value;
  10068. if (autoLocate && wrapperRef.value) {
  10069. const offsetParent = getContainingBlock(wrapperRef.value);
  10070. if (offsetParent) {
  10071. offsetValue -= use.useRect(offsetParent).top;
  10072. }
  10073. }
  10074. if (direction === "down") {
  10075. style.top = `${offsetValue}px`;
  10076. } else {
  10077. style.bottom = `${offsetValue}px`;
  10078. }
  10079. return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  10080. "ref": wrapperRef,
  10081. "style": style,
  10082. "class": bem$K([direction]),
  10083. "onClick": onClickWrapper
  10084. }, attrs), [vue.createVNode(Popup, {
  10085. "show": state.showPopup,
  10086. "onUpdate:show": ($event) => state.showPopup = $event,
  10087. "role": "menu",
  10088. "class": bem$K("content"),
  10089. "overlay": overlay,
  10090. "position": direction === "down" ? "top" : "bottom",
  10091. "duration": state.transition ? duration : 0,
  10092. "lazyRender": props2.lazyRender,
  10093. "overlayStyle": {
  10094. position: "absolute"
  10095. },
  10096. "aria-labelledby": `${parent.id}-${index.value}`,
  10097. "data-allow-mismatch": "attribute",
  10098. "closeOnClickOverlay": closeOnClickOverlay,
  10099. "onOpen": onOpen,
  10100. "onClose": onClose,
  10101. "onOpened": onOpened,
  10102. "onClosed": onClosed
  10103. }, {
  10104. default: () => {
  10105. var _a;
  10106. return [props2.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  10107. }
  10108. })]), [[vue.vShow, state.showWrapper]]);
  10109. };
  10110. useExpose({
  10111. state,
  10112. toggle,
  10113. renderTitle
  10114. });
  10115. return () => {
  10116. if (props2.teleport) {
  10117. return vue.createVNode(vue.Teleport, {
  10118. "to": props2.teleport
  10119. }, {
  10120. default: () => [renderContent()]
  10121. });
  10122. }
  10123. return renderContent();
  10124. };
  10125. }
  10126. });
  10127. const DropdownItem = withInstall(stdin_default$T);
  10128. const DropdownMenu = withInstall(stdin_default$U);
  10129. const floatingBubbleProps = {
  10130. gap: makeNumberProp(24),
  10131. icon: String,
  10132. axis: makeStringProp("y"),
  10133. magnetic: String,
  10134. offset: {
  10135. type: Object,
  10136. default: () => ({
  10137. x: -1,
  10138. y: -1
  10139. })
  10140. },
  10141. teleport: {
  10142. type: [String, Object],
  10143. default: "body"
  10144. }
  10145. };
  10146. const [name$J, bem$J] = createNamespace("floating-bubble");
  10147. var stdin_default$S = vue.defineComponent({
  10148. name: name$J,
  10149. inheritAttrs: false,
  10150. props: floatingBubbleProps,
  10151. emits: ["click", "update:offset", "offsetChange"],
  10152. setup(props2, {
  10153. slots,
  10154. emit,
  10155. attrs
  10156. }) {
  10157. const rootRef = vue.ref();
  10158. const state = vue.ref({
  10159. x: 0,
  10160. y: 0,
  10161. width: 0,
  10162. height: 0
  10163. });
  10164. const boundary = vue.computed(() => ({
  10165. top: props2.gap,
  10166. right: windowWidth.value - state.value.width - props2.gap,
  10167. bottom: windowHeight.value - state.value.height - props2.gap,
  10168. left: props2.gap
  10169. }));
  10170. const dragging = vue.ref(false);
  10171. let initialized = false;
  10172. const rootStyle = vue.computed(() => {
  10173. const style = {};
  10174. const x = addUnit(state.value.x);
  10175. const y = addUnit(state.value.y);
  10176. style.transform = `translate3d(${x}, ${y}, 0)`;
  10177. if (dragging.value || !initialized) {
  10178. style.transition = "none";
  10179. }
  10180. return style;
  10181. });
  10182. const updateState = () => {
  10183. if (!show.value) return;
  10184. const {
  10185. width,
  10186. height
  10187. } = use.useRect(rootRef.value);
  10188. const {
  10189. offset
  10190. } = props2;
  10191. state.value = {
  10192. x: offset.x > -1 ? offset.x : windowWidth.value - width - props2.gap,
  10193. y: offset.y > -1 ? offset.y : windowHeight.value - height - props2.gap,
  10194. width,
  10195. height
  10196. };
  10197. };
  10198. const touch = useTouch();
  10199. let prevX = 0;
  10200. let prevY = 0;
  10201. const onTouchStart = (e) => {
  10202. touch.start(e);
  10203. dragging.value = true;
  10204. prevX = state.value.x;
  10205. prevY = state.value.y;
  10206. };
  10207. const onTouchMove = (e) => {
  10208. e.preventDefault();
  10209. touch.move(e);
  10210. if (props2.axis === "lock") return;
  10211. if (!touch.isTap.value) {
  10212. if (props2.axis === "x" || props2.axis === "xy") {
  10213. let nextX = prevX + touch.deltaX.value;
  10214. if (nextX < boundary.value.left) nextX = boundary.value.left;
  10215. if (nextX > boundary.value.right) nextX = boundary.value.right;
  10216. state.value.x = nextX;
  10217. }
  10218. if (props2.axis === "y" || props2.axis === "xy") {
  10219. let nextY = prevY + touch.deltaY.value;
  10220. if (nextY < boundary.value.top) nextY = boundary.value.top;
  10221. if (nextY > boundary.value.bottom) nextY = boundary.value.bottom;
  10222. state.value.y = nextY;
  10223. }
  10224. const offset = pick(state.value, ["x", "y"]);
  10225. emit("update:offset", offset);
  10226. }
  10227. };
  10228. use.useEventListener("touchmove", onTouchMove, {
  10229. target: rootRef
  10230. });
  10231. const onTouchEnd = () => {
  10232. dragging.value = false;
  10233. vue.nextTick(() => {
  10234. if (props2.magnetic === "x") {
  10235. const nextX = closest([boundary.value.left, boundary.value.right], state.value.x);
  10236. state.value.x = nextX;
  10237. }
  10238. if (props2.magnetic === "y") {
  10239. const nextY = closest([boundary.value.top, boundary.value.bottom], state.value.y);
  10240. state.value.y = nextY;
  10241. }
  10242. if (!touch.isTap.value) {
  10243. const offset = pick(state.value, ["x", "y"]);
  10244. emit("update:offset", offset);
  10245. if (prevX !== offset.x || prevY !== offset.y) {
  10246. emit("offsetChange", offset);
  10247. }
  10248. }
  10249. });
  10250. };
  10251. const onClick = (e) => {
  10252. if (touch.isTap.value) emit("click", e);
  10253. else e.stopPropagation();
  10254. };
  10255. vue.onMounted(() => {
  10256. updateState();
  10257. vue.nextTick(() => {
  10258. initialized = true;
  10259. });
  10260. });
  10261. vue.watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState, {
  10262. deep: true
  10263. });
  10264. const show = vue.ref(true);
  10265. vue.onActivated(() => {
  10266. show.value = true;
  10267. });
  10268. vue.onDeactivated(() => {
  10269. if (props2.teleport) {
  10270. show.value = false;
  10271. }
  10272. });
  10273. return () => {
  10274. const Content = vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  10275. "class": bem$J(),
  10276. "ref": rootRef,
  10277. "onTouchstartPassive": onTouchStart,
  10278. "onTouchend": onTouchEnd,
  10279. "onTouchcancel": onTouchEnd,
  10280. "onClickCapture": onClick,
  10281. "style": rootStyle.value
  10282. }, attrs), [slots.default ? slots.default() : vue.createVNode(stdin_default$1Q, {
  10283. "name": props2.icon,
  10284. "class": bem$J("icon")
  10285. }, null)]), [[vue.vShow, show.value]]);
  10286. return props2.teleport ? vue.createVNode(vue.Teleport, {
  10287. "to": props2.teleport
  10288. }, {
  10289. default: () => [Content]
  10290. }) : Content;
  10291. };
  10292. }
  10293. });
  10294. const FloatingBubble = withInstall(stdin_default$S);
  10295. const floatingPanelProps = {
  10296. height: makeNumericProp(0),
  10297. anchors: makeArrayProp(),
  10298. duration: makeNumericProp(0.3),
  10299. contentDraggable: truthProp,
  10300. lockScroll: Boolean,
  10301. safeAreaInsetBottom: truthProp
  10302. };
  10303. const [name$I, bem$I] = createNamespace("floating-panel");
  10304. var stdin_default$R = vue.defineComponent({
  10305. name: name$I,
  10306. props: floatingPanelProps,
  10307. emits: ["heightChange", "update:height"],
  10308. setup(props2, {
  10309. emit,
  10310. slots
  10311. }) {
  10312. const DAMP = 0.2;
  10313. const rootRef = vue.ref();
  10314. const contentRef = vue.ref();
  10315. const height = useSyncPropRef(() => +props2.height, (value) => emit("update:height", value));
  10316. const boundary = vue.computed(() => {
  10317. var _a, _b;
  10318. return {
  10319. min: (_a = props2.anchors[0]) != null ? _a : 100,
  10320. max: (_b = props2.anchors[props2.anchors.length - 1]) != null ? _b : Math.round(windowHeight.value * 0.6)
  10321. };
  10322. });
  10323. const anchors = vue.computed(() => props2.anchors.length >= 2 ? props2.anchors : [boundary.value.min, boundary.value.max]);
  10324. const dragging = vue.ref(false);
  10325. const rootStyle = vue.computed(() => ({
  10326. height: addUnit(boundary.value.max),
  10327. transform: `translateY(calc(100% + ${addUnit(-height.value)}))`,
  10328. transition: !dragging.value ? `transform ${props2.duration}s cubic-bezier(0.18, 0.89, 0.32, 1.28)` : "none"
  10329. }));
  10330. const ease = (moveY) => {
  10331. const absDistance = Math.abs(moveY);
  10332. const {
  10333. min,
  10334. max
  10335. } = boundary.value;
  10336. if (absDistance > max) {
  10337. return -(max + (absDistance - max) * DAMP);
  10338. }
  10339. if (absDistance < min) {
  10340. return -(min - (min - absDistance) * DAMP);
  10341. }
  10342. return moveY;
  10343. };
  10344. let startY;
  10345. let maxScroll = -1;
  10346. const touch = useTouch();
  10347. const onTouchstart = (e) => {
  10348. touch.start(e);
  10349. dragging.value = true;
  10350. startY = -height.value;
  10351. maxScroll = -1;
  10352. };
  10353. const onTouchmove = (e) => {
  10354. var _a;
  10355. touch.move(e);
  10356. const target = e.target;
  10357. if (contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target))) {
  10358. const {
  10359. scrollTop
  10360. } = contentRef.value;
  10361. maxScroll = Math.max(maxScroll, scrollTop);
  10362. if (!props2.contentDraggable) return;
  10363. if (-startY < boundary.value.max) {
  10364. preventDefault(e, true);
  10365. } else if (!(scrollTop <= 0 && touch.deltaY.value > 0) || maxScroll > 0) {
  10366. return;
  10367. }
  10368. }
  10369. const moveY = touch.deltaY.value + startY;
  10370. height.value = -ease(moveY);
  10371. };
  10372. const onTouchend = () => {
  10373. maxScroll = -1;
  10374. dragging.value = false;
  10375. height.value = closest(anchors.value, height.value);
  10376. if (height.value !== -startY) {
  10377. emit("heightChange", {
  10378. height: height.value
  10379. });
  10380. }
  10381. };
  10382. vue.watch(boundary, () => {
  10383. height.value = closest(anchors.value, height.value);
  10384. }, {
  10385. immediate: true
  10386. });
  10387. useLockScroll(rootRef, () => props2.lockScroll || dragging.value);
  10388. use.useEventListener("touchmove", onTouchmove, {
  10389. target: rootRef
  10390. });
  10391. const renderHeader = () => {
  10392. if (slots.header) {
  10393. return slots.header();
  10394. }
  10395. return vue.createVNode("div", {
  10396. "class": bem$I("header")
  10397. }, [vue.createVNode("div", {
  10398. "class": bem$I("header-bar")
  10399. }, null)]);
  10400. };
  10401. return () => {
  10402. var _a;
  10403. return vue.createVNode("div", {
  10404. "class": [bem$I(), {
  10405. "van-safe-area-bottom": props2.safeAreaInsetBottom
  10406. }],
  10407. "ref": rootRef,
  10408. "style": rootStyle.value,
  10409. "onTouchstartPassive": onTouchstart,
  10410. "onTouchend": onTouchend,
  10411. "onTouchcancel": onTouchend
  10412. }, [renderHeader(), vue.createVNode("div", {
  10413. "class": bem$I("content"),
  10414. "ref": contentRef
  10415. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  10416. };
  10417. }
  10418. });
  10419. const FloatingPanel = withInstall(stdin_default$R);
  10420. const [name$H, bem$H] = createNamespace("grid");
  10421. const gridProps = {
  10422. square: Boolean,
  10423. center: truthProp,
  10424. border: truthProp,
  10425. gutter: numericProp,
  10426. reverse: Boolean,
  10427. iconSize: numericProp,
  10428. direction: String,
  10429. clickable: Boolean,
  10430. columnNum: makeNumericProp(4)
  10431. };
  10432. const GRID_KEY = Symbol(name$H);
  10433. var stdin_default$Q = vue.defineComponent({
  10434. name: name$H,
  10435. props: gridProps,
  10436. setup(props2, {
  10437. slots
  10438. }) {
  10439. const {
  10440. linkChildren
  10441. } = use.useChildren(GRID_KEY);
  10442. linkChildren({
  10443. props: props2
  10444. });
  10445. return () => {
  10446. var _a;
  10447. return vue.createVNode("div", {
  10448. "style": {
  10449. paddingLeft: addUnit(props2.gutter)
  10450. },
  10451. "class": [bem$H(), {
  10452. [BORDER_TOP]: props2.border && !props2.gutter
  10453. }]
  10454. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10455. };
  10456. }
  10457. });
  10458. const Grid = withInstall(stdin_default$Q);
  10459. const [name$G, bem$G] = createNamespace("grid-item");
  10460. const gridItemProps = extend({}, routeProps, {
  10461. dot: Boolean,
  10462. text: String,
  10463. icon: String,
  10464. badge: numericProp,
  10465. iconColor: String,
  10466. iconPrefix: String,
  10467. badgeProps: Object
  10468. });
  10469. var stdin_default$P = vue.defineComponent({
  10470. name: name$G,
  10471. props: gridItemProps,
  10472. setup(props2, {
  10473. slots
  10474. }) {
  10475. const {
  10476. parent,
  10477. index
  10478. } = use.useParent(GRID_KEY);
  10479. const route2 = useRoute();
  10480. if (!parent) {
  10481. if (process.env.NODE_ENV !== "production") {
  10482. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  10483. }
  10484. return;
  10485. }
  10486. const rootStyle = vue.computed(() => {
  10487. const {
  10488. square,
  10489. gutter,
  10490. columnNum
  10491. } = parent.props;
  10492. const percent = `${100 / +columnNum}%`;
  10493. const style = {
  10494. flexBasis: percent
  10495. };
  10496. if (square) {
  10497. style.paddingTop = percent;
  10498. } else if (gutter) {
  10499. const gutterValue = addUnit(gutter);
  10500. style.paddingRight = gutterValue;
  10501. if (index.value >= +columnNum) {
  10502. style.marginTop = gutterValue;
  10503. }
  10504. }
  10505. return style;
  10506. });
  10507. const contentStyle = vue.computed(() => {
  10508. const {
  10509. square,
  10510. gutter
  10511. } = parent.props;
  10512. if (square && gutter) {
  10513. const gutterValue = addUnit(gutter);
  10514. return {
  10515. right: gutterValue,
  10516. bottom: gutterValue,
  10517. height: "auto"
  10518. };
  10519. }
  10520. });
  10521. const renderIcon = () => {
  10522. if (slots.icon) {
  10523. return vue.createVNode(Badge, vue.mergeProps({
  10524. "dot": props2.dot,
  10525. "content": props2.badge
  10526. }, props2.badgeProps), {
  10527. default: slots.icon
  10528. });
  10529. }
  10530. if (props2.icon) {
  10531. return vue.createVNode(Icon, {
  10532. "dot": props2.dot,
  10533. "name": props2.icon,
  10534. "size": parent.props.iconSize,
  10535. "badge": props2.badge,
  10536. "class": bem$G("icon"),
  10537. "color": props2.iconColor,
  10538. "badgeProps": props2.badgeProps,
  10539. "classPrefix": props2.iconPrefix
  10540. }, null);
  10541. }
  10542. };
  10543. const renderText = () => {
  10544. if (slots.text) {
  10545. return slots.text();
  10546. }
  10547. if (props2.text) {
  10548. return vue.createVNode("span", {
  10549. "class": bem$G("text")
  10550. }, [props2.text]);
  10551. }
  10552. };
  10553. const renderContent = () => {
  10554. if (slots.default) {
  10555. return slots.default();
  10556. }
  10557. return [renderIcon(), renderText()];
  10558. };
  10559. return () => {
  10560. const {
  10561. center,
  10562. border,
  10563. square,
  10564. gutter,
  10565. reverse,
  10566. direction,
  10567. clickable
  10568. } = parent.props;
  10569. const classes = [bem$G("content", [direction, {
  10570. center,
  10571. square,
  10572. reverse,
  10573. clickable,
  10574. surround: border && gutter
  10575. }]), {
  10576. [BORDER]: border
  10577. }];
  10578. return vue.createVNode("div", {
  10579. "class": [bem$G({
  10580. square
  10581. })],
  10582. "style": rootStyle.value
  10583. }, [vue.createVNode("div", {
  10584. "role": clickable ? "button" : void 0,
  10585. "class": classes,
  10586. "style": contentStyle.value,
  10587. "tabindex": clickable ? 0 : void 0,
  10588. "onClick": route2
  10589. }, [renderContent()])]);
  10590. };
  10591. }
  10592. });
  10593. const GridItem = withInstall(stdin_default$P);
  10594. const [name$F, bem$F] = createNamespace("highlight");
  10595. const highlightProps = {
  10596. autoEscape: truthProp,
  10597. caseSensitive: Boolean,
  10598. highlightClass: String,
  10599. highlightTag: makeStringProp("span"),
  10600. keywords: makeRequiredProp([String, Array]),
  10601. sourceString: makeStringProp(""),
  10602. tag: makeStringProp("div"),
  10603. unhighlightClass: String,
  10604. unhighlightTag: makeStringProp("span")
  10605. };
  10606. var stdin_default$O = vue.defineComponent({
  10607. name: name$F,
  10608. props: highlightProps,
  10609. setup(props2) {
  10610. const highlightChunks = vue.computed(() => {
  10611. const {
  10612. autoEscape,
  10613. caseSensitive,
  10614. keywords,
  10615. sourceString
  10616. } = props2;
  10617. const flags = caseSensitive ? "g" : "gi";
  10618. const _keywords = Array.isArray(keywords) ? keywords : [keywords];
  10619. let chunks = _keywords.filter((keyword) => keyword).reduce((chunks2, keyword) => {
  10620. if (autoEscape) {
  10621. keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  10622. }
  10623. const regex = new RegExp(keyword, flags);
  10624. let match;
  10625. while (match = regex.exec(sourceString)) {
  10626. const start = match.index;
  10627. const end = regex.lastIndex;
  10628. if (start >= end) {
  10629. regex.lastIndex++;
  10630. continue;
  10631. }
  10632. chunks2.push({
  10633. start,
  10634. end,
  10635. highlight: true
  10636. });
  10637. }
  10638. return chunks2;
  10639. }, []);
  10640. chunks = chunks.sort((a, b) => a.start - b.start).reduce((chunks2, currentChunk) => {
  10641. const prevChunk = chunks2[chunks2.length - 1];
  10642. if (!prevChunk || currentChunk.start > prevChunk.end) {
  10643. const unhighlightStart = prevChunk ? prevChunk.end : 0;
  10644. const unhighlightEnd = currentChunk.start;
  10645. if (unhighlightStart !== unhighlightEnd) {
  10646. chunks2.push({
  10647. start: unhighlightStart,
  10648. end: unhighlightEnd,
  10649. highlight: false
  10650. });
  10651. }
  10652. chunks2.push(currentChunk);
  10653. } else {
  10654. prevChunk.end = Math.max(prevChunk.end, currentChunk.end);
  10655. }
  10656. return chunks2;
  10657. }, []);
  10658. const lastChunk = chunks[chunks.length - 1];
  10659. if (!lastChunk) {
  10660. chunks.push({
  10661. start: 0,
  10662. end: sourceString.length,
  10663. highlight: false
  10664. });
  10665. }
  10666. if (lastChunk && lastChunk.end < sourceString.length) {
  10667. chunks.push({
  10668. start: lastChunk.end,
  10669. end: sourceString.length,
  10670. highlight: false
  10671. });
  10672. }
  10673. return chunks;
  10674. });
  10675. const renderContent = () => {
  10676. const {
  10677. sourceString,
  10678. highlightClass,
  10679. unhighlightClass,
  10680. highlightTag,
  10681. unhighlightTag
  10682. } = props2;
  10683. return highlightChunks.value.map((chunk) => {
  10684. const {
  10685. start,
  10686. end,
  10687. highlight
  10688. } = chunk;
  10689. const text = sourceString.slice(start, end);
  10690. if (highlight) {
  10691. return vue.createVNode(highlightTag, {
  10692. "class": [bem$F("tag"), highlightClass]
  10693. }, {
  10694. default: () => [text]
  10695. });
  10696. }
  10697. return vue.createVNode(unhighlightTag, {
  10698. "class": unhighlightClass
  10699. }, {
  10700. default: () => [text]
  10701. });
  10702. });
  10703. };
  10704. return () => {
  10705. const {
  10706. tag
  10707. } = props2;
  10708. return vue.createVNode(tag, {
  10709. "class": bem$F()
  10710. }, {
  10711. default: () => [renderContent()]
  10712. });
  10713. };
  10714. }
  10715. });
  10716. const Highlight = withInstall(stdin_default$O);
  10717. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  10718. const getCenter = (touches) => ({
  10719. x: (touches[0].clientX + touches[1].clientX) / 2,
  10720. y: (touches[0].clientY + touches[1].clientY) / 2
  10721. });
  10722. const bem$E = createNamespace("image-preview")[1];
  10723. const longImageRatio = 2.6;
  10724. const imagePreviewItemProps = {
  10725. src: String,
  10726. show: Boolean,
  10727. active: Number,
  10728. minZoom: makeRequiredProp(numericProp),
  10729. maxZoom: makeRequiredProp(numericProp),
  10730. rootWidth: makeRequiredProp(Number),
  10731. rootHeight: makeRequiredProp(Number),
  10732. disableZoom: Boolean,
  10733. doubleScale: Boolean,
  10734. closeOnClickImage: Boolean,
  10735. closeOnClickOverlay: Boolean,
  10736. vertical: Boolean
  10737. };
  10738. var stdin_default$N = vue.defineComponent({
  10739. props: imagePreviewItemProps,
  10740. emits: ["scale", "close", "longPress"],
  10741. setup(props2, {
  10742. emit,
  10743. slots
  10744. }) {
  10745. const state = vue.reactive({
  10746. scale: 1,
  10747. moveX: 0,
  10748. moveY: 0,
  10749. moving: false,
  10750. zooming: false,
  10751. initializing: false,
  10752. imageRatio: 0
  10753. });
  10754. const touch = useTouch();
  10755. const imageRef = vue.ref();
  10756. const swipeItem = vue.ref();
  10757. const vertical = vue.ref(false);
  10758. const isLongImage = vue.ref(false);
  10759. let initialMoveY = 0;
  10760. const imageStyle = vue.computed(() => {
  10761. const {
  10762. scale,
  10763. moveX,
  10764. moveY,
  10765. moving,
  10766. zooming,
  10767. initializing
  10768. } = state;
  10769. const style = {
  10770. transitionDuration: zooming || moving || initializing ? "0s" : ".3s"
  10771. };
  10772. if (scale !== 1 || isLongImage.value) {
  10773. style.transform = `matrix(${scale}, 0, 0, ${scale}, ${moveX}, ${moveY})`;
  10774. }
  10775. return style;
  10776. });
  10777. const maxMoveX = vue.computed(() => {
  10778. if (state.imageRatio) {
  10779. const {
  10780. rootWidth,
  10781. rootHeight
  10782. } = props2;
  10783. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  10784. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  10785. }
  10786. return 0;
  10787. });
  10788. const maxMoveY = vue.computed(() => {
  10789. if (state.imageRatio) {
  10790. const {
  10791. rootWidth,
  10792. rootHeight
  10793. } = props2;
  10794. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  10795. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  10796. }
  10797. return 0;
  10798. });
  10799. const setScale = (scale, center) => {
  10800. var _a;
  10801. scale = clamp(scale, +props2.minZoom, +props2.maxZoom + 1);
  10802. if (scale !== state.scale) {
  10803. const ratio = scale / state.scale;
  10804. state.scale = scale;
  10805. if (center) {
  10806. const imageRect = use.useRect((_a = imageRef.value) == null ? void 0 : _a.$el);
  10807. const origin = {
  10808. x: imageRect.width * 0.5,
  10809. y: imageRect.height * 0.5
  10810. };
  10811. const moveX = state.moveX - (center.x - imageRect.left - origin.x) * (ratio - 1);
  10812. const moveY = state.moveY - (center.y - imageRect.top - origin.y) * (ratio - 1);
  10813. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  10814. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  10815. } else {
  10816. state.moveX = 0;
  10817. state.moveY = isLongImage.value ? initialMoveY : 0;
  10818. }
  10819. emit("scale", {
  10820. scale,
  10821. index: props2.active
  10822. });
  10823. }
  10824. };
  10825. const resetScale = () => {
  10826. setScale(1);
  10827. };
  10828. const toggleScale = () => {
  10829. const scale = state.scale > 1 ? 1 : 2;
  10830. setScale(scale, scale === 2 || isLongImage.value ? {
  10831. x: touch.startX.value,
  10832. y: touch.startY.value
  10833. } : void 0);
  10834. };
  10835. let fingerNum;
  10836. let startMoveX;
  10837. let startMoveY;
  10838. let startScale;
  10839. let startDistance;
  10840. let lastCenter;
  10841. let doubleTapTimer;
  10842. let touchStartTime;
  10843. let isImageMoved = false;
  10844. const onTouchStart = (event) => {
  10845. const {
  10846. touches
  10847. } = event;
  10848. fingerNum = touches.length;
  10849. if (fingerNum === 2 && props2.disableZoom) {
  10850. return;
  10851. }
  10852. const {
  10853. offsetX
  10854. } = touch;
  10855. touch.start(event);
  10856. startMoveX = state.moveX;
  10857. startMoveY = state.moveY;
  10858. touchStartTime = Date.now();
  10859. isImageMoved = false;
  10860. state.moving = fingerNum === 1 && (state.scale !== 1 || isLongImage.value);
  10861. state.zooming = fingerNum === 2 && !offsetX.value;
  10862. if (state.zooming) {
  10863. startScale = state.scale;
  10864. startDistance = getDistance(touches);
  10865. }
  10866. };
  10867. const onTouchMove = (event) => {
  10868. const {
  10869. touches
  10870. } = event;
  10871. touch.move(event);
  10872. if (state.moving) {
  10873. const {
  10874. deltaX,
  10875. deltaY
  10876. } = touch;
  10877. const moveX = deltaX.value + startMoveX;
  10878. const moveY = deltaY.value + startMoveY;
  10879. if ((props2.vertical ? touch.isVertical() && Math.abs(moveY) > maxMoveY.value : touch.isHorizontal() && Math.abs(moveX) > maxMoveX.value) && !isImageMoved) {
  10880. state.moving = false;
  10881. return;
  10882. }
  10883. isImageMoved = true;
  10884. preventDefault(event, true);
  10885. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  10886. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  10887. }
  10888. if (state.zooming) {
  10889. preventDefault(event, true);
  10890. if (touches.length === 2) {
  10891. const distance = getDistance(touches);
  10892. const scale = startScale * distance / startDistance;
  10893. lastCenter = getCenter(touches);
  10894. setScale(scale, lastCenter);
  10895. }
  10896. }
  10897. };
  10898. const checkClose = (event) => {
  10899. var _a;
  10900. const swipeItemEl = (_a = swipeItem.value) == null ? void 0 : _a.$el;
  10901. if (!swipeItemEl) return;
  10902. const imageEl = swipeItemEl.firstElementChild;
  10903. const isClickOverlay = event.target === swipeItemEl;
  10904. const isClickImage = imageEl == null ? void 0 : imageEl.contains(event.target);
  10905. if (!props2.closeOnClickImage && isClickImage) return;
  10906. if (!props2.closeOnClickOverlay && isClickOverlay) return;
  10907. emit("close");
  10908. };
  10909. const checkTap = (event) => {
  10910. if (fingerNum > 1) {
  10911. return;
  10912. }
  10913. const deltaTime = Date.now() - touchStartTime;
  10914. const TAP_TIME = 250;
  10915. if (touch.isTap.value) {
  10916. if (deltaTime < TAP_TIME) {
  10917. if (props2.doubleScale) {
  10918. if (doubleTapTimer) {
  10919. clearTimeout(doubleTapTimer);
  10920. doubleTapTimer = null;
  10921. toggleScale();
  10922. } else {
  10923. doubleTapTimer = setTimeout(() => {
  10924. checkClose(event);
  10925. doubleTapTimer = null;
  10926. }, TAP_TIME);
  10927. }
  10928. } else {
  10929. checkClose(event);
  10930. }
  10931. } else if (deltaTime > LONG_PRESS_START_TIME) {
  10932. emit("longPress");
  10933. }
  10934. }
  10935. };
  10936. const onTouchEnd = (event) => {
  10937. let stopPropagation2 = false;
  10938. if (state.moving || state.zooming) {
  10939. stopPropagation2 = true;
  10940. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  10941. stopPropagation2 = false;
  10942. }
  10943. if (!event.touches.length) {
  10944. if (state.zooming) {
  10945. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  10946. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  10947. state.zooming = false;
  10948. }
  10949. state.moving = false;
  10950. startMoveX = 0;
  10951. startMoveY = 0;
  10952. startScale = 1;
  10953. if (state.scale < 1) {
  10954. resetScale();
  10955. }
  10956. const maxZoom = +props2.maxZoom;
  10957. if (state.scale > maxZoom) {
  10958. setScale(maxZoom, lastCenter);
  10959. }
  10960. }
  10961. }
  10962. preventDefault(event, stopPropagation2);
  10963. checkTap(event);
  10964. touch.reset();
  10965. };
  10966. const resize = () => {
  10967. const {
  10968. rootWidth,
  10969. rootHeight
  10970. } = props2;
  10971. const rootRatio = rootHeight / rootWidth;
  10972. const {
  10973. imageRatio
  10974. } = state;
  10975. vertical.value = state.imageRatio > rootRatio && imageRatio < longImageRatio;
  10976. isLongImage.value = state.imageRatio > rootRatio && imageRatio >= longImageRatio;
  10977. if (isLongImage.value) {
  10978. initialMoveY = (imageRatio * rootWidth - rootHeight) / 2;
  10979. state.moveY = initialMoveY;
  10980. state.initializing = true;
  10981. use.raf(() => {
  10982. state.initializing = false;
  10983. });
  10984. }
  10985. resetScale();
  10986. };
  10987. const onLoad = (event) => {
  10988. const {
  10989. naturalWidth,
  10990. naturalHeight
  10991. } = event.target;
  10992. state.imageRatio = naturalHeight / naturalWidth;
  10993. resize();
  10994. };
  10995. vue.watch(() => props2.active, resetScale);
  10996. vue.watch(() => props2.show, (value) => {
  10997. if (!value) {
  10998. resetScale();
  10999. }
  11000. });
  11001. vue.watch(() => [props2.rootWidth, props2.rootHeight], resize);
  11002. use.useEventListener("touchmove", onTouchMove, {
  11003. target: vue.computed(() => {
  11004. var _a;
  11005. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  11006. })
  11007. });
  11008. useExpose({
  11009. resetScale
  11010. });
  11011. return () => {
  11012. const imageSlots = {
  11013. loading: () => vue.createVNode(Loading, {
  11014. "type": "spinner"
  11015. }, null)
  11016. };
  11017. return vue.createVNode(SwipeItem, {
  11018. "ref": swipeItem,
  11019. "class": bem$E("swipe-item"),
  11020. "onTouchstartPassive": onTouchStart,
  11021. "onTouchend": onTouchEnd,
  11022. "onTouchcancel": onTouchEnd
  11023. }, {
  11024. default: () => [slots.image ? vue.createVNode("div", {
  11025. "class": bem$E("image-wrap")
  11026. }, [slots.image({
  11027. src: props2.src,
  11028. onLoad,
  11029. style: imageStyle.value
  11030. })]) : vue.createVNode(Image$1, {
  11031. "ref": imageRef,
  11032. "src": props2.src,
  11033. "fit": "contain",
  11034. "class": bem$E("image", {
  11035. vertical: vertical.value
  11036. }),
  11037. "style": imageStyle.value,
  11038. "onLoad": onLoad
  11039. }, imageSlots)]
  11040. });
  11041. };
  11042. }
  11043. });
  11044. const [name$E, bem$D] = createNamespace("image-preview");
  11045. const popupProps$1 = ["show", "teleport", "transition", "overlayStyle", "closeOnPopstate"];
  11046. const imagePreviewProps = {
  11047. show: Boolean,
  11048. loop: truthProp,
  11049. images: makeArrayProp(),
  11050. minZoom: makeNumericProp(1 / 3),
  11051. maxZoom: makeNumericProp(3),
  11052. overlay: truthProp,
  11053. vertical: Boolean,
  11054. closeable: Boolean,
  11055. showIndex: truthProp,
  11056. className: unknownProp,
  11057. closeIcon: makeStringProp("clear"),
  11058. transition: String,
  11059. beforeClose: Function,
  11060. doubleScale: truthProp,
  11061. overlayClass: unknownProp,
  11062. overlayStyle: Object,
  11063. swipeDuration: makeNumericProp(300),
  11064. startPosition: makeNumericProp(0),
  11065. showIndicators: Boolean,
  11066. closeOnPopstate: truthProp,
  11067. closeOnClickImage: truthProp,
  11068. closeOnClickOverlay: truthProp,
  11069. closeIconPosition: makeStringProp("top-right"),
  11070. teleport: [String, Object]
  11071. };
  11072. var stdin_default$M = vue.defineComponent({
  11073. name: name$E,
  11074. props: imagePreviewProps,
  11075. emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
  11076. setup(props2, {
  11077. emit,
  11078. slots
  11079. }) {
  11080. const swipeRef = vue.ref();
  11081. const activedPreviewItemRef = vue.ref();
  11082. const state = vue.reactive({
  11083. active: 0,
  11084. rootWidth: 0,
  11085. rootHeight: 0,
  11086. disableZoom: false
  11087. });
  11088. const resize = () => {
  11089. if (swipeRef.value) {
  11090. const rect = use.useRect(swipeRef.value.$el);
  11091. state.rootWidth = rect.width;
  11092. state.rootHeight = rect.height;
  11093. swipeRef.value.resize();
  11094. }
  11095. };
  11096. const emitScale = (args) => emit("scale", args);
  11097. const updateShow = (show) => emit("update:show", show);
  11098. const emitClose = () => {
  11099. callInterceptor(props2.beforeClose, {
  11100. args: [state.active],
  11101. done: () => updateShow(false)
  11102. });
  11103. };
  11104. const setActive = (active) => {
  11105. if (active !== state.active) {
  11106. state.active = active;
  11107. emit("change", active);
  11108. }
  11109. };
  11110. const renderIndex = () => {
  11111. if (props2.showIndex) {
  11112. return vue.createVNode("div", {
  11113. "class": bem$D("index")
  11114. }, [slots.index ? slots.index({
  11115. index: state.active
  11116. }) : `${state.active + 1} / ${props2.images.length}`]);
  11117. }
  11118. };
  11119. const renderCover = () => {
  11120. if (slots.cover) {
  11121. return vue.createVNode("div", {
  11122. "class": bem$D("cover")
  11123. }, [slots.cover()]);
  11124. }
  11125. };
  11126. const onDragStart = () => {
  11127. state.disableZoom = true;
  11128. };
  11129. const onDragEnd = () => {
  11130. state.disableZoom = false;
  11131. };
  11132. const renderImages = () => vue.createVNode(Swipe, {
  11133. "ref": swipeRef,
  11134. "lazyRender": true,
  11135. "loop": props2.loop,
  11136. "class": bem$D("swipe"),
  11137. "vertical": props2.vertical,
  11138. "duration": props2.swipeDuration,
  11139. "initialSwipe": props2.startPosition,
  11140. "showIndicators": props2.showIndicators,
  11141. "indicatorColor": "white",
  11142. "onChange": setActive,
  11143. "onDragEnd": onDragEnd,
  11144. "onDragStart": onDragStart
  11145. }, {
  11146. default: () => [props2.images.map((image, index) => vue.createVNode(stdin_default$N, {
  11147. "ref": (item) => {
  11148. if (index === state.active) {
  11149. activedPreviewItemRef.value = item;
  11150. }
  11151. },
  11152. "src": image,
  11153. "show": props2.show,
  11154. "active": state.active,
  11155. "maxZoom": props2.maxZoom,
  11156. "minZoom": props2.minZoom,
  11157. "rootWidth": state.rootWidth,
  11158. "rootHeight": state.rootHeight,
  11159. "disableZoom": state.disableZoom,
  11160. "doubleScale": props2.doubleScale,
  11161. "closeOnClickImage": props2.closeOnClickImage,
  11162. "closeOnClickOverlay": props2.closeOnClickOverlay,
  11163. "vertical": props2.vertical,
  11164. "onScale": emitScale,
  11165. "onClose": emitClose,
  11166. "onLongPress": () => emit("longPress", {
  11167. index
  11168. })
  11169. }, {
  11170. image: slots.image
  11171. }))]
  11172. });
  11173. const renderClose = () => {
  11174. if (props2.closeable) {
  11175. return vue.createVNode(Icon, {
  11176. "role": "button",
  11177. "name": props2.closeIcon,
  11178. "class": [bem$D("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
  11179. "onClick": emitClose
  11180. }, null);
  11181. }
  11182. };
  11183. const onClosed = () => emit("closed");
  11184. const swipeTo = (index, options) => {
  11185. var _a;
  11186. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  11187. };
  11188. useExpose({
  11189. resetScale: () => {
  11190. var _a;
  11191. (_a = activedPreviewItemRef.value) == null ? void 0 : _a.resetScale();
  11192. },
  11193. swipeTo
  11194. });
  11195. vue.onMounted(resize);
  11196. vue.watch([windowWidth, windowHeight], resize);
  11197. vue.watch(() => props2.startPosition, (value) => setActive(+value));
  11198. vue.watch(() => props2.show, (value) => {
  11199. const {
  11200. images,
  11201. startPosition
  11202. } = props2;
  11203. if (value) {
  11204. setActive(+startPosition);
  11205. vue.nextTick(() => {
  11206. resize();
  11207. swipeTo(+startPosition, {
  11208. immediate: true
  11209. });
  11210. });
  11211. } else {
  11212. emit("close", {
  11213. index: state.active,
  11214. url: images[state.active]
  11215. });
  11216. }
  11217. });
  11218. return () => vue.createVNode(Popup, vue.mergeProps({
  11219. "class": [bem$D(), props2.className],
  11220. "overlayClass": [bem$D("overlay"), props2.overlayClass],
  11221. "onClosed": onClosed,
  11222. "onUpdate:show": updateShow
  11223. }, pick(props2, popupProps$1)), {
  11224. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  11225. });
  11226. }
  11227. });
  11228. let instance$1;
  11229. const defaultConfig = {
  11230. loop: true,
  11231. images: [],
  11232. maxZoom: 3,
  11233. minZoom: 1 / 3,
  11234. onScale: void 0,
  11235. onClose: void 0,
  11236. onChange: void 0,
  11237. vertical: false,
  11238. teleport: "body",
  11239. className: "",
  11240. showIndex: true,
  11241. closeable: false,
  11242. closeIcon: "clear",
  11243. transition: void 0,
  11244. beforeClose: void 0,
  11245. doubleScale: true,
  11246. overlayStyle: void 0,
  11247. overlayClass: void 0,
  11248. startPosition: 0,
  11249. swipeDuration: 300,
  11250. showIndicators: false,
  11251. closeOnPopstate: true,
  11252. closeOnClickOverlay: true,
  11253. closeIconPosition: "top-right"
  11254. };
  11255. function initInstance$1() {
  11256. ({
  11257. instance: instance$1
  11258. } = mountComponent({
  11259. setup() {
  11260. const {
  11261. state,
  11262. toggle
  11263. } = usePopupState();
  11264. const onClosed = () => {
  11265. state.images = [];
  11266. };
  11267. return () => vue.createVNode(stdin_default$M, vue.mergeProps(state, {
  11268. "onClosed": onClosed,
  11269. "onUpdate:show": toggle
  11270. }), null);
  11271. }
  11272. }));
  11273. }
  11274. const showImagePreview = (options, startPosition = 0) => {
  11275. if (!inBrowser) {
  11276. return;
  11277. }
  11278. if (!instance$1) {
  11279. initInstance$1();
  11280. }
  11281. options = Array.isArray(options) ? {
  11282. images: options,
  11283. startPosition
  11284. } : options;
  11285. instance$1.open(extend({}, defaultConfig, options));
  11286. return instance$1;
  11287. };
  11288. const ImagePreview = withInstall(stdin_default$M);
  11289. function genAlphabet() {
  11290. const charCodeOfA = "A".charCodeAt(0);
  11291. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  11292. return indexList;
  11293. }
  11294. const [name$D, bem$C] = createNamespace("index-bar");
  11295. const indexBarProps = {
  11296. sticky: truthProp,
  11297. zIndex: numericProp,
  11298. teleport: [String, Object],
  11299. highlightColor: String,
  11300. stickyOffsetTop: makeNumberProp(0),
  11301. indexList: {
  11302. type: Array,
  11303. default: genAlphabet
  11304. }
  11305. };
  11306. const INDEX_BAR_KEY = Symbol(name$D);
  11307. var stdin_default$L = vue.defineComponent({
  11308. name: name$D,
  11309. props: indexBarProps,
  11310. emits: ["select", "change"],
  11311. setup(props2, {
  11312. emit,
  11313. slots
  11314. }) {
  11315. const root = vue.ref();
  11316. const sidebar = vue.ref();
  11317. const activeAnchor = vue.ref("");
  11318. const touch = useTouch();
  11319. const scrollParent = use.useScrollParent(root);
  11320. const {
  11321. children,
  11322. linkChildren
  11323. } = use.useChildren(INDEX_BAR_KEY);
  11324. let selectActiveIndex;
  11325. linkChildren({
  11326. props: props2
  11327. });
  11328. const sidebarStyle = vue.computed(() => {
  11329. if (isDef(props2.zIndex)) {
  11330. return {
  11331. zIndex: +props2.zIndex + 1
  11332. };
  11333. }
  11334. });
  11335. const highlightStyle = vue.computed(() => {
  11336. if (props2.highlightColor) {
  11337. return {
  11338. color: props2.highlightColor
  11339. };
  11340. }
  11341. });
  11342. const getActiveAnchor = (scrollTop, rects) => {
  11343. for (let i = children.length - 1; i >= 0; i--) {
  11344. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  11345. const reachTop = props2.sticky ? prevHeight + props2.stickyOffsetTop : 0;
  11346. if (scrollTop + reachTop >= rects[i].top) {
  11347. return i;
  11348. }
  11349. }
  11350. return -1;
  11351. };
  11352. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  11353. const onScroll = () => {
  11354. if (isHidden(root)) {
  11355. return;
  11356. }
  11357. const {
  11358. sticky,
  11359. indexList
  11360. } = props2;
  11361. const scrollTop = getScrollTop(scrollParent.value);
  11362. const scrollParentRect = use.useRect(scrollParent);
  11363. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  11364. let active = -1;
  11365. if (selectActiveIndex) {
  11366. const match = getMatchAnchor(selectActiveIndex);
  11367. if (match) {
  11368. const rect = match.getRect(scrollParent.value, scrollParentRect);
  11369. if (props2.sticky && props2.stickyOffsetTop) {
  11370. active = getActiveAnchor(rect.top - props2.stickyOffsetTop, rects);
  11371. } else {
  11372. active = getActiveAnchor(rect.top, rects);
  11373. }
  11374. }
  11375. } else {
  11376. active = getActiveAnchor(scrollTop, rects);
  11377. }
  11378. activeAnchor.value = indexList[active];
  11379. if (sticky) {
  11380. children.forEach((item, index) => {
  11381. const {
  11382. state,
  11383. $el
  11384. } = item;
  11385. if (index === active || index === active - 1) {
  11386. const rect = $el.getBoundingClientRect();
  11387. state.left = rect.left;
  11388. state.width = rect.width;
  11389. } else {
  11390. state.left = null;
  11391. state.width = null;
  11392. }
  11393. if (index === active) {
  11394. state.active = true;
  11395. state.top = Math.max(props2.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  11396. } else if (index === active - 1 && selectActiveIndex === "") {
  11397. const activeItemTop = rects[active].top - scrollTop;
  11398. state.active = activeItemTop > 0;
  11399. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  11400. } else {
  11401. state.active = false;
  11402. }
  11403. });
  11404. }
  11405. selectActiveIndex = "";
  11406. };
  11407. const init = () => {
  11408. vue.nextTick(onScroll);
  11409. };
  11410. use.useEventListener("scroll", onScroll, {
  11411. target: scrollParent,
  11412. passive: true
  11413. });
  11414. vue.onMounted(init);
  11415. vue.watch(() => props2.indexList, init);
  11416. vue.watch(activeAnchor, (value) => {
  11417. if (value) {
  11418. emit("change", value);
  11419. }
  11420. });
  11421. const renderIndexes = () => props2.indexList.map((index) => {
  11422. const active = index === activeAnchor.value;
  11423. return vue.createVNode("span", {
  11424. "class": bem$C("index", {
  11425. active
  11426. }),
  11427. "style": active ? highlightStyle.value : void 0,
  11428. "data-index": index
  11429. }, [index]);
  11430. });
  11431. const scrollTo = (index) => {
  11432. selectActiveIndex = String(index);
  11433. const match = getMatchAnchor(selectActiveIndex);
  11434. if (match) {
  11435. const scrollTop = getScrollTop(scrollParent.value);
  11436. const scrollParentRect = use.useRect(scrollParent);
  11437. const {
  11438. offsetHeight
  11439. } = document.documentElement;
  11440. match.$el.scrollIntoView();
  11441. if (scrollTop === offsetHeight - scrollParentRect.height) {
  11442. onScroll();
  11443. return;
  11444. }
  11445. if (props2.sticky && props2.stickyOffsetTop) {
  11446. if (getRootScrollTop() === offsetHeight - scrollParentRect.height) {
  11447. setRootScrollTop(getRootScrollTop());
  11448. } else {
  11449. setRootScrollTop(getRootScrollTop() - props2.stickyOffsetTop);
  11450. }
  11451. }
  11452. emit("select", match.index);
  11453. }
  11454. };
  11455. const scrollToElement = (element) => {
  11456. const {
  11457. index
  11458. } = element.dataset;
  11459. if (index) {
  11460. scrollTo(index);
  11461. }
  11462. };
  11463. const onClickSidebar = (event) => {
  11464. scrollToElement(event.target);
  11465. };
  11466. let touchActiveIndex;
  11467. const onTouchMove = (event) => {
  11468. touch.move(event);
  11469. if (touch.isVertical()) {
  11470. preventDefault(event);
  11471. const {
  11472. clientX,
  11473. clientY
  11474. } = event.touches[0];
  11475. const target = document.elementFromPoint(clientX, clientY);
  11476. if (target) {
  11477. const {
  11478. index
  11479. } = target.dataset;
  11480. if (index && touchActiveIndex !== index) {
  11481. touchActiveIndex = index;
  11482. scrollToElement(target);
  11483. }
  11484. }
  11485. }
  11486. };
  11487. const renderSidebar = () => vue.createVNode("div", {
  11488. "ref": sidebar,
  11489. "class": bem$C("sidebar"),
  11490. "style": sidebarStyle.value,
  11491. "onClick": onClickSidebar,
  11492. "onTouchstartPassive": touch.start
  11493. }, [renderIndexes()]);
  11494. useExpose({
  11495. scrollTo
  11496. });
  11497. use.useEventListener("touchmove", onTouchMove, {
  11498. target: sidebar
  11499. });
  11500. return () => {
  11501. var _a;
  11502. return vue.createVNode("div", {
  11503. "ref": root,
  11504. "class": bem$C()
  11505. }, [props2.teleport ? vue.createVNode(vue.Teleport, {
  11506. "to": props2.teleport
  11507. }, {
  11508. default: () => [renderSidebar()]
  11509. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  11510. };
  11511. }
  11512. });
  11513. const [name$C, bem$B] = createNamespace("index-anchor");
  11514. const indexAnchorProps = {
  11515. index: numericProp
  11516. };
  11517. var stdin_default$K = vue.defineComponent({
  11518. name: name$C,
  11519. props: indexAnchorProps,
  11520. setup(props2, {
  11521. slots
  11522. }) {
  11523. const state = vue.reactive({
  11524. top: 0,
  11525. left: null,
  11526. rect: {
  11527. top: 0,
  11528. height: 0
  11529. },
  11530. width: null,
  11531. active: false
  11532. });
  11533. const root = vue.ref();
  11534. const {
  11535. parent
  11536. } = use.useParent(INDEX_BAR_KEY);
  11537. if (!parent) {
  11538. if (process.env.NODE_ENV !== "production") {
  11539. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  11540. }
  11541. return;
  11542. }
  11543. const isSticky = () => state.active && parent.props.sticky;
  11544. const anchorStyle = vue.computed(() => {
  11545. const {
  11546. zIndex,
  11547. highlightColor
  11548. } = parent.props;
  11549. if (isSticky()) {
  11550. return extend(getZIndexStyle(zIndex), {
  11551. left: state.left ? `${state.left}px` : void 0,
  11552. width: state.width ? `${state.width}px` : void 0,
  11553. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  11554. color: highlightColor
  11555. });
  11556. }
  11557. });
  11558. const getRect = (scrollParent, scrollParentRect) => {
  11559. const rootRect = use.useRect(root);
  11560. state.rect.height = rootRect.height;
  11561. if (scrollParent === window || scrollParent === document.body) {
  11562. state.rect.top = rootRect.top + getRootScrollTop();
  11563. } else {
  11564. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  11565. }
  11566. return state.rect;
  11567. };
  11568. useExpose({
  11569. state,
  11570. getRect
  11571. });
  11572. return () => {
  11573. const sticky = isSticky();
  11574. return vue.createVNode("div", {
  11575. "ref": root,
  11576. "style": {
  11577. height: sticky ? `${state.rect.height}px` : void 0
  11578. }
  11579. }, [vue.createVNode("div", {
  11580. "style": anchorStyle.value,
  11581. "class": [bem$B({
  11582. sticky
  11583. }), {
  11584. [BORDER_BOTTOM]: sticky
  11585. }]
  11586. }, [slots.default ? slots.default() : props2.index])]);
  11587. };
  11588. }
  11589. });
  11590. const IndexAnchor = withInstall(stdin_default$K);
  11591. const IndexBar = withInstall(stdin_default$L);
  11592. const [name$B, bem$A, t$7] = createNamespace("list");
  11593. const listProps = {
  11594. error: Boolean,
  11595. offset: makeNumericProp(300),
  11596. loading: Boolean,
  11597. disabled: Boolean,
  11598. finished: Boolean,
  11599. scroller: Object,
  11600. errorText: String,
  11601. direction: makeStringProp("down"),
  11602. loadingText: String,
  11603. finishedText: String,
  11604. immediateCheck: truthProp
  11605. };
  11606. var stdin_default$J = vue.defineComponent({
  11607. name: name$B,
  11608. props: listProps,
  11609. emits: ["load", "update:error", "update:loading"],
  11610. setup(props2, {
  11611. emit,
  11612. slots
  11613. }) {
  11614. const loading = vue.ref(props2.loading);
  11615. const root = vue.ref();
  11616. const placeholder = vue.ref();
  11617. const tabStatus = useTabStatus();
  11618. const scrollParent = use.useScrollParent(root);
  11619. const scroller = vue.computed(() => props2.scroller || scrollParent.value);
  11620. const check = () => {
  11621. vue.nextTick(() => {
  11622. if (loading.value || props2.finished || props2.disabled || props2.error || // skip check when inside an inactive tab
  11623. (tabStatus == null ? void 0 : tabStatus.value) === false) {
  11624. return;
  11625. }
  11626. const {
  11627. direction
  11628. } = props2;
  11629. const offset = +props2.offset;
  11630. const scrollParentRect = use.useRect(scroller);
  11631. if (!scrollParentRect.height || isHidden(root)) {
  11632. return;
  11633. }
  11634. let isReachEdge = false;
  11635. const placeholderRect = use.useRect(placeholder);
  11636. if (direction === "up") {
  11637. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  11638. } else {
  11639. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  11640. }
  11641. if (isReachEdge) {
  11642. loading.value = true;
  11643. emit("update:loading", true);
  11644. emit("load");
  11645. }
  11646. });
  11647. };
  11648. const renderFinishedText = () => {
  11649. if (props2.finished) {
  11650. const text = slots.finished ? slots.finished() : props2.finishedText;
  11651. if (text) {
  11652. return vue.createVNode("div", {
  11653. "class": bem$A("finished-text")
  11654. }, [text]);
  11655. }
  11656. }
  11657. };
  11658. const clickErrorText = () => {
  11659. emit("update:error", false);
  11660. check();
  11661. };
  11662. const renderErrorText = () => {
  11663. if (props2.error) {
  11664. const text = slots.error ? slots.error() : props2.errorText;
  11665. if (text) {
  11666. return vue.createVNode("div", {
  11667. "role": "button",
  11668. "class": bem$A("error-text"),
  11669. "tabindex": 0,
  11670. "onClick": clickErrorText
  11671. }, [text]);
  11672. }
  11673. }
  11674. };
  11675. const renderLoading = () => {
  11676. if (loading.value && !props2.finished && !props2.disabled) {
  11677. return vue.createVNode("div", {
  11678. "class": bem$A("loading")
  11679. }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
  11680. "class": bem$A("loading-icon")
  11681. }, {
  11682. default: () => [props2.loadingText || t$7("loading")]
  11683. })]);
  11684. }
  11685. };
  11686. vue.watch(() => [props2.loading, props2.finished, props2.error], check);
  11687. if (tabStatus) {
  11688. vue.watch(tabStatus, (tabActive) => {
  11689. if (tabActive) {
  11690. check();
  11691. }
  11692. });
  11693. }
  11694. vue.onUpdated(() => {
  11695. loading.value = props2.loading;
  11696. });
  11697. vue.onMounted(() => {
  11698. if (props2.immediateCheck) {
  11699. check();
  11700. }
  11701. });
  11702. useExpose({
  11703. check
  11704. });
  11705. use.useEventListener("scroll", check, {
  11706. target: scroller,
  11707. passive: true
  11708. });
  11709. return () => {
  11710. var _a;
  11711. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  11712. const Placeholder = vue.createVNode("div", {
  11713. "ref": placeholder,
  11714. "class": bem$A("placeholder")
  11715. }, null);
  11716. return vue.createVNode("div", {
  11717. "ref": root,
  11718. "role": "feed",
  11719. "class": bem$A(),
  11720. "aria-busy": loading.value
  11721. }, [props2.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props2.direction === "up" ? Content : Placeholder]);
  11722. };
  11723. }
  11724. });
  11725. const List = withInstall(stdin_default$J);
  11726. const [name$A, bem$z] = createNamespace("nav-bar");
  11727. const navBarProps = {
  11728. title: String,
  11729. fixed: Boolean,
  11730. zIndex: numericProp,
  11731. border: truthProp,
  11732. leftText: String,
  11733. rightText: String,
  11734. leftDisabled: Boolean,
  11735. rightDisabled: Boolean,
  11736. leftArrow: Boolean,
  11737. placeholder: Boolean,
  11738. safeAreaInsetTop: Boolean,
  11739. clickable: truthProp
  11740. };
  11741. var stdin_default$I = vue.defineComponent({
  11742. name: name$A,
  11743. props: navBarProps,
  11744. emits: ["clickLeft", "clickRight"],
  11745. setup(props2, {
  11746. emit,
  11747. slots
  11748. }) {
  11749. const navBarRef = vue.ref();
  11750. const renderPlaceholder = usePlaceholder(navBarRef, bem$z);
  11751. const onClickLeft = (event) => {
  11752. if (!props2.leftDisabled) {
  11753. emit("clickLeft", event);
  11754. }
  11755. };
  11756. const onClickRight = (event) => {
  11757. if (!props2.rightDisabled) {
  11758. emit("clickRight", event);
  11759. }
  11760. };
  11761. const renderLeft = () => {
  11762. if (slots.left) {
  11763. return slots.left();
  11764. }
  11765. return [props2.leftArrow && vue.createVNode(Icon, {
  11766. "class": bem$z("arrow"),
  11767. "name": "arrow-left"
  11768. }, null), props2.leftText && vue.createVNode("span", {
  11769. "class": bem$z("text")
  11770. }, [props2.leftText])];
  11771. };
  11772. const renderRight = () => {
  11773. if (slots.right) {
  11774. return slots.right();
  11775. }
  11776. return vue.createVNode("span", {
  11777. "class": bem$z("text")
  11778. }, [props2.rightText]);
  11779. };
  11780. const renderNavBar = () => {
  11781. const {
  11782. title,
  11783. fixed,
  11784. border,
  11785. zIndex
  11786. } = props2;
  11787. const style = getZIndexStyle(zIndex);
  11788. const hasLeft = props2.leftArrow || props2.leftText || slots.left;
  11789. const hasRight = props2.rightText || slots.right;
  11790. return vue.createVNode("div", {
  11791. "ref": navBarRef,
  11792. "style": style,
  11793. "class": [bem$z({
  11794. fixed
  11795. }), {
  11796. [BORDER_BOTTOM]: border,
  11797. "van-safe-area-top": props2.safeAreaInsetTop
  11798. }]
  11799. }, [vue.createVNode("div", {
  11800. "class": bem$z("content")
  11801. }, [hasLeft && vue.createVNode("div", {
  11802. "class": [bem$z("left", {
  11803. disabled: props2.leftDisabled
  11804. }), props2.clickable && !props2.leftDisabled ? HAPTICS_FEEDBACK : ""],
  11805. "onClick": onClickLeft
  11806. }, [renderLeft()]), vue.createVNode("div", {
  11807. "class": [bem$z("title"), "van-ellipsis"]
  11808. }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
  11809. "class": [bem$z("right", {
  11810. disabled: props2.rightDisabled
  11811. }), props2.clickable && !props2.rightDisabled ? HAPTICS_FEEDBACK : ""],
  11812. "onClick": onClickRight
  11813. }, [renderRight()])])]);
  11814. };
  11815. return () => {
  11816. if (props2.fixed && props2.placeholder) {
  11817. return renderPlaceholder(renderNavBar);
  11818. }
  11819. return renderNavBar();
  11820. };
  11821. }
  11822. });
  11823. const NavBar = withInstall(stdin_default$I);
  11824. const [name$z, bem$y] = createNamespace("notice-bar");
  11825. const noticeBarProps = {
  11826. text: String,
  11827. mode: String,
  11828. color: String,
  11829. delay: makeNumericProp(1),
  11830. speed: makeNumericProp(60),
  11831. leftIcon: String,
  11832. wrapable: Boolean,
  11833. background: String,
  11834. scrollable: {
  11835. type: Boolean,
  11836. default: null
  11837. }
  11838. };
  11839. var stdin_default$H = vue.defineComponent({
  11840. name: name$z,
  11841. props: noticeBarProps,
  11842. emits: ["close", "replay"],
  11843. setup(props2, {
  11844. emit,
  11845. slots
  11846. }) {
  11847. let wrapWidth = 0;
  11848. let contentWidth = 0;
  11849. let startTimer;
  11850. const wrapRef = vue.ref();
  11851. const contentRef = vue.ref();
  11852. const state = vue.reactive({
  11853. show: true,
  11854. offset: 0,
  11855. duration: 0
  11856. });
  11857. const renderLeftIcon = () => {
  11858. if (slots["left-icon"]) {
  11859. return slots["left-icon"]();
  11860. }
  11861. if (props2.leftIcon) {
  11862. return vue.createVNode(Icon, {
  11863. "class": bem$y("left-icon"),
  11864. "name": props2.leftIcon
  11865. }, null);
  11866. }
  11867. };
  11868. const getRightIconName = () => {
  11869. if (props2.mode === "closeable") {
  11870. return "cross";
  11871. }
  11872. if (props2.mode === "link") {
  11873. return "arrow";
  11874. }
  11875. };
  11876. const onClickRightIcon = (event) => {
  11877. if (props2.mode === "closeable") {
  11878. state.show = false;
  11879. emit("close", event);
  11880. }
  11881. };
  11882. const renderRightIcon = () => {
  11883. if (slots["right-icon"]) {
  11884. return slots["right-icon"]();
  11885. }
  11886. const name2 = getRightIconName();
  11887. if (name2) {
  11888. return vue.createVNode(Icon, {
  11889. "name": name2,
  11890. "class": bem$y("right-icon"),
  11891. "onClick": onClickRightIcon
  11892. }, null);
  11893. }
  11894. };
  11895. const onTransitionEnd = () => {
  11896. state.offset = wrapWidth;
  11897. state.duration = 0;
  11898. use.raf(() => {
  11899. use.doubleRaf(() => {
  11900. state.offset = -contentWidth;
  11901. state.duration = (contentWidth + wrapWidth) / +props2.speed;
  11902. emit("replay");
  11903. });
  11904. });
  11905. };
  11906. const renderMarquee = () => {
  11907. const ellipsis = props2.scrollable === false && !props2.wrapable;
  11908. const style = {
  11909. transform: state.offset ? `translateX(${state.offset}px)` : "",
  11910. transitionDuration: `${state.duration}s`
  11911. };
  11912. return vue.createVNode("div", {
  11913. "ref": wrapRef,
  11914. "role": "marquee",
  11915. "class": bem$y("wrap")
  11916. }, [vue.createVNode("div", {
  11917. "ref": contentRef,
  11918. "style": style,
  11919. "class": [bem$y("content"), {
  11920. "van-ellipsis": ellipsis
  11921. }],
  11922. "onTransitionend": onTransitionEnd
  11923. }, [slots.default ? slots.default() : props2.text])]);
  11924. };
  11925. const reset = () => {
  11926. const {
  11927. delay,
  11928. speed,
  11929. scrollable
  11930. } = props2;
  11931. const ms = isDef(delay) ? +delay * 1e3 : 0;
  11932. wrapWidth = 0;
  11933. contentWidth = 0;
  11934. state.offset = 0;
  11935. state.duration = 0;
  11936. clearTimeout(startTimer);
  11937. startTimer = setTimeout(() => {
  11938. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  11939. return;
  11940. }
  11941. const wrapRefWidth = use.useRect(wrapRef).width;
  11942. const contentRefWidth = use.useRect(contentRef).width;
  11943. if (scrollable || contentRefWidth > wrapRefWidth) {
  11944. use.doubleRaf(() => {
  11945. wrapWidth = wrapRefWidth;
  11946. contentWidth = contentRefWidth;
  11947. state.offset = -contentWidth;
  11948. state.duration = contentWidth / +speed;
  11949. });
  11950. }
  11951. }, ms);
  11952. };
  11953. onPopupReopen(reset);
  11954. use.onMountedOrActivated(reset);
  11955. use.useEventListener("pageshow", reset);
  11956. useExpose({
  11957. reset
  11958. });
  11959. vue.watch(() => [props2.text, props2.scrollable], reset);
  11960. return () => {
  11961. const {
  11962. color,
  11963. wrapable,
  11964. background
  11965. } = props2;
  11966. return vue.withDirectives(vue.createVNode("div", {
  11967. "role": "alert",
  11968. "class": bem$y({
  11969. wrapable
  11970. }),
  11971. "style": {
  11972. color,
  11973. background
  11974. }
  11975. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
  11976. };
  11977. }
  11978. });
  11979. const NoticeBar = withInstall(stdin_default$H);
  11980. const [name$y, bem$x] = createNamespace("notify");
  11981. const popupInheritProps = ["lockScroll", "position", "show", "teleport", "zIndex"];
  11982. const notifyProps = extend({}, popupSharedProps, {
  11983. type: makeStringProp("danger"),
  11984. color: String,
  11985. message: numericProp,
  11986. position: makeStringProp("top"),
  11987. className: unknownProp,
  11988. background: String,
  11989. lockScroll: Boolean
  11990. });
  11991. var stdin_default$G = vue.defineComponent({
  11992. name: name$y,
  11993. props: notifyProps,
  11994. emits: ["update:show"],
  11995. setup(props2, {
  11996. emit,
  11997. slots
  11998. }) {
  11999. const updateShow = (show) => emit("update:show", show);
  12000. return () => vue.createVNode(Popup, vue.mergeProps({
  12001. "class": [bem$x([props2.type]), props2.className],
  12002. "style": {
  12003. color: props2.color,
  12004. background: props2.background
  12005. },
  12006. "overlay": false,
  12007. "duration": 0.2,
  12008. "onUpdate:show": updateShow
  12009. }, pick(props2, popupInheritProps)), {
  12010. default: () => [slots.default ? slots.default() : props2.message]
  12011. });
  12012. }
  12013. });
  12014. let timer;
  12015. let instance;
  12016. const parseOptions = (message) => isObject(message) ? message : {
  12017. message
  12018. };
  12019. function initInstance() {
  12020. ({
  12021. instance
  12022. } = mountComponent({
  12023. setup() {
  12024. const {
  12025. state,
  12026. toggle
  12027. } = usePopupState();
  12028. return () => vue.createVNode(stdin_default$G, vue.mergeProps(state, {
  12029. "onUpdate:show": toggle
  12030. }), null);
  12031. }
  12032. }));
  12033. }
  12034. const getDefaultOptions = () => ({
  12035. type: "danger",
  12036. color: void 0,
  12037. message: "",
  12038. onClose: void 0,
  12039. onClick: void 0,
  12040. onOpened: void 0,
  12041. duration: 3e3,
  12042. position: void 0,
  12043. className: "",
  12044. lockScroll: false,
  12045. background: void 0
  12046. });
  12047. let currentOptions = getDefaultOptions();
  12048. const closeNotify = () => {
  12049. if (instance) {
  12050. instance.toggle(false);
  12051. }
  12052. };
  12053. function showNotify(options) {
  12054. if (!inBrowser) {
  12055. return;
  12056. }
  12057. if (!instance) {
  12058. initInstance();
  12059. }
  12060. options = extend({}, currentOptions, parseOptions(options));
  12061. instance.open(options);
  12062. clearTimeout(timer);
  12063. if (options.duration > 0) {
  12064. timer = setTimeout(closeNotify, options.duration);
  12065. }
  12066. return instance;
  12067. }
  12068. const setNotifyDefaultOptions = (options) => extend(currentOptions, options);
  12069. const resetNotifyDefaultOptions = () => {
  12070. currentOptions = getDefaultOptions();
  12071. };
  12072. const Notify = withInstall(stdin_default$G);
  12073. const [name$x, bem$w] = createNamespace("key");
  12074. const CollapseIcon = vue.createVNode("svg", {
  12075. "class": bem$w("collapse-icon"),
  12076. "viewBox": "0 0 30 24"
  12077. }, [vue.createVNode("path", {
  12078. "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",
  12079. "fill": "currentColor"
  12080. }, null)]);
  12081. const DeleteIcon = vue.createVNode("svg", {
  12082. "class": bem$w("delete-icon"),
  12083. "viewBox": "0 0 32 22"
  12084. }, [vue.createVNode("path", {
  12085. "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",
  12086. "fill": "currentColor"
  12087. }, null)]);
  12088. var stdin_default$F = vue.defineComponent({
  12089. name: name$x,
  12090. props: {
  12091. type: String,
  12092. text: numericProp,
  12093. color: String,
  12094. wider: Boolean,
  12095. large: Boolean,
  12096. loading: Boolean
  12097. },
  12098. emits: ["press"],
  12099. setup(props2, {
  12100. emit,
  12101. slots
  12102. }) {
  12103. const active = vue.ref(false);
  12104. const touch = useTouch();
  12105. const onTouchStart = (event) => {
  12106. touch.start(event);
  12107. active.value = true;
  12108. };
  12109. const onTouchMove = (event) => {
  12110. touch.move(event);
  12111. if (touch.direction.value) {
  12112. active.value = false;
  12113. }
  12114. };
  12115. const onTouchEnd = (event) => {
  12116. if (active.value) {
  12117. if (!slots.default) {
  12118. preventDefault(event);
  12119. }
  12120. active.value = false;
  12121. emit("press", props2.text, props2.type);
  12122. }
  12123. };
  12124. const renderContent = () => {
  12125. if (props2.loading) {
  12126. return vue.createVNode(Loading, {
  12127. "class": bem$w("loading-icon")
  12128. }, null);
  12129. }
  12130. const text = slots.default ? slots.default() : props2.text;
  12131. switch (props2.type) {
  12132. case "delete":
  12133. return text || DeleteIcon;
  12134. case "extra":
  12135. return text || CollapseIcon;
  12136. default:
  12137. return text;
  12138. }
  12139. };
  12140. return () => vue.createVNode("div", {
  12141. "class": bem$w("wrapper", {
  12142. wider: props2.wider
  12143. }),
  12144. "onTouchstartPassive": onTouchStart,
  12145. "onTouchmovePassive": onTouchMove,
  12146. "onTouchend": onTouchEnd,
  12147. "onTouchcancel": onTouchEnd
  12148. }, [vue.createVNode("div", {
  12149. "role": "button",
  12150. "tabindex": 0,
  12151. "class": bem$w([props2.color, {
  12152. large: props2.large,
  12153. active: active.value,
  12154. delete: props2.type === "delete"
  12155. }])
  12156. }, [renderContent()])]);
  12157. }
  12158. });
  12159. const [name$w, bem$v] = createNamespace("number-keyboard");
  12160. const numberKeyboardProps = {
  12161. show: Boolean,
  12162. title: String,
  12163. theme: makeStringProp("default"),
  12164. zIndex: numericProp,
  12165. teleport: [String, Object],
  12166. maxlength: makeNumericProp(Infinity),
  12167. modelValue: makeStringProp(""),
  12168. transition: truthProp,
  12169. blurOnClose: truthProp,
  12170. showDeleteKey: truthProp,
  12171. randomKeyOrder: Boolean,
  12172. closeButtonText: String,
  12173. deleteButtonText: String,
  12174. closeButtonLoading: Boolean,
  12175. hideOnClickOutside: truthProp,
  12176. safeAreaInsetBottom: truthProp,
  12177. extraKey: {
  12178. type: [String, Array],
  12179. default: ""
  12180. }
  12181. };
  12182. function shuffle(array) {
  12183. for (let i = array.length - 1; i > 0; i--) {
  12184. const j = Math.floor(Math.random() * (i + 1));
  12185. const temp = array[i];
  12186. array[i] = array[j];
  12187. array[j] = temp;
  12188. }
  12189. return array;
  12190. }
  12191. var stdin_default$E = vue.defineComponent({
  12192. name: name$w,
  12193. inheritAttrs: false,
  12194. props: numberKeyboardProps,
  12195. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  12196. setup(props2, {
  12197. emit,
  12198. slots,
  12199. attrs
  12200. }) {
  12201. const root = vue.ref();
  12202. const genBasicKeys = () => {
  12203. const keys2 = Array(9).fill("").map((_, i) => ({
  12204. text: i + 1
  12205. }));
  12206. if (props2.randomKeyOrder) {
  12207. shuffle(keys2);
  12208. }
  12209. return keys2;
  12210. };
  12211. const genDefaultKeys = () => [...genBasicKeys(), {
  12212. text: props2.extraKey,
  12213. type: "extra"
  12214. }, {
  12215. text: 0
  12216. }, {
  12217. text: props2.showDeleteKey ? props2.deleteButtonText : "",
  12218. type: props2.showDeleteKey ? "delete" : ""
  12219. }];
  12220. const genCustomKeys = () => {
  12221. const keys2 = genBasicKeys();
  12222. const {
  12223. extraKey
  12224. } = props2;
  12225. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  12226. if (extraKeys.length === 0) {
  12227. keys2.push({
  12228. text: 0,
  12229. wider: true
  12230. });
  12231. } else if (extraKeys.length === 1) {
  12232. keys2.push({
  12233. text: 0,
  12234. wider: true
  12235. }, {
  12236. text: extraKeys[0],
  12237. type: "extra"
  12238. });
  12239. } else if (extraKeys.length === 2) {
  12240. keys2.push({
  12241. text: extraKeys[0],
  12242. type: "extra"
  12243. }, {
  12244. text: 0
  12245. }, {
  12246. text: extraKeys[1],
  12247. type: "extra"
  12248. });
  12249. }
  12250. return keys2;
  12251. };
  12252. const keys = vue.computed(() => props2.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  12253. const onBlur = () => {
  12254. if (props2.show) {
  12255. emit("blur");
  12256. }
  12257. };
  12258. const onClose = () => {
  12259. emit("close");
  12260. if (props2.blurOnClose) {
  12261. onBlur();
  12262. }
  12263. };
  12264. const onAnimationEnd = () => emit(props2.show ? "show" : "hide");
  12265. const onPress = (text, type) => {
  12266. if (text === "") {
  12267. if (type === "extra") {
  12268. onBlur();
  12269. }
  12270. return;
  12271. }
  12272. const value = props2.modelValue;
  12273. if (type === "delete") {
  12274. emit("delete");
  12275. emit("update:modelValue", value.slice(0, value.length - 1));
  12276. } else if (type === "close") {
  12277. onClose();
  12278. } else if (value.length < +props2.maxlength) {
  12279. emit("input", text);
  12280. emit("update:modelValue", value + text);
  12281. }
  12282. };
  12283. const renderTitle = () => {
  12284. const {
  12285. title,
  12286. theme,
  12287. closeButtonText
  12288. } = props2;
  12289. const leftSlot = slots["title-left"];
  12290. const showClose = closeButtonText && theme === "default";
  12291. const showTitle = title || showClose || leftSlot;
  12292. if (!showTitle) {
  12293. return;
  12294. }
  12295. return vue.createVNode("div", {
  12296. "class": bem$v("header")
  12297. }, [leftSlot && vue.createVNode("span", {
  12298. "class": bem$v("title-left")
  12299. }, [leftSlot()]), title && vue.createVNode("h2", {
  12300. "class": bem$v("title")
  12301. }, [title]), showClose && vue.createVNode("button", {
  12302. "type": "button",
  12303. "class": [bem$v("close"), HAPTICS_FEEDBACK],
  12304. "onClick": onClose
  12305. }, [closeButtonText])]);
  12306. };
  12307. const renderKeys = () => keys.value.map((key) => {
  12308. const keySlots = {};
  12309. if (key.type === "delete") {
  12310. keySlots.default = slots.delete;
  12311. }
  12312. if (key.type === "extra") {
  12313. keySlots.default = slots["extra-key"];
  12314. }
  12315. return vue.createVNode(stdin_default$F, {
  12316. "key": key.text,
  12317. "text": key.text,
  12318. "type": key.type,
  12319. "wider": key.wider,
  12320. "color": key.color,
  12321. "onPress": onPress
  12322. }, keySlots);
  12323. });
  12324. const renderSidebar = () => {
  12325. if (props2.theme === "custom") {
  12326. return vue.createVNode("div", {
  12327. "class": bem$v("sidebar")
  12328. }, [props2.showDeleteKey && vue.createVNode(stdin_default$F, {
  12329. "large": true,
  12330. "text": props2.deleteButtonText,
  12331. "type": "delete",
  12332. "onPress": onPress
  12333. }, {
  12334. default: slots.delete
  12335. }), vue.createVNode(stdin_default$F, {
  12336. "large": true,
  12337. "text": props2.closeButtonText,
  12338. "type": "close",
  12339. "color": "blue",
  12340. "loading": props2.closeButtonLoading,
  12341. "onPress": onPress
  12342. }, null)]);
  12343. }
  12344. };
  12345. vue.watch(() => props2.show, (value) => {
  12346. if (!props2.transition) {
  12347. emit(value ? "show" : "hide");
  12348. }
  12349. });
  12350. if (props2.hideOnClickOutside) {
  12351. use.useClickAway(root, onBlur, {
  12352. eventName: "touchstart"
  12353. });
  12354. }
  12355. return () => {
  12356. const Title = renderTitle();
  12357. const Content = vue.createVNode(vue.Transition, {
  12358. "name": props2.transition ? "van-slide-up" : ""
  12359. }, {
  12360. default: () => [vue.withDirectives(vue.createVNode("div", vue.mergeProps({
  12361. "ref": root,
  12362. "style": getZIndexStyle(props2.zIndex),
  12363. "class": bem$v({
  12364. unfit: !props2.safeAreaInsetBottom,
  12365. "with-title": !!Title
  12366. }),
  12367. "onAnimationend": onAnimationEnd,
  12368. "onTouchstartPassive": stopPropagation
  12369. }, attrs), [Title, vue.createVNode("div", {
  12370. "class": bem$v("body")
  12371. }, [vue.createVNode("div", {
  12372. "class": bem$v("keys")
  12373. }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props2.show]])]
  12374. });
  12375. if (props2.teleport) {
  12376. return vue.createVNode(vue.Teleport, {
  12377. "to": props2.teleport
  12378. }, {
  12379. default: () => [Content]
  12380. });
  12381. }
  12382. return Content;
  12383. };
  12384. }
  12385. });
  12386. const NumberKeyboard = withInstall(stdin_default$E);
  12387. const [name$v, bem$u, t$6] = createNamespace("pagination");
  12388. const makePage = (number, text, active) => ({
  12389. number,
  12390. text,
  12391. active
  12392. });
  12393. const paginationProps = {
  12394. mode: makeStringProp("multi"),
  12395. prevText: String,
  12396. nextText: String,
  12397. pageCount: makeNumericProp(0),
  12398. modelValue: makeNumberProp(0),
  12399. totalItems: makeNumericProp(0),
  12400. showPageSize: makeNumericProp(5),
  12401. itemsPerPage: makeNumericProp(10),
  12402. forceEllipses: Boolean,
  12403. showPrevButton: truthProp,
  12404. showNextButton: truthProp
  12405. };
  12406. var stdin_default$D = vue.defineComponent({
  12407. name: name$v,
  12408. props: paginationProps,
  12409. emits: ["change", "update:modelValue"],
  12410. setup(props2, {
  12411. emit,
  12412. slots
  12413. }) {
  12414. const count = vue.computed(() => {
  12415. const {
  12416. pageCount,
  12417. totalItems,
  12418. itemsPerPage
  12419. } = props2;
  12420. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  12421. return Math.max(1, count2);
  12422. });
  12423. const pages = vue.computed(() => {
  12424. const items = [];
  12425. const pageCount = count.value;
  12426. const showPageSize = +props2.showPageSize;
  12427. const {
  12428. modelValue,
  12429. forceEllipses
  12430. } = props2;
  12431. let startPage = 1;
  12432. let endPage = pageCount;
  12433. const isMaxSized = showPageSize < pageCount;
  12434. if (isMaxSized) {
  12435. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  12436. endPage = startPage + showPageSize - 1;
  12437. if (endPage > pageCount) {
  12438. endPage = pageCount;
  12439. startPage = endPage - showPageSize + 1;
  12440. }
  12441. }
  12442. for (let number = startPage; number <= endPage; number++) {
  12443. const page = makePage(number, number, number === modelValue);
  12444. items.push(page);
  12445. }
  12446. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  12447. if (startPage > 1) {
  12448. const prevPages = makePage(startPage - 1, "...");
  12449. items.unshift(prevPages);
  12450. }
  12451. if (endPage < pageCount) {
  12452. const nextPages = makePage(endPage + 1, "...");
  12453. items.push(nextPages);
  12454. }
  12455. }
  12456. return items;
  12457. });
  12458. const updateModelValue = (value, emitChange) => {
  12459. value = clamp(value, 1, count.value);
  12460. if (props2.modelValue !== value) {
  12461. emit("update:modelValue", value);
  12462. if (emitChange) {
  12463. emit("change", value);
  12464. }
  12465. }
  12466. };
  12467. vue.watchEffect(() => updateModelValue(props2.modelValue));
  12468. const renderDesc = () => vue.createVNode("li", {
  12469. "class": bem$u("page-desc")
  12470. }, [slots.pageDesc ? slots.pageDesc() : `${props2.modelValue}/${count.value}`]);
  12471. const renderPrevButton = () => {
  12472. const {
  12473. mode,
  12474. modelValue,
  12475. showPrevButton
  12476. } = props2;
  12477. if (!showPrevButton) {
  12478. return;
  12479. }
  12480. const slot = slots["prev-text"];
  12481. const disabled = modelValue === 1;
  12482. return vue.createVNode("li", {
  12483. "class": [bem$u("item", {
  12484. disabled,
  12485. border: mode === "simple",
  12486. prev: true
  12487. }), BORDER_SURROUND]
  12488. }, [vue.createVNode("button", {
  12489. "type": "button",
  12490. "disabled": disabled,
  12491. "onClick": () => updateModelValue(modelValue - 1, true)
  12492. }, [slot ? slot() : props2.prevText || t$6("prev")])]);
  12493. };
  12494. const renderNextButton = () => {
  12495. const {
  12496. mode,
  12497. modelValue,
  12498. showNextButton
  12499. } = props2;
  12500. if (!showNextButton) {
  12501. return;
  12502. }
  12503. const slot = slots["next-text"];
  12504. const disabled = modelValue === count.value;
  12505. return vue.createVNode("li", {
  12506. "class": [bem$u("item", {
  12507. disabled,
  12508. border: mode === "simple",
  12509. next: true
  12510. }), BORDER_SURROUND]
  12511. }, [vue.createVNode("button", {
  12512. "type": "button",
  12513. "disabled": disabled,
  12514. "onClick": () => updateModelValue(modelValue + 1, true)
  12515. }, [slot ? slot() : props2.nextText || t$6("next")])]);
  12516. };
  12517. const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
  12518. "class": [bem$u("item", {
  12519. active: page.active,
  12520. page: true
  12521. }), BORDER_SURROUND]
  12522. }, [vue.createVNode("button", {
  12523. "type": "button",
  12524. "aria-current": page.active || void 0,
  12525. "onClick": () => updateModelValue(page.number, true)
  12526. }, [slots.page ? slots.page(page) : page.text])]));
  12527. return () => vue.createVNode("nav", {
  12528. "role": "navigation",
  12529. "class": bem$u()
  12530. }, [vue.createVNode("ul", {
  12531. "class": bem$u("items")
  12532. }, [renderPrevButton(), props2.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  12533. }
  12534. });
  12535. const Pagination = withInstall(stdin_default$D);
  12536. const [name$u, bem$t] = createNamespace("password-input");
  12537. const passwordInputProps = {
  12538. info: String,
  12539. mask: truthProp,
  12540. value: makeStringProp(""),
  12541. gutter: numericProp,
  12542. length: makeNumericProp(6),
  12543. focused: Boolean,
  12544. errorInfo: String
  12545. };
  12546. var stdin_default$C = vue.defineComponent({
  12547. name: name$u,
  12548. props: passwordInputProps,
  12549. emits: ["focus"],
  12550. setup(props2, {
  12551. emit
  12552. }) {
  12553. const onTouchStart = (event) => {
  12554. event.stopPropagation();
  12555. emit("focus", event);
  12556. };
  12557. const renderPoints = () => {
  12558. const Points = [];
  12559. const {
  12560. mask,
  12561. value,
  12562. gutter,
  12563. focused
  12564. } = props2;
  12565. const length = +props2.length;
  12566. for (let i = 0; i < length; i++) {
  12567. const char = value[i];
  12568. const showBorder = i !== 0 && !gutter;
  12569. const showCursor = focused && i === value.length;
  12570. let style;
  12571. if (i !== 0 && gutter) {
  12572. style = {
  12573. marginLeft: addUnit(gutter)
  12574. };
  12575. }
  12576. Points.push(vue.createVNode("li", {
  12577. "class": [{
  12578. [BORDER_LEFT]: showBorder
  12579. }, bem$t("item", {
  12580. focus: showCursor
  12581. })],
  12582. "style": style
  12583. }, [mask ? vue.createVNode("i", {
  12584. "style": {
  12585. visibility: char ? "visible" : "hidden"
  12586. }
  12587. }, null) : char, showCursor && vue.createVNode("div", {
  12588. "class": bem$t("cursor")
  12589. }, null)]));
  12590. }
  12591. return Points;
  12592. };
  12593. return () => {
  12594. const info = props2.errorInfo || props2.info;
  12595. return vue.createVNode("div", {
  12596. "class": bem$t()
  12597. }, [vue.createVNode("ul", {
  12598. "class": [bem$t("security"), {
  12599. [BORDER_SURROUND]: !props2.gutter
  12600. }],
  12601. "onTouchstartPassive": onTouchStart
  12602. }, [renderPoints()]), info && vue.createVNode("div", {
  12603. "class": bem$t(props2.errorInfo ? "error-info" : "info")
  12604. }, [info])]);
  12605. };
  12606. }
  12607. });
  12608. const PasswordInput = withInstall(stdin_default$C);
  12609. const PickerGroup = withInstall(stdin_default$1A);
  12610. const [name$t, bem$s] = createNamespace("popover");
  12611. const popupProps = ["overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  12612. const popoverProps = {
  12613. show: Boolean,
  12614. theme: makeStringProp("light"),
  12615. overlay: Boolean,
  12616. actions: makeArrayProp(),
  12617. actionsDirection: makeStringProp("vertical"),
  12618. trigger: makeStringProp("click"),
  12619. duration: numericProp,
  12620. showArrow: truthProp,
  12621. placement: makeStringProp("bottom"),
  12622. iconPrefix: String,
  12623. overlayClass: unknownProp,
  12624. overlayStyle: Object,
  12625. closeOnClickAction: truthProp,
  12626. closeOnClickOverlay: truthProp,
  12627. closeOnClickOutside: truthProp,
  12628. offset: {
  12629. type: Array,
  12630. default: () => [0, 8]
  12631. },
  12632. teleport: {
  12633. type: [String, Object],
  12634. default: "body"
  12635. }
  12636. };
  12637. var stdin_default$B = vue.defineComponent({
  12638. name: name$t,
  12639. props: popoverProps,
  12640. emits: ["select", "touchstart", "update:show"],
  12641. setup(props2, {
  12642. emit,
  12643. slots,
  12644. attrs
  12645. }) {
  12646. let popper;
  12647. const popupRef = vue.ref();
  12648. const wrapperRef = vue.ref();
  12649. const popoverRef = vue.ref();
  12650. const show = useSyncPropRef(() => props2.show, (value) => emit("update:show", value));
  12651. const getPopoverOptions = () => ({
  12652. placement: props2.placement,
  12653. modifiers: [{
  12654. name: "computeStyles",
  12655. options: {
  12656. adaptive: false,
  12657. gpuAcceleration: false
  12658. }
  12659. }, extend({}, popperjs.offsetModifier, {
  12660. options: {
  12661. offset: props2.offset
  12662. }
  12663. })]
  12664. });
  12665. const createPopperInstance = () => {
  12666. if (wrapperRef.value && popoverRef.value) {
  12667. return popperjs.createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  12668. }
  12669. return null;
  12670. };
  12671. const updateLocation = () => {
  12672. vue.nextTick(() => {
  12673. if (!show.value) {
  12674. return;
  12675. }
  12676. if (!popper) {
  12677. popper = createPopperInstance();
  12678. if (inBrowser) {
  12679. window.addEventListener("animationend", updateLocation);
  12680. window.addEventListener("transitionend", updateLocation);
  12681. }
  12682. } else {
  12683. popper.setOptions(getPopoverOptions());
  12684. }
  12685. });
  12686. };
  12687. const updateShow = (value) => {
  12688. show.value = value;
  12689. };
  12690. const onClickWrapper = () => {
  12691. if (props2.trigger === "click") {
  12692. show.value = !show.value;
  12693. }
  12694. };
  12695. const onClickAction = (action, index) => {
  12696. if (action.disabled) {
  12697. return;
  12698. }
  12699. emit("select", action, index);
  12700. if (props2.closeOnClickAction) {
  12701. show.value = false;
  12702. }
  12703. };
  12704. const onClickAway = () => {
  12705. if (show.value && props2.closeOnClickOutside && (!props2.overlay || props2.closeOnClickOverlay)) {
  12706. show.value = false;
  12707. }
  12708. };
  12709. const renderActionContent = (action, index) => {
  12710. if (slots.action) {
  12711. return slots.action({
  12712. action,
  12713. index
  12714. });
  12715. }
  12716. return [action.icon && vue.createVNode(Icon, {
  12717. "name": action.icon,
  12718. "classPrefix": props2.iconPrefix,
  12719. "class": bem$s("action-icon")
  12720. }, null), vue.createVNode("div", {
  12721. "class": [bem$s("action-text"), {
  12722. [BORDER_BOTTOM]: props2.actionsDirection === "vertical"
  12723. }]
  12724. }, [action.text])];
  12725. };
  12726. const renderAction = (action, index) => {
  12727. const {
  12728. icon,
  12729. color,
  12730. disabled,
  12731. className
  12732. } = action;
  12733. return vue.createVNode("div", {
  12734. "role": "menuitem",
  12735. "class": [bem$s("action", {
  12736. disabled,
  12737. "with-icon": icon
  12738. }), {
  12739. [BORDER_RIGHT]: props2.actionsDirection === "horizontal"
  12740. }, className],
  12741. "style": {
  12742. color
  12743. },
  12744. "tabindex": disabled ? void 0 : 0,
  12745. "aria-disabled": disabled || void 0,
  12746. "onClick": () => onClickAction(action, index)
  12747. }, [renderActionContent(action, index)]);
  12748. };
  12749. vue.onMounted(() => {
  12750. updateLocation();
  12751. vue.watchEffect(() => {
  12752. var _a;
  12753. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  12754. });
  12755. });
  12756. vue.onBeforeUnmount(() => {
  12757. if (popper) {
  12758. if (inBrowser) {
  12759. window.removeEventListener("animationend", updateLocation);
  12760. window.removeEventListener("transitionend", updateLocation);
  12761. }
  12762. popper.destroy();
  12763. popper = null;
  12764. }
  12765. });
  12766. vue.watch(() => [show.value, props2.offset, props2.placement], updateLocation);
  12767. use.useClickAway([wrapperRef, popupRef], onClickAway, {
  12768. eventName: "touchstart"
  12769. });
  12770. return () => {
  12771. var _a;
  12772. return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
  12773. "ref": wrapperRef,
  12774. "class": bem$s("wrapper"),
  12775. "onClick": onClickWrapper
  12776. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
  12777. "ref": popoverRef,
  12778. "show": show.value,
  12779. "class": bem$s([props2.theme]),
  12780. "position": "",
  12781. "transition": "van-popover-zoom",
  12782. "lockScroll": false,
  12783. "onUpdate:show": updateShow
  12784. }, attrs, useScopeId(), pick(props2, popupProps)), {
  12785. default: () => [props2.showArrow && vue.createVNode("div", {
  12786. "class": bem$s("arrow")
  12787. }, null), vue.createVNode("div", {
  12788. "role": "menu",
  12789. "class": bem$s("content", props2.actionsDirection)
  12790. }, [slots.default ? slots.default() : props2.actions.map(renderAction)])]
  12791. })]);
  12792. };
  12793. }
  12794. });
  12795. const Popover = withInstall(stdin_default$B);
  12796. const [name$s, bem$r] = createNamespace("progress");
  12797. const progressProps = {
  12798. color: String,
  12799. inactive: Boolean,
  12800. pivotText: String,
  12801. textColor: String,
  12802. showPivot: truthProp,
  12803. pivotColor: String,
  12804. trackColor: String,
  12805. strokeWidth: numericProp,
  12806. percentage: {
  12807. type: numericProp,
  12808. default: 0,
  12809. validator: (value) => +value >= 0 && +value <= 100
  12810. }
  12811. };
  12812. var stdin_default$A = vue.defineComponent({
  12813. name: name$s,
  12814. props: progressProps,
  12815. setup(props2) {
  12816. const background = vue.computed(() => props2.inactive ? void 0 : props2.color);
  12817. const renderPivot = () => {
  12818. const {
  12819. textColor,
  12820. pivotText,
  12821. pivotColor,
  12822. percentage
  12823. } = props2;
  12824. const text = pivotText != null ? pivotText : `${percentage}%`;
  12825. if (props2.showPivot && text) {
  12826. const style = {
  12827. color: textColor,
  12828. left: `${+percentage}%`,
  12829. transform: `translate(-${+percentage}%,-50%)`,
  12830. background: pivotColor || background.value
  12831. };
  12832. return vue.createVNode("span", {
  12833. "style": style,
  12834. "class": bem$r("pivot", {
  12835. inactive: props2.inactive
  12836. })
  12837. }, [text]);
  12838. }
  12839. };
  12840. return () => {
  12841. const {
  12842. trackColor,
  12843. percentage,
  12844. strokeWidth
  12845. } = props2;
  12846. const rootStyle = {
  12847. background: trackColor,
  12848. height: addUnit(strokeWidth)
  12849. };
  12850. const portionStyle = {
  12851. width: `${percentage}%`,
  12852. background: background.value
  12853. };
  12854. return vue.createVNode("div", {
  12855. "class": bem$r(),
  12856. "style": rootStyle
  12857. }, [vue.createVNode("span", {
  12858. "class": bem$r("portion", {
  12859. inactive: props2.inactive
  12860. }),
  12861. "style": portionStyle
  12862. }, null), renderPivot()]);
  12863. };
  12864. }
  12865. });
  12866. const Progress = withInstall(stdin_default$A);
  12867. const [name$r, bem$q, t$5] = createNamespace("pull-refresh");
  12868. const DEFAULT_HEAD_HEIGHT = 50;
  12869. const TEXT_STATUS = ["pulling", "loosing", "success"];
  12870. const pullRefreshProps = {
  12871. disabled: Boolean,
  12872. modelValue: Boolean,
  12873. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  12874. successText: String,
  12875. pullingText: String,
  12876. loosingText: String,
  12877. loadingText: String,
  12878. pullDistance: numericProp,
  12879. successDuration: makeNumericProp(500),
  12880. animationDuration: makeNumericProp(300)
  12881. };
  12882. var stdin_default$z = vue.defineComponent({
  12883. name: name$r,
  12884. props: pullRefreshProps,
  12885. emits: ["change", "refresh", "update:modelValue"],
  12886. setup(props2, {
  12887. emit,
  12888. slots
  12889. }) {
  12890. let reachTop;
  12891. const root = vue.ref();
  12892. const track = vue.ref();
  12893. const scrollParent = use.useScrollParent(root);
  12894. const state = vue.reactive({
  12895. status: "normal",
  12896. distance: 0,
  12897. duration: 0
  12898. });
  12899. const touch = useTouch();
  12900. const getHeadStyle = () => {
  12901. if (props2.headHeight !== DEFAULT_HEAD_HEIGHT) {
  12902. return {
  12903. height: `${props2.headHeight}px`
  12904. };
  12905. }
  12906. };
  12907. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props2.disabled;
  12908. const ease = (distance) => {
  12909. const pullDistance = +(props2.pullDistance || props2.headHeight);
  12910. if (distance > pullDistance) {
  12911. if (distance < pullDistance * 2) {
  12912. distance = pullDistance + (distance - pullDistance) / 2;
  12913. } else {
  12914. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  12915. }
  12916. }
  12917. return Math.round(distance);
  12918. };
  12919. const setStatus = (distance, isLoading) => {
  12920. const pullDistance = +(props2.pullDistance || props2.headHeight);
  12921. state.distance = distance;
  12922. if (isLoading) {
  12923. state.status = "loading";
  12924. } else if (distance === 0) {
  12925. state.status = "normal";
  12926. } else if (distance < pullDistance) {
  12927. state.status = "pulling";
  12928. } else {
  12929. state.status = "loosing";
  12930. }
  12931. emit("change", {
  12932. status: state.status,
  12933. distance
  12934. });
  12935. };
  12936. const getStatusText = () => {
  12937. const {
  12938. status
  12939. } = state;
  12940. if (status === "normal") {
  12941. return "";
  12942. }
  12943. return props2[`${status}Text`] || t$5(status);
  12944. };
  12945. const renderStatus = () => {
  12946. const {
  12947. status,
  12948. distance
  12949. } = state;
  12950. if (slots[status]) {
  12951. return slots[status]({
  12952. distance
  12953. });
  12954. }
  12955. const nodes = [];
  12956. if (TEXT_STATUS.includes(status)) {
  12957. nodes.push(vue.createVNode("div", {
  12958. "class": bem$q("text")
  12959. }, [getStatusText()]));
  12960. }
  12961. if (status === "loading") {
  12962. nodes.push(vue.createVNode(Loading, {
  12963. "class": bem$q("loading")
  12964. }, {
  12965. default: getStatusText
  12966. }));
  12967. }
  12968. return nodes;
  12969. };
  12970. const showSuccessTip = () => {
  12971. state.status = "success";
  12972. setTimeout(() => {
  12973. setStatus(0);
  12974. }, +props2.successDuration);
  12975. };
  12976. const checkPosition = (event) => {
  12977. reachTop = getScrollTop(scrollParent.value) === 0;
  12978. if (reachTop) {
  12979. state.duration = 0;
  12980. touch.start(event);
  12981. }
  12982. };
  12983. const onTouchStart = (event) => {
  12984. if (isTouchable()) {
  12985. checkPosition(event);
  12986. }
  12987. };
  12988. const onTouchMove = (event) => {
  12989. if (isTouchable()) {
  12990. if (!reachTop) {
  12991. checkPosition(event);
  12992. }
  12993. const {
  12994. deltaY
  12995. } = touch;
  12996. touch.move(event);
  12997. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  12998. preventDefault(event);
  12999. setStatus(ease(deltaY.value));
  13000. }
  13001. }
  13002. };
  13003. const onTouchEnd = () => {
  13004. if (reachTop && touch.deltaY.value && isTouchable()) {
  13005. state.duration = +props2.animationDuration;
  13006. if (state.status === "loosing") {
  13007. setStatus(+props2.headHeight, true);
  13008. emit("update:modelValue", true);
  13009. vue.nextTick(() => emit("refresh"));
  13010. } else {
  13011. setStatus(0);
  13012. }
  13013. }
  13014. };
  13015. vue.watch(() => props2.modelValue, (value) => {
  13016. state.duration = +props2.animationDuration;
  13017. if (value) {
  13018. setStatus(+props2.headHeight, true);
  13019. } else if (slots.success || props2.successText) {
  13020. showSuccessTip();
  13021. } else {
  13022. setStatus(0, false);
  13023. }
  13024. });
  13025. use.useEventListener("touchmove", onTouchMove, {
  13026. target: track
  13027. });
  13028. return () => {
  13029. var _a;
  13030. const trackStyle = {
  13031. transitionDuration: `${state.duration}ms`,
  13032. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  13033. };
  13034. return vue.createVNode("div", {
  13035. "ref": root,
  13036. "class": bem$q()
  13037. }, [vue.createVNode("div", {
  13038. "ref": track,
  13039. "class": bem$q("track"),
  13040. "style": trackStyle,
  13041. "onTouchstartPassive": onTouchStart,
  13042. "onTouchend": onTouchEnd,
  13043. "onTouchcancel": onTouchEnd
  13044. }, [vue.createVNode("div", {
  13045. "class": bem$q("head"),
  13046. "style": getHeadStyle()
  13047. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  13048. };
  13049. }
  13050. });
  13051. const PullRefresh = withInstall(stdin_default$z);
  13052. const [name$q, bem$p] = createNamespace("rate");
  13053. function getRateStatus(value, index, allowHalf, readonly) {
  13054. if (value >= index) {
  13055. return {
  13056. status: "full",
  13057. value: 1
  13058. };
  13059. }
  13060. if (value + 0.5 >= index && allowHalf && !readonly) {
  13061. return {
  13062. status: "half",
  13063. value: 0.5
  13064. };
  13065. }
  13066. if (value + 1 >= index && allowHalf && readonly) {
  13067. const cardinal = 10 ** 10;
  13068. return {
  13069. status: "half",
  13070. value: Math.round((value - index + 1) * cardinal) / cardinal
  13071. };
  13072. }
  13073. return {
  13074. status: "void",
  13075. value: 0
  13076. };
  13077. }
  13078. const rateProps = {
  13079. size: numericProp,
  13080. icon: makeStringProp("star"),
  13081. color: String,
  13082. count: makeNumericProp(5),
  13083. gutter: numericProp,
  13084. clearable: Boolean,
  13085. readonly: Boolean,
  13086. disabled: Boolean,
  13087. voidIcon: makeStringProp("star-o"),
  13088. allowHalf: Boolean,
  13089. voidColor: String,
  13090. touchable: truthProp,
  13091. iconPrefix: String,
  13092. modelValue: makeNumberProp(0),
  13093. disabledColor: String
  13094. };
  13095. var stdin_default$y = vue.defineComponent({
  13096. name: name$q,
  13097. props: rateProps,
  13098. emits: ["change", "update:modelValue"],
  13099. setup(props2, {
  13100. emit
  13101. }) {
  13102. const touch = useTouch();
  13103. const [itemRefs, setItemRefs] = useRefs();
  13104. const groupRef = vue.ref();
  13105. const unselectable = vue.computed(() => props2.readonly || props2.disabled);
  13106. const untouchable = vue.computed(() => unselectable.value || !props2.touchable);
  13107. const list = vue.computed(() => Array(+props2.count).fill("").map((_, i) => getRateStatus(props2.modelValue, i + 1, props2.allowHalf, props2.readonly)));
  13108. let ranges;
  13109. let groupRefRect;
  13110. let minRectTop = Number.MAX_SAFE_INTEGER;
  13111. let maxRectTop = Number.MIN_SAFE_INTEGER;
  13112. const updateRanges = () => {
  13113. groupRefRect = use.useRect(groupRef);
  13114. const rects = itemRefs.value.map(use.useRect);
  13115. ranges = [];
  13116. rects.forEach((rect, index) => {
  13117. minRectTop = Math.min(rect.top, minRectTop);
  13118. maxRectTop = Math.max(rect.top, maxRectTop);
  13119. if (props2.allowHalf) {
  13120. ranges.push({
  13121. score: index + 0.5,
  13122. left: rect.left,
  13123. top: rect.top,
  13124. height: rect.height
  13125. }, {
  13126. score: index + 1,
  13127. left: rect.left + rect.width / 2,
  13128. top: rect.top,
  13129. height: rect.height
  13130. });
  13131. } else {
  13132. ranges.push({
  13133. score: index + 1,
  13134. left: rect.left,
  13135. top: rect.top,
  13136. height: rect.height
  13137. });
  13138. }
  13139. });
  13140. };
  13141. const getScoreByPosition = (x, y) => {
  13142. for (let i = ranges.length - 1; i > 0; i--) {
  13143. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  13144. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  13145. return ranges[i].score;
  13146. }
  13147. } else {
  13148. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  13149. if (x > ranges[i].left && ranges[i].top === curTop) {
  13150. return ranges[i].score;
  13151. }
  13152. }
  13153. }
  13154. return props2.allowHalf ? 0.5 : 1;
  13155. };
  13156. const select = (value) => {
  13157. if (unselectable.value || value === props2.modelValue) return;
  13158. emit("update:modelValue", value);
  13159. emit("change", value);
  13160. };
  13161. const onTouchStart = (event) => {
  13162. if (untouchable.value) {
  13163. return;
  13164. }
  13165. touch.start(event);
  13166. updateRanges();
  13167. };
  13168. const onTouchMove = (event) => {
  13169. if (untouchable.value) {
  13170. return;
  13171. }
  13172. touch.move(event);
  13173. if (touch.isHorizontal() && !touch.isTap.value) {
  13174. const {
  13175. clientX,
  13176. clientY
  13177. } = event.touches[0];
  13178. preventDefault(event);
  13179. select(getScoreByPosition(clientX, clientY));
  13180. }
  13181. };
  13182. const renderStar = (item, index) => {
  13183. const {
  13184. icon,
  13185. size,
  13186. color,
  13187. count,
  13188. gutter,
  13189. voidIcon,
  13190. disabled,
  13191. voidColor,
  13192. allowHalf,
  13193. iconPrefix,
  13194. disabledColor
  13195. } = props2;
  13196. const score = index + 1;
  13197. const isFull = item.status === "full";
  13198. const isVoid = item.status === "void";
  13199. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  13200. let style;
  13201. if (gutter && score !== +count) {
  13202. style = {
  13203. paddingRight: addUnit(gutter)
  13204. };
  13205. }
  13206. const onClickItem = (event) => {
  13207. updateRanges();
  13208. let value = allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score;
  13209. if (props2.clearable && touch.isTap.value && value === props2.modelValue) {
  13210. value = 0;
  13211. }
  13212. select(value);
  13213. };
  13214. return vue.createVNode("div", {
  13215. "key": index,
  13216. "ref": setItemRefs(index),
  13217. "role": "radio",
  13218. "style": style,
  13219. "class": bem$p("item"),
  13220. "tabindex": disabled ? void 0 : 0,
  13221. "aria-setsize": count,
  13222. "aria-posinset": score,
  13223. "aria-checked": !isVoid,
  13224. "onClick": onClickItem
  13225. }, [vue.createVNode(Icon, {
  13226. "size": size,
  13227. "name": isFull ? icon : voidIcon,
  13228. "class": bem$p("icon", {
  13229. disabled,
  13230. full: isFull
  13231. }),
  13232. "color": disabled ? disabledColor : isFull ? color : voidColor,
  13233. "classPrefix": iconPrefix
  13234. }, null), renderHalf && vue.createVNode(Icon, {
  13235. "size": size,
  13236. "style": {
  13237. width: item.value + "em"
  13238. },
  13239. "name": isVoid ? voidIcon : icon,
  13240. "class": bem$p("icon", ["half", {
  13241. disabled,
  13242. full: !isVoid
  13243. }]),
  13244. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  13245. "classPrefix": iconPrefix
  13246. }, null)]);
  13247. };
  13248. use.useCustomFieldValue(() => props2.modelValue);
  13249. use.useEventListener("touchmove", onTouchMove, {
  13250. target: groupRef
  13251. });
  13252. return () => vue.createVNode("div", {
  13253. "ref": groupRef,
  13254. "role": "radiogroup",
  13255. "class": bem$p({
  13256. readonly: props2.readonly,
  13257. disabled: props2.disabled
  13258. }),
  13259. "tabindex": props2.disabled ? void 0 : 0,
  13260. "aria-disabled": props2.disabled,
  13261. "aria-readonly": props2.readonly,
  13262. "onTouchstartPassive": onTouchStart
  13263. }, [list.value.map(renderStar)]);
  13264. }
  13265. });
  13266. const Rate = withInstall(stdin_default$y);
  13267. const props = {
  13268. figureArr: makeArrayProp(),
  13269. delay: Number,
  13270. duration: makeNumberProp(2),
  13271. isStart: Boolean,
  13272. direction: makeStringProp("down"),
  13273. height: makeNumberProp(40)
  13274. };
  13275. const [name$p, bem$o] = createNamespace("rolling-text-item");
  13276. var stdin_default$x = vue.defineComponent({
  13277. name: name$p,
  13278. props,
  13279. setup(props2) {
  13280. const newFigureArr = vue.computed(() => props2.direction === "down" ? props2.figureArr.slice().reverse() : props2.figureArr);
  13281. const translatePx = vue.computed(() => {
  13282. const totalHeight = props2.height * (props2.figureArr.length - 1);
  13283. return `-${totalHeight}px`;
  13284. });
  13285. const itemStyle = vue.computed(() => ({
  13286. lineHeight: addUnit(props2.height)
  13287. }));
  13288. const rootStyle = vue.computed(() => ({
  13289. height: addUnit(props2.height),
  13290. "--van-translate": translatePx.value,
  13291. "--van-duration": props2.duration + "s",
  13292. "--van-delay": props2.delay + "s"
  13293. }));
  13294. return () => vue.createVNode("div", {
  13295. "class": bem$o([props2.direction]),
  13296. "style": rootStyle.value
  13297. }, [vue.createVNode("div", {
  13298. "class": bem$o("box", {
  13299. animate: props2.isStart
  13300. })
  13301. }, [Array.isArray(newFigureArr.value) && newFigureArr.value.map((figure) => vue.createVNode("div", {
  13302. "class": bem$o("item"),
  13303. "style": itemStyle.value
  13304. }, [figure]))])]);
  13305. }
  13306. });
  13307. const [name$o, bem$n] = createNamespace("rolling-text");
  13308. const rollingTextProps = {
  13309. startNum: makeNumberProp(0),
  13310. targetNum: Number,
  13311. textList: makeArrayProp(),
  13312. duration: makeNumberProp(2),
  13313. autoStart: truthProp,
  13314. direction: makeStringProp("down"),
  13315. stopOrder: makeStringProp("ltr"),
  13316. height: makeNumberProp(40)
  13317. };
  13318. const CIRCLE_NUM = 2;
  13319. var stdin_default$w = vue.defineComponent({
  13320. name: name$o,
  13321. props: rollingTextProps,
  13322. setup(props2) {
  13323. const isCustomType = vue.computed(() => Array.isArray(props2.textList) && props2.textList.length);
  13324. const itemLength = vue.computed(() => {
  13325. if (isCustomType.value) return props2.textList[0].length;
  13326. return `${Math.max(props2.startNum, props2.targetNum)}`.length;
  13327. });
  13328. const getTextArrByIdx = (idx) => {
  13329. const result = [];
  13330. for (let i = 0; i < props2.textList.length; i++) {
  13331. result.push(props2.textList[i][idx]);
  13332. }
  13333. return result;
  13334. };
  13335. const targetNumArr = vue.computed(() => {
  13336. if (isCustomType.value) return new Array(itemLength.value).fill("");
  13337. return padZero(props2.targetNum, itemLength.value).split("");
  13338. });
  13339. const startNumArr = vue.computed(() => padZero(props2.startNum, itemLength.value).split(""));
  13340. const getFigureArr = (i) => {
  13341. const start2 = +startNumArr.value[i];
  13342. const target = +targetNumArr.value[i];
  13343. const result = [];
  13344. for (let i2 = start2; i2 <= 9; i2++) {
  13345. result.push(i2);
  13346. }
  13347. for (let i2 = 0; i2 <= CIRCLE_NUM; i2++) {
  13348. for (let j = 0; j <= 9; j++) {
  13349. result.push(j);
  13350. }
  13351. }
  13352. for (let i2 = 0; i2 <= target; i2++) {
  13353. result.push(i2);
  13354. }
  13355. return result;
  13356. };
  13357. const getDelay = (i, len) => {
  13358. if (props2.stopOrder === "ltr") return 0.2 * i;
  13359. return 0.2 * (len - 1 - i);
  13360. };
  13361. const rolling = vue.ref(props2.autoStart);
  13362. const start = () => {
  13363. rolling.value = true;
  13364. };
  13365. const reset = () => {
  13366. rolling.value = false;
  13367. if (props2.autoStart) {
  13368. use.raf(() => start());
  13369. }
  13370. };
  13371. vue.watch(() => props2.autoStart, (value) => {
  13372. if (value) {
  13373. start();
  13374. }
  13375. });
  13376. useExpose({
  13377. start,
  13378. reset
  13379. });
  13380. return () => vue.createVNode("div", {
  13381. "class": bem$n()
  13382. }, [targetNumArr.value.map((_, i) => vue.createVNode(stdin_default$x, {
  13383. "figureArr": isCustomType.value ? getTextArrByIdx(i) : getFigureArr(i),
  13384. "duration": props2.duration,
  13385. "direction": props2.direction,
  13386. "isStart": rolling.value,
  13387. "height": props2.height,
  13388. "delay": getDelay(i, itemLength.value)
  13389. }, null))]);
  13390. }
  13391. });
  13392. const RollingText = withInstall(stdin_default$w);
  13393. const Row = withInstall(stdin_default$17);
  13394. const [name$n, bem$m, t$4] = createNamespace("search");
  13395. const searchProps = extend({}, fieldSharedProps, {
  13396. label: String,
  13397. shape: makeStringProp("square"),
  13398. leftIcon: makeStringProp("search"),
  13399. clearable: truthProp,
  13400. actionText: String,
  13401. background: String,
  13402. showAction: Boolean
  13403. });
  13404. var stdin_default$v = vue.defineComponent({
  13405. name: name$n,
  13406. props: searchProps,
  13407. emits: ["blur", "focus", "clear", "search", "cancel", "clickInput", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  13408. setup(props2, {
  13409. emit,
  13410. slots,
  13411. attrs
  13412. }) {
  13413. const id = useId();
  13414. const fieldRef = vue.ref();
  13415. const onCancel = () => {
  13416. if (!slots.action) {
  13417. emit("update:modelValue", "");
  13418. emit("cancel");
  13419. }
  13420. };
  13421. const onKeypress = (event) => {
  13422. const ENTER_CODE = 13;
  13423. if (event.keyCode === ENTER_CODE) {
  13424. preventDefault(event);
  13425. emit("search", props2.modelValue);
  13426. }
  13427. };
  13428. const getInputId = () => props2.id || `${id}-input`;
  13429. const renderLabel = () => {
  13430. if (slots.label || props2.label) {
  13431. return vue.createVNode("label", {
  13432. "class": bem$m("label"),
  13433. "for": getInputId(),
  13434. "data-allow-mismatch": "attribute"
  13435. }, [slots.label ? slots.label() : props2.label]);
  13436. }
  13437. };
  13438. const renderAction = () => {
  13439. if (props2.showAction) {
  13440. const text = props2.actionText || t$4("cancel");
  13441. return vue.createVNode("div", {
  13442. "class": bem$m("action"),
  13443. "role": "button",
  13444. "tabindex": 0,
  13445. "onClick": onCancel
  13446. }, [slots.action ? slots.action() : text]);
  13447. }
  13448. };
  13449. const blur = () => {
  13450. var _a;
  13451. return (_a = fieldRef.value) == null ? void 0 : _a.blur();
  13452. };
  13453. const focus = () => {
  13454. var _a;
  13455. return (_a = fieldRef.value) == null ? void 0 : _a.focus();
  13456. };
  13457. const onBlur = (event) => emit("blur", event);
  13458. const onFocus = (event) => emit("focus", event);
  13459. const onClear = (event) => emit("clear", event);
  13460. const onClickInput = (event) => emit("clickInput", event);
  13461. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  13462. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  13463. const fieldPropNames = Object.keys(fieldSharedProps);
  13464. const renderField = () => {
  13465. const fieldAttrs = extend({}, attrs, pick(props2, fieldPropNames), {
  13466. id: getInputId()
  13467. });
  13468. const onInput = (value) => emit("update:modelValue", value);
  13469. return vue.createVNode(Field, vue.mergeProps({
  13470. "ref": fieldRef,
  13471. "type": "search",
  13472. "class": bem$m("field", {
  13473. "with-message": fieldAttrs.errorMessage
  13474. }),
  13475. "border": false,
  13476. "onBlur": onBlur,
  13477. "onFocus": onFocus,
  13478. "onClear": onClear,
  13479. "onKeypress": onKeypress,
  13480. "onClickInput": onClickInput,
  13481. "onClickLeftIcon": onClickLeftIcon,
  13482. "onClickRightIcon": onClickRightIcon,
  13483. "onUpdate:modelValue": onInput
  13484. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  13485. };
  13486. useExpose({
  13487. focus,
  13488. blur
  13489. });
  13490. return () => {
  13491. var _a;
  13492. return vue.createVNode("div", {
  13493. "class": bem$m({
  13494. "show-action": props2.showAction
  13495. }),
  13496. "style": {
  13497. background: props2.background
  13498. }
  13499. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
  13500. "class": bem$m("content", props2.shape)
  13501. }, [renderLabel(), renderField()]), renderAction()]);
  13502. };
  13503. }
  13504. });
  13505. const Search = withInstall(stdin_default$v);
  13506. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  13507. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  13508. const iconMap = {
  13509. qq: "qq",
  13510. link: "link-o",
  13511. weibo: "weibo",
  13512. qrcode: "qr",
  13513. poster: "photo-o",
  13514. wechat: "wechat",
  13515. "weapp-qrcode": "miniprogram-o",
  13516. "wechat-moments": "wechat-moments"
  13517. };
  13518. const [name$m, bem$l, t$3] = createNamespace("share-sheet");
  13519. const shareSheetProps = extend({}, popupSharedProps, {
  13520. title: String,
  13521. round: truthProp,
  13522. options: makeArrayProp(),
  13523. cancelText: String,
  13524. description: String,
  13525. closeOnPopstate: truthProp,
  13526. safeAreaInsetBottom: truthProp
  13527. });
  13528. var stdin_default$u = vue.defineComponent({
  13529. name: name$m,
  13530. props: shareSheetProps,
  13531. emits: ["cancel", "select", "update:show"],
  13532. setup(props2, {
  13533. emit,
  13534. slots
  13535. }) {
  13536. const updateShow = (value) => emit("update:show", value);
  13537. const onCancel = () => {
  13538. updateShow(false);
  13539. emit("cancel");
  13540. };
  13541. const onSelect = (option, index) => emit("select", option, index);
  13542. const renderHeader = () => {
  13543. const title = slots.title ? slots.title() : props2.title;
  13544. const description = slots.description ? slots.description() : props2.description;
  13545. if (title || description) {
  13546. return vue.createVNode("div", {
  13547. "class": bem$l("header")
  13548. }, [title && vue.createVNode("h2", {
  13549. "class": bem$l("title")
  13550. }, [title]), description && vue.createVNode("span", {
  13551. "class": bem$l("description")
  13552. }, [description])]);
  13553. }
  13554. };
  13555. const renderIcon = (icon) => {
  13556. if (isImage(icon)) {
  13557. return vue.createVNode("img", {
  13558. "src": icon,
  13559. "class": bem$l("image-icon")
  13560. }, null);
  13561. }
  13562. return vue.createVNode("div", {
  13563. "class": bem$l("icon", [icon])
  13564. }, [vue.createVNode(Icon, {
  13565. "name": iconMap[icon] || icon
  13566. }, null)]);
  13567. };
  13568. const renderOption = (option, index) => {
  13569. const {
  13570. name: name2,
  13571. icon,
  13572. className,
  13573. description
  13574. } = option;
  13575. return vue.createVNode("div", {
  13576. "role": "button",
  13577. "tabindex": 0,
  13578. "class": [bem$l("option"), className, HAPTICS_FEEDBACK],
  13579. "onClick": () => onSelect(option, index)
  13580. }, [renderIcon(icon), name2 && vue.createVNode("span", {
  13581. "class": bem$l("name")
  13582. }, [name2]), description && vue.createVNode("span", {
  13583. "class": bem$l("option-description")
  13584. }, [description])]);
  13585. };
  13586. const renderOptions = (options, border) => vue.createVNode("div", {
  13587. "class": bem$l("options", {
  13588. border
  13589. })
  13590. }, [options.map(renderOption)]);
  13591. const renderRows = () => {
  13592. const {
  13593. options
  13594. } = props2;
  13595. if (Array.isArray(options[0])) {
  13596. return options.map((item, index) => renderOptions(item, index !== 0));
  13597. }
  13598. return renderOptions(options);
  13599. };
  13600. const renderCancelButton = () => {
  13601. var _a;
  13602. const cancelText = (_a = props2.cancelText) != null ? _a : t$3("cancel");
  13603. if (slots.cancel || cancelText) {
  13604. return vue.createVNode("button", {
  13605. "type": "button",
  13606. "class": bem$l("cancel"),
  13607. "onClick": onCancel
  13608. }, [slots.cancel ? slots.cancel() : cancelText]);
  13609. }
  13610. };
  13611. return () => vue.createVNode(Popup, vue.mergeProps({
  13612. "class": bem$l(),
  13613. "position": "bottom",
  13614. "onUpdate:show": updateShow
  13615. }, pick(props2, popupInheritKeys)), {
  13616. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  13617. });
  13618. }
  13619. });
  13620. const ShareSheet = withInstall(stdin_default$u);
  13621. const [name$l, bem$k] = createNamespace("sidebar");
  13622. const SIDEBAR_KEY = Symbol(name$l);
  13623. const sidebarProps = {
  13624. modelValue: makeNumericProp(0)
  13625. };
  13626. var stdin_default$t = vue.defineComponent({
  13627. name: name$l,
  13628. props: sidebarProps,
  13629. emits: ["change", "update:modelValue"],
  13630. setup(props2, {
  13631. emit,
  13632. slots
  13633. }) {
  13634. const {
  13635. linkChildren
  13636. } = use.useChildren(SIDEBAR_KEY);
  13637. const getActive = () => +props2.modelValue;
  13638. const setActive = (value) => {
  13639. if (value !== getActive()) {
  13640. emit("update:modelValue", value);
  13641. emit("change", value);
  13642. }
  13643. };
  13644. linkChildren({
  13645. getActive,
  13646. setActive
  13647. });
  13648. return () => {
  13649. var _a;
  13650. return vue.createVNode("div", {
  13651. "role": "tablist",
  13652. "class": bem$k()
  13653. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13654. };
  13655. }
  13656. });
  13657. const Sidebar = withInstall(stdin_default$t);
  13658. const [name$k, bem$j] = createNamespace("sidebar-item");
  13659. const sidebarItemProps = extend({}, routeProps, {
  13660. dot: Boolean,
  13661. title: String,
  13662. badge: numericProp,
  13663. disabled: Boolean,
  13664. badgeProps: Object
  13665. });
  13666. var stdin_default$s = vue.defineComponent({
  13667. name: name$k,
  13668. props: sidebarItemProps,
  13669. emits: ["click"],
  13670. setup(props2, {
  13671. emit,
  13672. slots
  13673. }) {
  13674. const route2 = useRoute();
  13675. const {
  13676. parent,
  13677. index
  13678. } = use.useParent(SIDEBAR_KEY);
  13679. if (!parent) {
  13680. if (process.env.NODE_ENV !== "production") {
  13681. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  13682. }
  13683. return;
  13684. }
  13685. const onClick = () => {
  13686. if (props2.disabled) {
  13687. return;
  13688. }
  13689. emit("click", index.value);
  13690. parent.setActive(index.value);
  13691. route2();
  13692. };
  13693. return () => {
  13694. const {
  13695. dot,
  13696. badge,
  13697. title,
  13698. disabled
  13699. } = props2;
  13700. const selected = index.value === parent.getActive();
  13701. return vue.createVNode("div", {
  13702. "role": "tab",
  13703. "class": bem$j({
  13704. select: selected,
  13705. disabled
  13706. }),
  13707. "tabindex": disabled ? void 0 : 0,
  13708. "aria-selected": selected,
  13709. "onClick": onClick
  13710. }, [vue.createVNode(Badge, vue.mergeProps({
  13711. "dot": dot,
  13712. "class": bem$j("text"),
  13713. "content": badge
  13714. }, props2.badgeProps), {
  13715. default: () => [slots.title ? slots.title() : title]
  13716. })]);
  13717. };
  13718. }
  13719. });
  13720. const SidebarItem = withInstall(stdin_default$s);
  13721. const [name$j, bem$i, t$2] = createNamespace("signature");
  13722. const signatureProps = {
  13723. tips: String,
  13724. type: makeStringProp("png"),
  13725. penColor: makeStringProp("#000"),
  13726. lineWidth: makeNumberProp(3),
  13727. clearButtonText: String,
  13728. backgroundColor: makeStringProp(""),
  13729. confirmButtonText: String
  13730. };
  13731. const hasCanvasSupport = () => {
  13732. var _a;
  13733. const canvas = document.createElement("canvas");
  13734. return !!((_a = canvas.getContext) == null ? void 0 : _a.call(canvas, "2d"));
  13735. };
  13736. var stdin_default$r = vue.defineComponent({
  13737. name: name$j,
  13738. props: signatureProps,
  13739. emits: ["submit", "clear", "start", "end", "signing"],
  13740. setup(props2, {
  13741. emit
  13742. }) {
  13743. const canvasRef = vue.ref();
  13744. const wrapRef = vue.ref();
  13745. const ctx = vue.computed(() => {
  13746. if (!canvasRef.value) return null;
  13747. return canvasRef.value.getContext("2d");
  13748. });
  13749. const isRenderCanvas = inBrowser ? hasCanvasSupport() : true;
  13750. let canvasWidth = 0;
  13751. let canvasHeight = 0;
  13752. let canvasRect;
  13753. const touchStart = () => {
  13754. if (!ctx.value) {
  13755. return false;
  13756. }
  13757. ctx.value.beginPath();
  13758. ctx.value.lineWidth = props2.lineWidth;
  13759. ctx.value.strokeStyle = props2.penColor;
  13760. canvasRect = use.useRect(canvasRef);
  13761. emit("start");
  13762. };
  13763. const touchMove = (event) => {
  13764. if (!ctx.value) {
  13765. return false;
  13766. }
  13767. preventDefault(event);
  13768. const touch = event.touches[0];
  13769. const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
  13770. const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
  13771. ctx.value.lineCap = "round";
  13772. ctx.value.lineJoin = "round";
  13773. ctx.value.lineTo(mouseX, mouseY);
  13774. ctx.value.stroke();
  13775. emit("signing", event);
  13776. };
  13777. const touchEnd = (event) => {
  13778. preventDefault(event);
  13779. emit("end");
  13780. };
  13781. const isCanvasEmpty = (canvas) => {
  13782. const empty = document.createElement("canvas");
  13783. empty.width = canvas.width;
  13784. empty.height = canvas.height;
  13785. if (props2.backgroundColor) {
  13786. const emptyCtx = empty.getContext("2d");
  13787. setCanvasBgColor(emptyCtx);
  13788. }
  13789. return canvas.toDataURL() === empty.toDataURL();
  13790. };
  13791. const setCanvasBgColor = (ctx2) => {
  13792. if (ctx2 && props2.backgroundColor) {
  13793. ctx2.fillStyle = props2.backgroundColor;
  13794. ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
  13795. }
  13796. };
  13797. const submit = () => {
  13798. var _a, _b;
  13799. const canvas = canvasRef.value;
  13800. if (!canvas) {
  13801. return;
  13802. }
  13803. const isEmpty = isCanvasEmpty(canvas);
  13804. const image = isEmpty ? "" : ((_b = (_a = {
  13805. jpg: () => canvas.toDataURL("image/jpeg", 0.8),
  13806. jpeg: () => canvas.toDataURL("image/jpeg", 0.8)
  13807. })[props2.type]) == null ? void 0 : _b.call(_a)) || canvas.toDataURL(`image/${props2.type}`);
  13808. emit("submit", {
  13809. image,
  13810. canvas
  13811. });
  13812. };
  13813. const clear = () => {
  13814. if (ctx.value) {
  13815. ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
  13816. ctx.value.closePath();
  13817. setCanvasBgColor(ctx.value);
  13818. }
  13819. emit("clear");
  13820. };
  13821. const initialize = () => {
  13822. var _a, _b, _c;
  13823. if (isRenderCanvas && canvasRef.value) {
  13824. const canvas = canvasRef.value;
  13825. const dpr = inBrowser ? window.devicePixelRatio : 1;
  13826. canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
  13827. canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
  13828. (_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
  13829. setCanvasBgColor(ctx.value);
  13830. }
  13831. };
  13832. const resize = () => {
  13833. if (ctx.value) {
  13834. const data = ctx.value.getImageData(0, 0, canvasWidth, canvasHeight);
  13835. initialize();
  13836. ctx.value.putImageData(data, 0, 0);
  13837. }
  13838. };
  13839. vue.watch(windowWidth, resize);
  13840. vue.onMounted(initialize);
  13841. useExpose({
  13842. resize,
  13843. clear,
  13844. submit
  13845. });
  13846. return () => vue.createVNode("div", {
  13847. "class": bem$i()
  13848. }, [vue.createVNode("div", {
  13849. "class": bem$i("content"),
  13850. "ref": wrapRef
  13851. }, [isRenderCanvas ? vue.createVNode("canvas", {
  13852. "ref": canvasRef,
  13853. "onTouchstartPassive": touchStart,
  13854. "onTouchmove": touchMove,
  13855. "onTouchend": touchEnd
  13856. }, null) : vue.createVNode("p", null, [props2.tips])]), vue.createVNode("div", {
  13857. "class": bem$i("footer")
  13858. }, [vue.createVNode(Button, {
  13859. "size": "small",
  13860. "onClick": clear
  13861. }, {
  13862. default: () => [props2.clearButtonText || t$2("clear")]
  13863. }), vue.createVNode(Button, {
  13864. "type": "primary",
  13865. "size": "small",
  13866. "onClick": submit
  13867. }, {
  13868. default: () => [props2.confirmButtonText || t$2("confirm")]
  13869. })])]);
  13870. }
  13871. });
  13872. const Signature = withInstall(stdin_default$r);
  13873. const [name$i, bem$h] = createNamespace("skeleton-title");
  13874. const skeletonTitleProps = {
  13875. round: Boolean,
  13876. titleWidth: numericProp
  13877. };
  13878. var stdin_default$q = vue.defineComponent({
  13879. name: name$i,
  13880. props: skeletonTitleProps,
  13881. setup(props2) {
  13882. return () => vue.createVNode("h3", {
  13883. "class": bem$h([{
  13884. round: props2.round
  13885. }]),
  13886. "style": {
  13887. width: addUnit(props2.titleWidth)
  13888. }
  13889. }, null);
  13890. }
  13891. });
  13892. const SkeletonTitle = withInstall(stdin_default$q);
  13893. var stdin_default$p = SkeletonTitle;
  13894. const [name$h, bem$g] = createNamespace("skeleton-avatar");
  13895. const skeletonAvatarProps = {
  13896. avatarSize: numericProp,
  13897. avatarShape: makeStringProp("round")
  13898. };
  13899. var stdin_default$o = vue.defineComponent({
  13900. name: name$h,
  13901. props: skeletonAvatarProps,
  13902. setup(props2) {
  13903. return () => vue.createVNode("div", {
  13904. "class": bem$g([props2.avatarShape]),
  13905. "style": getSizeStyle(props2.avatarSize)
  13906. }, null);
  13907. }
  13908. });
  13909. const SkeletonAvatar = withInstall(stdin_default$o);
  13910. var stdin_default$n = SkeletonAvatar;
  13911. const DEFAULT_ROW_WIDTH = "100%";
  13912. const skeletonParagraphProps = {
  13913. round: Boolean,
  13914. rowWidth: {
  13915. type: numericProp,
  13916. default: DEFAULT_ROW_WIDTH
  13917. }
  13918. };
  13919. const [name$g, bem$f] = createNamespace("skeleton-paragraph");
  13920. var stdin_default$m = vue.defineComponent({
  13921. name: name$g,
  13922. props: skeletonParagraphProps,
  13923. setup(props2) {
  13924. return () => vue.createVNode("div", {
  13925. "class": bem$f([{
  13926. round: props2.round
  13927. }]),
  13928. "style": {
  13929. width: props2.rowWidth
  13930. }
  13931. }, null);
  13932. }
  13933. });
  13934. const SkeletonParagraph = withInstall(stdin_default$m);
  13935. var stdin_default$l = SkeletonParagraph;
  13936. const [name$f, bem$e] = createNamespace("skeleton");
  13937. const DEFAULT_LAST_ROW_WIDTH = "60%";
  13938. const skeletonProps = {
  13939. row: makeNumericProp(0),
  13940. round: Boolean,
  13941. title: Boolean,
  13942. titleWidth: numericProp,
  13943. avatar: Boolean,
  13944. avatarSize: numericProp,
  13945. avatarShape: makeStringProp("round"),
  13946. loading: truthProp,
  13947. animate: truthProp,
  13948. rowWidth: {
  13949. type: [Number, String, Array],
  13950. default: DEFAULT_ROW_WIDTH
  13951. }
  13952. };
  13953. var stdin_default$k = vue.defineComponent({
  13954. name: name$f,
  13955. inheritAttrs: false,
  13956. props: skeletonProps,
  13957. setup(props2, {
  13958. slots,
  13959. attrs
  13960. }) {
  13961. const renderAvatar = () => {
  13962. if (props2.avatar) {
  13963. return vue.createVNode(stdin_default$n, {
  13964. "avatarShape": props2.avatarShape,
  13965. "avatarSize": props2.avatarSize
  13966. }, null);
  13967. }
  13968. };
  13969. const renderTitle = () => {
  13970. if (props2.title) {
  13971. return vue.createVNode(stdin_default$p, {
  13972. "round": props2.round,
  13973. "titleWidth": props2.titleWidth
  13974. }, null);
  13975. }
  13976. };
  13977. const getRowWidth = (index) => {
  13978. const {
  13979. rowWidth
  13980. } = props2;
  13981. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props2.row - 1) {
  13982. return DEFAULT_LAST_ROW_WIDTH;
  13983. }
  13984. if (Array.isArray(rowWidth)) {
  13985. return rowWidth[index];
  13986. }
  13987. return rowWidth;
  13988. };
  13989. const renderRows = () => Array(+props2.row).fill("").map((_, i) => vue.createVNode(stdin_default$l, {
  13990. "key": i,
  13991. "round": props2.round,
  13992. "rowWidth": addUnit(getRowWidth(i))
  13993. }, null));
  13994. const renderContents = () => {
  13995. if (slots.template) {
  13996. return slots.template();
  13997. }
  13998. return vue.createVNode(vue.Fragment, null, [renderAvatar(), vue.createVNode("div", {
  13999. "class": bem$e("content")
  14000. }, [renderTitle(), renderRows()])]);
  14001. };
  14002. return () => {
  14003. var _a;
  14004. if (!props2.loading) {
  14005. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  14006. }
  14007. return vue.createVNode("div", vue.mergeProps({
  14008. "class": bem$e({
  14009. animate: props2.animate,
  14010. round: props2.round
  14011. })
  14012. }, attrs), [renderContents()]);
  14013. };
  14014. }
  14015. });
  14016. const Skeleton = withInstall(stdin_default$k);
  14017. const [name$e, bem$d] = createNamespace("skeleton-image");
  14018. const skeletonImageProps = {
  14019. imageSize: numericProp,
  14020. imageShape: makeStringProp("square")
  14021. };
  14022. var stdin_default$j = vue.defineComponent({
  14023. name: name$e,
  14024. props: skeletonImageProps,
  14025. setup(props2) {
  14026. return () => vue.createVNode("div", {
  14027. "class": bem$d([props2.imageShape]),
  14028. "style": getSizeStyle(props2.imageSize)
  14029. }, [vue.createVNode(Icon, {
  14030. "name": "photo",
  14031. "class": bem$d("icon")
  14032. }, null)]);
  14033. }
  14034. });
  14035. const SkeletonImage = withInstall(stdin_default$j);
  14036. const [name$d, bem$c] = createNamespace("slider");
  14037. const sliderProps = {
  14038. min: makeNumericProp(0),
  14039. max: makeNumericProp(100),
  14040. step: makeNumericProp(1),
  14041. range: Boolean,
  14042. reverse: Boolean,
  14043. disabled: Boolean,
  14044. readonly: Boolean,
  14045. vertical: Boolean,
  14046. barHeight: numericProp,
  14047. buttonSize: numericProp,
  14048. activeColor: String,
  14049. inactiveColor: String,
  14050. modelValue: {
  14051. type: [Number, Array],
  14052. default: 0
  14053. }
  14054. };
  14055. var stdin_default$i = vue.defineComponent({
  14056. name: name$d,
  14057. props: sliderProps,
  14058. emits: ["change", "dragEnd", "dragStart", "update:modelValue"],
  14059. setup(props2, {
  14060. emit,
  14061. slots
  14062. }) {
  14063. let buttonIndex;
  14064. let current2;
  14065. let startValue;
  14066. const root = vue.ref();
  14067. const slider = [vue.ref(), vue.ref()];
  14068. const dragStatus = vue.ref();
  14069. const touch = useTouch();
  14070. const scope = vue.computed(() => Number(props2.max) - Number(props2.min));
  14071. const wrapperStyle = vue.computed(() => {
  14072. const crossAxis = props2.vertical ? "width" : "height";
  14073. return {
  14074. background: props2.inactiveColor,
  14075. [crossAxis]: addUnit(props2.barHeight)
  14076. };
  14077. });
  14078. const isRange = (val) => props2.range && Array.isArray(val);
  14079. const calcMainAxis = () => {
  14080. const {
  14081. modelValue,
  14082. min
  14083. } = props2;
  14084. if (isRange(modelValue)) {
  14085. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  14086. }
  14087. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  14088. };
  14089. const calcOffset = () => {
  14090. const {
  14091. modelValue,
  14092. min
  14093. } = props2;
  14094. if (isRange(modelValue)) {
  14095. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  14096. }
  14097. return "0%";
  14098. };
  14099. const barStyle = vue.computed(() => {
  14100. const mainAxis = props2.vertical ? "height" : "width";
  14101. const style = {
  14102. [mainAxis]: calcMainAxis(),
  14103. background: props2.activeColor
  14104. };
  14105. if (dragStatus.value) {
  14106. style.transition = "none";
  14107. }
  14108. const getPositionKey = () => {
  14109. if (props2.vertical) {
  14110. return props2.reverse ? "bottom" : "top";
  14111. }
  14112. return props2.reverse ? "right" : "left";
  14113. };
  14114. style[getPositionKey()] = calcOffset();
  14115. return style;
  14116. });
  14117. const format2 = (value) => {
  14118. const min = +props2.min;
  14119. const max = +props2.max;
  14120. const step = +props2.step;
  14121. value = clamp(value, min, max);
  14122. const diff = Math.round((value - min) / step) * step;
  14123. return addNumber(min, diff);
  14124. };
  14125. const updateStartValue = () => {
  14126. const current22 = props2.modelValue;
  14127. if (isRange(current22)) {
  14128. startValue = current22.map(format2);
  14129. } else {
  14130. startValue = format2(current22);
  14131. }
  14132. };
  14133. const handleRangeValue = (value) => {
  14134. var _a, _b;
  14135. const left = (_a = value[0]) != null ? _a : Number(props2.min);
  14136. const right = (_b = value[1]) != null ? _b : Number(props2.max);
  14137. return left > right ? [right, left] : [left, right];
  14138. };
  14139. const updateValue = (value, end) => {
  14140. if (isRange(value)) {
  14141. value = handleRangeValue(value).map(format2);
  14142. } else {
  14143. value = format2(value);
  14144. }
  14145. if (!isSameValue(value, props2.modelValue)) {
  14146. emit("update:modelValue", value);
  14147. }
  14148. if (end && !isSameValue(value, startValue)) {
  14149. emit("change", value);
  14150. }
  14151. };
  14152. const onClick = (event) => {
  14153. event.stopPropagation();
  14154. if (props2.disabled || props2.readonly) {
  14155. return;
  14156. }
  14157. updateStartValue();
  14158. const {
  14159. min,
  14160. reverse,
  14161. vertical,
  14162. modelValue
  14163. } = props2;
  14164. const rect = use.useRect(root);
  14165. const getDelta = () => {
  14166. if (vertical) {
  14167. if (reverse) {
  14168. return rect.bottom - event.clientY;
  14169. }
  14170. return event.clientY - rect.top;
  14171. }
  14172. if (reverse) {
  14173. return rect.right - event.clientX;
  14174. }
  14175. return event.clientX - rect.left;
  14176. };
  14177. const total = vertical ? rect.height : rect.width;
  14178. const value = Number(min) + getDelta() / total * scope.value;
  14179. if (isRange(modelValue)) {
  14180. const [left, right] = modelValue;
  14181. const middle = (left + right) / 2;
  14182. if (value <= middle) {
  14183. updateValue([value, right], true);
  14184. } else {
  14185. updateValue([left, value], true);
  14186. }
  14187. } else {
  14188. updateValue(value, true);
  14189. }
  14190. };
  14191. const onTouchStart = (event) => {
  14192. if (props2.disabled || props2.readonly) {
  14193. return;
  14194. }
  14195. touch.start(event);
  14196. current2 = props2.modelValue;
  14197. updateStartValue();
  14198. dragStatus.value = "start";
  14199. };
  14200. const onTouchMove = (event) => {
  14201. if (props2.disabled || props2.readonly) {
  14202. return;
  14203. }
  14204. if (dragStatus.value === "start") {
  14205. emit("dragStart", event);
  14206. }
  14207. preventDefault(event, true);
  14208. touch.move(event);
  14209. dragStatus.value = "dragging";
  14210. const rect = use.useRect(root);
  14211. const delta = props2.vertical ? touch.deltaY.value : touch.deltaX.value;
  14212. const total = props2.vertical ? rect.height : rect.width;
  14213. let diff = delta / total * scope.value;
  14214. if (props2.reverse) {
  14215. diff = -diff;
  14216. }
  14217. if (isRange(startValue)) {
  14218. const index = props2.reverse ? 1 - buttonIndex : buttonIndex;
  14219. current2[index] = startValue[index] + diff;
  14220. } else {
  14221. current2 = startValue + diff;
  14222. }
  14223. updateValue(current2);
  14224. };
  14225. const onTouchEnd = (event) => {
  14226. if (props2.disabled || props2.readonly) {
  14227. return;
  14228. }
  14229. if (dragStatus.value === "dragging") {
  14230. updateValue(current2, true);
  14231. emit("dragEnd", event);
  14232. }
  14233. dragStatus.value = "";
  14234. };
  14235. const getButtonClassName = (index) => {
  14236. if (typeof index === "number") {
  14237. const position = ["left", "right"];
  14238. return bem$c(`button-wrapper`, position[index]);
  14239. }
  14240. return bem$c("button-wrapper", props2.reverse ? "left" : "right");
  14241. };
  14242. const renderButtonContent = (value, index) => {
  14243. const dragging = dragStatus.value === "dragging";
  14244. if (typeof index === "number") {
  14245. const slot = slots[index === 0 ? "left-button" : "right-button"];
  14246. let dragIndex;
  14247. if (dragging && Array.isArray(current2)) {
  14248. dragIndex = current2[0] > current2[1] ? buttonIndex ^ 1 : buttonIndex;
  14249. }
  14250. if (slot) {
  14251. return slot({
  14252. value,
  14253. dragging,
  14254. dragIndex
  14255. });
  14256. }
  14257. }
  14258. if (slots.button) {
  14259. return slots.button({
  14260. value,
  14261. dragging
  14262. });
  14263. }
  14264. return vue.createVNode("div", {
  14265. "class": bem$c("button"),
  14266. "style": getSizeStyle(props2.buttonSize)
  14267. }, null);
  14268. };
  14269. const renderButton = (index) => {
  14270. const current22 = typeof index === "number" ? props2.modelValue[index] : props2.modelValue;
  14271. return vue.createVNode("div", {
  14272. "ref": slider[index != null ? index : 0],
  14273. "role": "slider",
  14274. "class": getButtonClassName(index),
  14275. "tabindex": props2.disabled ? void 0 : 0,
  14276. "aria-valuemin": props2.min,
  14277. "aria-valuenow": current22,
  14278. "aria-valuemax": props2.max,
  14279. "aria-disabled": props2.disabled || void 0,
  14280. "aria-readonly": props2.readonly || void 0,
  14281. "aria-orientation": props2.vertical ? "vertical" : "horizontal",
  14282. "onTouchstartPassive": (event) => {
  14283. if (typeof index === "number") {
  14284. buttonIndex = index;
  14285. }
  14286. onTouchStart(event);
  14287. },
  14288. "onTouchend": onTouchEnd,
  14289. "onTouchcancel": onTouchEnd,
  14290. "onClick": stopPropagation
  14291. }, [renderButtonContent(current22, index)]);
  14292. };
  14293. updateValue(props2.modelValue);
  14294. use.useCustomFieldValue(() => props2.modelValue);
  14295. slider.forEach((item) => {
  14296. use.useEventListener("touchmove", onTouchMove, {
  14297. target: item
  14298. });
  14299. });
  14300. return () => vue.createVNode("div", {
  14301. "ref": root,
  14302. "style": wrapperStyle.value,
  14303. "class": bem$c({
  14304. vertical: props2.vertical,
  14305. disabled: props2.disabled
  14306. }),
  14307. "onClick": onClick
  14308. }, [vue.createVNode("div", {
  14309. "class": bem$c("bar"),
  14310. "style": barStyle.value
  14311. }, [props2.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  14312. }
  14313. });
  14314. const Slider = withInstall(stdin_default$i);
  14315. const [name$c, bem$b] = createNamespace("space");
  14316. const spaceProps = {
  14317. align: String,
  14318. direction: {
  14319. type: String,
  14320. default: "horizontal"
  14321. },
  14322. size: {
  14323. type: [Number, String, Array],
  14324. default: 8
  14325. },
  14326. wrap: Boolean,
  14327. fill: Boolean
  14328. };
  14329. function filterEmpty(children = []) {
  14330. const nodes = [];
  14331. children.forEach((child) => {
  14332. if (Array.isArray(child)) {
  14333. nodes.push(...child);
  14334. } else if (child.type === vue.Fragment) {
  14335. nodes.push(...filterEmpty(child.children));
  14336. } else {
  14337. nodes.push(child);
  14338. }
  14339. });
  14340. return nodes.filter((c) => {
  14341. var _a;
  14342. return !(c && (c.type === vue.Comment || c.type === vue.Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === vue.Text && c.children.trim() === ""));
  14343. });
  14344. }
  14345. var stdin_default$h = vue.defineComponent({
  14346. name: name$c,
  14347. props: spaceProps,
  14348. setup(props2, {
  14349. slots
  14350. }) {
  14351. const mergedAlign = vue.computed(() => {
  14352. var _a;
  14353. return (_a = props2.align) != null ? _a : props2.direction === "horizontal" ? "center" : "";
  14354. });
  14355. const getMargin = (size) => {
  14356. if (typeof size === "number") {
  14357. return size + "px";
  14358. }
  14359. return size;
  14360. };
  14361. const getMarginStyle = (isLast) => {
  14362. const style = {};
  14363. const marginRight = `${getMargin(Array.isArray(props2.size) ? props2.size[0] : props2.size)}`;
  14364. const marginBottom = `${getMargin(Array.isArray(props2.size) ? props2.size[1] : props2.size)}`;
  14365. if (isLast) {
  14366. return props2.wrap ? {
  14367. marginBottom
  14368. } : {};
  14369. }
  14370. if (props2.direction === "horizontal") {
  14371. style.marginRight = marginRight;
  14372. }
  14373. if (props2.direction === "vertical" || props2.wrap) {
  14374. style.marginBottom = marginBottom;
  14375. }
  14376. return style;
  14377. };
  14378. return () => {
  14379. var _a;
  14380. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  14381. return vue.createVNode("div", {
  14382. "class": [bem$b({
  14383. [props2.direction]: props2.direction,
  14384. [`align-${mergedAlign.value}`]: mergedAlign.value,
  14385. wrap: props2.wrap,
  14386. fill: props2.fill
  14387. })]
  14388. }, [children.map((c, i) => vue.createVNode("div", {
  14389. "key": `item-${i}`,
  14390. "class": `${name$c}-item`,
  14391. "style": getMarginStyle(i === children.length - 1)
  14392. }, [c]))]);
  14393. };
  14394. }
  14395. });
  14396. const Space = withInstall(stdin_default$h);
  14397. const [name$b, bem$a] = createNamespace("steps");
  14398. const stepsProps = {
  14399. active: makeNumericProp(0),
  14400. direction: makeStringProp("horizontal"),
  14401. activeIcon: makeStringProp("checked"),
  14402. iconPrefix: String,
  14403. finishIcon: String,
  14404. activeColor: String,
  14405. inactiveIcon: String,
  14406. inactiveColor: String
  14407. };
  14408. const STEPS_KEY = Symbol(name$b);
  14409. var stdin_default$g = vue.defineComponent({
  14410. name: name$b,
  14411. props: stepsProps,
  14412. emits: ["clickStep"],
  14413. setup(props2, {
  14414. emit,
  14415. slots
  14416. }) {
  14417. const {
  14418. linkChildren
  14419. } = use.useChildren(STEPS_KEY);
  14420. const onClickStep = (index) => emit("clickStep", index);
  14421. linkChildren({
  14422. props: props2,
  14423. onClickStep
  14424. });
  14425. return () => {
  14426. var _a;
  14427. return vue.createVNode("div", {
  14428. "class": bem$a([props2.direction])
  14429. }, [vue.createVNode("div", {
  14430. "class": bem$a("items")
  14431. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  14432. };
  14433. }
  14434. });
  14435. const [name$a, bem$9] = createNamespace("step");
  14436. var stdin_default$f = vue.defineComponent({
  14437. name: name$a,
  14438. setup(props2, {
  14439. slots
  14440. }) {
  14441. const {
  14442. parent,
  14443. index
  14444. } = use.useParent(STEPS_KEY);
  14445. if (!parent) {
  14446. if (process.env.NODE_ENV !== "production") {
  14447. console.error("[Vant] <Step> must be a child component of <Steps>.");
  14448. }
  14449. return;
  14450. }
  14451. const parentProps = parent.props;
  14452. const getStatus = () => {
  14453. const active = +parentProps.active;
  14454. if (index.value < active) {
  14455. return "finish";
  14456. }
  14457. return index.value === active ? "process" : "waiting";
  14458. };
  14459. const isActive = () => getStatus() === "process";
  14460. const lineStyle = vue.computed(() => ({
  14461. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  14462. }));
  14463. const titleStyle = vue.computed(() => {
  14464. if (isActive()) {
  14465. return {
  14466. color: parentProps.activeColor
  14467. };
  14468. }
  14469. if (getStatus() === "waiting") {
  14470. return {
  14471. color: parentProps.inactiveColor
  14472. };
  14473. }
  14474. });
  14475. const onClickStep = () => parent.onClickStep(index.value);
  14476. const renderCircle = () => {
  14477. const {
  14478. iconPrefix,
  14479. finishIcon,
  14480. activeIcon,
  14481. activeColor,
  14482. inactiveIcon
  14483. } = parentProps;
  14484. if (isActive()) {
  14485. if (slots["active-icon"]) {
  14486. return slots["active-icon"]();
  14487. }
  14488. return vue.createVNode(Icon, {
  14489. "class": bem$9("icon", "active"),
  14490. "name": activeIcon,
  14491. "color": activeColor,
  14492. "classPrefix": iconPrefix
  14493. }, null);
  14494. }
  14495. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  14496. if (slots["finish-icon"]) {
  14497. return slots["finish-icon"]();
  14498. }
  14499. return vue.createVNode(Icon, {
  14500. "class": bem$9("icon", "finish"),
  14501. "name": finishIcon,
  14502. "color": activeColor,
  14503. "classPrefix": iconPrefix
  14504. }, null);
  14505. }
  14506. if (slots["inactive-icon"]) {
  14507. return slots["inactive-icon"]();
  14508. }
  14509. if (inactiveIcon) {
  14510. return vue.createVNode(Icon, {
  14511. "class": bem$9("icon"),
  14512. "name": inactiveIcon,
  14513. "classPrefix": iconPrefix
  14514. }, null);
  14515. }
  14516. return vue.createVNode("i", {
  14517. "class": bem$9("circle"),
  14518. "style": lineStyle.value
  14519. }, null);
  14520. };
  14521. return () => {
  14522. var _a;
  14523. const status = getStatus();
  14524. return vue.createVNode("div", {
  14525. "class": [BORDER, bem$9([parentProps.direction, {
  14526. [status]: status
  14527. }])]
  14528. }, [vue.createVNode("div", {
  14529. "class": bem$9("title", {
  14530. active: isActive()
  14531. }),
  14532. "style": titleStyle.value,
  14533. "onClick": onClickStep
  14534. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
  14535. "class": bem$9("circle-container"),
  14536. "onClick": onClickStep
  14537. }, [renderCircle()]), vue.createVNode("div", {
  14538. "class": bem$9("line"),
  14539. "style": lineStyle.value
  14540. }, null)]);
  14541. };
  14542. }
  14543. });
  14544. const Step = withInstall(stdin_default$f);
  14545. const [name$9, bem$8] = createNamespace("stepper");
  14546. const LONG_PRESS_INTERVAL = 200;
  14547. const isEqual = (value1, value2) => String(value1) === String(value2);
  14548. const stepperProps = {
  14549. min: makeNumericProp(1),
  14550. max: makeNumericProp(Infinity),
  14551. name: makeNumericProp(""),
  14552. step: makeNumericProp(1),
  14553. theme: String,
  14554. integer: Boolean,
  14555. disabled: Boolean,
  14556. showPlus: truthProp,
  14557. showMinus: truthProp,
  14558. showInput: truthProp,
  14559. longPress: truthProp,
  14560. autoFixed: truthProp,
  14561. allowEmpty: Boolean,
  14562. modelValue: numericProp,
  14563. inputWidth: numericProp,
  14564. buttonSize: numericProp,
  14565. placeholder: String,
  14566. disablePlus: Boolean,
  14567. disableMinus: Boolean,
  14568. disableInput: Boolean,
  14569. beforeChange: Function,
  14570. defaultValue: makeNumericProp(1),
  14571. decimalLength: numericProp
  14572. };
  14573. var stdin_default$e = vue.defineComponent({
  14574. name: name$9,
  14575. props: stepperProps,
  14576. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  14577. setup(props2, {
  14578. emit
  14579. }) {
  14580. const format2 = (value, autoFixed = true) => {
  14581. const {
  14582. min,
  14583. max,
  14584. allowEmpty,
  14585. decimalLength
  14586. } = props2;
  14587. if (allowEmpty && value === "") {
  14588. return value;
  14589. }
  14590. value = formatNumber(String(value), !props2.integer);
  14591. value = value === "" ? 0 : +value;
  14592. value = Number.isNaN(value) ? +min : value;
  14593. value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
  14594. if (isDef(decimalLength)) {
  14595. value = value.toFixed(+decimalLength);
  14596. }
  14597. return value;
  14598. };
  14599. const getInitialValue = () => {
  14600. var _a;
  14601. const defaultValue = (_a = props2.modelValue) != null ? _a : props2.defaultValue;
  14602. const value = format2(defaultValue);
  14603. if (!isEqual(value, props2.modelValue)) {
  14604. emit("update:modelValue", value);
  14605. }
  14606. return value;
  14607. };
  14608. let actionType;
  14609. const inputRef = vue.ref();
  14610. const current2 = vue.ref(getInitialValue());
  14611. const minusDisabled = vue.computed(() => props2.disabled || props2.disableMinus || +current2.value <= +props2.min);
  14612. const plusDisabled = vue.computed(() => props2.disabled || props2.disablePlus || +current2.value >= +props2.max);
  14613. const inputStyle = vue.computed(() => ({
  14614. width: addUnit(props2.inputWidth),
  14615. height: addUnit(props2.buttonSize)
  14616. }));
  14617. const buttonStyle = vue.computed(() => getSizeStyle(props2.buttonSize));
  14618. const check = () => {
  14619. const value = format2(current2.value);
  14620. if (!isEqual(value, current2.value)) {
  14621. current2.value = value;
  14622. }
  14623. };
  14624. const setValue = (value) => {
  14625. if (props2.beforeChange) {
  14626. callInterceptor(props2.beforeChange, {
  14627. args: [value],
  14628. done() {
  14629. current2.value = value;
  14630. }
  14631. });
  14632. } else {
  14633. current2.value = value;
  14634. }
  14635. };
  14636. const onChange = () => {
  14637. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  14638. emit("overlimit", actionType);
  14639. return;
  14640. }
  14641. const diff = actionType === "minus" ? -props2.step : +props2.step;
  14642. const value = format2(addNumber(+current2.value, diff));
  14643. setValue(value);
  14644. emit(actionType);
  14645. };
  14646. const onInput = (event) => {
  14647. const input = event.target;
  14648. const {
  14649. value
  14650. } = input;
  14651. const {
  14652. decimalLength
  14653. } = props2;
  14654. let formatted = formatNumber(String(value), !props2.integer);
  14655. if (isDef(decimalLength) && formatted.includes(".")) {
  14656. const pair = formatted.split(".");
  14657. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  14658. }
  14659. if (props2.beforeChange) {
  14660. input.value = String(current2.value);
  14661. } else if (!isEqual(value, formatted)) {
  14662. input.value = formatted;
  14663. }
  14664. const isNumeric2 = formatted === String(+formatted);
  14665. setValue(isNumeric2 ? +formatted : formatted);
  14666. };
  14667. const onFocus = (event) => {
  14668. var _a;
  14669. if (props2.disableInput) {
  14670. (_a = inputRef.value) == null ? void 0 : _a.blur();
  14671. } else {
  14672. emit("focus", event);
  14673. }
  14674. };
  14675. const onBlur = (event) => {
  14676. const input = event.target;
  14677. const value = format2(input.value, props2.autoFixed);
  14678. input.value = String(value);
  14679. current2.value = value;
  14680. vue.nextTick(() => {
  14681. emit("blur", event);
  14682. resetScroll();
  14683. });
  14684. };
  14685. let isLongPress;
  14686. let longPressTimer;
  14687. const longPressStep = () => {
  14688. longPressTimer = setTimeout(() => {
  14689. onChange();
  14690. longPressStep();
  14691. }, LONG_PRESS_INTERVAL);
  14692. };
  14693. const onTouchStart = () => {
  14694. if (props2.longPress) {
  14695. isLongPress = false;
  14696. clearTimeout(longPressTimer);
  14697. longPressTimer = setTimeout(() => {
  14698. isLongPress = true;
  14699. onChange();
  14700. longPressStep();
  14701. }, LONG_PRESS_START_TIME);
  14702. }
  14703. };
  14704. const onTouchEnd = (event) => {
  14705. if (props2.longPress) {
  14706. clearTimeout(longPressTimer);
  14707. if (isLongPress) {
  14708. preventDefault(event);
  14709. }
  14710. }
  14711. };
  14712. const onMousedown = (event) => {
  14713. if (props2.disableInput) {
  14714. preventDefault(event);
  14715. }
  14716. };
  14717. const createListeners = (type) => ({
  14718. onClick: (event) => {
  14719. preventDefault(event);
  14720. actionType = type;
  14721. onChange();
  14722. },
  14723. onTouchstartPassive: () => {
  14724. actionType = type;
  14725. onTouchStart();
  14726. },
  14727. onTouchend: onTouchEnd,
  14728. onTouchcancel: onTouchEnd
  14729. });
  14730. vue.watch(() => [props2.max, props2.min, props2.integer, props2.decimalLength], check);
  14731. vue.watch(() => props2.modelValue, (value) => {
  14732. if (!isEqual(value, current2.value)) {
  14733. current2.value = format2(value);
  14734. }
  14735. });
  14736. vue.watch(current2, (value) => {
  14737. emit("update:modelValue", value);
  14738. emit("change", value, {
  14739. name: props2.name
  14740. });
  14741. });
  14742. use.useCustomFieldValue(() => props2.modelValue);
  14743. return () => vue.createVNode("div", {
  14744. "role": "group",
  14745. "class": bem$8([props2.theme])
  14746. }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  14747. "type": "button",
  14748. "style": buttonStyle.value,
  14749. "class": [bem$8("minus", {
  14750. disabled: minusDisabled.value
  14751. }), {
  14752. [HAPTICS_FEEDBACK]: !minusDisabled.value
  14753. }],
  14754. "aria-disabled": minusDisabled.value || void 0
  14755. }, createListeners("minus")), null), [[vue.vShow, props2.showMinus]]), vue.withDirectives(vue.createVNode("input", {
  14756. "ref": inputRef,
  14757. "type": props2.integer ? "tel" : "text",
  14758. "role": "spinbutton",
  14759. "class": bem$8("input"),
  14760. "value": current2.value,
  14761. "style": inputStyle.value,
  14762. "disabled": props2.disabled,
  14763. "readonly": props2.disableInput,
  14764. "inputmode": props2.integer ? "numeric" : "decimal",
  14765. "placeholder": props2.placeholder,
  14766. "autocomplete": "off",
  14767. "aria-valuemax": props2.max,
  14768. "aria-valuemin": props2.min,
  14769. "aria-valuenow": current2.value,
  14770. "onBlur": onBlur,
  14771. "onInput": onInput,
  14772. "onFocus": onFocus,
  14773. "onMousedown": onMousedown
  14774. }, null), [[vue.vShow, props2.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
  14775. "type": "button",
  14776. "style": buttonStyle.value,
  14777. "class": [bem$8("plus", {
  14778. disabled: plusDisabled.value
  14779. }), {
  14780. [HAPTICS_FEEDBACK]: !plusDisabled.value
  14781. }],
  14782. "aria-disabled": plusDisabled.value || void 0
  14783. }, createListeners("plus")), null), [[vue.vShow, props2.showPlus]])]);
  14784. }
  14785. });
  14786. const Stepper = withInstall(stdin_default$e);
  14787. const Steps = withInstall(stdin_default$g);
  14788. const [name$8, bem$7, t$1] = createNamespace("submit-bar");
  14789. const submitBarProps = {
  14790. tip: String,
  14791. label: String,
  14792. price: Number,
  14793. tipIcon: String,
  14794. loading: Boolean,
  14795. currency: makeStringProp("¥"),
  14796. disabled: Boolean,
  14797. textAlign: String,
  14798. buttonText: String,
  14799. buttonType: makeStringProp("danger"),
  14800. buttonColor: String,
  14801. suffixLabel: String,
  14802. placeholder: Boolean,
  14803. decimalLength: makeNumericProp(2),
  14804. safeAreaInsetBottom: truthProp
  14805. };
  14806. var stdin_default$d = vue.defineComponent({
  14807. name: name$8,
  14808. props: submitBarProps,
  14809. emits: ["submit"],
  14810. setup(props2, {
  14811. emit,
  14812. slots
  14813. }) {
  14814. const root = vue.ref();
  14815. const renderPlaceholder = usePlaceholder(root, bem$7);
  14816. const renderText = () => {
  14817. const {
  14818. price,
  14819. label,
  14820. currency,
  14821. textAlign,
  14822. suffixLabel,
  14823. decimalLength
  14824. } = props2;
  14825. if (typeof price === "number") {
  14826. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  14827. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  14828. return vue.createVNode("div", {
  14829. "class": bem$7("text"),
  14830. "style": {
  14831. textAlign
  14832. }
  14833. }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
  14834. "class": bem$7("price")
  14835. }, [currency, vue.createVNode("span", {
  14836. "class": bem$7("price-integer")
  14837. }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
  14838. "class": bem$7("suffix-label")
  14839. }, [suffixLabel])]);
  14840. }
  14841. };
  14842. const renderTip = () => {
  14843. var _a;
  14844. const {
  14845. tip,
  14846. tipIcon
  14847. } = props2;
  14848. if (slots.tip || tip) {
  14849. return vue.createVNode("div", {
  14850. "class": bem$7("tip")
  14851. }, [tipIcon && vue.createVNode(Icon, {
  14852. "class": bem$7("tip-icon"),
  14853. "name": tipIcon
  14854. }, null), tip && vue.createVNode("span", {
  14855. "class": bem$7("tip-text")
  14856. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  14857. }
  14858. };
  14859. const onClickButton = () => emit("submit");
  14860. const renderButton = () => {
  14861. if (slots.button) {
  14862. return slots.button();
  14863. }
  14864. return vue.createVNode(Button, {
  14865. "round": true,
  14866. "type": props2.buttonType,
  14867. "text": props2.buttonText,
  14868. "class": bem$7("button", props2.buttonType),
  14869. "color": props2.buttonColor,
  14870. "loading": props2.loading,
  14871. "disabled": props2.disabled,
  14872. "onClick": onClickButton
  14873. }, null);
  14874. };
  14875. const renderSubmitBar = () => {
  14876. var _a, _b;
  14877. return vue.createVNode("div", {
  14878. "ref": root,
  14879. "class": [bem$7(), {
  14880. "van-safe-area-bottom": props2.safeAreaInsetBottom
  14881. }]
  14882. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
  14883. "class": bem$7("bar")
  14884. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  14885. };
  14886. return () => {
  14887. if (props2.placeholder) {
  14888. return renderPlaceholder(renderSubmitBar);
  14889. }
  14890. return renderSubmitBar();
  14891. };
  14892. }
  14893. });
  14894. const SubmitBar = withInstall(stdin_default$d);
  14895. const [name$7, bem$6] = createNamespace("swipe-cell");
  14896. const swipeCellProps = {
  14897. name: makeNumericProp(""),
  14898. disabled: Boolean,
  14899. leftWidth: numericProp,
  14900. rightWidth: numericProp,
  14901. beforeClose: Function,
  14902. stopPropagation: Boolean
  14903. };
  14904. var stdin_default$c = vue.defineComponent({
  14905. name: name$7,
  14906. props: swipeCellProps,
  14907. emits: ["open", "close", "click"],
  14908. setup(props2, {
  14909. emit,
  14910. slots
  14911. }) {
  14912. let opened;
  14913. let lockClick2;
  14914. let startOffset;
  14915. let isInBeforeClosing;
  14916. const root = vue.ref();
  14917. const leftRef = vue.ref();
  14918. const rightRef = vue.ref();
  14919. const state = vue.reactive({
  14920. offset: 0,
  14921. dragging: false
  14922. });
  14923. const touch = useTouch();
  14924. const getWidthByRef = (ref2) => ref2.value ? use.useRect(ref2).width : 0;
  14925. const leftWidth = vue.computed(() => isDef(props2.leftWidth) ? +props2.leftWidth : getWidthByRef(leftRef));
  14926. const rightWidth = vue.computed(() => isDef(props2.rightWidth) ? +props2.rightWidth : getWidthByRef(rightRef));
  14927. const open = (side) => {
  14928. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  14929. if (!opened) {
  14930. opened = true;
  14931. emit("open", {
  14932. name: props2.name,
  14933. position: side
  14934. });
  14935. }
  14936. };
  14937. const close = (position) => {
  14938. state.offset = 0;
  14939. if (opened) {
  14940. opened = false;
  14941. emit("close", {
  14942. name: props2.name,
  14943. position
  14944. });
  14945. }
  14946. };
  14947. const toggle = (side) => {
  14948. const offset = Math.abs(state.offset);
  14949. const THRESHOLD = 0.15;
  14950. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  14951. const width = side === "left" ? leftWidth.value : rightWidth.value;
  14952. if (width && offset > width * threshold) {
  14953. open(side);
  14954. } else {
  14955. close(side);
  14956. }
  14957. };
  14958. const onTouchStart = (event) => {
  14959. if (!props2.disabled) {
  14960. startOffset = state.offset;
  14961. touch.start(event);
  14962. }
  14963. };
  14964. const onTouchMove = (event) => {
  14965. if (props2.disabled) {
  14966. return;
  14967. }
  14968. const {
  14969. deltaX
  14970. } = touch;
  14971. touch.move(event);
  14972. if (touch.isHorizontal()) {
  14973. lockClick2 = true;
  14974. state.dragging = true;
  14975. const isEdge = !opened || deltaX.value * startOffset < 0;
  14976. if (isEdge) {
  14977. preventDefault(event, props2.stopPropagation);
  14978. }
  14979. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  14980. }
  14981. };
  14982. const onTouchEnd = () => {
  14983. if (state.dragging) {
  14984. state.dragging = false;
  14985. toggle(state.offset > 0 ? "left" : "right");
  14986. setTimeout(() => {
  14987. lockClick2 = false;
  14988. }, 0);
  14989. }
  14990. };
  14991. const onClick = (position = "outside", event) => {
  14992. if (isInBeforeClosing) return;
  14993. emit("click", position);
  14994. if (opened && !lockClick2) {
  14995. isInBeforeClosing = true;
  14996. callInterceptor(props2.beforeClose, {
  14997. args: [{
  14998. event,
  14999. name: props2.name,
  15000. position
  15001. }],
  15002. done: () => {
  15003. isInBeforeClosing = false;
  15004. close(position);
  15005. },
  15006. canceled: () => isInBeforeClosing = false,
  15007. error: () => isInBeforeClosing = false
  15008. });
  15009. }
  15010. };
  15011. const getClickHandler = (position, stop) => (event) => {
  15012. if (stop) {
  15013. event.stopPropagation();
  15014. }
  15015. if (lockClick2) {
  15016. return;
  15017. }
  15018. onClick(position, event);
  15019. };
  15020. const renderSideContent = (side, ref2) => {
  15021. const contentSlot = slots[side];
  15022. if (contentSlot) {
  15023. return vue.createVNode("div", {
  15024. "ref": ref2,
  15025. "class": bem$6(side),
  15026. "onClick": getClickHandler(side, true)
  15027. }, [contentSlot()]);
  15028. }
  15029. };
  15030. useExpose({
  15031. open,
  15032. close
  15033. });
  15034. use.useClickAway(root, (event) => onClick("outside", event), {
  15035. eventName: "touchstart"
  15036. });
  15037. use.useEventListener("touchmove", onTouchMove, {
  15038. target: root
  15039. });
  15040. return () => {
  15041. var _a;
  15042. const wrapperStyle = {
  15043. transform: `translate3d(${state.offset}px, 0, 0)`,
  15044. transitionDuration: state.dragging ? "0s" : ".6s"
  15045. };
  15046. return vue.createVNode("div", {
  15047. "ref": root,
  15048. "class": bem$6(),
  15049. "onClick": getClickHandler("cell", lockClick2),
  15050. "onTouchstartPassive": onTouchStart,
  15051. "onTouchend": onTouchEnd,
  15052. "onTouchcancel": onTouchEnd
  15053. }, [vue.createVNode("div", {
  15054. "class": bem$6("wrapper"),
  15055. "style": wrapperStyle
  15056. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  15057. };
  15058. }
  15059. });
  15060. const SwipeCell = withInstall(stdin_default$c);
  15061. const [name$6, bem$5] = createNamespace("tabbar");
  15062. const tabbarProps = {
  15063. route: Boolean,
  15064. fixed: truthProp,
  15065. border: truthProp,
  15066. zIndex: numericProp,
  15067. placeholder: Boolean,
  15068. activeColor: String,
  15069. beforeChange: Function,
  15070. inactiveColor: String,
  15071. modelValue: makeNumericProp(0),
  15072. safeAreaInsetBottom: {
  15073. type: Boolean,
  15074. default: null
  15075. }
  15076. };
  15077. const TABBAR_KEY = Symbol(name$6);
  15078. var stdin_default$b = vue.defineComponent({
  15079. name: name$6,
  15080. props: tabbarProps,
  15081. emits: ["change", "update:modelValue"],
  15082. setup(props2, {
  15083. emit,
  15084. slots
  15085. }) {
  15086. const root = vue.ref();
  15087. const {
  15088. linkChildren
  15089. } = use.useChildren(TABBAR_KEY);
  15090. const renderPlaceholder = usePlaceholder(root, bem$5);
  15091. const enableSafeArea = () => {
  15092. var _a;
  15093. return (_a = props2.safeAreaInsetBottom) != null ? _a : props2.fixed;
  15094. };
  15095. const renderTabbar = () => {
  15096. var _a;
  15097. const {
  15098. fixed,
  15099. zIndex,
  15100. border
  15101. } = props2;
  15102. return vue.createVNode("div", {
  15103. "ref": root,
  15104. "role": "tablist",
  15105. "style": getZIndexStyle(zIndex),
  15106. "class": [bem$5({
  15107. fixed
  15108. }), {
  15109. [BORDER_TOP_BOTTOM]: border,
  15110. "van-safe-area-bottom": enableSafeArea()
  15111. }]
  15112. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  15113. };
  15114. const setActive = (active, afterChange) => {
  15115. callInterceptor(props2.beforeChange, {
  15116. args: [active],
  15117. done() {
  15118. emit("update:modelValue", active);
  15119. emit("change", active);
  15120. afterChange();
  15121. }
  15122. });
  15123. };
  15124. linkChildren({
  15125. props: props2,
  15126. setActive
  15127. });
  15128. return () => {
  15129. if (props2.fixed && props2.placeholder) {
  15130. return renderPlaceholder(renderTabbar);
  15131. }
  15132. return renderTabbar();
  15133. };
  15134. }
  15135. });
  15136. const Tabbar = withInstall(stdin_default$b);
  15137. const [name$5, bem$4] = createNamespace("tabbar-item");
  15138. const tabbarItemProps = extend({}, routeProps, {
  15139. dot: Boolean,
  15140. icon: String,
  15141. name: numericProp,
  15142. badge: numericProp,
  15143. badgeProps: Object,
  15144. iconPrefix: String
  15145. });
  15146. var stdin_default$a = vue.defineComponent({
  15147. name: name$5,
  15148. props: tabbarItemProps,
  15149. emits: ["click"],
  15150. setup(props2, {
  15151. emit,
  15152. slots
  15153. }) {
  15154. const route2 = useRoute();
  15155. const vm = vue.getCurrentInstance().proxy;
  15156. const {
  15157. parent,
  15158. index
  15159. } = use.useParent(TABBAR_KEY);
  15160. if (!parent) {
  15161. if (process.env.NODE_ENV !== "production") {
  15162. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  15163. }
  15164. return;
  15165. }
  15166. const active = vue.computed(() => {
  15167. var _a;
  15168. const {
  15169. route: route22,
  15170. modelValue
  15171. } = parent.props;
  15172. if (route22 && "$route" in vm) {
  15173. const {
  15174. $route
  15175. } = vm;
  15176. const {
  15177. to
  15178. } = props2;
  15179. const config = isObject(to) ? to : {
  15180. path: to
  15181. };
  15182. return !!$route.matched.find((val) => {
  15183. const pathMatched = "path" in config && config.path === val.path;
  15184. const nameMatched = "name" in config && config.name === val.name;
  15185. return pathMatched || nameMatched;
  15186. });
  15187. }
  15188. return ((_a = props2.name) != null ? _a : index.value) === modelValue;
  15189. });
  15190. const onClick = (event) => {
  15191. var _a;
  15192. if (!active.value) {
  15193. parent.setActive((_a = props2.name) != null ? _a : index.value, route2);
  15194. }
  15195. emit("click", event);
  15196. };
  15197. const renderIcon = () => {
  15198. if (slots.icon) {
  15199. return slots.icon({
  15200. active: active.value
  15201. });
  15202. }
  15203. if (props2.icon) {
  15204. return vue.createVNode(Icon, {
  15205. "name": props2.icon,
  15206. "classPrefix": props2.iconPrefix
  15207. }, null);
  15208. }
  15209. };
  15210. return () => {
  15211. var _a;
  15212. const {
  15213. dot,
  15214. badge
  15215. } = props2;
  15216. const {
  15217. activeColor,
  15218. inactiveColor
  15219. } = parent.props;
  15220. const color = active.value ? activeColor : inactiveColor;
  15221. return vue.createVNode("div", {
  15222. "role": "tab",
  15223. "class": bem$4({
  15224. active: active.value
  15225. }),
  15226. "style": {
  15227. color
  15228. },
  15229. "tabindex": 0,
  15230. "aria-selected": active.value,
  15231. "onClick": onClick
  15232. }, [vue.createVNode(Badge, vue.mergeProps({
  15233. "dot": dot,
  15234. "class": bem$4("icon"),
  15235. "content": badge
  15236. }, props2.badgeProps), {
  15237. default: renderIcon
  15238. }), vue.createVNode("div", {
  15239. "class": bem$4("text")
  15240. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  15241. active: active.value
  15242. })])]);
  15243. };
  15244. }
  15245. });
  15246. const TabbarItem = withInstall(stdin_default$a);
  15247. const [name$4, bem$3] = createNamespace("text-ellipsis");
  15248. const textEllipsisProps = {
  15249. rows: makeNumericProp(1),
  15250. dots: makeStringProp("..."),
  15251. content: makeStringProp(""),
  15252. expandText: makeStringProp(""),
  15253. collapseText: makeStringProp(""),
  15254. position: makeStringProp("end")
  15255. };
  15256. var stdin_default$9 = vue.defineComponent({
  15257. name: name$4,
  15258. props: textEllipsisProps,
  15259. emits: ["clickAction"],
  15260. setup(props2, {
  15261. emit,
  15262. slots
  15263. }) {
  15264. const text = vue.ref(props2.content);
  15265. const expanded = vue.ref(false);
  15266. const hasAction = vue.ref(false);
  15267. const root = vue.ref();
  15268. const actionRef = vue.ref();
  15269. let needRecalculate = false;
  15270. const actionText = vue.computed(() => expanded.value ? props2.collapseText : props2.expandText);
  15271. const pxToNum = (value) => {
  15272. if (!value) return 0;
  15273. const match = value.match(/^\d*(\.\d*)?/);
  15274. return match ? Number(match[0]) : 0;
  15275. };
  15276. const cloneContainer = () => {
  15277. if (!root.value || !root.value.isConnected) return;
  15278. const originStyle = window.getComputedStyle(root.value);
  15279. const container = document.createElement("div");
  15280. const styleNames = Array.prototype.slice.apply(originStyle);
  15281. styleNames.forEach((name2) => {
  15282. container.style.setProperty(name2, originStyle.getPropertyValue(name2));
  15283. });
  15284. container.style.position = "fixed";
  15285. container.style.zIndex = "-9999";
  15286. container.style.top = "-9999px";
  15287. container.style.height = "auto";
  15288. container.style.minHeight = "auto";
  15289. container.style.maxHeight = "auto";
  15290. container.innerText = props2.content;
  15291. document.body.appendChild(container);
  15292. return container;
  15293. };
  15294. const calcEllipsisText = (container, maxHeight) => {
  15295. var _a, _b;
  15296. const {
  15297. content,
  15298. position,
  15299. dots
  15300. } = props2;
  15301. const end = content.length;
  15302. const middle = 0 + end >> 1;
  15303. const actionHTML = slots.action ? (_b = (_a = actionRef.value) == null ? void 0 : _a.outerHTML) != null ? _b : "" : props2.expandText;
  15304. const calcEllipse = () => {
  15305. const tail = (left, right) => {
  15306. if (right - left <= 1) {
  15307. if (position === "end") {
  15308. return content.slice(0, left) + dots;
  15309. }
  15310. return dots + content.slice(right, end);
  15311. }
  15312. const middle2 = Math.round((left + right) / 2);
  15313. if (position === "end") {
  15314. container.innerText = content.slice(0, middle2) + dots;
  15315. } else {
  15316. container.innerText = dots + content.slice(middle2, end);
  15317. }
  15318. container.innerHTML += actionHTML;
  15319. if (container.offsetHeight > maxHeight) {
  15320. if (position === "end") {
  15321. return tail(left, middle2);
  15322. }
  15323. return tail(middle2, right);
  15324. }
  15325. if (position === "end") {
  15326. return tail(middle2, right);
  15327. }
  15328. return tail(left, middle2);
  15329. };
  15330. return tail(0, end);
  15331. };
  15332. const middleTail = (leftPart, rightPart) => {
  15333. if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
  15334. return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
  15335. }
  15336. const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
  15337. const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
  15338. container.innerText = props2.content.slice(0, leftMiddle) + props2.dots + props2.content.slice(rightMiddle, end);
  15339. container.innerHTML += actionHTML;
  15340. if (container.offsetHeight >= maxHeight) {
  15341. return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
  15342. }
  15343. return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
  15344. };
  15345. return props2.position === "middle" ? middleTail([0, middle], [middle, end]) : calcEllipse();
  15346. };
  15347. const calcEllipsised = () => {
  15348. const container = cloneContainer();
  15349. if (!container) {
  15350. needRecalculate = true;
  15351. return;
  15352. }
  15353. const {
  15354. paddingBottom,
  15355. paddingTop,
  15356. lineHeight
  15357. } = container.style;
  15358. const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
  15359. if (maxHeight < container.offsetHeight) {
  15360. hasAction.value = true;
  15361. text.value = calcEllipsisText(container, maxHeight);
  15362. } else {
  15363. hasAction.value = false;
  15364. text.value = props2.content;
  15365. }
  15366. document.body.removeChild(container);
  15367. };
  15368. const toggle = (isExpanded = !expanded.value) => {
  15369. expanded.value = isExpanded;
  15370. };
  15371. const onClickAction = (event) => {
  15372. toggle();
  15373. emit("clickAction", event);
  15374. };
  15375. const renderAction = () => {
  15376. const action = slots.action ? slots.action({
  15377. expanded: expanded.value
  15378. }) : actionText.value;
  15379. return vue.createVNode("span", {
  15380. "ref": actionRef,
  15381. "class": bem$3("action"),
  15382. "onClick": onClickAction
  15383. }, [action]);
  15384. };
  15385. vue.onMounted(() => {
  15386. calcEllipsised();
  15387. if (slots.action) {
  15388. vue.nextTick(calcEllipsised);
  15389. }
  15390. });
  15391. vue.onActivated(() => {
  15392. if (needRecalculate) {
  15393. needRecalculate = false;
  15394. calcEllipsised();
  15395. }
  15396. });
  15397. vue.watch([windowWidth, () => [props2.content, props2.rows, props2.position]], calcEllipsised);
  15398. useExpose({
  15399. toggle
  15400. });
  15401. return () => vue.createVNode("div", {
  15402. "ref": root,
  15403. "class": bem$3()
  15404. }, [expanded.value ? props2.content : text.value, hasAction.value ? renderAction() : null]);
  15405. }
  15406. });
  15407. const TextEllipsis = withInstall(stdin_default$9);
  15408. const [name$3] = createNamespace("time-picker");
  15409. const validateTime = (val) => /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(val);
  15410. const fullColumns = ["hour", "minute", "second"];
  15411. const timePickerProps = extend({}, sharedProps, {
  15412. minHour: makeNumericProp(0),
  15413. maxHour: makeNumericProp(23),
  15414. minMinute: makeNumericProp(0),
  15415. maxMinute: makeNumericProp(59),
  15416. minSecond: makeNumericProp(0),
  15417. maxSecond: makeNumericProp(59),
  15418. minTime: {
  15419. type: String,
  15420. validator: validateTime
  15421. },
  15422. maxTime: {
  15423. type: String,
  15424. validator: validateTime
  15425. },
  15426. columnsType: {
  15427. type: Array,
  15428. default: () => ["hour", "minute"]
  15429. }
  15430. });
  15431. var stdin_default$8 = vue.defineComponent({
  15432. name: name$3,
  15433. props: timePickerProps,
  15434. emits: ["confirm", "cancel", "change", "update:modelValue"],
  15435. setup(props2, {
  15436. emit,
  15437. slots
  15438. }) {
  15439. const currentValues = vue.ref(props2.modelValue);
  15440. const pickerRef = vue.ref();
  15441. const getValidTime = (time) => {
  15442. const timeLimitArr = time.split(":");
  15443. return fullColumns.map((col, i) => props2.columnsType.includes(col) ? timeLimitArr[i] : "00");
  15444. };
  15445. const confirm = () => {
  15446. var _a;
  15447. return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
  15448. };
  15449. const getSelectedTime = () => currentValues.value;
  15450. const columns = vue.computed(() => {
  15451. let {
  15452. minHour,
  15453. maxHour,
  15454. minMinute,
  15455. maxMinute,
  15456. minSecond,
  15457. maxSecond
  15458. } = props2;
  15459. if (props2.minTime || props2.maxTime) {
  15460. const fullTime = {
  15461. hour: 0,
  15462. minute: 0,
  15463. second: 0
  15464. };
  15465. props2.columnsType.forEach((col, i) => {
  15466. var _a;
  15467. fullTime[col] = (_a = currentValues.value[i]) != null ? _a : 0;
  15468. });
  15469. const {
  15470. hour,
  15471. minute
  15472. } = fullTime;
  15473. if (props2.minTime) {
  15474. const [minH, minM, minS] = getValidTime(props2.minTime);
  15475. minHour = minH;
  15476. minMinute = +hour <= +minHour ? minM : "00";
  15477. minSecond = +hour <= +minHour && +minute <= +minMinute ? minS : "00";
  15478. }
  15479. if (props2.maxTime) {
  15480. const [maxH, maxM, maxS] = getValidTime(props2.maxTime);
  15481. maxHour = maxH;
  15482. maxMinute = +hour >= +maxHour ? maxM : "59";
  15483. maxSecond = +hour >= +maxHour && +minute >= +maxMinute ? maxS : "59";
  15484. }
  15485. }
  15486. return props2.columnsType.map((type) => {
  15487. const {
  15488. filter,
  15489. formatter
  15490. } = props2;
  15491. switch (type) {
  15492. case "hour":
  15493. return genOptions(+minHour, +maxHour, type, formatter, filter, currentValues.value);
  15494. case "minute":
  15495. return genOptions(+minMinute, +maxMinute, type, formatter, filter, currentValues.value);
  15496. case "second":
  15497. return genOptions(+minSecond, +maxSecond, type, formatter, filter, currentValues.value);
  15498. default:
  15499. if (process.env.NODE_ENV !== "production") {
  15500. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  15501. }
  15502. return [];
  15503. }
  15504. });
  15505. });
  15506. vue.watch(currentValues, (newValues) => {
  15507. if (!isSameValue(newValues, props2.modelValue)) {
  15508. emit("update:modelValue", newValues);
  15509. }
  15510. });
  15511. vue.watch(() => props2.modelValue, (newValues) => {
  15512. newValues = formatValueRange(newValues, columns.value);
  15513. if (!isSameValue(newValues, currentValues.value)) {
  15514. currentValues.value = newValues;
  15515. }
  15516. }, {
  15517. immediate: true
  15518. });
  15519. const onChange = (...args) => emit("change", ...args);
  15520. const onCancel = (...args) => emit("cancel", ...args);
  15521. const onConfirm = (...args) => emit("confirm", ...args);
  15522. useExpose({
  15523. confirm,
  15524. getSelectedTime
  15525. });
  15526. return () => vue.createVNode(Picker, vue.mergeProps({
  15527. "ref": pickerRef,
  15528. "modelValue": currentValues.value,
  15529. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  15530. "columns": columns.value,
  15531. "onChange": onChange,
  15532. "onCancel": onCancel,
  15533. "onConfirm": onConfirm
  15534. }, pick(props2, pickerInheritKeys)), slots);
  15535. }
  15536. });
  15537. const TimePicker = withInstall(stdin_default$8);
  15538. const [name$2, bem$2] = createNamespace("tree-select");
  15539. const treeSelectProps = {
  15540. max: makeNumericProp(Infinity),
  15541. items: makeArrayProp(),
  15542. height: makeNumericProp(300),
  15543. selectedIcon: makeStringProp("success"),
  15544. mainActiveIndex: makeNumericProp(0),
  15545. activeId: {
  15546. type: [Number, String, Array],
  15547. default: 0
  15548. }
  15549. };
  15550. var stdin_default$7 = vue.defineComponent({
  15551. name: name$2,
  15552. props: treeSelectProps,
  15553. emits: ["clickNav", "clickItem", "update:activeId", "update:mainActiveIndex"],
  15554. setup(props2, {
  15555. emit,
  15556. slots
  15557. }) {
  15558. const isActiveItem = (id) => Array.isArray(props2.activeId) ? props2.activeId.includes(id) : props2.activeId === id;
  15559. const renderSubItem = (item) => {
  15560. const onClick = () => {
  15561. if (item.disabled) {
  15562. return;
  15563. }
  15564. let activeId;
  15565. if (Array.isArray(props2.activeId)) {
  15566. activeId = props2.activeId.slice();
  15567. const index = activeId.indexOf(item.id);
  15568. if (index !== -1) {
  15569. activeId.splice(index, 1);
  15570. } else if (activeId.length < +props2.max) {
  15571. activeId.push(item.id);
  15572. }
  15573. } else {
  15574. activeId = item.id;
  15575. }
  15576. emit("update:activeId", activeId);
  15577. emit("clickItem", item);
  15578. };
  15579. return vue.createVNode("div", {
  15580. "key": item.id,
  15581. "class": ["van-ellipsis", bem$2("item", {
  15582. active: isActiveItem(item.id),
  15583. disabled: item.disabled
  15584. })],
  15585. "onClick": onClick
  15586. }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
  15587. "name": props2.selectedIcon,
  15588. "class": bem$2("selected")
  15589. }, null)]);
  15590. };
  15591. const onSidebarChange = (index) => {
  15592. emit("update:mainActiveIndex", index);
  15593. };
  15594. const onClickSidebarItem = (index) => emit("clickNav", index);
  15595. const renderSidebar = () => {
  15596. const Items = props2.items.map((item) => vue.createVNode(SidebarItem, {
  15597. "dot": item.dot,
  15598. "badge": item.badge,
  15599. "class": [bem$2("nav-item"), item.className],
  15600. "disabled": item.disabled,
  15601. "onClick": onClickSidebarItem
  15602. }, {
  15603. title: () => slots["nav-text"] ? slots["nav-text"](item) : item.text
  15604. }));
  15605. return vue.createVNode(Sidebar, {
  15606. "class": bem$2("nav"),
  15607. "modelValue": props2.mainActiveIndex,
  15608. "onChange": onSidebarChange
  15609. }, {
  15610. default: () => [Items]
  15611. });
  15612. };
  15613. const renderContent = () => {
  15614. if (slots.content) {
  15615. return slots.content();
  15616. }
  15617. const selected = props2.items[+props2.mainActiveIndex] || {};
  15618. if (selected.children) {
  15619. return selected.children.map(renderSubItem);
  15620. }
  15621. };
  15622. return () => vue.createVNode("div", {
  15623. "class": bem$2(),
  15624. "style": {
  15625. height: addUnit(props2.height)
  15626. }
  15627. }, [renderSidebar(), vue.createVNode("div", {
  15628. "class": bem$2("content")
  15629. }, [renderContent()])]);
  15630. }
  15631. });
  15632. const TreeSelect = withInstall(stdin_default$7);
  15633. const [name$1, bem$1, t] = createNamespace("uploader");
  15634. function readFileContent(file, resultType) {
  15635. return new Promise((resolve) => {
  15636. if (resultType === "file") {
  15637. resolve();
  15638. return;
  15639. }
  15640. const reader = new FileReader();
  15641. reader.onload = (event) => {
  15642. resolve(event.target.result);
  15643. };
  15644. if (resultType === "dataUrl") {
  15645. reader.readAsDataURL(file);
  15646. } else if (resultType === "text") {
  15647. reader.readAsText(file);
  15648. }
  15649. });
  15650. }
  15651. function isOversize(items, maxSize) {
  15652. return toArray(items).some((item) => {
  15653. if (item.file) {
  15654. if (isFunction(maxSize)) {
  15655. return maxSize(item.file);
  15656. }
  15657. return item.file.size > +maxSize;
  15658. }
  15659. return false;
  15660. });
  15661. }
  15662. function filterFiles(items, maxSize) {
  15663. const valid = [];
  15664. const invalid = [];
  15665. items.forEach((item) => {
  15666. if (isOversize(item, maxSize)) {
  15667. invalid.push(item);
  15668. } else {
  15669. valid.push(item);
  15670. }
  15671. });
  15672. return { valid, invalid };
  15673. }
  15674. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i;
  15675. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  15676. function isImageFile(item) {
  15677. if (item.isImage) {
  15678. return true;
  15679. }
  15680. if (item.file && item.file.type) {
  15681. return item.file.type.indexOf("image") === 0;
  15682. }
  15683. if (item.url) {
  15684. return isImageUrl(item.url);
  15685. }
  15686. if (typeof item.content === "string") {
  15687. return item.content.indexOf("data:image") === 0;
  15688. }
  15689. return false;
  15690. }
  15691. var stdin_default$6 = vue.defineComponent({
  15692. props: {
  15693. name: numericProp,
  15694. item: makeRequiredProp(Object),
  15695. index: Number,
  15696. imageFit: String,
  15697. lazyLoad: Boolean,
  15698. deletable: Boolean,
  15699. reupload: Boolean,
  15700. previewSize: [Number, String, Array],
  15701. beforeDelete: Function
  15702. },
  15703. emits: ["delete", "preview", "reupload"],
  15704. setup(props2, {
  15705. emit,
  15706. slots
  15707. }) {
  15708. const renderMask = () => {
  15709. const {
  15710. status,
  15711. message
  15712. } = props2.item;
  15713. if (status === "uploading" || status === "failed") {
  15714. const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
  15715. "name": "close",
  15716. "class": bem$1("mask-icon")
  15717. }, null) : vue.createVNode(Loading, {
  15718. "class": bem$1("loading")
  15719. }, null);
  15720. const showMessage = isDef(message) && message !== "";
  15721. return vue.createVNode("div", {
  15722. "class": bem$1("mask")
  15723. }, [MaskIcon, showMessage && vue.createVNode("div", {
  15724. "class": bem$1("mask-message")
  15725. }, [message])]);
  15726. }
  15727. };
  15728. const onDelete = (event) => {
  15729. const {
  15730. name: name2,
  15731. item,
  15732. index,
  15733. beforeDelete
  15734. } = props2;
  15735. event.stopPropagation();
  15736. callInterceptor(beforeDelete, {
  15737. args: [item, {
  15738. name: name2,
  15739. index
  15740. }],
  15741. done: () => emit("delete")
  15742. });
  15743. };
  15744. const onPreview = () => emit("preview");
  15745. const onReupload = () => emit("reupload");
  15746. const renderDeleteIcon = () => {
  15747. if (props2.deletable && props2.item.status !== "uploading") {
  15748. const slot = slots["preview-delete"];
  15749. return vue.createVNode("div", {
  15750. "role": "button",
  15751. "class": bem$1("preview-delete", {
  15752. shadow: !slot
  15753. }),
  15754. "tabindex": 0,
  15755. "aria-label": t("delete"),
  15756. "onClick": onDelete
  15757. }, [slot ? slot() : vue.createVNode(Icon, {
  15758. "name": "cross",
  15759. "class": bem$1("preview-delete-icon")
  15760. }, null)]);
  15761. }
  15762. };
  15763. const renderCover = () => {
  15764. if (slots["preview-cover"]) {
  15765. const {
  15766. index,
  15767. item
  15768. } = props2;
  15769. return vue.createVNode("div", {
  15770. "class": bem$1("preview-cover")
  15771. }, [slots["preview-cover"](extend({
  15772. index
  15773. }, item))]);
  15774. }
  15775. };
  15776. const renderPreview = () => {
  15777. const {
  15778. item,
  15779. lazyLoad,
  15780. imageFit,
  15781. previewSize,
  15782. reupload
  15783. } = props2;
  15784. if (isImageFile(item)) {
  15785. return vue.createVNode(Image$1, {
  15786. "fit": imageFit,
  15787. "src": item.objectUrl || item.content || item.url,
  15788. "class": bem$1("preview-image"),
  15789. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  15790. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  15791. "lazyLoad": lazyLoad,
  15792. "onClick": reupload ? onReupload : onPreview
  15793. }, {
  15794. default: renderCover
  15795. });
  15796. }
  15797. return vue.createVNode("div", {
  15798. "class": bem$1("file"),
  15799. "style": getSizeStyle(props2.previewSize)
  15800. }, [vue.createVNode(Icon, {
  15801. "class": bem$1("file-icon"),
  15802. "name": "description"
  15803. }, null), vue.createVNode("div", {
  15804. "class": [bem$1("file-name"), "van-ellipsis"]
  15805. }, [item.file ? item.file.name : item.url]), renderCover()]);
  15806. };
  15807. return () => vue.createVNode("div", {
  15808. "class": bem$1("preview")
  15809. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  15810. }
  15811. });
  15812. const uploaderProps = {
  15813. name: makeNumericProp(""),
  15814. accept: makeStringProp("image/*"),
  15815. capture: String,
  15816. multiple: Boolean,
  15817. disabled: Boolean,
  15818. readonly: Boolean,
  15819. lazyLoad: Boolean,
  15820. maxCount: makeNumericProp(Infinity),
  15821. imageFit: makeStringProp("cover"),
  15822. resultType: makeStringProp("dataUrl"),
  15823. uploadIcon: makeStringProp("photograph"),
  15824. uploadText: String,
  15825. deletable: truthProp,
  15826. reupload: Boolean,
  15827. afterRead: Function,
  15828. showUpload: truthProp,
  15829. modelValue: makeArrayProp(),
  15830. beforeRead: Function,
  15831. beforeDelete: Function,
  15832. previewSize: [Number, String, Array],
  15833. previewImage: truthProp,
  15834. previewOptions: Object,
  15835. previewFullImage: truthProp,
  15836. maxSize: {
  15837. type: [Number, String, Function],
  15838. default: Infinity
  15839. }
  15840. };
  15841. var stdin_default$5 = vue.defineComponent({
  15842. name: name$1,
  15843. props: uploaderProps,
  15844. emits: ["delete", "oversize", "clickUpload", "closePreview", "clickPreview", "clickReupload", "update:modelValue"],
  15845. setup(props2, {
  15846. emit,
  15847. slots
  15848. }) {
  15849. const inputRef = vue.ref();
  15850. const urls = [];
  15851. const reuploadIndex = vue.ref(-1);
  15852. const isReuploading = vue.ref(false);
  15853. const getDetail = (index = props2.modelValue.length) => ({
  15854. name: props2.name,
  15855. index
  15856. });
  15857. const resetInput = () => {
  15858. if (inputRef.value) {
  15859. inputRef.value.value = "";
  15860. }
  15861. };
  15862. const onAfterRead = (items) => {
  15863. resetInput();
  15864. if (isOversize(items, props2.maxSize)) {
  15865. if (Array.isArray(items)) {
  15866. const result = filterFiles(items, props2.maxSize);
  15867. items = result.valid;
  15868. emit("oversize", result.invalid, getDetail());
  15869. if (!items.length) {
  15870. return;
  15871. }
  15872. } else {
  15873. emit("oversize", items, getDetail());
  15874. return;
  15875. }
  15876. }
  15877. items = vue.reactive(items);
  15878. if (reuploadIndex.value > -1) {
  15879. const arr = [...props2.modelValue];
  15880. arr.splice(reuploadIndex.value, 1, items);
  15881. emit("update:modelValue", arr);
  15882. reuploadIndex.value = -1;
  15883. } else {
  15884. emit("update:modelValue", [...props2.modelValue, ...toArray(items)]);
  15885. }
  15886. if (props2.afterRead) {
  15887. props2.afterRead(items, getDetail());
  15888. }
  15889. };
  15890. const readFile = (files) => {
  15891. const {
  15892. maxCount,
  15893. modelValue,
  15894. resultType
  15895. } = props2;
  15896. if (Array.isArray(files)) {
  15897. const remainCount = +maxCount - modelValue.length;
  15898. if (files.length > remainCount) {
  15899. files = files.slice(0, remainCount);
  15900. }
  15901. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  15902. const fileList = files.map((file, index) => {
  15903. const result = {
  15904. file,
  15905. status: "",
  15906. message: "",
  15907. objectUrl: URL.createObjectURL(file)
  15908. };
  15909. if (contents[index]) {
  15910. result.content = contents[index];
  15911. }
  15912. return result;
  15913. });
  15914. onAfterRead(fileList);
  15915. });
  15916. } else {
  15917. readFileContent(files, resultType).then((content) => {
  15918. const result = {
  15919. file: files,
  15920. status: "",
  15921. message: "",
  15922. objectUrl: URL.createObjectURL(files)
  15923. };
  15924. if (content) {
  15925. result.content = content;
  15926. }
  15927. onAfterRead(result);
  15928. });
  15929. }
  15930. };
  15931. const onChange = (event) => {
  15932. const {
  15933. files
  15934. } = event.target;
  15935. if (props2.disabled || !files || !files.length) {
  15936. return;
  15937. }
  15938. const file = files.length === 1 ? files[0] : [].slice.call(files);
  15939. if (props2.beforeRead) {
  15940. const response = props2.beforeRead(file, getDetail());
  15941. if (!response) {
  15942. resetInput();
  15943. return;
  15944. }
  15945. if (isPromise(response)) {
  15946. response.then((data) => {
  15947. if (data) {
  15948. readFile(data);
  15949. } else {
  15950. readFile(file);
  15951. }
  15952. }).catch(resetInput);
  15953. return;
  15954. }
  15955. }
  15956. readFile(file);
  15957. };
  15958. let imagePreview;
  15959. const onClosePreview = () => emit("closePreview");
  15960. const previewImage = (item) => {
  15961. if (props2.previewFullImage) {
  15962. const imageFiles = props2.modelValue.filter(isImageFile);
  15963. const images = imageFiles.map((item2) => {
  15964. if (item2.objectUrl && !item2.url && item2.status !== "failed") {
  15965. item2.url = item2.objectUrl;
  15966. urls.push(item2.url);
  15967. }
  15968. return item2.url;
  15969. }).filter(Boolean);
  15970. imagePreview = showImagePreview(extend({
  15971. images,
  15972. startPosition: imageFiles.indexOf(item),
  15973. onClose: onClosePreview
  15974. }, props2.previewOptions));
  15975. }
  15976. };
  15977. const closeImagePreview = () => {
  15978. if (imagePreview) {
  15979. imagePreview.close();
  15980. }
  15981. };
  15982. const deleteFile = (item, index) => {
  15983. const fileList = props2.modelValue.slice(0);
  15984. fileList.splice(index, 1);
  15985. emit("update:modelValue", fileList);
  15986. emit("delete", item, getDetail(index));
  15987. };
  15988. const reuploadFile = (index) => {
  15989. isReuploading.value = true;
  15990. reuploadIndex.value = index;
  15991. vue.nextTick(() => chooseFile());
  15992. };
  15993. const onInputClick = () => {
  15994. if (!isReuploading.value) {
  15995. reuploadIndex.value = -1;
  15996. }
  15997. isReuploading.value = false;
  15998. };
  15999. const renderPreviewItem = (item, index) => {
  16000. const needPickData = ["imageFit", "deletable", "reupload", "previewSize", "beforeDelete"];
  16001. const previewData = extend(pick(props2, needPickData), pick(item, needPickData, true));
  16002. return vue.createVNode(stdin_default$6, vue.mergeProps({
  16003. "item": item,
  16004. "index": index,
  16005. "onClick": () => emit(props2.reupload ? "clickReupload" : "clickPreview", item, getDetail(index)),
  16006. "onDelete": () => deleteFile(item, index),
  16007. "onPreview": () => previewImage(item),
  16008. "onReupload": () => reuploadFile(index)
  16009. }, pick(props2, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  16010. };
  16011. const renderPreviewList = () => {
  16012. if (props2.previewImage) {
  16013. return props2.modelValue.map(renderPreviewItem);
  16014. }
  16015. };
  16016. const onClickUpload = (event) => emit("clickUpload", event);
  16017. const renderUpload = () => {
  16018. const lessThanMax = props2.modelValue.length < +props2.maxCount;
  16019. const Input = props2.readonly ? null : vue.createVNode("input", {
  16020. "ref": inputRef,
  16021. "type": "file",
  16022. "class": bem$1("input"),
  16023. "accept": props2.accept,
  16024. "capture": props2.capture,
  16025. "multiple": props2.multiple && reuploadIndex.value === -1,
  16026. "disabled": props2.disabled,
  16027. "onChange": onChange,
  16028. "onClick": onInputClick
  16029. }, null);
  16030. if (slots.default) {
  16031. return vue.withDirectives(vue.createVNode("div", {
  16032. "class": bem$1("input-wrapper"),
  16033. "onClick": onClickUpload
  16034. }, [slots.default(), Input]), [[vue.vShow, lessThanMax]]);
  16035. }
  16036. return vue.withDirectives(vue.createVNode("div", {
  16037. "class": bem$1("upload", {
  16038. readonly: props2.readonly
  16039. }),
  16040. "style": getSizeStyle(props2.previewSize),
  16041. "onClick": onClickUpload
  16042. }, [vue.createVNode(Icon, {
  16043. "name": props2.uploadIcon,
  16044. "class": bem$1("upload-icon")
  16045. }, null), props2.uploadText && vue.createVNode("span", {
  16046. "class": bem$1("upload-text")
  16047. }, [props2.uploadText]), Input]), [[vue.vShow, props2.showUpload && lessThanMax]]);
  16048. };
  16049. const chooseFile = () => {
  16050. if (inputRef.value && !props2.disabled) {
  16051. inputRef.value.click();
  16052. }
  16053. };
  16054. vue.onBeforeUnmount(() => {
  16055. urls.forEach((url) => URL.revokeObjectURL(url));
  16056. });
  16057. useExpose({
  16058. chooseFile,
  16059. reuploadFile,
  16060. closeImagePreview
  16061. });
  16062. use.useCustomFieldValue(() => props2.modelValue);
  16063. return () => vue.createVNode("div", {
  16064. "class": bem$1()
  16065. }, [vue.createVNode("div", {
  16066. "class": bem$1("wrapper", {
  16067. disabled: props2.disabled
  16068. })
  16069. }, [renderPreviewList(), renderUpload()])]);
  16070. }
  16071. });
  16072. const Uploader = withInstall(stdin_default$5);
  16073. const [name, bem] = createNamespace("watermark");
  16074. const watermarkProps = {
  16075. gapX: makeNumberProp(0),
  16076. gapY: makeNumberProp(0),
  16077. image: String,
  16078. width: makeNumberProp(100),
  16079. height: makeNumberProp(100),
  16080. rotate: makeNumericProp(-22),
  16081. zIndex: numericProp,
  16082. content: String,
  16083. opacity: numericProp,
  16084. fullPage: truthProp,
  16085. textColor: makeStringProp("#dcdee0")
  16086. };
  16087. var stdin_default$4 = vue.defineComponent({
  16088. name,
  16089. props: watermarkProps,
  16090. setup(props2, {
  16091. slots
  16092. }) {
  16093. const svgElRef = vue.ref();
  16094. const watermarkUrl = vue.ref("");
  16095. const imageBase64 = vue.ref("");
  16096. const renderWatermark = () => {
  16097. const rotateStyle = {
  16098. transformOrigin: "center",
  16099. transform: `rotate(${props2.rotate}deg)`
  16100. };
  16101. const svgInner = () => {
  16102. if (props2.image && !slots.content) {
  16103. return vue.createVNode("image", {
  16104. "href": imageBase64.value,
  16105. "xlink:href": imageBase64.value,
  16106. "x": "0",
  16107. "y": "0",
  16108. "width": props2.width,
  16109. "height": props2.height,
  16110. "style": rotateStyle
  16111. }, null);
  16112. }
  16113. return vue.createVNode("foreignObject", {
  16114. "x": "0",
  16115. "y": "0",
  16116. "width": props2.width,
  16117. "height": props2.height
  16118. }, [vue.createVNode("div", {
  16119. "xmlns": "http://www.w3.org/1999/xhtml",
  16120. "style": rotateStyle
  16121. }, [slots.content ? slots.content() : vue.createVNode("span", {
  16122. "style": {
  16123. color: props2.textColor
  16124. }
  16125. }, [props2.content])])]);
  16126. };
  16127. const svgWidth = props2.width + props2.gapX;
  16128. const svgHeight = props2.height + props2.gapY;
  16129. return vue.createVNode("svg", {
  16130. "viewBox": `0 0 ${svgWidth} ${svgHeight}`,
  16131. "width": svgWidth,
  16132. "height": svgHeight,
  16133. "xmlns": "http://www.w3.org/2000/svg",
  16134. "xmlns:xlink": "http://www.w3.org/1999/xlink",
  16135. "style": {
  16136. padding: `0 ${props2.gapX}px ${props2.gapY}px 0`,
  16137. opacity: props2.opacity
  16138. }
  16139. }, [svgInner()]);
  16140. };
  16141. const makeImageToBase64 = (url) => {
  16142. const canvas = document.createElement("canvas");
  16143. const image = new Image();
  16144. image.crossOrigin = "anonymous";
  16145. image.referrerPolicy = "no-referrer";
  16146. image.onload = () => {
  16147. canvas.width = image.naturalWidth;
  16148. canvas.height = image.naturalHeight;
  16149. const ctx = canvas.getContext("2d");
  16150. ctx == null ? void 0 : ctx.drawImage(image, 0, 0);
  16151. imageBase64.value = canvas.toDataURL();
  16152. };
  16153. image.src = url;
  16154. };
  16155. const makeSvgToBlobUrl = (svgStr) => {
  16156. const svgBlob = new Blob([svgStr], {
  16157. type: "image/svg+xml"
  16158. });
  16159. return URL.createObjectURL(svgBlob);
  16160. };
  16161. vue.watchEffect(() => {
  16162. if (props2.image) {
  16163. makeImageToBase64(props2.image);
  16164. }
  16165. });
  16166. vue.watch(() => [imageBase64.value, props2.content, props2.textColor, props2.height, props2.width, props2.rotate, props2.gapX, props2.gapY], () => {
  16167. vue.nextTick(() => {
  16168. if (svgElRef.value) {
  16169. if (watermarkUrl.value) {
  16170. URL.revokeObjectURL(watermarkUrl.value);
  16171. }
  16172. watermarkUrl.value = makeSvgToBlobUrl(svgElRef.value.innerHTML);
  16173. }
  16174. });
  16175. }, {
  16176. immediate: true
  16177. });
  16178. vue.onUnmounted(() => {
  16179. if (watermarkUrl.value) {
  16180. URL.revokeObjectURL(watermarkUrl.value);
  16181. }
  16182. });
  16183. return () => {
  16184. const style = extend({
  16185. backgroundImage: `url(${watermarkUrl.value})`
  16186. }, getZIndexStyle(props2.zIndex));
  16187. return vue.createVNode("div", {
  16188. "class": bem({
  16189. full: props2.fullPage
  16190. }),
  16191. "style": style
  16192. }, [vue.createVNode("div", {
  16193. "class": bem("wrapper"),
  16194. "ref": svgElRef
  16195. }, [renderWatermark()])]);
  16196. };
  16197. }
  16198. });
  16199. const Watermark = withInstall(stdin_default$4);
  16200. class ReactiveListener {
  16201. constructor({
  16202. el,
  16203. src,
  16204. error,
  16205. loading,
  16206. bindType,
  16207. $parent,
  16208. options,
  16209. cors,
  16210. elRenderer,
  16211. imageCache
  16212. }) {
  16213. this.el = el;
  16214. this.src = src;
  16215. this.error = error;
  16216. this.loading = loading;
  16217. this.bindType = bindType;
  16218. this.attempt = 0;
  16219. this.cors = cors;
  16220. this.naturalHeight = 0;
  16221. this.naturalWidth = 0;
  16222. this.options = options;
  16223. this.$parent = $parent;
  16224. this.elRenderer = elRenderer;
  16225. this.imageCache = imageCache;
  16226. this.performanceData = {
  16227. loadStart: 0,
  16228. loadEnd: 0
  16229. };
  16230. this.filter();
  16231. this.initState();
  16232. this.render("loading", false);
  16233. }
  16234. /*
  16235. * init listener state
  16236. * @return
  16237. */
  16238. initState() {
  16239. if ("dataset" in this.el) {
  16240. this.el.dataset.src = this.src;
  16241. } else {
  16242. this.el.setAttribute("data-src", this.src);
  16243. }
  16244. this.state = {
  16245. loading: false,
  16246. error: false,
  16247. loaded: false,
  16248. rendered: false
  16249. };
  16250. }
  16251. /*
  16252. * record performance
  16253. * @return
  16254. */
  16255. record(event) {
  16256. this.performanceData[event] = Date.now();
  16257. }
  16258. /*
  16259. * update image listener data
  16260. * @param {String} image uri
  16261. * @param {String} loading image uri
  16262. * @param {String} error image uri
  16263. * @return
  16264. */
  16265. update({ src, loading, error }) {
  16266. const oldSrc = this.src;
  16267. this.src = src;
  16268. this.loading = loading;
  16269. this.error = error;
  16270. this.filter();
  16271. if (oldSrc !== this.src) {
  16272. this.attempt = 0;
  16273. this.initState();
  16274. }
  16275. }
  16276. /*
  16277. * check el is in view
  16278. * @return {Boolean} el is in view
  16279. */
  16280. checkInView() {
  16281. const rect = use.useRect(this.el);
  16282. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  16283. }
  16284. /*
  16285. * listener filter
  16286. */
  16287. filter() {
  16288. Object.keys(this.options.filter).forEach((key) => {
  16289. this.options.filter[key](this, this.options);
  16290. });
  16291. }
  16292. /*
  16293. * render loading first
  16294. * @params cb:Function
  16295. * @return
  16296. */
  16297. renderLoading(cb) {
  16298. this.state.loading = true;
  16299. loadImageAsync(
  16300. {
  16301. src: this.loading,
  16302. cors: this.cors
  16303. },
  16304. () => {
  16305. this.render("loading", false);
  16306. this.state.loading = false;
  16307. cb();
  16308. },
  16309. () => {
  16310. cb();
  16311. this.state.loading = false;
  16312. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  16313. console.warn(
  16314. `[@vant/lazyload] load failed with loading image(${this.loading})`
  16315. );
  16316. }
  16317. );
  16318. }
  16319. /*
  16320. * try load image and render it
  16321. * @return
  16322. */
  16323. load(onFinish = noop) {
  16324. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  16325. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  16326. console.log(
  16327. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  16328. );
  16329. }
  16330. onFinish();
  16331. return;
  16332. }
  16333. if (this.state.rendered && this.state.loaded) return;
  16334. if (this.imageCache.has(this.src)) {
  16335. this.state.loaded = true;
  16336. this.render("loaded", true);
  16337. this.state.rendered = true;
  16338. return onFinish();
  16339. }
  16340. this.renderLoading(() => {
  16341. var _a, _b;
  16342. this.attempt++;
  16343. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  16344. this.record("loadStart");
  16345. loadImageAsync(
  16346. {
  16347. src: this.src,
  16348. cors: this.cors
  16349. },
  16350. (data) => {
  16351. this.naturalHeight = data.naturalHeight;
  16352. this.naturalWidth = data.naturalWidth;
  16353. this.state.loaded = true;
  16354. this.state.error = false;
  16355. this.record("loadEnd");
  16356. this.render("loaded", false);
  16357. this.state.rendered = true;
  16358. this.imageCache.add(this.src);
  16359. onFinish();
  16360. },
  16361. (err) => {
  16362. !this.options.silent && console.error(err);
  16363. this.state.error = true;
  16364. this.state.loaded = false;
  16365. this.render("error", false);
  16366. }
  16367. );
  16368. });
  16369. }
  16370. /*
  16371. * render image
  16372. * @param {String} state to render // ['loading', 'src', 'error']
  16373. * @param {String} is form cache
  16374. * @return
  16375. */
  16376. render(state, cache) {
  16377. this.elRenderer(this, state, cache);
  16378. }
  16379. /*
  16380. * output performance data
  16381. * @return {Object} performance data
  16382. */
  16383. performance() {
  16384. let state = "loading";
  16385. let time = 0;
  16386. if (this.state.loaded) {
  16387. state = "loaded";
  16388. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  16389. }
  16390. if (this.state.error) state = "error";
  16391. return {
  16392. src: this.src,
  16393. state,
  16394. time
  16395. };
  16396. }
  16397. /*
  16398. * $destroy
  16399. * @return
  16400. */
  16401. $destroy() {
  16402. this.el = null;
  16403. this.src = null;
  16404. this.error = null;
  16405. this.loading = null;
  16406. this.bindType = null;
  16407. this.attempt = 0;
  16408. }
  16409. }
  16410. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  16411. const DEFAULT_EVENTS = [
  16412. "scroll",
  16413. "wheel",
  16414. "mousewheel",
  16415. "resize",
  16416. "animationend",
  16417. "transitionend",
  16418. "touchmove"
  16419. ];
  16420. const DEFAULT_OBSERVER_OPTIONS = {
  16421. rootMargin: "0px",
  16422. threshold: 0
  16423. };
  16424. function stdin_default$3() {
  16425. return class Lazy {
  16426. constructor({
  16427. preLoad,
  16428. error,
  16429. throttleWait,
  16430. preLoadTop,
  16431. dispatchEvent,
  16432. loading,
  16433. attempt,
  16434. silent = true,
  16435. scale,
  16436. listenEvents,
  16437. filter,
  16438. adapter,
  16439. observer,
  16440. observerOptions
  16441. }) {
  16442. this.mode = modeType.event;
  16443. this.listeners = [];
  16444. this.targetIndex = 0;
  16445. this.targets = [];
  16446. this.options = {
  16447. silent,
  16448. dispatchEvent: !!dispatchEvent,
  16449. throttleWait: throttleWait || 200,
  16450. preLoad: preLoad || 1.3,
  16451. preLoadTop: preLoadTop || 0,
  16452. error: error || DEFAULT_URL,
  16453. loading: loading || DEFAULT_URL,
  16454. attempt: attempt || 3,
  16455. scale: scale || getDPR(scale),
  16456. ListenEvents: listenEvents || DEFAULT_EVENTS,
  16457. supportWebp: supportWebp(),
  16458. filter: filter || {},
  16459. adapter: adapter || {},
  16460. observer: !!observer,
  16461. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  16462. };
  16463. this.initEvent();
  16464. this.imageCache = new ImageCache({ max: 200 });
  16465. this.lazyLoadHandler = throttle(
  16466. this.lazyLoadHandler.bind(this),
  16467. this.options.throttleWait
  16468. );
  16469. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  16470. }
  16471. /**
  16472. * update config
  16473. * @param {Object} config params
  16474. * @return
  16475. */
  16476. config(options = {}) {
  16477. Object.assign(this.options, options);
  16478. }
  16479. /**
  16480. * output listener's load performance
  16481. * @return {Array}
  16482. */
  16483. performance() {
  16484. return this.listeners.map((item) => item.performance());
  16485. }
  16486. /*
  16487. * add lazy component to queue
  16488. * @param {Vue} vm lazy component instance
  16489. * @return
  16490. */
  16491. addLazyBox(vm) {
  16492. this.listeners.push(vm);
  16493. if (use.inBrowser) {
  16494. this.addListenerTarget(window);
  16495. this.observer && this.observer.observe(vm.el);
  16496. if (vm.$el && vm.$el.parentNode) {
  16497. this.addListenerTarget(vm.$el.parentNode);
  16498. }
  16499. }
  16500. }
  16501. /*
  16502. * add image listener to queue
  16503. * @param {DOM} el
  16504. * @param {object} binding vue directive binding
  16505. * @param {vnode} vnode vue directive vnode
  16506. * @return
  16507. */
  16508. add(el, binding, vnode) {
  16509. if (this.listeners.some((item) => item.el === el)) {
  16510. this.update(el, binding);
  16511. return vue.nextTick(this.lazyLoadHandler);
  16512. }
  16513. const value = this.valueFormatter(binding.value);
  16514. let { src } = value;
  16515. vue.nextTick(() => {
  16516. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  16517. this.observer && this.observer.observe(el);
  16518. const container = Object.keys(binding.modifiers)[0];
  16519. let $parent;
  16520. if (container) {
  16521. $parent = vnode.context.$refs[container];
  16522. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  16523. }
  16524. if (!$parent) {
  16525. $parent = use.getScrollParent(el);
  16526. }
  16527. const newListener = new ReactiveListener({
  16528. bindType: binding.arg,
  16529. $parent,
  16530. el,
  16531. src,
  16532. loading: value.loading,
  16533. error: value.error,
  16534. cors: value.cors,
  16535. elRenderer: this.elRenderer.bind(this),
  16536. options: this.options,
  16537. imageCache: this.imageCache
  16538. });
  16539. this.listeners.push(newListener);
  16540. if (use.inBrowser) {
  16541. this.addListenerTarget(window);
  16542. this.addListenerTarget($parent);
  16543. }
  16544. this.lazyLoadHandler();
  16545. vue.nextTick(() => this.lazyLoadHandler());
  16546. });
  16547. }
  16548. /**
  16549. * update image src
  16550. * @param {DOM} el
  16551. * @param {object} vue directive binding
  16552. * @return
  16553. */
  16554. update(el, binding, vnode) {
  16555. const value = this.valueFormatter(binding.value);
  16556. let { src } = value;
  16557. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  16558. const exist = this.listeners.find((item) => item.el === el);
  16559. if (!exist) {
  16560. this.add(el, binding, vnode);
  16561. } else {
  16562. exist.update({
  16563. src,
  16564. error: value.error,
  16565. loading: value.loading
  16566. });
  16567. }
  16568. if (this.observer) {
  16569. this.observer.unobserve(el);
  16570. this.observer.observe(el);
  16571. }
  16572. this.lazyLoadHandler();
  16573. vue.nextTick(() => this.lazyLoadHandler());
  16574. }
  16575. /**
  16576. * remove listener form list
  16577. * @param {DOM} el
  16578. * @return
  16579. */
  16580. remove(el) {
  16581. if (!el) return;
  16582. this.observer && this.observer.unobserve(el);
  16583. const existItem = this.listeners.find((item) => item.el === el);
  16584. if (existItem) {
  16585. this.removeListenerTarget(existItem.$parent);
  16586. this.removeListenerTarget(window);
  16587. remove(this.listeners, existItem);
  16588. existItem.$destroy();
  16589. }
  16590. }
  16591. /*
  16592. * remove lazy components form list
  16593. * @param {Vue} vm Vue instance
  16594. * @return
  16595. */
  16596. removeComponent(vm) {
  16597. if (!vm) return;
  16598. remove(this.listeners, vm);
  16599. this.observer && this.observer.unobserve(vm.el);
  16600. if (vm.$parent && vm.$el.parentNode) {
  16601. this.removeListenerTarget(vm.$el.parentNode);
  16602. }
  16603. this.removeListenerTarget(window);
  16604. }
  16605. setMode(mode) {
  16606. if (!hasIntersectionObserver && mode === modeType.observer) {
  16607. mode = modeType.event;
  16608. }
  16609. this.mode = mode;
  16610. if (mode === modeType.event) {
  16611. if (this.observer) {
  16612. this.listeners.forEach((listener) => {
  16613. this.observer.unobserve(listener.el);
  16614. });
  16615. this.observer = null;
  16616. }
  16617. this.targets.forEach((target) => {
  16618. this.initListen(target.el, true);
  16619. });
  16620. } else {
  16621. this.targets.forEach((target) => {
  16622. this.initListen(target.el, false);
  16623. });
  16624. this.initIntersectionObserver();
  16625. }
  16626. }
  16627. /*
  16628. *** Private functions ***
  16629. */
  16630. /*
  16631. * add listener target
  16632. * @param {DOM} el listener target
  16633. * @return
  16634. */
  16635. addListenerTarget(el) {
  16636. if (!el) return;
  16637. let target = this.targets.find((target2) => target2.el === el);
  16638. if (!target) {
  16639. target = {
  16640. el,
  16641. id: ++this.targetIndex,
  16642. childrenCount: 1,
  16643. listened: true
  16644. };
  16645. this.mode === modeType.event && this.initListen(target.el, true);
  16646. this.targets.push(target);
  16647. } else {
  16648. target.childrenCount++;
  16649. }
  16650. return this.targetIndex;
  16651. }
  16652. /*
  16653. * remove listener target or reduce target childrenCount
  16654. * @param {DOM} el or window
  16655. * @return
  16656. */
  16657. removeListenerTarget(el) {
  16658. this.targets.forEach((target, index) => {
  16659. if (target.el === el) {
  16660. target.childrenCount--;
  16661. if (!target.childrenCount) {
  16662. this.initListen(target.el, false);
  16663. this.targets.splice(index, 1);
  16664. target = null;
  16665. }
  16666. }
  16667. });
  16668. }
  16669. /*
  16670. * add or remove eventlistener
  16671. * @param {DOM} el DOM or Window
  16672. * @param {boolean} start flag
  16673. * @return
  16674. */
  16675. initListen(el, start) {
  16676. this.options.ListenEvents.forEach(
  16677. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  16678. );
  16679. }
  16680. initEvent() {
  16681. this.Event = {
  16682. listeners: {
  16683. loading: [],
  16684. loaded: [],
  16685. error: []
  16686. }
  16687. };
  16688. this.$on = (event, func) => {
  16689. if (!this.Event.listeners[event]) this.Event.listeners[event] = [];
  16690. this.Event.listeners[event].push(func);
  16691. };
  16692. this.$once = (event, func) => {
  16693. const on2 = (...args) => {
  16694. this.$off(event, on2);
  16695. func.apply(this, args);
  16696. };
  16697. this.$on(event, on2);
  16698. };
  16699. this.$off = (event, func) => {
  16700. if (!func) {
  16701. if (!this.Event.listeners[event]) return;
  16702. this.Event.listeners[event].length = 0;
  16703. return;
  16704. }
  16705. remove(this.Event.listeners[event], func);
  16706. };
  16707. this.$emit = (event, context, inCache) => {
  16708. if (!this.Event.listeners[event]) return;
  16709. this.Event.listeners[event].forEach((func) => func(context, inCache));
  16710. };
  16711. }
  16712. /**
  16713. * find nodes which in viewport and trigger load
  16714. * @return
  16715. */
  16716. lazyLoadHandler() {
  16717. const freeList = [];
  16718. this.listeners.forEach((listener) => {
  16719. if (!listener.el || !listener.el.parentNode) {
  16720. freeList.push(listener);
  16721. }
  16722. const catIn = listener.checkInView();
  16723. if (!catIn) return;
  16724. listener.load();
  16725. });
  16726. freeList.forEach((item) => {
  16727. remove(this.listeners, item);
  16728. item.$destroy();
  16729. });
  16730. }
  16731. /**
  16732. * init IntersectionObserver
  16733. * set mode to observer
  16734. * @return
  16735. */
  16736. initIntersectionObserver() {
  16737. if (!hasIntersectionObserver) {
  16738. return;
  16739. }
  16740. this.observer = new IntersectionObserver(
  16741. this.observerHandler.bind(this),
  16742. this.options.observerOptions
  16743. );
  16744. if (this.listeners.length) {
  16745. this.listeners.forEach((listener) => {
  16746. this.observer.observe(listener.el);
  16747. });
  16748. }
  16749. }
  16750. /**
  16751. * init IntersectionObserver
  16752. * @return
  16753. */
  16754. observerHandler(entries) {
  16755. entries.forEach((entry) => {
  16756. if (entry.isIntersecting) {
  16757. this.listeners.forEach((listener) => {
  16758. if (listener.el === entry.target) {
  16759. if (listener.state.loaded)
  16760. return this.observer.unobserve(listener.el);
  16761. listener.load();
  16762. }
  16763. });
  16764. }
  16765. });
  16766. }
  16767. /**
  16768. * set element attribute with image'url and state
  16769. * @param {object} lazyload listener object
  16770. * @param {string} state will be rendered
  16771. * @param {bool} inCache is rendered from cache
  16772. * @return
  16773. */
  16774. elRenderer(listener, state, cache) {
  16775. if (!listener.el) return;
  16776. const { el, bindType } = listener;
  16777. let src;
  16778. switch (state) {
  16779. case "loading":
  16780. src = listener.loading;
  16781. break;
  16782. case "error":
  16783. src = listener.error;
  16784. break;
  16785. default:
  16786. ({ src } = listener);
  16787. break;
  16788. }
  16789. if (bindType) {
  16790. el.style[bindType] = 'url("' + src + '")';
  16791. } else if (el.getAttribute("src") !== src) {
  16792. el.setAttribute("src", src);
  16793. }
  16794. el.setAttribute("lazy", state);
  16795. this.$emit(state, listener, cache);
  16796. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  16797. if (this.options.dispatchEvent) {
  16798. const event = new CustomEvent(state, {
  16799. detail: listener
  16800. });
  16801. el.dispatchEvent(event);
  16802. }
  16803. }
  16804. /**
  16805. * generate loading loaded error image url
  16806. * @param {string} image's src
  16807. * @return {object} image's loading, loaded, error url
  16808. */
  16809. valueFormatter(value) {
  16810. let src = value;
  16811. let { loading, error } = this.options;
  16812. if (isObject(value)) {
  16813. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  16814. console.error("[@vant/lazyload] miss src with " + value);
  16815. }
  16816. ({ src } = value);
  16817. loading = value.loading || this.options.loading;
  16818. error = value.error || this.options.error;
  16819. }
  16820. return {
  16821. src,
  16822. loading,
  16823. error
  16824. };
  16825. }
  16826. };
  16827. }
  16828. var stdin_default$2 = (lazy) => ({
  16829. props: {
  16830. tag: {
  16831. type: String,
  16832. default: "div"
  16833. }
  16834. },
  16835. emits: ["show"],
  16836. render() {
  16837. return vue.h(
  16838. this.tag,
  16839. this.show && this.$slots.default ? this.$slots.default() : null
  16840. );
  16841. },
  16842. data() {
  16843. return {
  16844. el: null,
  16845. state: {
  16846. loaded: false
  16847. },
  16848. show: false
  16849. };
  16850. },
  16851. mounted() {
  16852. this.el = this.$el;
  16853. lazy.addLazyBox(this);
  16854. lazy.lazyLoadHandler();
  16855. },
  16856. beforeUnmount() {
  16857. lazy.removeComponent(this);
  16858. },
  16859. methods: {
  16860. checkInView() {
  16861. const rect = use.useRect(this.$el);
  16862. return use.inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  16863. },
  16864. load() {
  16865. this.show = true;
  16866. this.state.loaded = true;
  16867. this.$emit("show", this);
  16868. },
  16869. destroy() {
  16870. return this.$destroy;
  16871. }
  16872. }
  16873. });
  16874. const defaultOptions = {
  16875. selector: "img"
  16876. };
  16877. class LazyContainer {
  16878. constructor({ el, binding, vnode, lazy }) {
  16879. this.el = null;
  16880. this.vnode = vnode;
  16881. this.binding = binding;
  16882. this.options = {};
  16883. this.lazy = lazy;
  16884. this.queue = [];
  16885. this.update({ el, binding });
  16886. }
  16887. update({ el, binding }) {
  16888. this.el = el;
  16889. this.options = Object.assign({}, defaultOptions, binding.value);
  16890. const imgs = this.getImgs();
  16891. imgs.forEach((el2) => {
  16892. this.lazy.add(
  16893. el2,
  16894. Object.assign({}, this.binding, {
  16895. value: {
  16896. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  16897. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  16898. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  16899. }
  16900. }),
  16901. this.vnode
  16902. );
  16903. });
  16904. }
  16905. getImgs() {
  16906. return Array.from(this.el.querySelectorAll(this.options.selector));
  16907. }
  16908. clear() {
  16909. const imgs = this.getImgs();
  16910. imgs.forEach((el) => this.lazy.remove(el));
  16911. this.vnode = null;
  16912. this.binding = null;
  16913. this.lazy = null;
  16914. }
  16915. }
  16916. class LazyContainerManager {
  16917. constructor({ lazy }) {
  16918. this.lazy = lazy;
  16919. this.queue = [];
  16920. }
  16921. bind(el, binding, vnode) {
  16922. const container = new LazyContainer({
  16923. el,
  16924. binding,
  16925. vnode,
  16926. lazy: this.lazy
  16927. });
  16928. this.queue.push(container);
  16929. }
  16930. update(el, binding, vnode) {
  16931. const container = this.queue.find((item) => item.el === el);
  16932. if (!container) return;
  16933. container.update({ el, binding, vnode });
  16934. }
  16935. unbind(el) {
  16936. const container = this.queue.find((item) => item.el === el);
  16937. if (!container) return;
  16938. container.clear();
  16939. remove(this.queue, container);
  16940. }
  16941. }
  16942. var stdin_default$1 = (lazyManager) => ({
  16943. props: {
  16944. src: [String, Object],
  16945. tag: {
  16946. type: String,
  16947. default: "img"
  16948. }
  16949. },
  16950. render() {
  16951. var _a, _b;
  16952. return vue.h(
  16953. this.tag,
  16954. {
  16955. src: this.renderSrc
  16956. },
  16957. (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
  16958. );
  16959. },
  16960. data() {
  16961. return {
  16962. el: null,
  16963. options: {
  16964. src: "",
  16965. error: "",
  16966. loading: "",
  16967. attempt: lazyManager.options.attempt
  16968. },
  16969. state: {
  16970. loaded: false,
  16971. error: false,
  16972. attempt: 0
  16973. },
  16974. renderSrc: ""
  16975. };
  16976. },
  16977. watch: {
  16978. src() {
  16979. this.init();
  16980. lazyManager.addLazyBox(this);
  16981. lazyManager.lazyLoadHandler();
  16982. }
  16983. },
  16984. created() {
  16985. this.init();
  16986. },
  16987. mounted() {
  16988. this.el = this.$el;
  16989. lazyManager.addLazyBox(this);
  16990. lazyManager.lazyLoadHandler();
  16991. },
  16992. beforeUnmount() {
  16993. lazyManager.removeComponent(this);
  16994. },
  16995. methods: {
  16996. init() {
  16997. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  16998. this.state.loaded = false;
  16999. this.options.src = src;
  17000. this.options.error = error;
  17001. this.options.loading = loading;
  17002. this.renderSrc = this.options.loading;
  17003. },
  17004. checkInView() {
  17005. const rect = use.useRect(this.$el);
  17006. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  17007. },
  17008. load(onFinish = noop) {
  17009. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  17010. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  17011. console.log(
  17012. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  17013. );
  17014. }
  17015. onFinish();
  17016. return;
  17017. }
  17018. const { src } = this.options;
  17019. loadImageAsync(
  17020. { src },
  17021. ({ src: src2 }) => {
  17022. this.renderSrc = src2;
  17023. this.state.loaded = true;
  17024. },
  17025. () => {
  17026. this.state.attempt++;
  17027. this.renderSrc = this.options.error;
  17028. this.state.error = true;
  17029. }
  17030. );
  17031. }
  17032. }
  17033. });
  17034. const Lazyload = {
  17035. /*
  17036. * install function
  17037. * @param {App} app
  17038. * @param {object} options lazyload options
  17039. */
  17040. install(app, options = {}) {
  17041. const LazyClass = stdin_default$3();
  17042. const lazy = new LazyClass(options);
  17043. const lazyContainer = new LazyContainerManager({ lazy });
  17044. app.config.globalProperties.$Lazyload = lazy;
  17045. if (options.lazyComponent) {
  17046. app.component("LazyComponent", stdin_default$2(lazy));
  17047. }
  17048. if (options.lazyImage) {
  17049. app.component("LazyImage", stdin_default$1(lazy));
  17050. }
  17051. app.directive("lazy", {
  17052. beforeMount: lazy.add.bind(lazy),
  17053. updated: lazy.update.bind(lazy),
  17054. unmounted: lazy.remove.bind(lazy)
  17055. });
  17056. app.directive("lazy-container", {
  17057. beforeMount: lazyContainer.bind.bind(lazyContainer),
  17058. updated: lazyContainer.update.bind(lazyContainer),
  17059. unmounted: lazyContainer.unbind.bind(lazyContainer)
  17060. });
  17061. }
  17062. };
  17063. const version = "4.9.9";
  17064. function install(app) {
  17065. const components = [
  17066. ActionBar,
  17067. ActionBarButton,
  17068. ActionBarIcon,
  17069. ActionSheet,
  17070. AddressEdit,
  17071. AddressList,
  17072. Area,
  17073. BackTop,
  17074. Badge,
  17075. Barrage,
  17076. Button,
  17077. Calendar,
  17078. Card,
  17079. Cascader,
  17080. Cell,
  17081. CellGroup,
  17082. Checkbox,
  17083. CheckboxGroup,
  17084. Circle,
  17085. Col,
  17086. Collapse,
  17087. CollapseItem,
  17088. ConfigProvider,
  17089. ContactCard,
  17090. ContactEdit,
  17091. ContactList,
  17092. CountDown,
  17093. Coupon,
  17094. CouponCell,
  17095. CouponList,
  17096. DatePicker,
  17097. Dialog,
  17098. Divider,
  17099. DropdownItem,
  17100. DropdownMenu,
  17101. Empty,
  17102. Field,
  17103. FloatingBubble,
  17104. FloatingPanel,
  17105. Form,
  17106. Grid,
  17107. GridItem,
  17108. Highlight,
  17109. Icon,
  17110. Image$1,
  17111. ImagePreview,
  17112. IndexAnchor,
  17113. IndexBar,
  17114. List,
  17115. Loading,
  17116. Locale,
  17117. NavBar,
  17118. NoticeBar,
  17119. Notify,
  17120. NumberKeyboard,
  17121. Overlay,
  17122. Pagination,
  17123. PasswordInput,
  17124. Picker,
  17125. PickerGroup,
  17126. Popover,
  17127. Popup,
  17128. Progress,
  17129. PullRefresh,
  17130. Radio,
  17131. RadioGroup,
  17132. Rate,
  17133. RollingText,
  17134. Row,
  17135. Search,
  17136. ShareSheet,
  17137. Sidebar,
  17138. SidebarItem,
  17139. Signature,
  17140. Skeleton,
  17141. SkeletonAvatar,
  17142. SkeletonImage,
  17143. SkeletonParagraph,
  17144. SkeletonTitle,
  17145. Slider,
  17146. Space,
  17147. Step,
  17148. Stepper,
  17149. Steps,
  17150. Sticky,
  17151. SubmitBar,
  17152. Swipe,
  17153. SwipeCell,
  17154. SwipeItem,
  17155. Switch,
  17156. Tab,
  17157. Tabbar,
  17158. TabbarItem,
  17159. Tabs,
  17160. Tag,
  17161. TextEllipsis,
  17162. TimePicker,
  17163. Toast,
  17164. TreeSelect,
  17165. Uploader,
  17166. Watermark
  17167. ];
  17168. components.forEach((item) => {
  17169. if (item.install) {
  17170. app.use(item);
  17171. } else if (item.name) {
  17172. app.component(item.name, item);
  17173. }
  17174. });
  17175. }
  17176. var stdin_default = {
  17177. install,
  17178. version
  17179. };
  17180. exports.ActionBar = ActionBar;
  17181. exports.ActionBarButton = ActionBarButton;
  17182. exports.ActionBarIcon = ActionBarIcon;
  17183. exports.ActionSheet = ActionSheet;
  17184. exports.AddressEdit = AddressEdit;
  17185. exports.AddressList = AddressList;
  17186. exports.Area = Area;
  17187. exports.BackTop = BackTop;
  17188. exports.Badge = Badge;
  17189. exports.Barrage = Barrage;
  17190. exports.Button = Button;
  17191. exports.Calendar = Calendar;
  17192. exports.Card = Card;
  17193. exports.Cascader = Cascader;
  17194. exports.Cell = Cell;
  17195. exports.CellGroup = CellGroup;
  17196. exports.Checkbox = Checkbox;
  17197. exports.CheckboxGroup = CheckboxGroup;
  17198. exports.Circle = Circle;
  17199. exports.Col = Col;
  17200. exports.Collapse = Collapse;
  17201. exports.CollapseItem = CollapseItem;
  17202. exports.ConfigProvider = ConfigProvider;
  17203. exports.ContactCard = ContactCard;
  17204. exports.ContactEdit = ContactEdit;
  17205. exports.ContactList = ContactList;
  17206. exports.CountDown = CountDown;
  17207. exports.Coupon = Coupon;
  17208. exports.CouponCell = CouponCell;
  17209. exports.CouponList = CouponList;
  17210. exports.DEFAULT_ROW_WIDTH = DEFAULT_ROW_WIDTH;
  17211. exports.DatePicker = DatePicker;
  17212. exports.Dialog = Dialog;
  17213. exports.Divider = Divider;
  17214. exports.DropdownItem = DropdownItem;
  17215. exports.DropdownMenu = DropdownMenu;
  17216. exports.Empty = Empty;
  17217. exports.Field = Field;
  17218. exports.FloatingBubble = FloatingBubble;
  17219. exports.FloatingPanel = FloatingPanel;
  17220. exports.Form = Form;
  17221. exports.Grid = Grid;
  17222. exports.GridItem = GridItem;
  17223. exports.Highlight = Highlight;
  17224. exports.Icon = Icon;
  17225. exports.Image = Image$1;
  17226. exports.ImagePreview = ImagePreview;
  17227. exports.IndexAnchor = IndexAnchor;
  17228. exports.IndexBar = IndexBar;
  17229. exports.Lazyload = Lazyload;
  17230. exports.List = List;
  17231. exports.Loading = Loading;
  17232. exports.Locale = Locale;
  17233. exports.NavBar = NavBar;
  17234. exports.NoticeBar = NoticeBar;
  17235. exports.Notify = Notify;
  17236. exports.NumberKeyboard = NumberKeyboard;
  17237. exports.Overlay = Overlay;
  17238. exports.Pagination = Pagination;
  17239. exports.PasswordInput = PasswordInput;
  17240. exports.Picker = Picker;
  17241. exports.PickerGroup = PickerGroup;
  17242. exports.Popover = Popover;
  17243. exports.Popup = Popup;
  17244. exports.Progress = Progress;
  17245. exports.PullRefresh = PullRefresh;
  17246. exports.Radio = Radio;
  17247. exports.RadioGroup = RadioGroup;
  17248. exports.Rate = Rate;
  17249. exports.RollingText = RollingText;
  17250. exports.Row = Row;
  17251. exports.Search = Search;
  17252. exports.ShareSheet = ShareSheet;
  17253. exports.Sidebar = Sidebar;
  17254. exports.SidebarItem = SidebarItem;
  17255. exports.Signature = Signature;
  17256. exports.Skeleton = Skeleton;
  17257. exports.SkeletonAvatar = SkeletonAvatar;
  17258. exports.SkeletonImage = SkeletonImage;
  17259. exports.SkeletonParagraph = SkeletonParagraph;
  17260. exports.SkeletonTitle = SkeletonTitle;
  17261. exports.Slider = Slider;
  17262. exports.Space = Space;
  17263. exports.Step = Step;
  17264. exports.Stepper = Stepper;
  17265. exports.Steps = Steps;
  17266. exports.Sticky = Sticky;
  17267. exports.SubmitBar = SubmitBar;
  17268. exports.Swipe = Swipe;
  17269. exports.SwipeCell = SwipeCell;
  17270. exports.SwipeItem = SwipeItem;
  17271. exports.Switch = Switch;
  17272. exports.Tab = Tab;
  17273. exports.Tabbar = Tabbar;
  17274. exports.TabbarItem = TabbarItem;
  17275. exports.Tabs = Tabs;
  17276. exports.Tag = Tag;
  17277. exports.TextEllipsis = TextEllipsis;
  17278. exports.TimePicker = TimePicker;
  17279. exports.Toast = Toast;
  17280. exports.TreeSelect = TreeSelect;
  17281. exports.Uploader = Uploader;
  17282. exports.Watermark = Watermark;
  17283. exports.actionBarButtonProps = actionBarButtonProps;
  17284. exports.actionBarIconProps = actionBarIconProps;
  17285. exports.actionBarProps = actionBarProps;
  17286. exports.actionSheetProps = actionSheetProps;
  17287. exports.addressEditProps = addressEditProps;
  17288. exports.addressListProps = addressListProps;
  17289. exports.allowMultipleToast = allowMultipleToast;
  17290. exports.areaProps = areaProps;
  17291. exports.backTopProps = backTopProps;
  17292. exports.badgeProps = badgeProps;
  17293. exports.barrageProps = barrageProps;
  17294. exports.buttonProps = buttonProps;
  17295. exports.calendarProps = calendarProps;
  17296. exports.cardProps = cardProps;
  17297. exports.cascaderProps = cascaderProps;
  17298. exports.cellGroupProps = cellGroupProps;
  17299. exports.cellProps = cellProps;
  17300. exports.checkboxGroupProps = checkboxGroupProps;
  17301. exports.checkboxProps = checkboxProps;
  17302. exports.circleProps = circleProps;
  17303. exports.closeDialog = closeDialog;
  17304. exports.closeNotify = closeNotify;
  17305. exports.closeToast = closeToast;
  17306. exports.colProps = colProps;
  17307. exports.collapseItemProps = collapseItemProps;
  17308. exports.collapseProps = collapseProps;
  17309. exports.configProviderProps = configProviderProps;
  17310. exports.contactCardProps = contactCardProps;
  17311. exports.contactEditProps = contactEditProps;
  17312. exports.contactListProps = contactListProps;
  17313. exports.countDownProps = countDownProps;
  17314. exports.couponCellProps = couponCellProps;
  17315. exports.couponListProps = couponListProps;
  17316. exports.datePickerProps = datePickerProps;
  17317. exports.default = stdin_default;
  17318. exports.dialogProps = dialogProps;
  17319. exports.dividerProps = dividerProps;
  17320. exports.dropdownItemProps = dropdownItemProps;
  17321. exports.dropdownMenuProps = dropdownMenuProps;
  17322. exports.emptyProps = emptyProps;
  17323. exports.fieldProps = fieldProps;
  17324. exports.floatingBubbleProps = floatingBubbleProps;
  17325. exports.floatingPanelProps = floatingPanelProps;
  17326. exports.formProps = formProps;
  17327. exports.gridItemProps = gridItemProps;
  17328. exports.gridProps = gridProps;
  17329. exports.highlightProps = highlightProps;
  17330. exports.iconProps = iconProps;
  17331. exports.imagePreviewProps = imagePreviewProps;
  17332. exports.imageProps = imageProps;
  17333. exports.indexAnchorProps = indexAnchorProps;
  17334. exports.indexBarProps = indexBarProps;
  17335. exports.install = install;
  17336. exports.listProps = listProps;
  17337. exports.loadingProps = loadingProps;
  17338. exports.navBarProps = navBarProps;
  17339. exports.noticeBarProps = noticeBarProps;
  17340. exports.notifyProps = notifyProps;
  17341. exports.numberKeyboardProps = numberKeyboardProps;
  17342. exports.overlayProps = overlayProps;
  17343. exports.paginationProps = paginationProps;
  17344. exports.passwordInputProps = passwordInputProps;
  17345. exports.pickerGroupProps = pickerGroupProps;
  17346. exports.pickerProps = pickerProps;
  17347. exports.popoverProps = popoverProps;
  17348. exports.popupProps = popupProps$2;
  17349. exports.progressProps = progressProps;
  17350. exports.pullRefreshProps = pullRefreshProps;
  17351. exports.radioGroupProps = radioGroupProps;
  17352. exports.radioProps = radioProps;
  17353. exports.rateProps = rateProps;
  17354. exports.resetDialogDefaultOptions = resetDialogDefaultOptions;
  17355. exports.resetNotifyDefaultOptions = resetNotifyDefaultOptions;
  17356. exports.resetToastDefaultOptions = resetToastDefaultOptions;
  17357. exports.rollingTextProps = rollingTextProps;
  17358. exports.rowProps = rowProps;
  17359. exports.searchProps = searchProps;
  17360. exports.setDialogDefaultOptions = setDialogDefaultOptions;
  17361. exports.setNotifyDefaultOptions = setNotifyDefaultOptions;
  17362. exports.setToastDefaultOptions = setToastDefaultOptions;
  17363. exports.shareSheetProps = shareSheetProps;
  17364. exports.showConfirmDialog = showConfirmDialog;
  17365. exports.showDialog = showDialog;
  17366. exports.showFailToast = showFailToast;
  17367. exports.showImagePreview = showImagePreview;
  17368. exports.showLoadingToast = showLoadingToast;
  17369. exports.showNotify = showNotify;
  17370. exports.showSuccessToast = showSuccessToast;
  17371. exports.showToast = showToast;
  17372. exports.sidebarItemProps = sidebarItemProps;
  17373. exports.sidebarProps = sidebarProps;
  17374. exports.skeletonAvatarProps = skeletonAvatarProps;
  17375. exports.skeletonImageProps = skeletonImageProps;
  17376. exports.skeletonParagraphProps = skeletonParagraphProps;
  17377. exports.skeletonProps = skeletonProps;
  17378. exports.skeletonTitleProps = skeletonTitleProps;
  17379. exports.sliderProps = sliderProps;
  17380. exports.spaceProps = spaceProps;
  17381. exports.stepperProps = stepperProps;
  17382. exports.stepsProps = stepsProps;
  17383. exports.stickyProps = stickyProps;
  17384. exports.submitBarProps = submitBarProps;
  17385. exports.swipeCellProps = swipeCellProps;
  17386. exports.swipeProps = swipeProps;
  17387. exports.switchProps = switchProps;
  17388. exports.tabProps = tabProps;
  17389. exports.tabbarItemProps = tabbarItemProps;
  17390. exports.tabbarProps = tabbarProps;
  17391. exports.tabsProps = tabsProps;
  17392. exports.tagProps = tagProps;
  17393. exports.textEllipsisProps = textEllipsisProps;
  17394. exports.timePickerProps = timePickerProps;
  17395. exports.toastProps = toastProps;
  17396. exports.treeSelectProps = treeSelectProps;
  17397. exports.uploaderProps = uploaderProps;
  17398. exports.useCurrentLang = useCurrentLang;
  17399. exports.version = version;
  17400. exports.watermarkProps = watermarkProps;