vendor.js 479 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115
  1. (global["webpackJsonp"] = global["webpackJsonp"] || []).push([["common/vendor"],[
  2. /* 0 */,
  3. /* 1 */
  4. /*!*********************************************************!*\
  5. !*** ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js ***!
  6. \*********************************************************/
  7. /*! no static exports found */
  8. /***/ (function(module, exports, __webpack_require__) {
  9. "use strict";
  10. Object.defineProperty(exports, "__esModule", {
  11. value: true
  12. });
  13. exports.default = void 0;
  14. var objectKeys = ['qy', 'env', 'error', 'version', 'lanDebug', 'cloud', 'serviceMarket', 'router', 'worklet', '__webpack_require_UNI_MP_PLUGIN__'];
  15. var singlePageDisableKey = ['lanDebug', 'router', 'worklet'];
  16. var target = typeof globalThis !== 'undefined' ? globalThis : function () {
  17. return this;
  18. }();
  19. var key = ['w', 'x'].join('');
  20. var oldWx = target[key];
  21. var launchOption = oldWx.getLaunchOptionsSync ? oldWx.getLaunchOptionsSync() : null;
  22. function isWxKey(key) {
  23. if (launchOption && launchOption.scene === 1154 && singlePageDisableKey.includes(key)) {
  24. return false;
  25. }
  26. return objectKeys.indexOf(key) > -1 || typeof oldWx[key] === 'function';
  27. }
  28. function initWx() {
  29. var newWx = {};
  30. for (var _key in oldWx) {
  31. if (isWxKey(_key)) {
  32. // TODO wrapper function
  33. newWx[_key] = oldWx[_key];
  34. }
  35. }
  36. return newWx;
  37. }
  38. target[key] = initWx();
  39. var _default = target[key];
  40. exports.default = _default;
  41. /***/ }),
  42. /* 2 */
  43. /*!************************************************************!*\
  44. !*** ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js ***!
  45. \************************************************************/
  46. /*! no static exports found */
  47. /***/ (function(module, exports, __webpack_require__) {
  48. "use strict";
  49. /* WEBPACK VAR INJECTION */(function(wx, global) {
  50. var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
  51. Object.defineProperty(exports, "__esModule", {
  52. value: true
  53. });
  54. exports.createApp = createApp;
  55. exports.createComponent = createComponent;
  56. exports.createPage = createPage;
  57. exports.createPlugin = createPlugin;
  58. exports.createSubpackageApp = createSubpackageApp;
  59. exports.default = void 0;
  60. var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ 5));
  61. var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
  62. var _construct2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/construct */ 15));
  63. var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ 18));
  64. var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ 13));
  65. var _uniI18n = __webpack_require__(/*! @dcloudio/uni-i18n */ 22);
  66. var _vue = _interopRequireDefault(__webpack_require__(/*! vue */ 25));
  67. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  68. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  69. var realAtob;
  70. var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  71. var b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
  72. if (typeof atob !== 'function') {
  73. realAtob = function realAtob(str) {
  74. str = String(str).replace(/[\t\n\f\r ]+/g, '');
  75. if (!b64re.test(str)) {
  76. throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
  77. }
  78. // Adding the padding if missing, for semplicity
  79. str += '=='.slice(2 - (str.length & 3));
  80. var bitmap;
  81. var result = '';
  82. var r1;
  83. var r2;
  84. var i = 0;
  85. for (; i < str.length;) {
  86. bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
  87. result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
  88. }
  89. return result;
  90. };
  91. } else {
  92. // 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
  93. realAtob = atob;
  94. }
  95. function b64DecodeUnicode(str) {
  96. return decodeURIComponent(realAtob(str).split('').map(function (c) {
  97. return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  98. }).join(''));
  99. }
  100. function getCurrentUserInfo() {
  101. var token = wx.getStorageSync('uni_id_token') || '';
  102. var tokenArr = token.split('.');
  103. if (!token || tokenArr.length !== 3) {
  104. return {
  105. uid: null,
  106. role: [],
  107. permission: [],
  108. tokenExpired: 0
  109. };
  110. }
  111. var userInfo;
  112. try {
  113. userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
  114. } catch (error) {
  115. throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message);
  116. }
  117. userInfo.tokenExpired = userInfo.exp * 1000;
  118. delete userInfo.exp;
  119. delete userInfo.iat;
  120. return userInfo;
  121. }
  122. function uniIdMixin(Vue) {
  123. Vue.prototype.uniIDHasRole = function (roleId) {
  124. var _getCurrentUserInfo = getCurrentUserInfo(),
  125. role = _getCurrentUserInfo.role;
  126. return role.indexOf(roleId) > -1;
  127. };
  128. Vue.prototype.uniIDHasPermission = function (permissionId) {
  129. var _getCurrentUserInfo2 = getCurrentUserInfo(),
  130. permission = _getCurrentUserInfo2.permission;
  131. return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1;
  132. };
  133. Vue.prototype.uniIDTokenValid = function () {
  134. var _getCurrentUserInfo3 = getCurrentUserInfo(),
  135. tokenExpired = _getCurrentUserInfo3.tokenExpired;
  136. return tokenExpired > Date.now();
  137. };
  138. }
  139. var _toString = Object.prototype.toString;
  140. var hasOwnProperty = Object.prototype.hasOwnProperty;
  141. function isFn(fn) {
  142. return typeof fn === 'function';
  143. }
  144. function isStr(str) {
  145. return typeof str === 'string';
  146. }
  147. function isObject(obj) {
  148. return obj !== null && (0, _typeof2.default)(obj) === 'object';
  149. }
  150. function isPlainObject(obj) {
  151. return _toString.call(obj) === '[object Object]';
  152. }
  153. function hasOwn(obj, key) {
  154. return hasOwnProperty.call(obj, key);
  155. }
  156. function noop() {}
  157. /**
  158. * Create a cached version of a pure function.
  159. */
  160. function cached(fn) {
  161. var cache = Object.create(null);
  162. return function cachedFn(str) {
  163. var hit = cache[str];
  164. return hit || (cache[str] = fn(str));
  165. };
  166. }
  167. /**
  168. * Camelize a hyphen-delimited string.
  169. */
  170. var camelizeRE = /-(\w)/g;
  171. var camelize = cached(function (str) {
  172. return str.replace(camelizeRE, function (_, c) {
  173. return c ? c.toUpperCase() : '';
  174. });
  175. });
  176. function sortObject(obj) {
  177. var sortObj = {};
  178. if (isPlainObject(obj)) {
  179. Object.keys(obj).sort().forEach(function (key) {
  180. sortObj[key] = obj[key];
  181. });
  182. }
  183. return !Object.keys(sortObj) ? obj : sortObj;
  184. }
  185. var HOOKS = ['invoke', 'success', 'fail', 'complete', 'returnValue'];
  186. var globalInterceptors = {};
  187. var scopedInterceptors = {};
  188. function mergeHook(parentVal, childVal) {
  189. var res = childVal ? parentVal ? parentVal.concat(childVal) : Array.isArray(childVal) ? childVal : [childVal] : parentVal;
  190. return res ? dedupeHooks(res) : res;
  191. }
  192. function dedupeHooks(hooks) {
  193. var res = [];
  194. for (var i = 0; i < hooks.length; i++) {
  195. if (res.indexOf(hooks[i]) === -1) {
  196. res.push(hooks[i]);
  197. }
  198. }
  199. return res;
  200. }
  201. function removeHook(hooks, hook) {
  202. var index = hooks.indexOf(hook);
  203. if (index !== -1) {
  204. hooks.splice(index, 1);
  205. }
  206. }
  207. function mergeInterceptorHook(interceptor, option) {
  208. Object.keys(option).forEach(function (hook) {
  209. if (HOOKS.indexOf(hook) !== -1 && isFn(option[hook])) {
  210. interceptor[hook] = mergeHook(interceptor[hook], option[hook]);
  211. }
  212. });
  213. }
  214. function removeInterceptorHook(interceptor, option) {
  215. if (!interceptor || !option) {
  216. return;
  217. }
  218. Object.keys(option).forEach(function (hook) {
  219. if (HOOKS.indexOf(hook) !== -1 && isFn(option[hook])) {
  220. removeHook(interceptor[hook], option[hook]);
  221. }
  222. });
  223. }
  224. function addInterceptor(method, option) {
  225. if (typeof method === 'string' && isPlainObject(option)) {
  226. mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), option);
  227. } else if (isPlainObject(method)) {
  228. mergeInterceptorHook(globalInterceptors, method);
  229. }
  230. }
  231. function removeInterceptor(method, option) {
  232. if (typeof method === 'string') {
  233. if (isPlainObject(option)) {
  234. removeInterceptorHook(scopedInterceptors[method], option);
  235. } else {
  236. delete scopedInterceptors[method];
  237. }
  238. } else if (isPlainObject(method)) {
  239. removeInterceptorHook(globalInterceptors, method);
  240. }
  241. }
  242. function wrapperHook(hook, params) {
  243. return function (data) {
  244. return hook(data, params) || data;
  245. };
  246. }
  247. function isPromise(obj) {
  248. return !!obj && ((0, _typeof2.default)(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
  249. }
  250. function queue(hooks, data, params) {
  251. var promise = false;
  252. for (var i = 0; i < hooks.length; i++) {
  253. var hook = hooks[i];
  254. if (promise) {
  255. promise = Promise.resolve(wrapperHook(hook, params));
  256. } else {
  257. var res = hook(data, params);
  258. if (isPromise(res)) {
  259. promise = Promise.resolve(res);
  260. }
  261. if (res === false) {
  262. return {
  263. then: function then() {}
  264. };
  265. }
  266. }
  267. }
  268. return promise || {
  269. then: function then(callback) {
  270. return callback(data);
  271. }
  272. };
  273. }
  274. function wrapperOptions(interceptor) {
  275. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  276. ['success', 'fail', 'complete'].forEach(function (name) {
  277. if (Array.isArray(interceptor[name])) {
  278. var oldCallback = options[name];
  279. options[name] = function callbackInterceptor(res) {
  280. queue(interceptor[name], res, options).then(function (res) {
  281. /* eslint-disable no-mixed-operators */
  282. return isFn(oldCallback) && oldCallback(res) || res;
  283. });
  284. };
  285. }
  286. });
  287. return options;
  288. }
  289. function wrapperReturnValue(method, returnValue) {
  290. var returnValueHooks = [];
  291. if (Array.isArray(globalInterceptors.returnValue)) {
  292. returnValueHooks.push.apply(returnValueHooks, (0, _toConsumableArray2.default)(globalInterceptors.returnValue));
  293. }
  294. var interceptor = scopedInterceptors[method];
  295. if (interceptor && Array.isArray(interceptor.returnValue)) {
  296. returnValueHooks.push.apply(returnValueHooks, (0, _toConsumableArray2.default)(interceptor.returnValue));
  297. }
  298. returnValueHooks.forEach(function (hook) {
  299. returnValue = hook(returnValue) || returnValue;
  300. });
  301. return returnValue;
  302. }
  303. function getApiInterceptorHooks(method) {
  304. var interceptor = Object.create(null);
  305. Object.keys(globalInterceptors).forEach(function (hook) {
  306. if (hook !== 'returnValue') {
  307. interceptor[hook] = globalInterceptors[hook].slice();
  308. }
  309. });
  310. var scopedInterceptor = scopedInterceptors[method];
  311. if (scopedInterceptor) {
  312. Object.keys(scopedInterceptor).forEach(function (hook) {
  313. if (hook !== 'returnValue') {
  314. interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
  315. }
  316. });
  317. }
  318. return interceptor;
  319. }
  320. function invokeApi(method, api, options) {
  321. for (var _len = arguments.length, params = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
  322. params[_key - 3] = arguments[_key];
  323. }
  324. var interceptor = getApiInterceptorHooks(method);
  325. if (interceptor && Object.keys(interceptor).length) {
  326. if (Array.isArray(interceptor.invoke)) {
  327. var res = queue(interceptor.invoke, options);
  328. return res.then(function (options) {
  329. // 重新访问 getApiInterceptorHooks, 允许 invoke 中再次调用 addInterceptor,removeInterceptor
  330. return api.apply(void 0, [wrapperOptions(getApiInterceptorHooks(method), options)].concat(params));
  331. });
  332. } else {
  333. return api.apply(void 0, [wrapperOptions(interceptor, options)].concat(params));
  334. }
  335. }
  336. return api.apply(void 0, [options].concat(params));
  337. }
  338. var promiseInterceptor = {
  339. returnValue: function returnValue(res) {
  340. if (!isPromise(res)) {
  341. return res;
  342. }
  343. return new Promise(function (resolve, reject) {
  344. res.then(function (res) {
  345. if (res[0]) {
  346. reject(res[0]);
  347. } else {
  348. resolve(res[1]);
  349. }
  350. });
  351. });
  352. }
  353. };
  354. var SYNC_API_RE = /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/;
  355. var CONTEXT_API_RE = /^create|Manager$/;
  356. // Context例外情况
  357. var CONTEXT_API_RE_EXC = ['createBLEConnection'];
  358. // 同步例外情况
  359. var ASYNC_API = ['createBLEConnection', 'createPushMessage'];
  360. var CALLBACK_API_RE = /^on|^off/;
  361. function isContextApi(name) {
  362. return CONTEXT_API_RE.test(name) && CONTEXT_API_RE_EXC.indexOf(name) === -1;
  363. }
  364. function isSyncApi(name) {
  365. return SYNC_API_RE.test(name) && ASYNC_API.indexOf(name) === -1;
  366. }
  367. function isCallbackApi(name) {
  368. return CALLBACK_API_RE.test(name) && name !== 'onPush';
  369. }
  370. function handlePromise(promise) {
  371. return promise.then(function (data) {
  372. return [null, data];
  373. }).catch(function (err) {
  374. return [err];
  375. });
  376. }
  377. function shouldPromise(name) {
  378. if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
  379. return false;
  380. }
  381. return true;
  382. }
  383. /* eslint-disable no-extend-native */
  384. if (!Promise.prototype.finally) {
  385. Promise.prototype.finally = function (callback) {
  386. var promise = this.constructor;
  387. return this.then(function (value) {
  388. return promise.resolve(callback()).then(function () {
  389. return value;
  390. });
  391. }, function (reason) {
  392. return promise.resolve(callback()).then(function () {
  393. throw reason;
  394. });
  395. });
  396. };
  397. }
  398. function promisify(name, api) {
  399. if (!shouldPromise(name) || !isFn(api)) {
  400. return api;
  401. }
  402. return function promiseApi() {
  403. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  404. for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  405. params[_key2 - 1] = arguments[_key2];
  406. }
  407. if (isFn(options.success) || isFn(options.fail) || isFn(options.complete)) {
  408. return wrapperReturnValue(name, invokeApi.apply(void 0, [name, api, options].concat(params)));
  409. }
  410. return wrapperReturnValue(name, handlePromise(new Promise(function (resolve, reject) {
  411. invokeApi.apply(void 0, [name, api, Object.assign({}, options, {
  412. success: resolve,
  413. fail: reject
  414. })].concat(params));
  415. })));
  416. };
  417. }
  418. var EPS = 1e-4;
  419. var BASE_DEVICE_WIDTH = 750;
  420. var isIOS = false;
  421. var deviceWidth = 0;
  422. var deviceDPR = 0;
  423. function checkDeviceWidth() {
  424. var _wx$getSystemInfoSync = wx.getSystemInfoSync(),
  425. platform = _wx$getSystemInfoSync.platform,
  426. pixelRatio = _wx$getSystemInfoSync.pixelRatio,
  427. windowWidth = _wx$getSystemInfoSync.windowWidth; // uni=>wx runtime 编译目标是 uni 对象,内部不允许直接使用 uni
  428. deviceWidth = windowWidth;
  429. deviceDPR = pixelRatio;
  430. isIOS = platform === 'ios';
  431. }
  432. function upx2px(number, newDeviceWidth) {
  433. if (deviceWidth === 0) {
  434. checkDeviceWidth();
  435. }
  436. number = Number(number);
  437. if (number === 0) {
  438. return 0;
  439. }
  440. var result = number / BASE_DEVICE_WIDTH * (newDeviceWidth || deviceWidth);
  441. if (result < 0) {
  442. result = -result;
  443. }
  444. result = Math.floor(result + EPS);
  445. if (result === 0) {
  446. if (deviceDPR === 1 || !isIOS) {
  447. result = 1;
  448. } else {
  449. result = 0.5;
  450. }
  451. }
  452. return number < 0 ? -result : result;
  453. }
  454. var LOCALE_ZH_HANS = 'zh-Hans';
  455. var LOCALE_ZH_HANT = 'zh-Hant';
  456. var LOCALE_EN = 'en';
  457. var LOCALE_FR = 'fr';
  458. var LOCALE_ES = 'es';
  459. var messages = {};
  460. var locale;
  461. {
  462. locale = normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN;
  463. }
  464. function initI18nMessages() {
  465. if (!isEnableLocale()) {
  466. return;
  467. }
  468. var localeKeys = Object.keys(__uniConfig.locales);
  469. if (localeKeys.length) {
  470. localeKeys.forEach(function (locale) {
  471. var curMessages = messages[locale];
  472. var userMessages = __uniConfig.locales[locale];
  473. if (curMessages) {
  474. Object.assign(curMessages, userMessages);
  475. } else {
  476. messages[locale] = userMessages;
  477. }
  478. });
  479. }
  480. }
  481. initI18nMessages();
  482. var i18n = (0, _uniI18n.initVueI18n)(locale, {});
  483. var t = i18n.t;
  484. var i18nMixin = i18n.mixin = {
  485. beforeCreate: function beforeCreate() {
  486. var _this = this;
  487. var unwatch = i18n.i18n.watchLocale(function () {
  488. _this.$forceUpdate();
  489. });
  490. this.$once('hook:beforeDestroy', function () {
  491. unwatch();
  492. });
  493. },
  494. methods: {
  495. $$t: function $$t(key, values) {
  496. return t(key, values);
  497. }
  498. }
  499. };
  500. var setLocale = i18n.setLocale;
  501. var getLocale = i18n.getLocale;
  502. function initAppLocale(Vue, appVm, locale) {
  503. var state = Vue.observable({
  504. locale: locale || i18n.getLocale()
  505. });
  506. var localeWatchers = [];
  507. appVm.$watchLocale = function (fn) {
  508. localeWatchers.push(fn);
  509. };
  510. Object.defineProperty(appVm, '$locale', {
  511. get: function get() {
  512. return state.locale;
  513. },
  514. set: function set(v) {
  515. state.locale = v;
  516. localeWatchers.forEach(function (watch) {
  517. return watch(v);
  518. });
  519. }
  520. });
  521. }
  522. function isEnableLocale() {
  523. return typeof __uniConfig !== 'undefined' && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length;
  524. }
  525. function include(str, parts) {
  526. return !!parts.find(function (part) {
  527. return str.indexOf(part) !== -1;
  528. });
  529. }
  530. function startsWith(str, parts) {
  531. return parts.find(function (part) {
  532. return str.indexOf(part) === 0;
  533. });
  534. }
  535. function normalizeLocale(locale, messages) {
  536. if (!locale) {
  537. return;
  538. }
  539. locale = locale.trim().replace(/_/g, '-');
  540. if (messages && messages[locale]) {
  541. return locale;
  542. }
  543. locale = locale.toLowerCase();
  544. if (locale === 'chinese') {
  545. // 支付宝
  546. return LOCALE_ZH_HANS;
  547. }
  548. if (locale.indexOf('zh') === 0) {
  549. if (locale.indexOf('-hans') > -1) {
  550. return LOCALE_ZH_HANS;
  551. }
  552. if (locale.indexOf('-hant') > -1) {
  553. return LOCALE_ZH_HANT;
  554. }
  555. if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
  556. return LOCALE_ZH_HANT;
  557. }
  558. return LOCALE_ZH_HANS;
  559. }
  560. var lang = startsWith(locale, [LOCALE_EN, LOCALE_FR, LOCALE_ES]);
  561. if (lang) {
  562. return lang;
  563. }
  564. }
  565. // export function initI18n() {
  566. // const localeKeys = Object.keys(__uniConfig.locales || {})
  567. // if (localeKeys.length) {
  568. // localeKeys.forEach((locale) =>
  569. // i18n.add(locale, __uniConfig.locales[locale])
  570. // )
  571. // }
  572. // }
  573. function getLocale$1() {
  574. // 优先使用 $locale
  575. if (isFn(getApp)) {
  576. var app = getApp({
  577. allowDefault: true
  578. });
  579. if (app && app.$vm) {
  580. return app.$vm.$locale;
  581. }
  582. }
  583. return normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN;
  584. }
  585. function setLocale$1(locale) {
  586. var app = isFn(getApp) ? getApp() : false;
  587. if (!app) {
  588. return false;
  589. }
  590. var oldLocale = app.$vm.$locale;
  591. if (oldLocale !== locale) {
  592. app.$vm.$locale = locale;
  593. onLocaleChangeCallbacks.forEach(function (fn) {
  594. return fn({
  595. locale: locale
  596. });
  597. });
  598. return true;
  599. }
  600. return false;
  601. }
  602. var onLocaleChangeCallbacks = [];
  603. function onLocaleChange(fn) {
  604. if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
  605. onLocaleChangeCallbacks.push(fn);
  606. }
  607. }
  608. if (typeof global !== 'undefined') {
  609. global.getLocale = getLocale$1;
  610. }
  611. var interceptors = {
  612. promiseInterceptor: promiseInterceptor
  613. };
  614. var baseApi = /*#__PURE__*/Object.freeze({
  615. __proto__: null,
  616. upx2px: upx2px,
  617. getLocale: getLocale$1,
  618. setLocale: setLocale$1,
  619. onLocaleChange: onLocaleChange,
  620. addInterceptor: addInterceptor,
  621. removeInterceptor: removeInterceptor,
  622. interceptors: interceptors
  623. });
  624. function findExistsPageIndex(url) {
  625. var pages = getCurrentPages();
  626. var len = pages.length;
  627. while (len--) {
  628. var page = pages[len];
  629. if (page.$page && page.$page.fullPath === url) {
  630. return len;
  631. }
  632. }
  633. return -1;
  634. }
  635. var redirectTo = {
  636. name: function name(fromArgs) {
  637. if (fromArgs.exists === 'back' && fromArgs.delta) {
  638. return 'navigateBack';
  639. }
  640. return 'redirectTo';
  641. },
  642. args: function args(fromArgs) {
  643. if (fromArgs.exists === 'back' && fromArgs.url) {
  644. var existsPageIndex = findExistsPageIndex(fromArgs.url);
  645. if (existsPageIndex !== -1) {
  646. var delta = getCurrentPages().length - 1 - existsPageIndex;
  647. if (delta > 0) {
  648. fromArgs.delta = delta;
  649. }
  650. }
  651. }
  652. }
  653. };
  654. var previewImage = {
  655. args: function args(fromArgs) {
  656. var currentIndex = parseInt(fromArgs.current);
  657. if (isNaN(currentIndex)) {
  658. return;
  659. }
  660. var urls = fromArgs.urls;
  661. if (!Array.isArray(urls)) {
  662. return;
  663. }
  664. var len = urls.length;
  665. if (!len) {
  666. return;
  667. }
  668. if (currentIndex < 0) {
  669. currentIndex = 0;
  670. } else if (currentIndex >= len) {
  671. currentIndex = len - 1;
  672. }
  673. if (currentIndex > 0) {
  674. fromArgs.current = urls[currentIndex];
  675. fromArgs.urls = urls.filter(function (item, index) {
  676. return index < currentIndex ? item !== urls[currentIndex] : true;
  677. });
  678. } else {
  679. fromArgs.current = urls[0];
  680. }
  681. return {
  682. indicator: false,
  683. loop: false
  684. };
  685. }
  686. };
  687. var UUID_KEY = '__DC_STAT_UUID';
  688. var deviceId;
  689. function useDeviceId(result) {
  690. deviceId = deviceId || wx.getStorageSync(UUID_KEY);
  691. if (!deviceId) {
  692. deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7);
  693. wx.setStorage({
  694. key: UUID_KEY,
  695. data: deviceId
  696. });
  697. }
  698. result.deviceId = deviceId;
  699. }
  700. function addSafeAreaInsets(result) {
  701. if (result.safeArea) {
  702. var safeArea = result.safeArea;
  703. result.safeAreaInsets = {
  704. top: safeArea.top,
  705. left: safeArea.left,
  706. right: result.windowWidth - safeArea.right,
  707. bottom: result.screenHeight - safeArea.bottom
  708. };
  709. }
  710. }
  711. function populateParameters(result) {
  712. var _result$brand = result.brand,
  713. brand = _result$brand === void 0 ? '' : _result$brand,
  714. _result$model = result.model,
  715. model = _result$model === void 0 ? '' : _result$model,
  716. _result$system = result.system,
  717. system = _result$system === void 0 ? '' : _result$system,
  718. _result$language = result.language,
  719. language = _result$language === void 0 ? '' : _result$language,
  720. theme = result.theme,
  721. version = result.version,
  722. platform = result.platform,
  723. fontSizeSetting = result.fontSizeSetting,
  724. SDKVersion = result.SDKVersion,
  725. pixelRatio = result.pixelRatio,
  726. deviceOrientation = result.deviceOrientation;
  727. // const isQuickApp = "mp-weixin".indexOf('quickapp-webview') !== -1
  728. var extraParam = {};
  729. // osName osVersion
  730. var osName = '';
  731. var osVersion = '';
  732. {
  733. osName = system.split(' ')[0] || '';
  734. osVersion = system.split(' ')[1] || '';
  735. }
  736. var hostVersion = version;
  737. // deviceType
  738. var deviceType = getGetDeviceType(result, model);
  739. // deviceModel
  740. var deviceBrand = getDeviceBrand(brand);
  741. // hostName
  742. var _hostName = getHostName(result);
  743. // deviceOrientation
  744. var _deviceOrientation = deviceOrientation; // 仅 微信 百度 支持
  745. // devicePixelRatio
  746. var _devicePixelRatio = pixelRatio;
  747. // SDKVersion
  748. var _SDKVersion = SDKVersion;
  749. // hostLanguage
  750. var hostLanguage = language.replace(/_/g, '-');
  751. // wx.getAccountInfoSync
  752. var parameters = {
  753. appId: "__UNI__6867529",
  754. appName: "travel_applet",
  755. appVersion: "1.0.0",
  756. appVersionCode: "100",
  757. appLanguage: getAppLanguage(hostLanguage),
  758. uniCompileVersion: "3.8.7",
  759. uniRuntimeVersion: "3.8.7",
  760. uniPlatform: undefined || "mp-weixin",
  761. deviceBrand: deviceBrand,
  762. deviceModel: model,
  763. deviceType: deviceType,
  764. devicePixelRatio: _devicePixelRatio,
  765. deviceOrientation: _deviceOrientation,
  766. osName: osName.toLocaleLowerCase(),
  767. osVersion: osVersion,
  768. hostTheme: theme,
  769. hostVersion: hostVersion,
  770. hostLanguage: hostLanguage,
  771. hostName: _hostName,
  772. hostSDKVersion: _SDKVersion,
  773. hostFontSizeSetting: fontSizeSetting,
  774. windowTop: 0,
  775. windowBottom: 0,
  776. // TODO
  777. osLanguage: undefined,
  778. osTheme: undefined,
  779. ua: undefined,
  780. hostPackageName: undefined,
  781. browserName: undefined,
  782. browserVersion: undefined
  783. };
  784. Object.assign(result, parameters, extraParam);
  785. }
  786. function getGetDeviceType(result, model) {
  787. var deviceType = result.deviceType || 'phone';
  788. {
  789. var deviceTypeMaps = {
  790. ipad: 'pad',
  791. windows: 'pc',
  792. mac: 'pc'
  793. };
  794. var deviceTypeMapsKeys = Object.keys(deviceTypeMaps);
  795. var _model = model.toLocaleLowerCase();
  796. for (var index = 0; index < deviceTypeMapsKeys.length; index++) {
  797. var _m = deviceTypeMapsKeys[index];
  798. if (_model.indexOf(_m) !== -1) {
  799. deviceType = deviceTypeMaps[_m];
  800. break;
  801. }
  802. }
  803. }
  804. return deviceType;
  805. }
  806. function getDeviceBrand(brand) {
  807. var deviceBrand = brand;
  808. if (deviceBrand) {
  809. deviceBrand = brand.toLocaleLowerCase();
  810. }
  811. return deviceBrand;
  812. }
  813. function getAppLanguage(defaultLanguage) {
  814. return getLocale$1 ? getLocale$1() : defaultLanguage;
  815. }
  816. function getHostName(result) {
  817. var _platform = 'WeChat';
  818. var _hostName = result.hostName || _platform; // mp-jd
  819. {
  820. if (result.environment) {
  821. _hostName = result.environment;
  822. } else if (result.host && result.host.env) {
  823. _hostName = result.host.env;
  824. }
  825. }
  826. return _hostName;
  827. }
  828. var getSystemInfo = {
  829. returnValue: function returnValue(result) {
  830. useDeviceId(result);
  831. addSafeAreaInsets(result);
  832. populateParameters(result);
  833. }
  834. };
  835. var showActionSheet = {
  836. args: function args(fromArgs) {
  837. if ((0, _typeof2.default)(fromArgs) === 'object') {
  838. fromArgs.alertText = fromArgs.title;
  839. }
  840. }
  841. };
  842. var getAppBaseInfo = {
  843. returnValue: function returnValue(result) {
  844. var _result = result,
  845. version = _result.version,
  846. language = _result.language,
  847. SDKVersion = _result.SDKVersion,
  848. theme = _result.theme;
  849. var _hostName = getHostName(result);
  850. var hostLanguage = language.replace('_', '-');
  851. result = sortObject(Object.assign(result, {
  852. appId: "__UNI__6867529",
  853. appName: "travel_applet",
  854. appVersion: "1.0.0",
  855. appVersionCode: "100",
  856. appLanguage: getAppLanguage(hostLanguage),
  857. hostVersion: version,
  858. hostLanguage: hostLanguage,
  859. hostName: _hostName,
  860. hostSDKVersion: SDKVersion,
  861. hostTheme: theme
  862. }));
  863. }
  864. };
  865. var getDeviceInfo = {
  866. returnValue: function returnValue(result) {
  867. var _result2 = result,
  868. brand = _result2.brand,
  869. model = _result2.model;
  870. var deviceType = getGetDeviceType(result, model);
  871. var deviceBrand = getDeviceBrand(brand);
  872. useDeviceId(result);
  873. result = sortObject(Object.assign(result, {
  874. deviceType: deviceType,
  875. deviceBrand: deviceBrand,
  876. deviceModel: model
  877. }));
  878. }
  879. };
  880. var getWindowInfo = {
  881. returnValue: function returnValue(result) {
  882. addSafeAreaInsets(result);
  883. result = sortObject(Object.assign(result, {
  884. windowTop: 0,
  885. windowBottom: 0
  886. }));
  887. }
  888. };
  889. var getAppAuthorizeSetting = {
  890. returnValue: function returnValue(result) {
  891. var locationReducedAccuracy = result.locationReducedAccuracy;
  892. result.locationAccuracy = 'unsupported';
  893. if (locationReducedAccuracy === true) {
  894. result.locationAccuracy = 'reduced';
  895. } else if (locationReducedAccuracy === false) {
  896. result.locationAccuracy = 'full';
  897. }
  898. }
  899. };
  900. // import navigateTo from 'uni-helpers/navigate-to'
  901. var compressImage = {
  902. args: function args(fromArgs) {
  903. // https://developers.weixin.qq.com/community/develop/doc/000c08940c865011298e0a43256800?highLine=compressHeight
  904. if (fromArgs.compressedHeight && !fromArgs.compressHeight) {
  905. fromArgs.compressHeight = fromArgs.compressedHeight;
  906. }
  907. if (fromArgs.compressedWidth && !fromArgs.compressWidth) {
  908. fromArgs.compressWidth = fromArgs.compressedWidth;
  909. }
  910. }
  911. };
  912. var protocols = {
  913. redirectTo: redirectTo,
  914. // navigateTo, // 由于在微信开发者工具的页面参数,会显示__id__参数,因此暂时关闭mp-weixin对于navigateTo的AOP
  915. previewImage: previewImage,
  916. getSystemInfo: getSystemInfo,
  917. getSystemInfoSync: getSystemInfo,
  918. showActionSheet: showActionSheet,
  919. getAppBaseInfo: getAppBaseInfo,
  920. getDeviceInfo: getDeviceInfo,
  921. getWindowInfo: getWindowInfo,
  922. getAppAuthorizeSetting: getAppAuthorizeSetting,
  923. compressImage: compressImage
  924. };
  925. var todos = ['vibrate', 'preloadPage', 'unPreloadPage', 'loadSubPackage'];
  926. var canIUses = [];
  927. var CALLBACKS = ['success', 'fail', 'cancel', 'complete'];
  928. function processCallback(methodName, method, returnValue) {
  929. return function (res) {
  930. return method(processReturnValue(methodName, res, returnValue));
  931. };
  932. }
  933. function processArgs(methodName, fromArgs) {
  934. var argsOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  935. var returnValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  936. var keepFromArgs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  937. if (isPlainObject(fromArgs)) {
  938. // 一般 api 的参数解析
  939. var toArgs = keepFromArgs === true ? fromArgs : {}; // returnValue 为 false 时,说明是格式化返回值,直接在返回值对象上修改赋值
  940. if (isFn(argsOption)) {
  941. argsOption = argsOption(fromArgs, toArgs) || {};
  942. }
  943. for (var key in fromArgs) {
  944. if (hasOwn(argsOption, key)) {
  945. var keyOption = argsOption[key];
  946. if (isFn(keyOption)) {
  947. keyOption = keyOption(fromArgs[key], fromArgs, toArgs);
  948. }
  949. if (!keyOption) {
  950. // 不支持的参数
  951. console.warn("The '".concat(methodName, "' method of platform '\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F' does not support option '").concat(key, "'"));
  952. } else if (isStr(keyOption)) {
  953. // 重写参数 key
  954. toArgs[keyOption] = fromArgs[key];
  955. } else if (isPlainObject(keyOption)) {
  956. // {name:newName,value:value}可重新指定参数 key:value
  957. toArgs[keyOption.name ? keyOption.name : key] = keyOption.value;
  958. }
  959. } else if (CALLBACKS.indexOf(key) !== -1) {
  960. if (isFn(fromArgs[key])) {
  961. toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
  962. }
  963. } else {
  964. if (!keepFromArgs) {
  965. toArgs[key] = fromArgs[key];
  966. }
  967. }
  968. }
  969. return toArgs;
  970. } else if (isFn(fromArgs)) {
  971. fromArgs = processCallback(methodName, fromArgs, returnValue);
  972. }
  973. return fromArgs;
  974. }
  975. function processReturnValue(methodName, res, returnValue) {
  976. var keepReturnValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  977. if (isFn(protocols.returnValue)) {
  978. // 处理通用 returnValue
  979. res = protocols.returnValue(methodName, res);
  980. }
  981. return processArgs(methodName, res, returnValue, {}, keepReturnValue);
  982. }
  983. function wrapper(methodName, method) {
  984. if (hasOwn(protocols, methodName)) {
  985. var protocol = protocols[methodName];
  986. if (!protocol) {
  987. // 暂不支持的 api
  988. return function () {
  989. console.error("Platform '\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F' does not support '".concat(methodName, "'."));
  990. };
  991. }
  992. return function (arg1, arg2) {
  993. // 目前 api 最多两个参数
  994. var options = protocol;
  995. if (isFn(protocol)) {
  996. options = protocol(arg1);
  997. }
  998. arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
  999. var args = [arg1];
  1000. if (typeof arg2 !== 'undefined') {
  1001. args.push(arg2);
  1002. }
  1003. if (isFn(options.name)) {
  1004. methodName = options.name(arg1);
  1005. } else if (isStr(options.name)) {
  1006. methodName = options.name;
  1007. }
  1008. var returnValue = wx[methodName].apply(wx, args);
  1009. if (isSyncApi(methodName)) {
  1010. // 同步 api
  1011. return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName));
  1012. }
  1013. return returnValue;
  1014. };
  1015. }
  1016. return method;
  1017. }
  1018. var todoApis = Object.create(null);
  1019. var TODOS = ['onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', 'offPush', 'share'];
  1020. function createTodoApi(name) {
  1021. return function todoApi(_ref) {
  1022. var fail = _ref.fail,
  1023. complete = _ref.complete;
  1024. var res = {
  1025. errMsg: "".concat(name, ":fail method '").concat(name, "' not supported")
  1026. };
  1027. isFn(fail) && fail(res);
  1028. isFn(complete) && complete(res);
  1029. };
  1030. }
  1031. TODOS.forEach(function (name) {
  1032. todoApis[name] = createTodoApi(name);
  1033. });
  1034. var providers = {
  1035. oauth: ['weixin'],
  1036. share: ['weixin'],
  1037. payment: ['wxpay'],
  1038. push: ['weixin']
  1039. };
  1040. function getProvider(_ref2) {
  1041. var service = _ref2.service,
  1042. success = _ref2.success,
  1043. fail = _ref2.fail,
  1044. complete = _ref2.complete;
  1045. var res = false;
  1046. if (providers[service]) {
  1047. res = {
  1048. errMsg: 'getProvider:ok',
  1049. service: service,
  1050. provider: providers[service]
  1051. };
  1052. isFn(success) && success(res);
  1053. } else {
  1054. res = {
  1055. errMsg: 'getProvider:fail service not found'
  1056. };
  1057. isFn(fail) && fail(res);
  1058. }
  1059. isFn(complete) && complete(res);
  1060. }
  1061. var extraApi = /*#__PURE__*/Object.freeze({
  1062. __proto__: null,
  1063. getProvider: getProvider
  1064. });
  1065. var getEmitter = function () {
  1066. var Emitter;
  1067. return function getUniEmitter() {
  1068. if (!Emitter) {
  1069. Emitter = new _vue.default();
  1070. }
  1071. return Emitter;
  1072. };
  1073. }();
  1074. function apply(ctx, method, args) {
  1075. return ctx[method].apply(ctx, args);
  1076. }
  1077. function $on() {
  1078. return apply(getEmitter(), '$on', Array.prototype.slice.call(arguments));
  1079. }
  1080. function $off() {
  1081. return apply(getEmitter(), '$off', Array.prototype.slice.call(arguments));
  1082. }
  1083. function $once() {
  1084. return apply(getEmitter(), '$once', Array.prototype.slice.call(arguments));
  1085. }
  1086. function $emit() {
  1087. return apply(getEmitter(), '$emit', Array.prototype.slice.call(arguments));
  1088. }
  1089. var eventApi = /*#__PURE__*/Object.freeze({
  1090. __proto__: null,
  1091. $on: $on,
  1092. $off: $off,
  1093. $once: $once,
  1094. $emit: $emit
  1095. });
  1096. /**
  1097. * 框架内 try-catch
  1098. */
  1099. /**
  1100. * 开发者 try-catch
  1101. */
  1102. function tryCatch(fn) {
  1103. return function () {
  1104. try {
  1105. return fn.apply(fn, arguments);
  1106. } catch (e) {
  1107. // TODO
  1108. console.error(e);
  1109. }
  1110. };
  1111. }
  1112. function getApiCallbacks(params) {
  1113. var apiCallbacks = {};
  1114. for (var name in params) {
  1115. var param = params[name];
  1116. if (isFn(param)) {
  1117. apiCallbacks[name] = tryCatch(param);
  1118. delete params[name];
  1119. }
  1120. }
  1121. return apiCallbacks;
  1122. }
  1123. var cid;
  1124. var cidErrMsg;
  1125. var enabled;
  1126. function normalizePushMessage(message) {
  1127. try {
  1128. return JSON.parse(message);
  1129. } catch (e) {}
  1130. return message;
  1131. }
  1132. function invokePushCallback(args) {
  1133. if (args.type === 'enabled') {
  1134. enabled = true;
  1135. } else if (args.type === 'clientId') {
  1136. cid = args.cid;
  1137. cidErrMsg = args.errMsg;
  1138. invokeGetPushCidCallbacks(cid, args.errMsg);
  1139. } else if (args.type === 'pushMsg') {
  1140. var message = {
  1141. type: 'receive',
  1142. data: normalizePushMessage(args.message)
  1143. };
  1144. for (var i = 0; i < onPushMessageCallbacks.length; i++) {
  1145. var callback = onPushMessageCallbacks[i];
  1146. callback(message);
  1147. // 该消息已被阻止
  1148. if (message.stopped) {
  1149. break;
  1150. }
  1151. }
  1152. } else if (args.type === 'click') {
  1153. onPushMessageCallbacks.forEach(function (callback) {
  1154. callback({
  1155. type: 'click',
  1156. data: normalizePushMessage(args.message)
  1157. });
  1158. });
  1159. }
  1160. }
  1161. var getPushCidCallbacks = [];
  1162. function invokeGetPushCidCallbacks(cid, errMsg) {
  1163. getPushCidCallbacks.forEach(function (callback) {
  1164. callback(cid, errMsg);
  1165. });
  1166. getPushCidCallbacks.length = 0;
  1167. }
  1168. function getPushClientId(args) {
  1169. if (!isPlainObject(args)) {
  1170. args = {};
  1171. }
  1172. var _getApiCallbacks = getApiCallbacks(args),
  1173. success = _getApiCallbacks.success,
  1174. fail = _getApiCallbacks.fail,
  1175. complete = _getApiCallbacks.complete;
  1176. var hasSuccess = isFn(success);
  1177. var hasFail = isFn(fail);
  1178. var hasComplete = isFn(complete);
  1179. Promise.resolve().then(function () {
  1180. if (typeof enabled === 'undefined') {
  1181. enabled = false;
  1182. cid = '';
  1183. cidErrMsg = 'uniPush is not enabled';
  1184. }
  1185. getPushCidCallbacks.push(function (cid, errMsg) {
  1186. var res;
  1187. if (cid) {
  1188. res = {
  1189. errMsg: 'getPushClientId:ok',
  1190. cid: cid
  1191. };
  1192. hasSuccess && success(res);
  1193. } else {
  1194. res = {
  1195. errMsg: 'getPushClientId:fail' + (errMsg ? ' ' + errMsg : '')
  1196. };
  1197. hasFail && fail(res);
  1198. }
  1199. hasComplete && complete(res);
  1200. });
  1201. if (typeof cid !== 'undefined') {
  1202. invokeGetPushCidCallbacks(cid, cidErrMsg);
  1203. }
  1204. });
  1205. }
  1206. var onPushMessageCallbacks = [];
  1207. // 不使用 defineOnApi 实现,是因为 defineOnApi 依赖 UniServiceJSBridge ,该对象目前在小程序上未提供,故简单实现
  1208. var onPushMessage = function onPushMessage(fn) {
  1209. if (onPushMessageCallbacks.indexOf(fn) === -1) {
  1210. onPushMessageCallbacks.push(fn);
  1211. }
  1212. };
  1213. var offPushMessage = function offPushMessage(fn) {
  1214. if (!fn) {
  1215. onPushMessageCallbacks.length = 0;
  1216. } else {
  1217. var index = onPushMessageCallbacks.indexOf(fn);
  1218. if (index > -1) {
  1219. onPushMessageCallbacks.splice(index, 1);
  1220. }
  1221. }
  1222. };
  1223. var baseInfo = wx.getAppBaseInfo && wx.getAppBaseInfo();
  1224. if (!baseInfo) {
  1225. baseInfo = wx.getSystemInfoSync();
  1226. }
  1227. var host = baseInfo ? baseInfo.host : null;
  1228. var shareVideoMessage = host && host.env === 'SAAASDK' ? wx.miniapp.shareVideoMessage : wx.shareVideoMessage;
  1229. var api = /*#__PURE__*/Object.freeze({
  1230. __proto__: null,
  1231. shareVideoMessage: shareVideoMessage,
  1232. getPushClientId: getPushClientId,
  1233. onPushMessage: onPushMessage,
  1234. offPushMessage: offPushMessage,
  1235. invokePushCallback: invokePushCallback
  1236. });
  1237. var mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'];
  1238. function findVmByVueId(vm, vuePid) {
  1239. var $children = vm.$children;
  1240. // 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
  1241. for (var i = $children.length - 1; i >= 0; i--) {
  1242. var childVm = $children[i];
  1243. if (childVm.$scope._$vueId === vuePid) {
  1244. return childVm;
  1245. }
  1246. }
  1247. // 反向递归查找
  1248. var parentVm;
  1249. for (var _i = $children.length - 1; _i >= 0; _i--) {
  1250. parentVm = findVmByVueId($children[_i], vuePid);
  1251. if (parentVm) {
  1252. return parentVm;
  1253. }
  1254. }
  1255. }
  1256. function initBehavior(options) {
  1257. return Behavior(options);
  1258. }
  1259. function isPage() {
  1260. return !!this.route;
  1261. }
  1262. function initRelation(detail) {
  1263. this.triggerEvent('__l', detail);
  1264. }
  1265. function selectAllComponents(mpInstance, selector, $refs) {
  1266. var components = mpInstance.selectAllComponents(selector) || [];
  1267. components.forEach(function (component) {
  1268. var ref = component.dataset.ref;
  1269. $refs[ref] = component.$vm || toSkip(component);
  1270. {
  1271. if (component.dataset.vueGeneric === 'scoped') {
  1272. component.selectAllComponents('.scoped-ref').forEach(function (scopedComponent) {
  1273. selectAllComponents(scopedComponent, selector, $refs);
  1274. });
  1275. }
  1276. }
  1277. });
  1278. }
  1279. function syncRefs(refs, newRefs) {
  1280. var oldKeys = (0, _construct2.default)(Set, (0, _toConsumableArray2.default)(Object.keys(refs)));
  1281. var newKeys = Object.keys(newRefs);
  1282. newKeys.forEach(function (key) {
  1283. var oldValue = refs[key];
  1284. var newValue = newRefs[key];
  1285. if (Array.isArray(oldValue) && Array.isArray(newValue) && oldValue.length === newValue.length && newValue.every(function (value) {
  1286. return oldValue.includes(value);
  1287. })) {
  1288. return;
  1289. }
  1290. refs[key] = newValue;
  1291. oldKeys.delete(key);
  1292. });
  1293. oldKeys.forEach(function (key) {
  1294. delete refs[key];
  1295. });
  1296. return refs;
  1297. }
  1298. function initRefs(vm) {
  1299. var mpInstance = vm.$scope;
  1300. var refs = {};
  1301. Object.defineProperty(vm, '$refs', {
  1302. get: function get() {
  1303. var $refs = {};
  1304. selectAllComponents(mpInstance, '.vue-ref', $refs);
  1305. // TODO 暂不考虑 for 中的 scoped
  1306. var forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') || [];
  1307. forComponents.forEach(function (component) {
  1308. var ref = component.dataset.ref;
  1309. if (!$refs[ref]) {
  1310. $refs[ref] = [];
  1311. }
  1312. $refs[ref].push(component.$vm || toSkip(component));
  1313. });
  1314. return syncRefs(refs, $refs);
  1315. }
  1316. });
  1317. }
  1318. function handleLink(event) {
  1319. var _ref3 = event.detail || event.value,
  1320. vuePid = _ref3.vuePid,
  1321. vueOptions = _ref3.vueOptions; // detail 是微信,value 是百度(dipatch)
  1322. var parentVm;
  1323. if (vuePid) {
  1324. parentVm = findVmByVueId(this.$vm, vuePid);
  1325. }
  1326. if (!parentVm) {
  1327. parentVm = this.$vm;
  1328. }
  1329. vueOptions.parent = parentVm;
  1330. }
  1331. function markMPComponent(component) {
  1332. // 在 Vue 中标记为小程序组件
  1333. var IS_MP = '__v_isMPComponent';
  1334. Object.defineProperty(component, IS_MP, {
  1335. configurable: true,
  1336. enumerable: false,
  1337. value: true
  1338. });
  1339. return component;
  1340. }
  1341. function toSkip(obj) {
  1342. var OB = '__ob__';
  1343. var SKIP = '__v_skip';
  1344. if (isObject(obj) && Object.isExtensible(obj)) {
  1345. // 避免被 @vue/composition-api 观测
  1346. Object.defineProperty(obj, OB, {
  1347. configurable: true,
  1348. enumerable: false,
  1349. value: (0, _defineProperty2.default)({}, SKIP, true)
  1350. });
  1351. }
  1352. return obj;
  1353. }
  1354. var WORKLET_RE = /_(.*)_worklet_factory_/;
  1355. function initWorkletMethods(mpMethods, vueMethods) {
  1356. if (vueMethods) {
  1357. Object.keys(vueMethods).forEach(function (name) {
  1358. var matches = name.match(WORKLET_RE);
  1359. if (matches) {
  1360. var workletName = matches[1];
  1361. mpMethods[name] = vueMethods[name];
  1362. mpMethods[workletName] = vueMethods[workletName];
  1363. }
  1364. });
  1365. }
  1366. }
  1367. var MPPage = Page;
  1368. var MPComponent = Component;
  1369. var customizeRE = /:/g;
  1370. var customize = cached(function (str) {
  1371. return camelize(str.replace(customizeRE, '-'));
  1372. });
  1373. function initTriggerEvent(mpInstance) {
  1374. var oldTriggerEvent = mpInstance.triggerEvent;
  1375. var newTriggerEvent = function newTriggerEvent(event) {
  1376. for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
  1377. args[_key3 - 1] = arguments[_key3];
  1378. }
  1379. // 事件名统一转驼峰格式,仅处理:当前组件为 vue 组件、当前组件为 vue 组件子组件
  1380. if (this.$vm || this.dataset && this.dataset.comType) {
  1381. event = customize(event);
  1382. } else {
  1383. // 针对微信/QQ小程序单独补充驼峰格式事件,以兼容历史项目
  1384. var newEvent = customize(event);
  1385. if (newEvent !== event) {
  1386. oldTriggerEvent.apply(this, [newEvent].concat(args));
  1387. }
  1388. }
  1389. return oldTriggerEvent.apply(this, [event].concat(args));
  1390. };
  1391. try {
  1392. // 京东小程序 triggerEvent 为只读
  1393. mpInstance.triggerEvent = newTriggerEvent;
  1394. } catch (error) {
  1395. mpInstance._triggerEvent = newTriggerEvent;
  1396. }
  1397. }
  1398. function initHook(name, options, isComponent) {
  1399. var oldHook = options[name];
  1400. options[name] = function () {
  1401. markMPComponent(this);
  1402. initTriggerEvent(this);
  1403. if (oldHook) {
  1404. for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  1405. args[_key4] = arguments[_key4];
  1406. }
  1407. return oldHook.apply(this, args);
  1408. }
  1409. };
  1410. }
  1411. if (!MPPage.__$wrappered) {
  1412. MPPage.__$wrappered = true;
  1413. Page = function Page() {
  1414. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1415. initHook('onLoad', options);
  1416. return MPPage(options);
  1417. };
  1418. Page.after = MPPage.after;
  1419. Component = function Component() {
  1420. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1421. initHook('created', options);
  1422. return MPComponent(options);
  1423. };
  1424. }
  1425. var PAGE_EVENT_HOOKS = ['onPullDownRefresh', 'onReachBottom', 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', 'onResize', 'onTabItemTap'];
  1426. function initMocks(vm, mocks) {
  1427. var mpInstance = vm.$mp[vm.mpType];
  1428. mocks.forEach(function (mock) {
  1429. if (hasOwn(mpInstance, mock)) {
  1430. vm[mock] = mpInstance[mock];
  1431. }
  1432. });
  1433. }
  1434. function hasHook(hook, vueOptions) {
  1435. if (!vueOptions) {
  1436. return true;
  1437. }
  1438. if (_vue.default.options && Array.isArray(_vue.default.options[hook])) {
  1439. return true;
  1440. }
  1441. vueOptions = vueOptions.default || vueOptions;
  1442. if (isFn(vueOptions)) {
  1443. if (isFn(vueOptions.extendOptions[hook])) {
  1444. return true;
  1445. }
  1446. if (vueOptions.super && vueOptions.super.options && Array.isArray(vueOptions.super.options[hook])) {
  1447. return true;
  1448. }
  1449. return false;
  1450. }
  1451. if (isFn(vueOptions[hook]) || Array.isArray(vueOptions[hook])) {
  1452. return true;
  1453. }
  1454. var mixins = vueOptions.mixins;
  1455. if (Array.isArray(mixins)) {
  1456. return !!mixins.find(function (mixin) {
  1457. return hasHook(hook, mixin);
  1458. });
  1459. }
  1460. }
  1461. function initHooks(mpOptions, hooks, vueOptions) {
  1462. hooks.forEach(function (hook) {
  1463. if (hasHook(hook, vueOptions)) {
  1464. mpOptions[hook] = function (args) {
  1465. return this.$vm && this.$vm.__call_hook(hook, args);
  1466. };
  1467. }
  1468. });
  1469. }
  1470. function initUnknownHooks(mpOptions, vueOptions) {
  1471. var excludes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  1472. findHooks(vueOptions).forEach(function (hook) {
  1473. return initHook$1(mpOptions, hook, excludes);
  1474. });
  1475. }
  1476. function findHooks(vueOptions) {
  1477. var hooks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  1478. if (vueOptions) {
  1479. Object.keys(vueOptions).forEach(function (name) {
  1480. if (name.indexOf('on') === 0 && isFn(vueOptions[name])) {
  1481. hooks.push(name);
  1482. }
  1483. });
  1484. }
  1485. return hooks;
  1486. }
  1487. function initHook$1(mpOptions, hook, excludes) {
  1488. if (excludes.indexOf(hook) === -1 && !hasOwn(mpOptions, hook)) {
  1489. mpOptions[hook] = function (args) {
  1490. return this.$vm && this.$vm.__call_hook(hook, args);
  1491. };
  1492. }
  1493. }
  1494. function initVueComponent(Vue, vueOptions) {
  1495. vueOptions = vueOptions.default || vueOptions;
  1496. var VueComponent;
  1497. if (isFn(vueOptions)) {
  1498. VueComponent = vueOptions;
  1499. } else {
  1500. VueComponent = Vue.extend(vueOptions);
  1501. }
  1502. vueOptions = VueComponent.options;
  1503. return [VueComponent, vueOptions];
  1504. }
  1505. function initSlots(vm, vueSlots) {
  1506. if (Array.isArray(vueSlots) && vueSlots.length) {
  1507. var $slots = Object.create(null);
  1508. vueSlots.forEach(function (slotName) {
  1509. $slots[slotName] = true;
  1510. });
  1511. vm.$scopedSlots = vm.$slots = $slots;
  1512. }
  1513. }
  1514. function initVueIds(vueIds, mpInstance) {
  1515. vueIds = (vueIds || '').split(',');
  1516. var len = vueIds.length;
  1517. if (len === 1) {
  1518. mpInstance._$vueId = vueIds[0];
  1519. } else if (len === 2) {
  1520. mpInstance._$vueId = vueIds[0];
  1521. mpInstance._$vuePid = vueIds[1];
  1522. }
  1523. }
  1524. function initData(vueOptions, context) {
  1525. var data = vueOptions.data || {};
  1526. var methods = vueOptions.methods || {};
  1527. if (typeof data === 'function') {
  1528. try {
  1529. data = data.call(context); // 支持 Vue.prototype 上挂的数据
  1530. } catch (e) {
  1531. if (Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"travel_applet","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
  1532. console.warn('根据 Vue 的 data 函数初始化小程序 data 失败,请尽量确保 data 函数中不访问 vm 对象,否则可能影响首次数据渲染速度。', data);
  1533. }
  1534. }
  1535. } else {
  1536. try {
  1537. // 对 data 格式化
  1538. data = JSON.parse(JSON.stringify(data));
  1539. } catch (e) {}
  1540. }
  1541. if (!isPlainObject(data)) {
  1542. data = {};
  1543. }
  1544. Object.keys(methods).forEach(function (methodName) {
  1545. if (context.__lifecycle_hooks__.indexOf(methodName) === -1 && !hasOwn(data, methodName)) {
  1546. data[methodName] = methods[methodName];
  1547. }
  1548. });
  1549. return data;
  1550. }
  1551. var PROP_TYPES = [String, Number, Boolean, Object, Array, null];
  1552. function createObserver(name) {
  1553. return function observer(newVal, oldVal) {
  1554. if (this.$vm) {
  1555. this.$vm[name] = newVal; // 为了触发其他非 render watcher
  1556. }
  1557. };
  1558. }
  1559. function initBehaviors(vueOptions, initBehavior) {
  1560. var vueBehaviors = vueOptions.behaviors;
  1561. var vueExtends = vueOptions.extends;
  1562. var vueMixins = vueOptions.mixins;
  1563. var vueProps = vueOptions.props;
  1564. if (!vueProps) {
  1565. vueOptions.props = vueProps = [];
  1566. }
  1567. var behaviors = [];
  1568. if (Array.isArray(vueBehaviors)) {
  1569. vueBehaviors.forEach(function (behavior) {
  1570. behaviors.push(behavior.replace('uni://', "wx".concat("://")));
  1571. if (behavior === 'uni://form-field') {
  1572. if (Array.isArray(vueProps)) {
  1573. vueProps.push('name');
  1574. vueProps.push('value');
  1575. } else {
  1576. vueProps.name = {
  1577. type: String,
  1578. default: ''
  1579. };
  1580. vueProps.value = {
  1581. type: [String, Number, Boolean, Array, Object, Date],
  1582. default: ''
  1583. };
  1584. }
  1585. }
  1586. });
  1587. }
  1588. if (isPlainObject(vueExtends) && vueExtends.props) {
  1589. behaviors.push(initBehavior({
  1590. properties: initProperties(vueExtends.props, true)
  1591. }));
  1592. }
  1593. if (Array.isArray(vueMixins)) {
  1594. vueMixins.forEach(function (vueMixin) {
  1595. if (isPlainObject(vueMixin) && vueMixin.props) {
  1596. behaviors.push(initBehavior({
  1597. properties: initProperties(vueMixin.props, true)
  1598. }));
  1599. }
  1600. });
  1601. }
  1602. return behaviors;
  1603. }
  1604. function parsePropType(key, type, defaultValue, file) {
  1605. // [String]=>String
  1606. if (Array.isArray(type) && type.length === 1) {
  1607. return type[0];
  1608. }
  1609. return type;
  1610. }
  1611. function initProperties(props) {
  1612. var isBehavior = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1613. var file = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  1614. var options = arguments.length > 3 ? arguments[3] : undefined;
  1615. var properties = {};
  1616. if (!isBehavior) {
  1617. properties.vueId = {
  1618. type: String,
  1619. value: ''
  1620. };
  1621. {
  1622. if (options.virtualHost) {
  1623. properties.virtualHostStyle = {
  1624. type: null,
  1625. value: ''
  1626. };
  1627. properties.virtualHostClass = {
  1628. type: null,
  1629. value: ''
  1630. };
  1631. }
  1632. }
  1633. // scopedSlotsCompiler auto
  1634. properties.scopedSlotsCompiler = {
  1635. type: String,
  1636. value: ''
  1637. };
  1638. properties.vueSlots = {
  1639. // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
  1640. type: null,
  1641. value: [],
  1642. observer: function observer(newVal, oldVal) {
  1643. var $slots = Object.create(null);
  1644. newVal.forEach(function (slotName) {
  1645. $slots[slotName] = true;
  1646. });
  1647. this.setData({
  1648. $slots: $slots
  1649. });
  1650. }
  1651. };
  1652. }
  1653. if (Array.isArray(props)) {
  1654. // ['title']
  1655. props.forEach(function (key) {
  1656. properties[key] = {
  1657. type: null,
  1658. observer: createObserver(key)
  1659. };
  1660. });
  1661. } else if (isPlainObject(props)) {
  1662. // {title:{type:String,default:''},content:String}
  1663. Object.keys(props).forEach(function (key) {
  1664. var opts = props[key];
  1665. if (isPlainObject(opts)) {
  1666. // title:{type:String,default:''}
  1667. var value = opts.default;
  1668. if (isFn(value)) {
  1669. value = value();
  1670. }
  1671. opts.type = parsePropType(key, opts.type);
  1672. properties[key] = {
  1673. type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
  1674. value: value,
  1675. observer: createObserver(key)
  1676. };
  1677. } else {
  1678. // content:String
  1679. var type = parsePropType(key, opts);
  1680. properties[key] = {
  1681. type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
  1682. observer: createObserver(key)
  1683. };
  1684. }
  1685. });
  1686. }
  1687. return properties;
  1688. }
  1689. function wrapper$1(event) {
  1690. // TODO 又得兼容 mpvue 的 mp 对象
  1691. try {
  1692. event.mp = JSON.parse(JSON.stringify(event));
  1693. } catch (e) {}
  1694. event.stopPropagation = noop;
  1695. event.preventDefault = noop;
  1696. event.target = event.target || {};
  1697. if (!hasOwn(event, 'detail')) {
  1698. event.detail = {};
  1699. }
  1700. if (hasOwn(event, 'markerId')) {
  1701. event.detail = (0, _typeof2.default)(event.detail) === 'object' ? event.detail : {};
  1702. event.detail.markerId = event.markerId;
  1703. }
  1704. if (isPlainObject(event.detail)) {
  1705. event.target = Object.assign({}, event.target, event.detail);
  1706. }
  1707. return event;
  1708. }
  1709. function getExtraValue(vm, dataPathsArray) {
  1710. var context = vm;
  1711. dataPathsArray.forEach(function (dataPathArray) {
  1712. var dataPath = dataPathArray[0];
  1713. var value = dataPathArray[2];
  1714. if (dataPath || typeof value !== 'undefined') {
  1715. // ['','',index,'disable']
  1716. var propPath = dataPathArray[1];
  1717. var valuePath = dataPathArray[3];
  1718. var vFor;
  1719. if (Number.isInteger(dataPath)) {
  1720. vFor = dataPath;
  1721. } else if (!dataPath) {
  1722. vFor = context;
  1723. } else if (typeof dataPath === 'string' && dataPath) {
  1724. if (dataPath.indexOf('#s#') === 0) {
  1725. vFor = dataPath.substr(3);
  1726. } else {
  1727. vFor = vm.__get_value(dataPath, context);
  1728. }
  1729. }
  1730. if (Number.isInteger(vFor)) {
  1731. context = value;
  1732. } else if (!propPath) {
  1733. context = vFor[value];
  1734. } else {
  1735. if (Array.isArray(vFor)) {
  1736. context = vFor.find(function (vForItem) {
  1737. return vm.__get_value(propPath, vForItem) === value;
  1738. });
  1739. } else if (isPlainObject(vFor)) {
  1740. context = Object.keys(vFor).find(function (vForKey) {
  1741. return vm.__get_value(propPath, vFor[vForKey]) === value;
  1742. });
  1743. } else {
  1744. console.error('v-for 暂不支持循环数据:', vFor);
  1745. }
  1746. }
  1747. if (valuePath) {
  1748. context = vm.__get_value(valuePath, context);
  1749. }
  1750. }
  1751. });
  1752. return context;
  1753. }
  1754. function processEventExtra(vm, extra, event, __args__) {
  1755. var extraObj = {};
  1756. if (Array.isArray(extra) && extra.length) {
  1757. /**
  1758. *[
  1759. * ['data.items', 'data.id', item.data.id],
  1760. * ['metas', 'id', meta.id]
  1761. *],
  1762. *[
  1763. * ['data.items', 'data.id', item.data.id],
  1764. * ['metas', 'id', meta.id]
  1765. *],
  1766. *'test'
  1767. */
  1768. extra.forEach(function (dataPath, index) {
  1769. if (typeof dataPath === 'string') {
  1770. if (!dataPath) {
  1771. // model,prop.sync
  1772. extraObj['$' + index] = vm;
  1773. } else {
  1774. if (dataPath === '$event') {
  1775. // $event
  1776. extraObj['$' + index] = event;
  1777. } else if (dataPath === 'arguments') {
  1778. extraObj['$' + index] = event.detail ? event.detail.__args__ || __args__ : __args__;
  1779. } else if (dataPath.indexOf('$event.') === 0) {
  1780. // $event.target.value
  1781. extraObj['$' + index] = vm.__get_value(dataPath.replace('$event.', ''), event);
  1782. } else {
  1783. extraObj['$' + index] = vm.__get_value(dataPath);
  1784. }
  1785. }
  1786. } else {
  1787. extraObj['$' + index] = getExtraValue(vm, dataPath);
  1788. }
  1789. });
  1790. }
  1791. return extraObj;
  1792. }
  1793. function getObjByArray(arr) {
  1794. var obj = {};
  1795. for (var i = 1; i < arr.length; i++) {
  1796. var element = arr[i];
  1797. obj[element[0]] = element[1];
  1798. }
  1799. return obj;
  1800. }
  1801. function processEventArgs(vm, event) {
  1802. var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  1803. var extra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
  1804. var isCustom = arguments.length > 4 ? arguments[4] : undefined;
  1805. var methodName = arguments.length > 5 ? arguments[5] : undefined;
  1806. var isCustomMPEvent = false; // wxcomponent 组件,传递原始 event 对象
  1807. // fixed 用户直接触发 mpInstance.triggerEvent
  1808. var __args__ = isPlainObject(event.detail) ? event.detail.__args__ || [event.detail] : [event.detail];
  1809. if (isCustom) {
  1810. // 自定义事件
  1811. isCustomMPEvent = event.currentTarget && event.currentTarget.dataset && event.currentTarget.dataset.comType === 'wx';
  1812. if (!args.length) {
  1813. // 无参数,直接传入 event 或 detail 数组
  1814. if (isCustomMPEvent) {
  1815. return [event];
  1816. }
  1817. return __args__;
  1818. }
  1819. }
  1820. var extraObj = processEventExtra(vm, extra, event, __args__);
  1821. var ret = [];
  1822. args.forEach(function (arg) {
  1823. if (arg === '$event') {
  1824. if (methodName === '__set_model' && !isCustom) {
  1825. // input v-model value
  1826. ret.push(event.target.value);
  1827. } else {
  1828. if (isCustom && !isCustomMPEvent) {
  1829. ret.push(__args__[0]);
  1830. } else {
  1831. // wxcomponent 组件或内置组件
  1832. ret.push(event);
  1833. }
  1834. }
  1835. } else {
  1836. if (Array.isArray(arg) && arg[0] === 'o') {
  1837. ret.push(getObjByArray(arg));
  1838. } else if (typeof arg === 'string' && hasOwn(extraObj, arg)) {
  1839. ret.push(extraObj[arg]);
  1840. } else {
  1841. ret.push(arg);
  1842. }
  1843. }
  1844. });
  1845. return ret;
  1846. }
  1847. var ONCE = '~';
  1848. var CUSTOM = '^';
  1849. function isMatchEventType(eventType, optType) {
  1850. return eventType === optType || optType === 'regionchange' && (eventType === 'begin' || eventType === 'end');
  1851. }
  1852. function getContextVm(vm) {
  1853. var $parent = vm.$parent;
  1854. // 父组件是 scoped slots 或者其他自定义组件时继续查找
  1855. while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) {
  1856. $parent = $parent.$parent;
  1857. }
  1858. return $parent && $parent.$parent;
  1859. }
  1860. function handleEvent(event) {
  1861. var _this2 = this;
  1862. event = wrapper$1(event);
  1863. // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
  1864. var dataset = (event.currentTarget || event.target).dataset;
  1865. if (!dataset) {
  1866. return console.warn('事件信息不存在');
  1867. }
  1868. var eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
  1869. if (!eventOpts) {
  1870. return console.warn('事件信息不存在');
  1871. }
  1872. // [['handle',[1,2,a]],['handle1',[1,2,a]]]
  1873. var eventType = event.type;
  1874. var ret = [];
  1875. eventOpts.forEach(function (eventOpt) {
  1876. var type = eventOpt[0];
  1877. var eventsArray = eventOpt[1];
  1878. var isCustom = type.charAt(0) === CUSTOM;
  1879. type = isCustom ? type.slice(1) : type;
  1880. var isOnce = type.charAt(0) === ONCE;
  1881. type = isOnce ? type.slice(1) : type;
  1882. if (eventsArray && isMatchEventType(eventType, type)) {
  1883. eventsArray.forEach(function (eventArray) {
  1884. var methodName = eventArray[0];
  1885. if (methodName) {
  1886. var handlerCtx = _this2.$vm;
  1887. if (handlerCtx.$options.generic) {
  1888. // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
  1889. handlerCtx = getContextVm(handlerCtx) || handlerCtx;
  1890. }
  1891. if (methodName === '$emit') {
  1892. handlerCtx.$emit.apply(handlerCtx, processEventArgs(_this2.$vm, event, eventArray[1], eventArray[2], isCustom, methodName));
  1893. return;
  1894. }
  1895. var handler = handlerCtx[methodName];
  1896. if (!isFn(handler)) {
  1897. var _type = _this2.$vm.mpType === 'page' ? 'Page' : 'Component';
  1898. var path = _this2.route || _this2.is;
  1899. throw new Error("".concat(_type, " \"").concat(path, "\" does not have a method \"").concat(methodName, "\""));
  1900. }
  1901. if (isOnce) {
  1902. if (handler.once) {
  1903. return;
  1904. }
  1905. handler.once = true;
  1906. }
  1907. var params = processEventArgs(_this2.$vm, event, eventArray[1], eventArray[2], isCustom, methodName);
  1908. params = Array.isArray(params) ? params : [];
  1909. // 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
  1910. if (/=\s*\S+\.eventParams\s*\|\|\s*\S+\[['"]event-params['"]\]/.test(handler.toString())) {
  1911. // eslint-disable-next-line no-sparse-arrays
  1912. params = params.concat([,,,,,,,,,, event]);
  1913. }
  1914. ret.push(handler.apply(handlerCtx, params));
  1915. }
  1916. });
  1917. }
  1918. });
  1919. if (eventType === 'input' && ret.length === 1 && typeof ret[0] !== 'undefined') {
  1920. return ret[0];
  1921. }
  1922. }
  1923. var eventChannels = {};
  1924. function getEventChannel(id) {
  1925. var eventChannel = eventChannels[id];
  1926. delete eventChannels[id];
  1927. return eventChannel;
  1928. }
  1929. var hooks = ['onShow', 'onHide', 'onError', 'onPageNotFound', 'onThemeChange', 'onUnhandledRejection'];
  1930. function initEventChannel() {
  1931. _vue.default.prototype.getOpenerEventChannel = function () {
  1932. // 微信小程序使用自身getOpenerEventChannel
  1933. {
  1934. return this.$scope.getOpenerEventChannel();
  1935. }
  1936. };
  1937. var callHook = _vue.default.prototype.__call_hook;
  1938. _vue.default.prototype.__call_hook = function (hook, args) {
  1939. if (hook === 'onLoad' && args && args.__id__) {
  1940. this.__eventChannel__ = getEventChannel(args.__id__);
  1941. delete args.__id__;
  1942. }
  1943. return callHook.call(this, hook, args);
  1944. };
  1945. }
  1946. function initScopedSlotsParams() {
  1947. var center = {};
  1948. var parents = {};
  1949. function currentId(fn) {
  1950. var vueIds = this.$options.propsData.vueId;
  1951. if (vueIds) {
  1952. var vueId = vueIds.split(',')[0];
  1953. fn(vueId);
  1954. }
  1955. }
  1956. _vue.default.prototype.$hasSSP = function (vueId) {
  1957. var slot = center[vueId];
  1958. if (!slot) {
  1959. parents[vueId] = this;
  1960. this.$on('hook:destroyed', function () {
  1961. delete parents[vueId];
  1962. });
  1963. }
  1964. return slot;
  1965. };
  1966. _vue.default.prototype.$getSSP = function (vueId, name, needAll) {
  1967. var slot = center[vueId];
  1968. if (slot) {
  1969. var params = slot[name] || [];
  1970. if (needAll) {
  1971. return params;
  1972. }
  1973. return params[0];
  1974. }
  1975. };
  1976. _vue.default.prototype.$setSSP = function (name, value) {
  1977. var index = 0;
  1978. currentId.call(this, function (vueId) {
  1979. var slot = center[vueId];
  1980. var params = slot[name] = slot[name] || [];
  1981. params.push(value);
  1982. index = params.length - 1;
  1983. });
  1984. return index;
  1985. };
  1986. _vue.default.prototype.$initSSP = function () {
  1987. currentId.call(this, function (vueId) {
  1988. center[vueId] = {};
  1989. });
  1990. };
  1991. _vue.default.prototype.$callSSP = function () {
  1992. currentId.call(this, function (vueId) {
  1993. if (parents[vueId]) {
  1994. parents[vueId].$forceUpdate();
  1995. }
  1996. });
  1997. };
  1998. _vue.default.mixin({
  1999. destroyed: function destroyed() {
  2000. var propsData = this.$options.propsData;
  2001. var vueId = propsData && propsData.vueId;
  2002. if (vueId) {
  2003. delete center[vueId];
  2004. delete parents[vueId];
  2005. }
  2006. }
  2007. });
  2008. }
  2009. function parseBaseApp(vm, _ref4) {
  2010. var mocks = _ref4.mocks,
  2011. initRefs = _ref4.initRefs;
  2012. initEventChannel();
  2013. {
  2014. initScopedSlotsParams();
  2015. }
  2016. if (vm.$options.store) {
  2017. _vue.default.prototype.$store = vm.$options.store;
  2018. }
  2019. uniIdMixin(_vue.default);
  2020. _vue.default.prototype.mpHost = "mp-weixin";
  2021. _vue.default.mixin({
  2022. beforeCreate: function beforeCreate() {
  2023. if (!this.$options.mpType) {
  2024. return;
  2025. }
  2026. this.mpType = this.$options.mpType;
  2027. this.$mp = (0, _defineProperty2.default)({
  2028. data: {}
  2029. }, this.mpType, this.$options.mpInstance);
  2030. this.$scope = this.$options.mpInstance;
  2031. delete this.$options.mpType;
  2032. delete this.$options.mpInstance;
  2033. if (this.mpType === 'page' && typeof getApp === 'function') {
  2034. // hack vue-i18n
  2035. var app = getApp();
  2036. if (app.$vm && app.$vm.$i18n) {
  2037. this._i18n = app.$vm.$i18n;
  2038. }
  2039. }
  2040. if (this.mpType !== 'app') {
  2041. initRefs(this);
  2042. initMocks(this, mocks);
  2043. }
  2044. }
  2045. });
  2046. var appOptions = {
  2047. onLaunch: function onLaunch(args) {
  2048. if (this.$vm) {
  2049. // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
  2050. return;
  2051. }
  2052. {
  2053. if (wx.canIUse && !wx.canIUse('nextTick')) {
  2054. // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
  2055. console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
  2056. }
  2057. }
  2058. this.$vm = vm;
  2059. this.$vm.$mp = {
  2060. app: this
  2061. };
  2062. this.$vm.$scope = this;
  2063. // vm 上也挂载 globalData
  2064. this.$vm.globalData = this.globalData;
  2065. this.$vm._isMounted = true;
  2066. this.$vm.__call_hook('mounted', args);
  2067. this.$vm.__call_hook('onLaunch', args);
  2068. }
  2069. };
  2070. // 兼容旧版本 globalData
  2071. appOptions.globalData = vm.$options.globalData || {};
  2072. // 将 methods 中的方法挂在 getApp() 中
  2073. var methods = vm.$options.methods;
  2074. if (methods) {
  2075. Object.keys(methods).forEach(function (name) {
  2076. appOptions[name] = methods[name];
  2077. });
  2078. }
  2079. initAppLocale(_vue.default, vm, normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN);
  2080. initHooks(appOptions, hooks);
  2081. initUnknownHooks(appOptions, vm.$options);
  2082. return appOptions;
  2083. }
  2084. function parseApp(vm) {
  2085. return parseBaseApp(vm, {
  2086. mocks: mocks,
  2087. initRefs: initRefs
  2088. });
  2089. }
  2090. function createApp(vm) {
  2091. App(parseApp(vm));
  2092. return vm;
  2093. }
  2094. var encodeReserveRE = /[!'()*]/g;
  2095. var encodeReserveReplacer = function encodeReserveReplacer(c) {
  2096. return '%' + c.charCodeAt(0).toString(16);
  2097. };
  2098. var commaRE = /%2C/g;
  2099. // fixed encodeURIComponent which is more conformant to RFC3986:
  2100. // - escapes [!'()*]
  2101. // - preserve commas
  2102. var encode = function encode(str) {
  2103. return encodeURIComponent(str).replace(encodeReserveRE, encodeReserveReplacer).replace(commaRE, ',');
  2104. };
  2105. function stringifyQuery(obj) {
  2106. var encodeStr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : encode;
  2107. var res = obj ? Object.keys(obj).map(function (key) {
  2108. var val = obj[key];
  2109. if (val === undefined) {
  2110. return '';
  2111. }
  2112. if (val === null) {
  2113. return encodeStr(key);
  2114. }
  2115. if (Array.isArray(val)) {
  2116. var result = [];
  2117. val.forEach(function (val2) {
  2118. if (val2 === undefined) {
  2119. return;
  2120. }
  2121. if (val2 === null) {
  2122. result.push(encodeStr(key));
  2123. } else {
  2124. result.push(encodeStr(key) + '=' + encodeStr(val2));
  2125. }
  2126. });
  2127. return result.join('&');
  2128. }
  2129. return encodeStr(key) + '=' + encodeStr(val);
  2130. }).filter(function (x) {
  2131. return x.length > 0;
  2132. }).join('&') : null;
  2133. return res ? "?".concat(res) : '';
  2134. }
  2135. function parseBaseComponent(vueComponentOptions) {
  2136. var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  2137. isPage = _ref5.isPage,
  2138. initRelation = _ref5.initRelation;
  2139. var needVueOptions = arguments.length > 2 ? arguments[2] : undefined;
  2140. var _initVueComponent = initVueComponent(_vue.default, vueComponentOptions),
  2141. _initVueComponent2 = (0, _slicedToArray2.default)(_initVueComponent, 2),
  2142. VueComponent = _initVueComponent2[0],
  2143. vueOptions = _initVueComponent2[1];
  2144. var options = _objectSpread({
  2145. multipleSlots: true,
  2146. // styleIsolation: 'apply-shared',
  2147. addGlobalClass: true
  2148. }, vueOptions.options || {});
  2149. {
  2150. // 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
  2151. if (vueOptions['mp-weixin'] && vueOptions['mp-weixin'].options) {
  2152. Object.assign(options, vueOptions['mp-weixin'].options);
  2153. }
  2154. }
  2155. var componentOptions = {
  2156. options: options,
  2157. data: initData(vueOptions, _vue.default.prototype),
  2158. behaviors: initBehaviors(vueOptions, initBehavior),
  2159. properties: initProperties(vueOptions.props, false, vueOptions.__file, options),
  2160. lifetimes: {
  2161. attached: function attached() {
  2162. var properties = this.properties;
  2163. var options = {
  2164. mpType: isPage.call(this) ? 'page' : 'component',
  2165. mpInstance: this,
  2166. propsData: properties
  2167. };
  2168. initVueIds(properties.vueId, this);
  2169. // 处理父子关系
  2170. initRelation.call(this, {
  2171. vuePid: this._$vuePid,
  2172. vueOptions: options
  2173. });
  2174. // 初始化 vue 实例
  2175. this.$vm = new VueComponent(options);
  2176. // 处理$slots,$scopedSlots(暂不支持动态变化$slots)
  2177. initSlots(this.$vm, properties.vueSlots);
  2178. // 触发首次 setData
  2179. this.$vm.$mount();
  2180. },
  2181. ready: function ready() {
  2182. // 当组件 props 默认值为 true,初始化时传入 false 会导致 created,ready 触发, 但 attached 不触发
  2183. // https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800
  2184. if (this.$vm) {
  2185. this.$vm._isMounted = true;
  2186. this.$vm.__call_hook('mounted');
  2187. this.$vm.__call_hook('onReady');
  2188. }
  2189. },
  2190. detached: function detached() {
  2191. this.$vm && this.$vm.$destroy();
  2192. }
  2193. },
  2194. pageLifetimes: {
  2195. show: function show(args) {
  2196. this.$vm && this.$vm.__call_hook('onPageShow', args);
  2197. },
  2198. hide: function hide() {
  2199. this.$vm && this.$vm.__call_hook('onPageHide');
  2200. },
  2201. resize: function resize(size) {
  2202. this.$vm && this.$vm.__call_hook('onPageResize', size);
  2203. }
  2204. },
  2205. methods: {
  2206. __l: handleLink,
  2207. __e: handleEvent
  2208. }
  2209. };
  2210. // externalClasses
  2211. if (vueOptions.externalClasses) {
  2212. componentOptions.externalClasses = vueOptions.externalClasses;
  2213. }
  2214. if (Array.isArray(vueOptions.wxsCallMethods)) {
  2215. vueOptions.wxsCallMethods.forEach(function (callMethod) {
  2216. componentOptions.methods[callMethod] = function (args) {
  2217. return this.$vm[callMethod](args);
  2218. };
  2219. });
  2220. }
  2221. if (needVueOptions) {
  2222. return [componentOptions, vueOptions, VueComponent];
  2223. }
  2224. if (isPage) {
  2225. return componentOptions;
  2226. }
  2227. return [componentOptions, VueComponent];
  2228. }
  2229. function parseComponent(vueComponentOptions, needVueOptions) {
  2230. return parseBaseComponent(vueComponentOptions, {
  2231. isPage: isPage,
  2232. initRelation: initRelation
  2233. }, needVueOptions);
  2234. }
  2235. var hooks$1 = ['onShow', 'onHide', 'onUnload'];
  2236. hooks$1.push.apply(hooks$1, PAGE_EVENT_HOOKS);
  2237. function parseBasePage(vuePageOptions) {
  2238. var _parseComponent = parseComponent(vuePageOptions, true),
  2239. _parseComponent2 = (0, _slicedToArray2.default)(_parseComponent, 2),
  2240. pageOptions = _parseComponent2[0],
  2241. vueOptions = _parseComponent2[1];
  2242. initHooks(pageOptions.methods, hooks$1, vueOptions);
  2243. pageOptions.methods.onLoad = function (query) {
  2244. this.options = query;
  2245. var copyQuery = Object.assign({}, query);
  2246. delete copyQuery.__id__;
  2247. this.$page = {
  2248. fullPath: '/' + (this.route || this.is) + stringifyQuery(copyQuery)
  2249. };
  2250. this.$vm.$mp.query = query; // 兼容 mpvue
  2251. this.$vm.__call_hook('onLoad', query);
  2252. };
  2253. {
  2254. initUnknownHooks(pageOptions.methods, vuePageOptions, ['onReady']);
  2255. }
  2256. {
  2257. initWorkletMethods(pageOptions.methods, vueOptions.methods);
  2258. }
  2259. return pageOptions;
  2260. }
  2261. function parsePage(vuePageOptions) {
  2262. return parseBasePage(vuePageOptions);
  2263. }
  2264. function createPage(vuePageOptions) {
  2265. {
  2266. return Component(parsePage(vuePageOptions));
  2267. }
  2268. }
  2269. function createComponent(vueOptions) {
  2270. {
  2271. return Component(parseComponent(vueOptions));
  2272. }
  2273. }
  2274. function createSubpackageApp(vm) {
  2275. var appOptions = parseApp(vm);
  2276. var app = getApp({
  2277. allowDefault: true
  2278. });
  2279. vm.$scope = app;
  2280. var globalData = app.globalData;
  2281. if (globalData) {
  2282. Object.keys(appOptions.globalData).forEach(function (name) {
  2283. if (!hasOwn(globalData, name)) {
  2284. globalData[name] = appOptions.globalData[name];
  2285. }
  2286. });
  2287. }
  2288. Object.keys(appOptions).forEach(function (name) {
  2289. if (!hasOwn(app, name)) {
  2290. app[name] = appOptions[name];
  2291. }
  2292. });
  2293. if (isFn(appOptions.onShow) && wx.onAppShow) {
  2294. wx.onAppShow(function () {
  2295. for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  2296. args[_key5] = arguments[_key5];
  2297. }
  2298. vm.__call_hook('onShow', args);
  2299. });
  2300. }
  2301. if (isFn(appOptions.onHide) && wx.onAppHide) {
  2302. wx.onAppHide(function () {
  2303. for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  2304. args[_key6] = arguments[_key6];
  2305. }
  2306. vm.__call_hook('onHide', args);
  2307. });
  2308. }
  2309. if (isFn(appOptions.onLaunch)) {
  2310. var args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
  2311. vm.__call_hook('onLaunch', args);
  2312. }
  2313. return vm;
  2314. }
  2315. function createPlugin(vm) {
  2316. var appOptions = parseApp(vm);
  2317. if (isFn(appOptions.onShow) && wx.onAppShow) {
  2318. wx.onAppShow(function () {
  2319. for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  2320. args[_key7] = arguments[_key7];
  2321. }
  2322. vm.__call_hook('onShow', args);
  2323. });
  2324. }
  2325. if (isFn(appOptions.onHide) && wx.onAppHide) {
  2326. wx.onAppHide(function () {
  2327. for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
  2328. args[_key8] = arguments[_key8];
  2329. }
  2330. vm.__call_hook('onHide', args);
  2331. });
  2332. }
  2333. if (isFn(appOptions.onLaunch)) {
  2334. var args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
  2335. vm.__call_hook('onLaunch', args);
  2336. }
  2337. return vm;
  2338. }
  2339. todos.forEach(function (todoApi) {
  2340. protocols[todoApi] = false;
  2341. });
  2342. canIUses.forEach(function (canIUseApi) {
  2343. var apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
  2344. if (!wx.canIUse(apiName)) {
  2345. protocols[canIUseApi] = false;
  2346. }
  2347. });
  2348. var uni = {};
  2349. if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') {
  2350. uni = new Proxy({}, {
  2351. get: function get(target, name) {
  2352. if (hasOwn(target, name)) {
  2353. return target[name];
  2354. }
  2355. if (baseApi[name]) {
  2356. return baseApi[name];
  2357. }
  2358. if (api[name]) {
  2359. return promisify(name, api[name]);
  2360. }
  2361. {
  2362. if (extraApi[name]) {
  2363. return promisify(name, extraApi[name]);
  2364. }
  2365. if (todoApis[name]) {
  2366. return promisify(name, todoApis[name]);
  2367. }
  2368. }
  2369. if (eventApi[name]) {
  2370. return eventApi[name];
  2371. }
  2372. return promisify(name, wrapper(name, wx[name]));
  2373. },
  2374. set: function set(target, name, value) {
  2375. target[name] = value;
  2376. return true;
  2377. }
  2378. });
  2379. } else {
  2380. Object.keys(baseApi).forEach(function (name) {
  2381. uni[name] = baseApi[name];
  2382. });
  2383. {
  2384. Object.keys(todoApis).forEach(function (name) {
  2385. uni[name] = promisify(name, todoApis[name]);
  2386. });
  2387. Object.keys(extraApi).forEach(function (name) {
  2388. uni[name] = promisify(name, extraApi[name]);
  2389. });
  2390. }
  2391. Object.keys(eventApi).forEach(function (name) {
  2392. uni[name] = eventApi[name];
  2393. });
  2394. Object.keys(api).forEach(function (name) {
  2395. uni[name] = promisify(name, api[name]);
  2396. });
  2397. Object.keys(wx).forEach(function (name) {
  2398. if (hasOwn(wx, name) || hasOwn(protocols, name)) {
  2399. uni[name] = promisify(name, wrapper(name, wx[name]));
  2400. }
  2401. });
  2402. }
  2403. wx.createApp = createApp;
  2404. wx.createPage = createPage;
  2405. wx.createComponent = createComponent;
  2406. wx.createSubpackageApp = createSubpackageApp;
  2407. wx.createPlugin = createPlugin;
  2408. var uni$1 = uni;
  2409. var _default = uni$1;
  2410. exports.default = _default;
  2411. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js */ 1)["default"], __webpack_require__(/*! ./../../../webpack/buildin/global.js */ 3)))
  2412. /***/ }),
  2413. /* 3 */
  2414. /*!***********************************!*\
  2415. !*** (webpack)/buildin/global.js ***!
  2416. \***********************************/
  2417. /*! no static exports found */
  2418. /***/ (function(module, exports) {
  2419. var g;
  2420. // This works in non-strict mode
  2421. g = (function() {
  2422. return this;
  2423. })();
  2424. try {
  2425. // This works if eval is allowed (see CSP)
  2426. g = g || new Function("return this")();
  2427. } catch (e) {
  2428. // This works if the window reference is available
  2429. if (typeof window === "object") g = window;
  2430. }
  2431. // g can still be undefined, but nothing to do about it...
  2432. // We return undefined, instead of nothing here, so it's
  2433. // easier to handle this case. if(!global) { ...}
  2434. module.exports = g;
  2435. /***/ }),
  2436. /* 4 */
  2437. /*!**********************************************************************!*\
  2438. !*** ./node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
  2439. \**********************************************************************/
  2440. /*! no static exports found */
  2441. /***/ (function(module, exports) {
  2442. function _interopRequireDefault(obj) {
  2443. return obj && obj.__esModule ? obj : {
  2444. "default": obj
  2445. };
  2446. }
  2447. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2448. /***/ }),
  2449. /* 5 */
  2450. /*!**************************************************************!*\
  2451. !*** ./node_modules/@babel/runtime/helpers/slicedToArray.js ***!
  2452. \**************************************************************/
  2453. /*! no static exports found */
  2454. /***/ (function(module, exports, __webpack_require__) {
  2455. var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ 6);
  2456. var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ 7);
  2457. var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ 8);
  2458. var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ 10);
  2459. function _slicedToArray(arr, i) {
  2460. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
  2461. }
  2462. module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2463. /***/ }),
  2464. /* 6 */
  2465. /*!***************************************************************!*\
  2466. !*** ./node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
  2467. \***************************************************************/
  2468. /*! no static exports found */
  2469. /***/ (function(module, exports) {
  2470. function _arrayWithHoles(arr) {
  2471. if (Array.isArray(arr)) return arr;
  2472. }
  2473. module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2474. /***/ }),
  2475. /* 7 */
  2476. /*!*********************************************************************!*\
  2477. !*** ./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
  2478. \*********************************************************************/
  2479. /*! no static exports found */
  2480. /***/ (function(module, exports) {
  2481. function _iterableToArrayLimit(arr, i) {
  2482. var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
  2483. if (null != _i) {
  2484. var _s,
  2485. _e,
  2486. _x,
  2487. _r,
  2488. _arr = [],
  2489. _n = !0,
  2490. _d = !1;
  2491. try {
  2492. if (_x = (_i = _i.call(arr)).next, 0 === i) {
  2493. if (Object(_i) !== _i) return;
  2494. _n = !1;
  2495. } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
  2496. ;
  2497. }
  2498. } catch (err) {
  2499. _d = !0, _e = err;
  2500. } finally {
  2501. try {
  2502. if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
  2503. } finally {
  2504. if (_d) throw _e;
  2505. }
  2506. }
  2507. return _arr;
  2508. }
  2509. }
  2510. module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2511. /***/ }),
  2512. /* 8 */
  2513. /*!***************************************************************************!*\
  2514. !*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
  2515. \***************************************************************************/
  2516. /*! no static exports found */
  2517. /***/ (function(module, exports, __webpack_require__) {
  2518. var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ 9);
  2519. function _unsupportedIterableToArray(o, minLen) {
  2520. if (!o) return;
  2521. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  2522. var n = Object.prototype.toString.call(o).slice(8, -1);
  2523. if (n === "Object" && o.constructor) n = o.constructor.name;
  2524. if (n === "Map" || n === "Set") return Array.from(o);
  2525. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
  2526. }
  2527. module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2528. /***/ }),
  2529. /* 9 */
  2530. /*!*****************************************************************!*\
  2531. !*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
  2532. \*****************************************************************/
  2533. /*! no static exports found */
  2534. /***/ (function(module, exports) {
  2535. function _arrayLikeToArray(arr, len) {
  2536. if (len == null || len > arr.length) len = arr.length;
  2537. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  2538. arr2[i] = arr[i];
  2539. }
  2540. return arr2;
  2541. }
  2542. module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2543. /***/ }),
  2544. /* 10 */
  2545. /*!****************************************************************!*\
  2546. !*** ./node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
  2547. \****************************************************************/
  2548. /*! no static exports found */
  2549. /***/ (function(module, exports) {
  2550. function _nonIterableRest() {
  2551. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2552. }
  2553. module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2554. /***/ }),
  2555. /* 11 */
  2556. /*!***************************************************************!*\
  2557. !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***!
  2558. \***************************************************************/
  2559. /*! no static exports found */
  2560. /***/ (function(module, exports, __webpack_require__) {
  2561. var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ 12);
  2562. function _defineProperty(obj, key, value) {
  2563. key = toPropertyKey(key);
  2564. if (key in obj) {
  2565. Object.defineProperty(obj, key, {
  2566. value: value,
  2567. enumerable: true,
  2568. configurable: true,
  2569. writable: true
  2570. });
  2571. } else {
  2572. obj[key] = value;
  2573. }
  2574. return obj;
  2575. }
  2576. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2577. /***/ }),
  2578. /* 12 */
  2579. /*!**************************************************************!*\
  2580. !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
  2581. \**************************************************************/
  2582. /*! no static exports found */
  2583. /***/ (function(module, exports, __webpack_require__) {
  2584. var _typeof = __webpack_require__(/*! ./typeof.js */ 13)["default"];
  2585. var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ 14);
  2586. function _toPropertyKey(arg) {
  2587. var key = toPrimitive(arg, "string");
  2588. return _typeof(key) === "symbol" ? key : String(key);
  2589. }
  2590. module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2591. /***/ }),
  2592. /* 13 */
  2593. /*!*******************************************************!*\
  2594. !*** ./node_modules/@babel/runtime/helpers/typeof.js ***!
  2595. \*******************************************************/
  2596. /*! no static exports found */
  2597. /***/ (function(module, exports) {
  2598. function _typeof(obj) {
  2599. "@babel/helpers - typeof";
  2600. return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  2601. return typeof obj;
  2602. } : function (obj) {
  2603. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2604. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
  2605. }
  2606. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2607. /***/ }),
  2608. /* 14 */
  2609. /*!************************************************************!*\
  2610. !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***!
  2611. \************************************************************/
  2612. /*! no static exports found */
  2613. /***/ (function(module, exports, __webpack_require__) {
  2614. var _typeof = __webpack_require__(/*! ./typeof.js */ 13)["default"];
  2615. function _toPrimitive(input, hint) {
  2616. if (_typeof(input) !== "object" || input === null) return input;
  2617. var prim = input[Symbol.toPrimitive];
  2618. if (prim !== undefined) {
  2619. var res = prim.call(input, hint || "default");
  2620. if (_typeof(res) !== "object") return res;
  2621. throw new TypeError("@@toPrimitive must return a primitive value.");
  2622. }
  2623. return (hint === "string" ? String : Number)(input);
  2624. }
  2625. module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2626. /***/ }),
  2627. /* 15 */
  2628. /*!**********************************************************!*\
  2629. !*** ./node_modules/@babel/runtime/helpers/construct.js ***!
  2630. \**********************************************************/
  2631. /*! no static exports found */
  2632. /***/ (function(module, exports, __webpack_require__) {
  2633. var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ 16);
  2634. var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ 17);
  2635. function _construct(Parent, args, Class) {
  2636. if (isNativeReflectConstruct()) {
  2637. module.exports = _construct = Reflect.construct.bind(), module.exports.__esModule = true, module.exports["default"] = module.exports;
  2638. } else {
  2639. module.exports = _construct = function _construct(Parent, args, Class) {
  2640. var a = [null];
  2641. a.push.apply(a, args);
  2642. var Constructor = Function.bind.apply(Parent, a);
  2643. var instance = new Constructor();
  2644. if (Class) setPrototypeOf(instance, Class.prototype);
  2645. return instance;
  2646. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2647. }
  2648. return _construct.apply(null, arguments);
  2649. }
  2650. module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2651. /***/ }),
  2652. /* 16 */
  2653. /*!***************************************************************!*\
  2654. !*** ./node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
  2655. \***************************************************************/
  2656. /*! no static exports found */
  2657. /***/ (function(module, exports) {
  2658. function _setPrototypeOf(o, p) {
  2659. module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
  2660. o.__proto__ = p;
  2661. return o;
  2662. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2663. return _setPrototypeOf(o, p);
  2664. }
  2665. module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2666. /***/ }),
  2667. /* 17 */
  2668. /*!*************************************************************************!*\
  2669. !*** ./node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
  2670. \*************************************************************************/
  2671. /*! no static exports found */
  2672. /***/ (function(module, exports) {
  2673. function _isNativeReflectConstruct() {
  2674. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  2675. if (Reflect.construct.sham) return false;
  2676. if (typeof Proxy === "function") return true;
  2677. try {
  2678. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  2679. return true;
  2680. } catch (e) {
  2681. return false;
  2682. }
  2683. }
  2684. module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2685. /***/ }),
  2686. /* 18 */
  2687. /*!******************************************************************!*\
  2688. !*** ./node_modules/@babel/runtime/helpers/toConsumableArray.js ***!
  2689. \******************************************************************/
  2690. /*! no static exports found */
  2691. /***/ (function(module, exports, __webpack_require__) {
  2692. var arrayWithoutHoles = __webpack_require__(/*! ./arrayWithoutHoles.js */ 19);
  2693. var iterableToArray = __webpack_require__(/*! ./iterableToArray.js */ 20);
  2694. var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ 8);
  2695. var nonIterableSpread = __webpack_require__(/*! ./nonIterableSpread.js */ 21);
  2696. function _toConsumableArray(arr) {
  2697. return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
  2698. }
  2699. module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2700. /***/ }),
  2701. /* 19 */
  2702. /*!******************************************************************!*\
  2703. !*** ./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***!
  2704. \******************************************************************/
  2705. /*! no static exports found */
  2706. /***/ (function(module, exports, __webpack_require__) {
  2707. var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ 9);
  2708. function _arrayWithoutHoles(arr) {
  2709. if (Array.isArray(arr)) return arrayLikeToArray(arr);
  2710. }
  2711. module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2712. /***/ }),
  2713. /* 20 */
  2714. /*!****************************************************************!*\
  2715. !*** ./node_modules/@babel/runtime/helpers/iterableToArray.js ***!
  2716. \****************************************************************/
  2717. /*! no static exports found */
  2718. /***/ (function(module, exports) {
  2719. function _iterableToArray(iter) {
  2720. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  2721. }
  2722. module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2723. /***/ }),
  2724. /* 21 */
  2725. /*!******************************************************************!*\
  2726. !*** ./node_modules/@babel/runtime/helpers/nonIterableSpread.js ***!
  2727. \******************************************************************/
  2728. /*! no static exports found */
  2729. /***/ (function(module, exports) {
  2730. function _nonIterableSpread() {
  2731. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2732. }
  2733. module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2734. /***/ }),
  2735. /* 22 */
  2736. /*!*************************************************************!*\
  2737. !*** ./node_modules/@dcloudio/uni-i18n/dist/uni-i18n.es.js ***!
  2738. \*************************************************************/
  2739. /*! no static exports found */
  2740. /***/ (function(module, exports, __webpack_require__) {
  2741. "use strict";
  2742. /* WEBPACK VAR INJECTION */(function(uni, global) {
  2743. var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
  2744. Object.defineProperty(exports, "__esModule", {
  2745. value: true
  2746. });
  2747. exports.LOCALE_ZH_HANT = exports.LOCALE_ZH_HANS = exports.LOCALE_FR = exports.LOCALE_ES = exports.LOCALE_EN = exports.I18n = exports.Formatter = void 0;
  2748. exports.compileI18nJsonStr = compileI18nJsonStr;
  2749. exports.hasI18nJson = hasI18nJson;
  2750. exports.initVueI18n = initVueI18n;
  2751. exports.isI18nStr = isI18nStr;
  2752. exports.isString = void 0;
  2753. exports.normalizeLocale = normalizeLocale;
  2754. exports.parseI18nJson = parseI18nJson;
  2755. exports.resolveLocale = resolveLocale;
  2756. var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ 5));
  2757. var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ 23));
  2758. var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ 24));
  2759. var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ 13));
  2760. var isObject = function isObject(val) {
  2761. return val !== null && (0, _typeof2.default)(val) === 'object';
  2762. };
  2763. var defaultDelimiters = ['{', '}'];
  2764. var BaseFormatter = /*#__PURE__*/function () {
  2765. function BaseFormatter() {
  2766. (0, _classCallCheck2.default)(this, BaseFormatter);
  2767. this._caches = Object.create(null);
  2768. }
  2769. (0, _createClass2.default)(BaseFormatter, [{
  2770. key: "interpolate",
  2771. value: function interpolate(message, values) {
  2772. var delimiters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultDelimiters;
  2773. if (!values) {
  2774. return [message];
  2775. }
  2776. var tokens = this._caches[message];
  2777. if (!tokens) {
  2778. tokens = parse(message, delimiters);
  2779. this._caches[message] = tokens;
  2780. }
  2781. return compile(tokens, values);
  2782. }
  2783. }]);
  2784. return BaseFormatter;
  2785. }();
  2786. exports.Formatter = BaseFormatter;
  2787. var RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
  2788. var RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
  2789. function parse(format, _ref) {
  2790. var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
  2791. startDelimiter = _ref2[0],
  2792. endDelimiter = _ref2[1];
  2793. var tokens = [];
  2794. var position = 0;
  2795. var text = '';
  2796. while (position < format.length) {
  2797. var char = format[position++];
  2798. if (char === startDelimiter) {
  2799. if (text) {
  2800. tokens.push({
  2801. type: 'text',
  2802. value: text
  2803. });
  2804. }
  2805. text = '';
  2806. var sub = '';
  2807. char = format[position++];
  2808. while (char !== undefined && char !== endDelimiter) {
  2809. sub += char;
  2810. char = format[position++];
  2811. }
  2812. var isClosed = char === endDelimiter;
  2813. var type = RE_TOKEN_LIST_VALUE.test(sub) ? 'list' : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? 'named' : 'unknown';
  2814. tokens.push({
  2815. value: sub,
  2816. type: type
  2817. });
  2818. }
  2819. // else if (char === '%') {
  2820. // // when found rails i18n syntax, skip text capture
  2821. // if (format[position] !== '{') {
  2822. // text += char
  2823. // }
  2824. // }
  2825. else {
  2826. text += char;
  2827. }
  2828. }
  2829. text && tokens.push({
  2830. type: 'text',
  2831. value: text
  2832. });
  2833. return tokens;
  2834. }
  2835. function compile(tokens, values) {
  2836. var compiled = [];
  2837. var index = 0;
  2838. var mode = Array.isArray(values) ? 'list' : isObject(values) ? 'named' : 'unknown';
  2839. if (mode === 'unknown') {
  2840. return compiled;
  2841. }
  2842. while (index < tokens.length) {
  2843. var token = tokens[index];
  2844. switch (token.type) {
  2845. case 'text':
  2846. compiled.push(token.value);
  2847. break;
  2848. case 'list':
  2849. compiled.push(values[parseInt(token.value, 10)]);
  2850. break;
  2851. case 'named':
  2852. if (mode === 'named') {
  2853. compiled.push(values[token.value]);
  2854. } else {
  2855. if (true) {
  2856. console.warn("Type of token '".concat(token.type, "' and format of value '").concat(mode, "' don't match!"));
  2857. }
  2858. }
  2859. break;
  2860. case 'unknown':
  2861. if (true) {
  2862. console.warn("Detect 'unknown' type of token!");
  2863. }
  2864. break;
  2865. }
  2866. index++;
  2867. }
  2868. return compiled;
  2869. }
  2870. var LOCALE_ZH_HANS = 'zh-Hans';
  2871. exports.LOCALE_ZH_HANS = LOCALE_ZH_HANS;
  2872. var LOCALE_ZH_HANT = 'zh-Hant';
  2873. exports.LOCALE_ZH_HANT = LOCALE_ZH_HANT;
  2874. var LOCALE_EN = 'en';
  2875. exports.LOCALE_EN = LOCALE_EN;
  2876. var LOCALE_FR = 'fr';
  2877. exports.LOCALE_FR = LOCALE_FR;
  2878. var LOCALE_ES = 'es';
  2879. exports.LOCALE_ES = LOCALE_ES;
  2880. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2881. var hasOwn = function hasOwn(val, key) {
  2882. return hasOwnProperty.call(val, key);
  2883. };
  2884. var defaultFormatter = new BaseFormatter();
  2885. function include(str, parts) {
  2886. return !!parts.find(function (part) {
  2887. return str.indexOf(part) !== -1;
  2888. });
  2889. }
  2890. function startsWith(str, parts) {
  2891. return parts.find(function (part) {
  2892. return str.indexOf(part) === 0;
  2893. });
  2894. }
  2895. function normalizeLocale(locale, messages) {
  2896. if (!locale) {
  2897. return;
  2898. }
  2899. locale = locale.trim().replace(/_/g, '-');
  2900. if (messages && messages[locale]) {
  2901. return locale;
  2902. }
  2903. locale = locale.toLowerCase();
  2904. if (locale === 'chinese') {
  2905. // 支付宝
  2906. return LOCALE_ZH_HANS;
  2907. }
  2908. if (locale.indexOf('zh') === 0) {
  2909. if (locale.indexOf('-hans') > -1) {
  2910. return LOCALE_ZH_HANS;
  2911. }
  2912. if (locale.indexOf('-hant') > -1) {
  2913. return LOCALE_ZH_HANT;
  2914. }
  2915. if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
  2916. return LOCALE_ZH_HANT;
  2917. }
  2918. return LOCALE_ZH_HANS;
  2919. }
  2920. var locales = [LOCALE_EN, LOCALE_FR, LOCALE_ES];
  2921. if (messages && Object.keys(messages).length > 0) {
  2922. locales = Object.keys(messages);
  2923. }
  2924. var lang = startsWith(locale, locales);
  2925. if (lang) {
  2926. return lang;
  2927. }
  2928. }
  2929. var I18n = /*#__PURE__*/function () {
  2930. function I18n(_ref3) {
  2931. var locale = _ref3.locale,
  2932. fallbackLocale = _ref3.fallbackLocale,
  2933. messages = _ref3.messages,
  2934. watcher = _ref3.watcher,
  2935. formater = _ref3.formater;
  2936. (0, _classCallCheck2.default)(this, I18n);
  2937. this.locale = LOCALE_EN;
  2938. this.fallbackLocale = LOCALE_EN;
  2939. this.message = {};
  2940. this.messages = {};
  2941. this.watchers = [];
  2942. if (fallbackLocale) {
  2943. this.fallbackLocale = fallbackLocale;
  2944. }
  2945. this.formater = formater || defaultFormatter;
  2946. this.messages = messages || {};
  2947. this.setLocale(locale || LOCALE_EN);
  2948. if (watcher) {
  2949. this.watchLocale(watcher);
  2950. }
  2951. }
  2952. (0, _createClass2.default)(I18n, [{
  2953. key: "setLocale",
  2954. value: function setLocale(locale) {
  2955. var _this = this;
  2956. var oldLocale = this.locale;
  2957. this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale;
  2958. if (!this.messages[this.locale]) {
  2959. // 可能初始化时不存在
  2960. this.messages[this.locale] = {};
  2961. }
  2962. this.message = this.messages[this.locale];
  2963. // 仅发生变化时,通知
  2964. if (oldLocale !== this.locale) {
  2965. this.watchers.forEach(function (watcher) {
  2966. watcher(_this.locale, oldLocale);
  2967. });
  2968. }
  2969. }
  2970. }, {
  2971. key: "getLocale",
  2972. value: function getLocale() {
  2973. return this.locale;
  2974. }
  2975. }, {
  2976. key: "watchLocale",
  2977. value: function watchLocale(fn) {
  2978. var _this2 = this;
  2979. var index = this.watchers.push(fn) - 1;
  2980. return function () {
  2981. _this2.watchers.splice(index, 1);
  2982. };
  2983. }
  2984. }, {
  2985. key: "add",
  2986. value: function add(locale, message) {
  2987. var override = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  2988. var curMessages = this.messages[locale];
  2989. if (curMessages) {
  2990. if (override) {
  2991. Object.assign(curMessages, message);
  2992. } else {
  2993. Object.keys(message).forEach(function (key) {
  2994. if (!hasOwn(curMessages, key)) {
  2995. curMessages[key] = message[key];
  2996. }
  2997. });
  2998. }
  2999. } else {
  3000. this.messages[locale] = message;
  3001. }
  3002. }
  3003. }, {
  3004. key: "f",
  3005. value: function f(message, values, delimiters) {
  3006. return this.formater.interpolate(message, values, delimiters).join('');
  3007. }
  3008. }, {
  3009. key: "t",
  3010. value: function t(key, locale, values) {
  3011. var message = this.message;
  3012. if (typeof locale === 'string') {
  3013. locale = normalizeLocale(locale, this.messages);
  3014. locale && (message = this.messages[locale]);
  3015. } else {
  3016. values = locale;
  3017. }
  3018. if (!hasOwn(message, key)) {
  3019. console.warn("Cannot translate the value of keypath ".concat(key, ". Use the value of keypath as default."));
  3020. return key;
  3021. }
  3022. return this.formater.interpolate(message[key], values).join('');
  3023. }
  3024. }]);
  3025. return I18n;
  3026. }();
  3027. exports.I18n = I18n;
  3028. function watchAppLocale(appVm, i18n) {
  3029. // 需要保证 watch 的触发在组件渲染之前
  3030. if (appVm.$watchLocale) {
  3031. // vue2
  3032. appVm.$watchLocale(function (newLocale) {
  3033. i18n.setLocale(newLocale);
  3034. });
  3035. } else {
  3036. appVm.$watch(function () {
  3037. return appVm.$locale;
  3038. }, function (newLocale) {
  3039. i18n.setLocale(newLocale);
  3040. });
  3041. }
  3042. }
  3043. function getDefaultLocale() {
  3044. if (typeof uni !== 'undefined' && uni.getLocale) {
  3045. return uni.getLocale();
  3046. }
  3047. // 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
  3048. if (typeof global !== 'undefined' && global.getLocale) {
  3049. return global.getLocale();
  3050. }
  3051. return LOCALE_EN;
  3052. }
  3053. function initVueI18n(locale) {
  3054. var messages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3055. var fallbackLocale = arguments.length > 2 ? arguments[2] : undefined;
  3056. var watcher = arguments.length > 3 ? arguments[3] : undefined;
  3057. // 兼容旧版本入参
  3058. if (typeof locale !== 'string') {
  3059. var _ref4 = [messages, locale];
  3060. locale = _ref4[0];
  3061. messages = _ref4[1];
  3062. }
  3063. if (typeof locale !== 'string') {
  3064. // 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
  3065. locale = getDefaultLocale();
  3066. }
  3067. if (typeof fallbackLocale !== 'string') {
  3068. fallbackLocale = typeof __uniConfig !== 'undefined' && __uniConfig.fallbackLocale || LOCALE_EN;
  3069. }
  3070. var i18n = new I18n({
  3071. locale: locale,
  3072. fallbackLocale: fallbackLocale,
  3073. messages: messages,
  3074. watcher: watcher
  3075. });
  3076. var _t = function t(key, values) {
  3077. if (typeof getApp !== 'function') {
  3078. // app view
  3079. /* eslint-disable no-func-assign */
  3080. _t = function t(key, values) {
  3081. return i18n.t(key, values);
  3082. };
  3083. } else {
  3084. var isWatchedAppLocale = false;
  3085. _t = function t(key, values) {
  3086. var appVm = getApp().$vm;
  3087. // 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
  3088. // options: {
  3089. // type: Array,
  3090. // default () {
  3091. // return [{
  3092. // icon: 'shop',
  3093. // text: t("uni-goods-nav.options.shop"),
  3094. // }, {
  3095. // icon: 'cart',
  3096. // text: t("uni-goods-nav.options.cart")
  3097. // }]
  3098. // }
  3099. // },
  3100. if (appVm) {
  3101. // 触发响应式
  3102. appVm.$locale;
  3103. if (!isWatchedAppLocale) {
  3104. isWatchedAppLocale = true;
  3105. watchAppLocale(appVm, i18n);
  3106. }
  3107. }
  3108. return i18n.t(key, values);
  3109. };
  3110. }
  3111. return _t(key, values);
  3112. };
  3113. return {
  3114. i18n: i18n,
  3115. f: function f(message, values, delimiters) {
  3116. return i18n.f(message, values, delimiters);
  3117. },
  3118. t: function t(key, values) {
  3119. return _t(key, values);
  3120. },
  3121. add: function add(locale, message) {
  3122. var override = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  3123. return i18n.add(locale, message, override);
  3124. },
  3125. watch: function watch(fn) {
  3126. return i18n.watchLocale(fn);
  3127. },
  3128. getLocale: function getLocale() {
  3129. return i18n.getLocale();
  3130. },
  3131. setLocale: function setLocale(newLocale) {
  3132. return i18n.setLocale(newLocale);
  3133. }
  3134. };
  3135. }
  3136. var isString = function isString(val) {
  3137. return typeof val === 'string';
  3138. };
  3139. exports.isString = isString;
  3140. var formater;
  3141. function hasI18nJson(jsonObj, delimiters) {
  3142. if (!formater) {
  3143. formater = new BaseFormatter();
  3144. }
  3145. return walkJsonObj(jsonObj, function (jsonObj, key) {
  3146. var value = jsonObj[key];
  3147. if (isString(value)) {
  3148. if (isI18nStr(value, delimiters)) {
  3149. return true;
  3150. }
  3151. } else {
  3152. return hasI18nJson(value, delimiters);
  3153. }
  3154. });
  3155. }
  3156. function parseI18nJson(jsonObj, values, delimiters) {
  3157. if (!formater) {
  3158. formater = new BaseFormatter();
  3159. }
  3160. walkJsonObj(jsonObj, function (jsonObj, key) {
  3161. var value = jsonObj[key];
  3162. if (isString(value)) {
  3163. if (isI18nStr(value, delimiters)) {
  3164. jsonObj[key] = compileStr(value, values, delimiters);
  3165. }
  3166. } else {
  3167. parseI18nJson(value, values, delimiters);
  3168. }
  3169. });
  3170. return jsonObj;
  3171. }
  3172. function compileI18nJsonStr(jsonStr, _ref5) {
  3173. var locale = _ref5.locale,
  3174. locales = _ref5.locales,
  3175. delimiters = _ref5.delimiters;
  3176. if (!isI18nStr(jsonStr, delimiters)) {
  3177. return jsonStr;
  3178. }
  3179. if (!formater) {
  3180. formater = new BaseFormatter();
  3181. }
  3182. var localeValues = [];
  3183. Object.keys(locales).forEach(function (name) {
  3184. if (name !== locale) {
  3185. localeValues.push({
  3186. locale: name,
  3187. values: locales[name]
  3188. });
  3189. }
  3190. });
  3191. localeValues.unshift({
  3192. locale: locale,
  3193. values: locales[locale]
  3194. });
  3195. try {
  3196. return JSON.stringify(compileJsonObj(JSON.parse(jsonStr), localeValues, delimiters), null, 2);
  3197. } catch (e) {}
  3198. return jsonStr;
  3199. }
  3200. function isI18nStr(value, delimiters) {
  3201. return value.indexOf(delimiters[0]) > -1;
  3202. }
  3203. function compileStr(value, values, delimiters) {
  3204. return formater.interpolate(value, values, delimiters).join('');
  3205. }
  3206. function compileValue(jsonObj, key, localeValues, delimiters) {
  3207. var value = jsonObj[key];
  3208. if (isString(value)) {
  3209. // 存在国际化
  3210. if (isI18nStr(value, delimiters)) {
  3211. jsonObj[key] = compileStr(value, localeValues[0].values, delimiters);
  3212. if (localeValues.length > 1) {
  3213. // 格式化国际化语言
  3214. var valueLocales = jsonObj[key + 'Locales'] = {};
  3215. localeValues.forEach(function (localValue) {
  3216. valueLocales[localValue.locale] = compileStr(value, localValue.values, delimiters);
  3217. });
  3218. }
  3219. }
  3220. } else {
  3221. compileJsonObj(value, localeValues, delimiters);
  3222. }
  3223. }
  3224. function compileJsonObj(jsonObj, localeValues, delimiters) {
  3225. walkJsonObj(jsonObj, function (jsonObj, key) {
  3226. compileValue(jsonObj, key, localeValues, delimiters);
  3227. });
  3228. return jsonObj;
  3229. }
  3230. function walkJsonObj(jsonObj, walk) {
  3231. if (Array.isArray(jsonObj)) {
  3232. for (var i = 0; i < jsonObj.length; i++) {
  3233. if (walk(jsonObj, i)) {
  3234. return true;
  3235. }
  3236. }
  3237. } else if (isObject(jsonObj)) {
  3238. for (var key in jsonObj) {
  3239. if (walk(jsonObj, key)) {
  3240. return true;
  3241. }
  3242. }
  3243. }
  3244. return false;
  3245. }
  3246. function resolveLocale(locales) {
  3247. return function (locale) {
  3248. if (!locale) {
  3249. return locale;
  3250. }
  3251. locale = normalizeLocale(locale) || locale;
  3252. return resolveLocaleChain(locale).find(function (locale) {
  3253. return locales.indexOf(locale) > -1;
  3254. });
  3255. };
  3256. }
  3257. function resolveLocaleChain(locale) {
  3258. var chain = [];
  3259. var tokens = locale.split('-');
  3260. while (tokens.length) {
  3261. chain.push(tokens.join('-'));
  3262. tokens.pop();
  3263. }
  3264. return chain;
  3265. }
  3266. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"], __webpack_require__(/*! ./../../../webpack/buildin/global.js */ 3)))
  3267. /***/ }),
  3268. /* 23 */
  3269. /*!***************************************************************!*\
  3270. !*** ./node_modules/@babel/runtime/helpers/classCallCheck.js ***!
  3271. \***************************************************************/
  3272. /*! no static exports found */
  3273. /***/ (function(module, exports) {
  3274. function _classCallCheck(instance, Constructor) {
  3275. if (!(instance instanceof Constructor)) {
  3276. throw new TypeError("Cannot call a class as a function");
  3277. }
  3278. }
  3279. module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
  3280. /***/ }),
  3281. /* 24 */
  3282. /*!************************************************************!*\
  3283. !*** ./node_modules/@babel/runtime/helpers/createClass.js ***!
  3284. \************************************************************/
  3285. /*! no static exports found */
  3286. /***/ (function(module, exports, __webpack_require__) {
  3287. var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ 12);
  3288. function _defineProperties(target, props) {
  3289. for (var i = 0; i < props.length; i++) {
  3290. var descriptor = props[i];
  3291. descriptor.enumerable = descriptor.enumerable || false;
  3292. descriptor.configurable = true;
  3293. if ("value" in descriptor) descriptor.writable = true;
  3294. Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
  3295. }
  3296. }
  3297. function _createClass(Constructor, protoProps, staticProps) {
  3298. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  3299. if (staticProps) _defineProperties(Constructor, staticProps);
  3300. Object.defineProperty(Constructor, "prototype", {
  3301. writable: false
  3302. });
  3303. return Constructor;
  3304. }
  3305. module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
  3306. /***/ }),
  3307. /* 25 */
  3308. /*!******************************************************************************************!*\
  3309. !*** ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js ***!
  3310. \******************************************************************************************/
  3311. /*! exports provided: default */
  3312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3313. "use strict";
  3314. __webpack_require__.r(__webpack_exports__);
  3315. /* WEBPACK VAR INJECTION */(function(global) {/*!
  3316. * Vue.js v2.6.11
  3317. * (c) 2014-2023 Evan You
  3318. * Released under the MIT License.
  3319. */
  3320. /* */
  3321. var emptyObject = Object.freeze({});
  3322. // These helpers produce better VM code in JS engines due to their
  3323. // explicitness and function inlining.
  3324. function isUndef (v) {
  3325. return v === undefined || v === null
  3326. }
  3327. function isDef (v) {
  3328. return v !== undefined && v !== null
  3329. }
  3330. function isTrue (v) {
  3331. return v === true
  3332. }
  3333. function isFalse (v) {
  3334. return v === false
  3335. }
  3336. /**
  3337. * Check if value is primitive.
  3338. */
  3339. function isPrimitive (value) {
  3340. return (
  3341. typeof value === 'string' ||
  3342. typeof value === 'number' ||
  3343. // $flow-disable-line
  3344. typeof value === 'symbol' ||
  3345. typeof value === 'boolean'
  3346. )
  3347. }
  3348. /**
  3349. * Quick object check - this is primarily used to tell
  3350. * Objects from primitive values when we know the value
  3351. * is a JSON-compliant type.
  3352. */
  3353. function isObject (obj) {
  3354. return obj !== null && typeof obj === 'object'
  3355. }
  3356. /**
  3357. * Get the raw type string of a value, e.g., [object Object].
  3358. */
  3359. var _toString = Object.prototype.toString;
  3360. function toRawType (value) {
  3361. return _toString.call(value).slice(8, -1)
  3362. }
  3363. /**
  3364. * Strict object type check. Only returns true
  3365. * for plain JavaScript objects.
  3366. */
  3367. function isPlainObject (obj) {
  3368. return _toString.call(obj) === '[object Object]'
  3369. }
  3370. function isRegExp (v) {
  3371. return _toString.call(v) === '[object RegExp]'
  3372. }
  3373. /**
  3374. * Check if val is a valid array index.
  3375. */
  3376. function isValidArrayIndex (val) {
  3377. var n = parseFloat(String(val));
  3378. return n >= 0 && Math.floor(n) === n && isFinite(val)
  3379. }
  3380. function isPromise (val) {
  3381. return (
  3382. isDef(val) &&
  3383. typeof val.then === 'function' &&
  3384. typeof val.catch === 'function'
  3385. )
  3386. }
  3387. /**
  3388. * Convert a value to a string that is actually rendered.
  3389. */
  3390. function toString (val) {
  3391. return val == null
  3392. ? ''
  3393. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  3394. ? JSON.stringify(val, null, 2)
  3395. : String(val)
  3396. }
  3397. /**
  3398. * Convert an input value to a number for persistence.
  3399. * If the conversion fails, return original string.
  3400. */
  3401. function toNumber (val) {
  3402. var n = parseFloat(val);
  3403. return isNaN(n) ? val : n
  3404. }
  3405. /**
  3406. * Make a map and return a function for checking if a key
  3407. * is in that map.
  3408. */
  3409. function makeMap (
  3410. str,
  3411. expectsLowerCase
  3412. ) {
  3413. var map = Object.create(null);
  3414. var list = str.split(',');
  3415. for (var i = 0; i < list.length; i++) {
  3416. map[list[i]] = true;
  3417. }
  3418. return expectsLowerCase
  3419. ? function (val) { return map[val.toLowerCase()]; }
  3420. : function (val) { return map[val]; }
  3421. }
  3422. /**
  3423. * Check if a tag is a built-in tag.
  3424. */
  3425. var isBuiltInTag = makeMap('slot,component', true);
  3426. /**
  3427. * Check if an attribute is a reserved attribute.
  3428. */
  3429. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  3430. /**
  3431. * Remove an item from an array.
  3432. */
  3433. function remove (arr, item) {
  3434. if (arr.length) {
  3435. var index = arr.indexOf(item);
  3436. if (index > -1) {
  3437. return arr.splice(index, 1)
  3438. }
  3439. }
  3440. }
  3441. /**
  3442. * Check whether an object has the property.
  3443. */
  3444. var hasOwnProperty = Object.prototype.hasOwnProperty;
  3445. function hasOwn (obj, key) {
  3446. return hasOwnProperty.call(obj, key)
  3447. }
  3448. /**
  3449. * Create a cached version of a pure function.
  3450. */
  3451. function cached (fn) {
  3452. var cache = Object.create(null);
  3453. return (function cachedFn (str) {
  3454. var hit = cache[str];
  3455. return hit || (cache[str] = fn(str))
  3456. })
  3457. }
  3458. /**
  3459. * Camelize a hyphen-delimited string.
  3460. */
  3461. var camelizeRE = /-(\w)/g;
  3462. var camelize = cached(function (str) {
  3463. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  3464. });
  3465. /**
  3466. * Capitalize a string.
  3467. */
  3468. var capitalize = cached(function (str) {
  3469. return str.charAt(0).toUpperCase() + str.slice(1)
  3470. });
  3471. /**
  3472. * Hyphenate a camelCase string.
  3473. */
  3474. var hyphenateRE = /\B([A-Z])/g;
  3475. var hyphenate = cached(function (str) {
  3476. return str.replace(hyphenateRE, '-$1').toLowerCase()
  3477. });
  3478. /**
  3479. * Simple bind polyfill for environments that do not support it,
  3480. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  3481. * since native bind is now performant enough in most browsers.
  3482. * But removing it would mean breaking code that was able to run in
  3483. * PhantomJS 1.x, so this must be kept for backward compatibility.
  3484. */
  3485. /* istanbul ignore next */
  3486. function polyfillBind (fn, ctx) {
  3487. function boundFn (a) {
  3488. var l = arguments.length;
  3489. return l
  3490. ? l > 1
  3491. ? fn.apply(ctx, arguments)
  3492. : fn.call(ctx, a)
  3493. : fn.call(ctx)
  3494. }
  3495. boundFn._length = fn.length;
  3496. return boundFn
  3497. }
  3498. function nativeBind (fn, ctx) {
  3499. return fn.bind(ctx)
  3500. }
  3501. var bind = Function.prototype.bind
  3502. ? nativeBind
  3503. : polyfillBind;
  3504. /**
  3505. * Convert an Array-like object to a real Array.
  3506. */
  3507. function toArray (list, start) {
  3508. start = start || 0;
  3509. var i = list.length - start;
  3510. var ret = new Array(i);
  3511. while (i--) {
  3512. ret[i] = list[i + start];
  3513. }
  3514. return ret
  3515. }
  3516. /**
  3517. * Mix properties into target object.
  3518. */
  3519. function extend (to, _from) {
  3520. for (var key in _from) {
  3521. to[key] = _from[key];
  3522. }
  3523. return to
  3524. }
  3525. /**
  3526. * Merge an Array of Objects into a single Object.
  3527. */
  3528. function toObject (arr) {
  3529. var res = {};
  3530. for (var i = 0; i < arr.length; i++) {
  3531. if (arr[i]) {
  3532. extend(res, arr[i]);
  3533. }
  3534. }
  3535. return res
  3536. }
  3537. /* eslint-disable no-unused-vars */
  3538. /**
  3539. * Perform no operation.
  3540. * Stubbing args to make Flow happy without leaving useless transpiled code
  3541. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  3542. */
  3543. function noop (a, b, c) {}
  3544. /**
  3545. * Always return false.
  3546. */
  3547. var no = function (a, b, c) { return false; };
  3548. /* eslint-enable no-unused-vars */
  3549. /**
  3550. * Return the same value.
  3551. */
  3552. var identity = function (_) { return _; };
  3553. /**
  3554. * Check if two values are loosely equal - that is,
  3555. * if they are plain objects, do they have the same shape?
  3556. */
  3557. function looseEqual (a, b) {
  3558. if (a === b) { return true }
  3559. var isObjectA = isObject(a);
  3560. var isObjectB = isObject(b);
  3561. if (isObjectA && isObjectB) {
  3562. try {
  3563. var isArrayA = Array.isArray(a);
  3564. var isArrayB = Array.isArray(b);
  3565. if (isArrayA && isArrayB) {
  3566. return a.length === b.length && a.every(function (e, i) {
  3567. return looseEqual(e, b[i])
  3568. })
  3569. } else if (a instanceof Date && b instanceof Date) {
  3570. return a.getTime() === b.getTime()
  3571. } else if (!isArrayA && !isArrayB) {
  3572. var keysA = Object.keys(a);
  3573. var keysB = Object.keys(b);
  3574. return keysA.length === keysB.length && keysA.every(function (key) {
  3575. return looseEqual(a[key], b[key])
  3576. })
  3577. } else {
  3578. /* istanbul ignore next */
  3579. return false
  3580. }
  3581. } catch (e) {
  3582. /* istanbul ignore next */
  3583. return false
  3584. }
  3585. } else if (!isObjectA && !isObjectB) {
  3586. return String(a) === String(b)
  3587. } else {
  3588. return false
  3589. }
  3590. }
  3591. /**
  3592. * Return the first index at which a loosely equal value can be
  3593. * found in the array (if value is a plain object, the array must
  3594. * contain an object of the same shape), or -1 if it is not present.
  3595. */
  3596. function looseIndexOf (arr, val) {
  3597. for (var i = 0; i < arr.length; i++) {
  3598. if (looseEqual(arr[i], val)) { return i }
  3599. }
  3600. return -1
  3601. }
  3602. /**
  3603. * Ensure a function is called only once.
  3604. */
  3605. function once (fn) {
  3606. var called = false;
  3607. return function () {
  3608. if (!called) {
  3609. called = true;
  3610. fn.apply(this, arguments);
  3611. }
  3612. }
  3613. }
  3614. var ASSET_TYPES = [
  3615. 'component',
  3616. 'directive',
  3617. 'filter'
  3618. ];
  3619. var LIFECYCLE_HOOKS = [
  3620. 'beforeCreate',
  3621. 'created',
  3622. 'beforeMount',
  3623. 'mounted',
  3624. 'beforeUpdate',
  3625. 'updated',
  3626. 'beforeDestroy',
  3627. 'destroyed',
  3628. 'activated',
  3629. 'deactivated',
  3630. 'errorCaptured',
  3631. 'serverPrefetch'
  3632. ];
  3633. /* */
  3634. var config = ({
  3635. /**
  3636. * Option merge strategies (used in core/util/options)
  3637. */
  3638. // $flow-disable-line
  3639. optionMergeStrategies: Object.create(null),
  3640. /**
  3641. * Whether to suppress warnings.
  3642. */
  3643. silent: false,
  3644. /**
  3645. * Show production mode tip message on boot?
  3646. */
  3647. productionTip: "development" !== 'production',
  3648. /**
  3649. * Whether to enable devtools
  3650. */
  3651. devtools: "development" !== 'production',
  3652. /**
  3653. * Whether to record perf
  3654. */
  3655. performance: false,
  3656. /**
  3657. * Error handler for watcher errors
  3658. */
  3659. errorHandler: null,
  3660. /**
  3661. * Warn handler for watcher warns
  3662. */
  3663. warnHandler: null,
  3664. /**
  3665. * Ignore certain custom elements
  3666. */
  3667. ignoredElements: [],
  3668. /**
  3669. * Custom user key aliases for v-on
  3670. */
  3671. // $flow-disable-line
  3672. keyCodes: Object.create(null),
  3673. /**
  3674. * Check if a tag is reserved so that it cannot be registered as a
  3675. * component. This is platform-dependent and may be overwritten.
  3676. */
  3677. isReservedTag: no,
  3678. /**
  3679. * Check if an attribute is reserved so that it cannot be used as a component
  3680. * prop. This is platform-dependent and may be overwritten.
  3681. */
  3682. isReservedAttr: no,
  3683. /**
  3684. * Check if a tag is an unknown element.
  3685. * Platform-dependent.
  3686. */
  3687. isUnknownElement: no,
  3688. /**
  3689. * Get the namespace of an element
  3690. */
  3691. getTagNamespace: noop,
  3692. /**
  3693. * Parse the real tag name for the specific platform.
  3694. */
  3695. parsePlatformTagName: identity,
  3696. /**
  3697. * Check if an attribute must be bound using property, e.g. value
  3698. * Platform-dependent.
  3699. */
  3700. mustUseProp: no,
  3701. /**
  3702. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  3703. * This will significantly reduce performance if set to false.
  3704. */
  3705. async: true,
  3706. /**
  3707. * Exposed for legacy reasons
  3708. */
  3709. _lifecycleHooks: LIFECYCLE_HOOKS
  3710. });
  3711. /* */
  3712. /**
  3713. * unicode letters used for parsing html tags, component names and property paths.
  3714. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  3715. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  3716. */
  3717. var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  3718. /**
  3719. * Check if a string starts with $ or _
  3720. */
  3721. function isReserved (str) {
  3722. var c = (str + '').charCodeAt(0);
  3723. return c === 0x24 || c === 0x5F
  3724. }
  3725. /**
  3726. * Define a property.
  3727. */
  3728. function def (obj, key, val, enumerable) {
  3729. Object.defineProperty(obj, key, {
  3730. value: val,
  3731. enumerable: !!enumerable,
  3732. writable: true,
  3733. configurable: true
  3734. });
  3735. }
  3736. /**
  3737. * Parse simple path.
  3738. */
  3739. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  3740. function parsePath (path) {
  3741. if (bailRE.test(path)) {
  3742. return
  3743. }
  3744. var segments = path.split('.');
  3745. return function (obj) {
  3746. for (var i = 0; i < segments.length; i++) {
  3747. if (!obj) { return }
  3748. obj = obj[segments[i]];
  3749. }
  3750. return obj
  3751. }
  3752. }
  3753. /* */
  3754. // can we use __proto__?
  3755. var hasProto = '__proto__' in {};
  3756. // Browser environment sniffing
  3757. var inBrowser = typeof window !== 'undefined';
  3758. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  3759. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  3760. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  3761. var isIE = UA && /msie|trident/.test(UA);
  3762. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  3763. var isEdge = UA && UA.indexOf('edge/') > 0;
  3764. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  3765. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  3766. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  3767. var isPhantomJS = UA && /phantomjs/.test(UA);
  3768. var isFF = UA && UA.match(/firefox\/(\d+)/);
  3769. // Firefox has a "watch" function on Object.prototype...
  3770. var nativeWatch = ({}).watch;
  3771. if (inBrowser) {
  3772. try {
  3773. var opts = {};
  3774. Object.defineProperty(opts, 'passive', ({
  3775. get: function get () {
  3776. }
  3777. })); // https://github.com/facebook/flow/issues/285
  3778. window.addEventListener('test-passive', null, opts);
  3779. } catch (e) {}
  3780. }
  3781. // this needs to be lazy-evaled because vue may be required before
  3782. // vue-server-renderer can set VUE_ENV
  3783. var _isServer;
  3784. var isServerRendering = function () {
  3785. if (_isServer === undefined) {
  3786. /* istanbul ignore if */
  3787. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  3788. // detect presence of vue-server-renderer and avoid
  3789. // Webpack shimming the process
  3790. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  3791. } else {
  3792. _isServer = false;
  3793. }
  3794. }
  3795. return _isServer
  3796. };
  3797. // detect devtools
  3798. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  3799. /* istanbul ignore next */
  3800. function isNative (Ctor) {
  3801. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  3802. }
  3803. var hasSymbol =
  3804. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  3805. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  3806. var _Set;
  3807. /* istanbul ignore if */ // $flow-disable-line
  3808. if (typeof Set !== 'undefined' && isNative(Set)) {
  3809. // use native Set when available.
  3810. _Set = Set;
  3811. } else {
  3812. // a non-standard Set polyfill that only works with primitive keys.
  3813. _Set = /*@__PURE__*/(function () {
  3814. function Set () {
  3815. this.set = Object.create(null);
  3816. }
  3817. Set.prototype.has = function has (key) {
  3818. return this.set[key] === true
  3819. };
  3820. Set.prototype.add = function add (key) {
  3821. this.set[key] = true;
  3822. };
  3823. Set.prototype.clear = function clear () {
  3824. this.set = Object.create(null);
  3825. };
  3826. return Set;
  3827. }());
  3828. }
  3829. /* */
  3830. var warn = noop;
  3831. var tip = noop;
  3832. var generateComponentTrace = (noop); // work around flow check
  3833. var formatComponentName = (noop);
  3834. if (true) {
  3835. var hasConsole = typeof console !== 'undefined';
  3836. var classifyRE = /(?:^|[-_])(\w)/g;
  3837. var classify = function (str) { return str
  3838. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  3839. .replace(/[-_]/g, ''); };
  3840. warn = function (msg, vm) {
  3841. var trace = vm ? generateComponentTrace(vm) : '';
  3842. if (config.warnHandler) {
  3843. config.warnHandler.call(null, msg, vm, trace);
  3844. } else if (hasConsole && (!config.silent)) {
  3845. console.error(("[Vue warn]: " + msg + trace));
  3846. }
  3847. };
  3848. tip = function (msg, vm) {
  3849. if (hasConsole && (!config.silent)) {
  3850. console.warn("[Vue tip]: " + msg + (
  3851. vm ? generateComponentTrace(vm) : ''
  3852. ));
  3853. }
  3854. };
  3855. formatComponentName = function (vm, includeFile) {
  3856. if (vm.$root === vm) {
  3857. if (vm.$options && vm.$options.__file) { // fixed by xxxxxx
  3858. return ('') + vm.$options.__file
  3859. }
  3860. return '<Root>'
  3861. }
  3862. var options = typeof vm === 'function' && vm.cid != null
  3863. ? vm.options
  3864. : vm._isVue
  3865. ? vm.$options || vm.constructor.options
  3866. : vm;
  3867. var name = options.name || options._componentTag;
  3868. var file = options.__file;
  3869. if (!name && file) {
  3870. var match = file.match(/([^/\\]+)\.vue$/);
  3871. name = match && match[1];
  3872. }
  3873. return (
  3874. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  3875. (file && includeFile !== false ? (" at " + file) : '')
  3876. )
  3877. };
  3878. var repeat = function (str, n) {
  3879. var res = '';
  3880. while (n) {
  3881. if (n % 2 === 1) { res += str; }
  3882. if (n > 1) { str += str; }
  3883. n >>= 1;
  3884. }
  3885. return res
  3886. };
  3887. generateComponentTrace = function (vm) {
  3888. if (vm._isVue && vm.$parent) {
  3889. var tree = [];
  3890. var currentRecursiveSequence = 0;
  3891. while (vm && vm.$options.name !== 'PageBody') {
  3892. if (tree.length > 0) {
  3893. var last = tree[tree.length - 1];
  3894. if (last.constructor === vm.constructor) {
  3895. currentRecursiveSequence++;
  3896. vm = vm.$parent;
  3897. continue
  3898. } else if (currentRecursiveSequence > 0) {
  3899. tree[tree.length - 1] = [last, currentRecursiveSequence];
  3900. currentRecursiveSequence = 0;
  3901. }
  3902. }
  3903. !vm.$options.isReserved && tree.push(vm);
  3904. vm = vm.$parent;
  3905. }
  3906. return '\n\nfound in\n\n' + tree
  3907. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  3908. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  3909. : formatComponentName(vm))); })
  3910. .join('\n')
  3911. } else {
  3912. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  3913. }
  3914. };
  3915. }
  3916. /* */
  3917. var uid = 0;
  3918. /**
  3919. * A dep is an observable that can have multiple
  3920. * directives subscribing to it.
  3921. */
  3922. var Dep = function Dep () {
  3923. this.id = uid++;
  3924. this.subs = [];
  3925. };
  3926. Dep.prototype.addSub = function addSub (sub) {
  3927. this.subs.push(sub);
  3928. };
  3929. Dep.prototype.removeSub = function removeSub (sub) {
  3930. remove(this.subs, sub);
  3931. };
  3932. Dep.prototype.depend = function depend () {
  3933. if (Dep.SharedObject.target) {
  3934. Dep.SharedObject.target.addDep(this);
  3935. }
  3936. };
  3937. Dep.prototype.notify = function notify () {
  3938. // stabilize the subscriber list first
  3939. var subs = this.subs.slice();
  3940. if ( true && !config.async) {
  3941. // subs aren't sorted in scheduler if not running async
  3942. // we need to sort them now to make sure they fire in correct
  3943. // order
  3944. subs.sort(function (a, b) { return a.id - b.id; });
  3945. }
  3946. for (var i = 0, l = subs.length; i < l; i++) {
  3947. subs[i].update();
  3948. }
  3949. };
  3950. // The current target watcher being evaluated.
  3951. // This is globally unique because only one watcher
  3952. // can be evaluated at a time.
  3953. // fixed by xxxxxx (nvue shared vuex)
  3954. /* eslint-disable no-undef */
  3955. Dep.SharedObject = {};
  3956. Dep.SharedObject.target = null;
  3957. Dep.SharedObject.targetStack = [];
  3958. function pushTarget (target) {
  3959. Dep.SharedObject.targetStack.push(target);
  3960. Dep.SharedObject.target = target;
  3961. Dep.target = target;
  3962. }
  3963. function popTarget () {
  3964. Dep.SharedObject.targetStack.pop();
  3965. Dep.SharedObject.target = Dep.SharedObject.targetStack[Dep.SharedObject.targetStack.length - 1];
  3966. Dep.target = Dep.SharedObject.target;
  3967. }
  3968. /* */
  3969. var VNode = function VNode (
  3970. tag,
  3971. data,
  3972. children,
  3973. text,
  3974. elm,
  3975. context,
  3976. componentOptions,
  3977. asyncFactory
  3978. ) {
  3979. this.tag = tag;
  3980. this.data = data;
  3981. this.children = children;
  3982. this.text = text;
  3983. this.elm = elm;
  3984. this.ns = undefined;
  3985. this.context = context;
  3986. this.fnContext = undefined;
  3987. this.fnOptions = undefined;
  3988. this.fnScopeId = undefined;
  3989. this.key = data && data.key;
  3990. this.componentOptions = componentOptions;
  3991. this.componentInstance = undefined;
  3992. this.parent = undefined;
  3993. this.raw = false;
  3994. this.isStatic = false;
  3995. this.isRootInsert = true;
  3996. this.isComment = false;
  3997. this.isCloned = false;
  3998. this.isOnce = false;
  3999. this.asyncFactory = asyncFactory;
  4000. this.asyncMeta = undefined;
  4001. this.isAsyncPlaceholder = false;
  4002. };
  4003. var prototypeAccessors = { child: { configurable: true } };
  4004. // DEPRECATED: alias for componentInstance for backwards compat.
  4005. /* istanbul ignore next */
  4006. prototypeAccessors.child.get = function () {
  4007. return this.componentInstance
  4008. };
  4009. Object.defineProperties( VNode.prototype, prototypeAccessors );
  4010. var createEmptyVNode = function (text) {
  4011. if ( text === void 0 ) text = '';
  4012. var node = new VNode();
  4013. node.text = text;
  4014. node.isComment = true;
  4015. return node
  4016. };
  4017. function createTextVNode (val) {
  4018. return new VNode(undefined, undefined, undefined, String(val))
  4019. }
  4020. // optimized shallow clone
  4021. // used for static nodes and slot nodes because they may be reused across
  4022. // multiple renders, cloning them avoids errors when DOM manipulations rely
  4023. // on their elm reference.
  4024. function cloneVNode (vnode) {
  4025. var cloned = new VNode(
  4026. vnode.tag,
  4027. vnode.data,
  4028. // #7975
  4029. // clone children array to avoid mutating original in case of cloning
  4030. // a child.
  4031. vnode.children && vnode.children.slice(),
  4032. vnode.text,
  4033. vnode.elm,
  4034. vnode.context,
  4035. vnode.componentOptions,
  4036. vnode.asyncFactory
  4037. );
  4038. cloned.ns = vnode.ns;
  4039. cloned.isStatic = vnode.isStatic;
  4040. cloned.key = vnode.key;
  4041. cloned.isComment = vnode.isComment;
  4042. cloned.fnContext = vnode.fnContext;
  4043. cloned.fnOptions = vnode.fnOptions;
  4044. cloned.fnScopeId = vnode.fnScopeId;
  4045. cloned.asyncMeta = vnode.asyncMeta;
  4046. cloned.isCloned = true;
  4047. return cloned
  4048. }
  4049. /*
  4050. * not type checking this file because flow doesn't play well with
  4051. * dynamically accessing methods on Array prototype
  4052. */
  4053. var arrayProto = Array.prototype;
  4054. var arrayMethods = Object.create(arrayProto);
  4055. var methodsToPatch = [
  4056. 'push',
  4057. 'pop',
  4058. 'shift',
  4059. 'unshift',
  4060. 'splice',
  4061. 'sort',
  4062. 'reverse'
  4063. ];
  4064. /**
  4065. * Intercept mutating methods and emit events
  4066. */
  4067. methodsToPatch.forEach(function (method) {
  4068. // cache original method
  4069. var original = arrayProto[method];
  4070. def(arrayMethods, method, function mutator () {
  4071. var args = [], len = arguments.length;
  4072. while ( len-- ) args[ len ] = arguments[ len ];
  4073. var result = original.apply(this, args);
  4074. var ob = this.__ob__;
  4075. var inserted;
  4076. switch (method) {
  4077. case 'push':
  4078. case 'unshift':
  4079. inserted = args;
  4080. break
  4081. case 'splice':
  4082. inserted = args.slice(2);
  4083. break
  4084. }
  4085. if (inserted) { ob.observeArray(inserted); }
  4086. // notify change
  4087. ob.dep.notify();
  4088. return result
  4089. });
  4090. });
  4091. /* */
  4092. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  4093. /**
  4094. * In some cases we may want to disable observation inside a component's
  4095. * update computation.
  4096. */
  4097. var shouldObserve = true;
  4098. function toggleObserving (value) {
  4099. shouldObserve = value;
  4100. }
  4101. /**
  4102. * Observer class that is attached to each observed
  4103. * object. Once attached, the observer converts the target
  4104. * object's property keys into getter/setters that
  4105. * collect dependencies and dispatch updates.
  4106. */
  4107. var Observer = function Observer (value) {
  4108. this.value = value;
  4109. this.dep = new Dep();
  4110. this.vmCount = 0;
  4111. def(value, '__ob__', this);
  4112. if (Array.isArray(value)) {
  4113. if (hasProto) {
  4114. {// fixed by xxxxxx 微信小程序使用 plugins 之后,数组方法被直接挂载到了数组对象上,需要执行 copyAugment 逻辑
  4115. if(value.push !== value.__proto__.push){
  4116. copyAugment(value, arrayMethods, arrayKeys);
  4117. } else {
  4118. protoAugment(value, arrayMethods);
  4119. }
  4120. }
  4121. } else {
  4122. copyAugment(value, arrayMethods, arrayKeys);
  4123. }
  4124. this.observeArray(value);
  4125. } else {
  4126. this.walk(value);
  4127. }
  4128. };
  4129. /**
  4130. * Walk through all properties and convert them into
  4131. * getter/setters. This method should only be called when
  4132. * value type is Object.
  4133. */
  4134. Observer.prototype.walk = function walk (obj) {
  4135. var keys = Object.keys(obj);
  4136. for (var i = 0; i < keys.length; i++) {
  4137. defineReactive$$1(obj, keys[i]);
  4138. }
  4139. };
  4140. /**
  4141. * Observe a list of Array items.
  4142. */
  4143. Observer.prototype.observeArray = function observeArray (items) {
  4144. for (var i = 0, l = items.length; i < l; i++) {
  4145. observe(items[i]);
  4146. }
  4147. };
  4148. // helpers
  4149. /**
  4150. * Augment a target Object or Array by intercepting
  4151. * the prototype chain using __proto__
  4152. */
  4153. function protoAugment (target, src) {
  4154. /* eslint-disable no-proto */
  4155. target.__proto__ = src;
  4156. /* eslint-enable no-proto */
  4157. }
  4158. /**
  4159. * Augment a target Object or Array by defining
  4160. * hidden properties.
  4161. */
  4162. /* istanbul ignore next */
  4163. function copyAugment (target, src, keys) {
  4164. for (var i = 0, l = keys.length; i < l; i++) {
  4165. var key = keys[i];
  4166. def(target, key, src[key]);
  4167. }
  4168. }
  4169. /**
  4170. * Attempt to create an observer instance for a value,
  4171. * returns the new observer if successfully observed,
  4172. * or the existing observer if the value already has one.
  4173. */
  4174. function observe (value, asRootData) {
  4175. if (!isObject(value) || value instanceof VNode) {
  4176. return
  4177. }
  4178. var ob;
  4179. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  4180. ob = value.__ob__;
  4181. } else if (
  4182. shouldObserve &&
  4183. !isServerRendering() &&
  4184. (Array.isArray(value) || isPlainObject(value)) &&
  4185. Object.isExtensible(value) &&
  4186. !value._isVue &&
  4187. !value.__v_isMPComponent
  4188. ) {
  4189. ob = new Observer(value);
  4190. }
  4191. if (asRootData && ob) {
  4192. ob.vmCount++;
  4193. }
  4194. return ob
  4195. }
  4196. /**
  4197. * Define a reactive property on an Object.
  4198. */
  4199. function defineReactive$$1 (
  4200. obj,
  4201. key,
  4202. val,
  4203. customSetter,
  4204. shallow
  4205. ) {
  4206. var dep = new Dep();
  4207. var property = Object.getOwnPropertyDescriptor(obj, key);
  4208. if (property && property.configurable === false) {
  4209. return
  4210. }
  4211. // cater for pre-defined getter/setters
  4212. var getter = property && property.get;
  4213. var setter = property && property.set;
  4214. if ((!getter || setter) && arguments.length === 2) {
  4215. val = obj[key];
  4216. }
  4217. var childOb = !shallow && observe(val);
  4218. Object.defineProperty(obj, key, {
  4219. enumerable: true,
  4220. configurable: true,
  4221. get: function reactiveGetter () {
  4222. var value = getter ? getter.call(obj) : val;
  4223. if (Dep.SharedObject.target) { // fixed by xxxxxx
  4224. dep.depend();
  4225. if (childOb) {
  4226. childOb.dep.depend();
  4227. if (Array.isArray(value)) {
  4228. dependArray(value);
  4229. }
  4230. }
  4231. }
  4232. return value
  4233. },
  4234. set: function reactiveSetter (newVal) {
  4235. var value = getter ? getter.call(obj) : val;
  4236. /* eslint-disable no-self-compare */
  4237. if (newVal === value || (newVal !== newVal && value !== value)) {
  4238. return
  4239. }
  4240. /* eslint-enable no-self-compare */
  4241. if ( true && customSetter) {
  4242. customSetter();
  4243. }
  4244. // #7981: for accessor properties without setter
  4245. if (getter && !setter) { return }
  4246. if (setter) {
  4247. setter.call(obj, newVal);
  4248. } else {
  4249. val = newVal;
  4250. }
  4251. childOb = !shallow && observe(newVal);
  4252. dep.notify();
  4253. }
  4254. });
  4255. }
  4256. /**
  4257. * Set a property on an object. Adds the new property and
  4258. * triggers change notification if the property doesn't
  4259. * already exist.
  4260. */
  4261. function set (target, key, val) {
  4262. if ( true &&
  4263. (isUndef(target) || isPrimitive(target))
  4264. ) {
  4265. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  4266. }
  4267. if (Array.isArray(target) && isValidArrayIndex(key)) {
  4268. target.length = Math.max(target.length, key);
  4269. target.splice(key, 1, val);
  4270. return val
  4271. }
  4272. if (key in target && !(key in Object.prototype)) {
  4273. target[key] = val;
  4274. return val
  4275. }
  4276. var ob = (target).__ob__;
  4277. if (target._isVue || (ob && ob.vmCount)) {
  4278. true && warn(
  4279. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  4280. 'at runtime - declare it upfront in the data option.'
  4281. );
  4282. return val
  4283. }
  4284. if (!ob) {
  4285. target[key] = val;
  4286. return val
  4287. }
  4288. defineReactive$$1(ob.value, key, val);
  4289. ob.dep.notify();
  4290. return val
  4291. }
  4292. /**
  4293. * Delete a property and trigger change if necessary.
  4294. */
  4295. function del (target, key) {
  4296. if ( true &&
  4297. (isUndef(target) || isPrimitive(target))
  4298. ) {
  4299. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  4300. }
  4301. if (Array.isArray(target) && isValidArrayIndex(key)) {
  4302. target.splice(key, 1);
  4303. return
  4304. }
  4305. var ob = (target).__ob__;
  4306. if (target._isVue || (ob && ob.vmCount)) {
  4307. true && warn(
  4308. 'Avoid deleting properties on a Vue instance or its root $data ' +
  4309. '- just set it to null.'
  4310. );
  4311. return
  4312. }
  4313. if (!hasOwn(target, key)) {
  4314. return
  4315. }
  4316. delete target[key];
  4317. if (!ob) {
  4318. return
  4319. }
  4320. ob.dep.notify();
  4321. }
  4322. /**
  4323. * Collect dependencies on array elements when the array is touched, since
  4324. * we cannot intercept array element access like property getters.
  4325. */
  4326. function dependArray (value) {
  4327. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  4328. e = value[i];
  4329. e && e.__ob__ && e.__ob__.dep.depend();
  4330. if (Array.isArray(e)) {
  4331. dependArray(e);
  4332. }
  4333. }
  4334. }
  4335. /* */
  4336. /**
  4337. * Option overwriting strategies are functions that handle
  4338. * how to merge a parent option value and a child option
  4339. * value into the final value.
  4340. */
  4341. var strats = config.optionMergeStrategies;
  4342. /**
  4343. * Options with restrictions
  4344. */
  4345. if (true) {
  4346. strats.el = strats.propsData = function (parent, child, vm, key) {
  4347. if (!vm) {
  4348. warn(
  4349. "option \"" + key + "\" can only be used during instance " +
  4350. 'creation with the `new` keyword.'
  4351. );
  4352. }
  4353. return defaultStrat(parent, child)
  4354. };
  4355. }
  4356. /**
  4357. * Helper that recursively merges two data objects together.
  4358. */
  4359. function mergeData (to, from) {
  4360. if (!from) { return to }
  4361. var key, toVal, fromVal;
  4362. var keys = hasSymbol
  4363. ? Reflect.ownKeys(from)
  4364. : Object.keys(from);
  4365. for (var i = 0; i < keys.length; i++) {
  4366. key = keys[i];
  4367. // in case the object is already observed...
  4368. if (key === '__ob__') { continue }
  4369. toVal = to[key];
  4370. fromVal = from[key];
  4371. if (!hasOwn(to, key)) {
  4372. set(to, key, fromVal);
  4373. } else if (
  4374. toVal !== fromVal &&
  4375. isPlainObject(toVal) &&
  4376. isPlainObject(fromVal)
  4377. ) {
  4378. mergeData(toVal, fromVal);
  4379. }
  4380. }
  4381. return to
  4382. }
  4383. /**
  4384. * Data
  4385. */
  4386. function mergeDataOrFn (
  4387. parentVal,
  4388. childVal,
  4389. vm
  4390. ) {
  4391. if (!vm) {
  4392. // in a Vue.extend merge, both should be functions
  4393. if (!childVal) {
  4394. return parentVal
  4395. }
  4396. if (!parentVal) {
  4397. return childVal
  4398. }
  4399. // when parentVal & childVal are both present,
  4400. // we need to return a function that returns the
  4401. // merged result of both functions... no need to
  4402. // check if parentVal is a function here because
  4403. // it has to be a function to pass previous merges.
  4404. return function mergedDataFn () {
  4405. return mergeData(
  4406. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  4407. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  4408. )
  4409. }
  4410. } else {
  4411. return function mergedInstanceDataFn () {
  4412. // instance merge
  4413. var instanceData = typeof childVal === 'function'
  4414. ? childVal.call(vm, vm)
  4415. : childVal;
  4416. var defaultData = typeof parentVal === 'function'
  4417. ? parentVal.call(vm, vm)
  4418. : parentVal;
  4419. if (instanceData) {
  4420. return mergeData(instanceData, defaultData)
  4421. } else {
  4422. return defaultData
  4423. }
  4424. }
  4425. }
  4426. }
  4427. strats.data = function (
  4428. parentVal,
  4429. childVal,
  4430. vm
  4431. ) {
  4432. if (!vm) {
  4433. if (childVal && typeof childVal !== 'function') {
  4434. true && warn(
  4435. 'The "data" option should be a function ' +
  4436. 'that returns a per-instance value in component ' +
  4437. 'definitions.',
  4438. vm
  4439. );
  4440. return parentVal
  4441. }
  4442. return mergeDataOrFn(parentVal, childVal)
  4443. }
  4444. return mergeDataOrFn(parentVal, childVal, vm)
  4445. };
  4446. /**
  4447. * Hooks and props are merged as arrays.
  4448. */
  4449. function mergeHook (
  4450. parentVal,
  4451. childVal
  4452. ) {
  4453. var res = childVal
  4454. ? parentVal
  4455. ? parentVal.concat(childVal)
  4456. : Array.isArray(childVal)
  4457. ? childVal
  4458. : [childVal]
  4459. : parentVal;
  4460. return res
  4461. ? dedupeHooks(res)
  4462. : res
  4463. }
  4464. function dedupeHooks (hooks) {
  4465. var res = [];
  4466. for (var i = 0; i < hooks.length; i++) {
  4467. if (res.indexOf(hooks[i]) === -1) {
  4468. res.push(hooks[i]);
  4469. }
  4470. }
  4471. return res
  4472. }
  4473. LIFECYCLE_HOOKS.forEach(function (hook) {
  4474. strats[hook] = mergeHook;
  4475. });
  4476. /**
  4477. * Assets
  4478. *
  4479. * When a vm is present (instance creation), we need to do
  4480. * a three-way merge between constructor options, instance
  4481. * options and parent options.
  4482. */
  4483. function mergeAssets (
  4484. parentVal,
  4485. childVal,
  4486. vm,
  4487. key
  4488. ) {
  4489. var res = Object.create(parentVal || null);
  4490. if (childVal) {
  4491. true && assertObjectType(key, childVal, vm);
  4492. return extend(res, childVal)
  4493. } else {
  4494. return res
  4495. }
  4496. }
  4497. ASSET_TYPES.forEach(function (type) {
  4498. strats[type + 's'] = mergeAssets;
  4499. });
  4500. /**
  4501. * Watchers.
  4502. *
  4503. * Watchers hashes should not overwrite one
  4504. * another, so we merge them as arrays.
  4505. */
  4506. strats.watch = function (
  4507. parentVal,
  4508. childVal,
  4509. vm,
  4510. key
  4511. ) {
  4512. // work around Firefox's Object.prototype.watch...
  4513. if (parentVal === nativeWatch) { parentVal = undefined; }
  4514. if (childVal === nativeWatch) { childVal = undefined; }
  4515. /* istanbul ignore if */
  4516. if (!childVal) { return Object.create(parentVal || null) }
  4517. if (true) {
  4518. assertObjectType(key, childVal, vm);
  4519. }
  4520. if (!parentVal) { return childVal }
  4521. var ret = {};
  4522. extend(ret, parentVal);
  4523. for (var key$1 in childVal) {
  4524. var parent = ret[key$1];
  4525. var child = childVal[key$1];
  4526. if (parent && !Array.isArray(parent)) {
  4527. parent = [parent];
  4528. }
  4529. ret[key$1] = parent
  4530. ? parent.concat(child)
  4531. : Array.isArray(child) ? child : [child];
  4532. }
  4533. return ret
  4534. };
  4535. /**
  4536. * Other object hashes.
  4537. */
  4538. strats.props =
  4539. strats.methods =
  4540. strats.inject =
  4541. strats.computed = function (
  4542. parentVal,
  4543. childVal,
  4544. vm,
  4545. key
  4546. ) {
  4547. if (childVal && "development" !== 'production') {
  4548. assertObjectType(key, childVal, vm);
  4549. }
  4550. if (!parentVal) { return childVal }
  4551. var ret = Object.create(null);
  4552. extend(ret, parentVal);
  4553. if (childVal) { extend(ret, childVal); }
  4554. return ret
  4555. };
  4556. strats.provide = mergeDataOrFn;
  4557. /**
  4558. * Default strategy.
  4559. */
  4560. var defaultStrat = function (parentVal, childVal) {
  4561. return childVal === undefined
  4562. ? parentVal
  4563. : childVal
  4564. };
  4565. /**
  4566. * Validate component names
  4567. */
  4568. function checkComponents (options) {
  4569. for (var key in options.components) {
  4570. validateComponentName(key);
  4571. }
  4572. }
  4573. function validateComponentName (name) {
  4574. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  4575. warn(
  4576. 'Invalid component name: "' + name + '". Component names ' +
  4577. 'should conform to valid custom element name in html5 specification.'
  4578. );
  4579. }
  4580. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  4581. warn(
  4582. 'Do not use built-in or reserved HTML elements as component ' +
  4583. 'id: ' + name
  4584. );
  4585. }
  4586. }
  4587. /**
  4588. * Ensure all props option syntax are normalized into the
  4589. * Object-based format.
  4590. */
  4591. function normalizeProps (options, vm) {
  4592. var props = options.props;
  4593. if (!props) { return }
  4594. var res = {};
  4595. var i, val, name;
  4596. if (Array.isArray(props)) {
  4597. i = props.length;
  4598. while (i--) {
  4599. val = props[i];
  4600. if (typeof val === 'string') {
  4601. name = camelize(val);
  4602. res[name] = { type: null };
  4603. } else if (true) {
  4604. warn('props must be strings when using array syntax.');
  4605. }
  4606. }
  4607. } else if (isPlainObject(props)) {
  4608. for (var key in props) {
  4609. val = props[key];
  4610. name = camelize(key);
  4611. res[name] = isPlainObject(val)
  4612. ? val
  4613. : { type: val };
  4614. }
  4615. } else if (true) {
  4616. warn(
  4617. "Invalid value for option \"props\": expected an Array or an Object, " +
  4618. "but got " + (toRawType(props)) + ".",
  4619. vm
  4620. );
  4621. }
  4622. options.props = res;
  4623. }
  4624. /**
  4625. * Normalize all injections into Object-based format
  4626. */
  4627. function normalizeInject (options, vm) {
  4628. var inject = options.inject;
  4629. if (!inject) { return }
  4630. var normalized = options.inject = {};
  4631. if (Array.isArray(inject)) {
  4632. for (var i = 0; i < inject.length; i++) {
  4633. normalized[inject[i]] = { from: inject[i] };
  4634. }
  4635. } else if (isPlainObject(inject)) {
  4636. for (var key in inject) {
  4637. var val = inject[key];
  4638. normalized[key] = isPlainObject(val)
  4639. ? extend({ from: key }, val)
  4640. : { from: val };
  4641. }
  4642. } else if (true) {
  4643. warn(
  4644. "Invalid value for option \"inject\": expected an Array or an Object, " +
  4645. "but got " + (toRawType(inject)) + ".",
  4646. vm
  4647. );
  4648. }
  4649. }
  4650. /**
  4651. * Normalize raw function directives into object format.
  4652. */
  4653. function normalizeDirectives (options) {
  4654. var dirs = options.directives;
  4655. if (dirs) {
  4656. for (var key in dirs) {
  4657. var def$$1 = dirs[key];
  4658. if (typeof def$$1 === 'function') {
  4659. dirs[key] = { bind: def$$1, update: def$$1 };
  4660. }
  4661. }
  4662. }
  4663. }
  4664. function assertObjectType (name, value, vm) {
  4665. if (!isPlainObject(value)) {
  4666. warn(
  4667. "Invalid value for option \"" + name + "\": expected an Object, " +
  4668. "but got " + (toRawType(value)) + ".",
  4669. vm
  4670. );
  4671. }
  4672. }
  4673. /**
  4674. * Merge two option objects into a new one.
  4675. * Core utility used in both instantiation and inheritance.
  4676. */
  4677. function mergeOptions (
  4678. parent,
  4679. child,
  4680. vm
  4681. ) {
  4682. if (true) {
  4683. checkComponents(child);
  4684. }
  4685. if (typeof child === 'function') {
  4686. child = child.options;
  4687. }
  4688. normalizeProps(child, vm);
  4689. normalizeInject(child, vm);
  4690. normalizeDirectives(child);
  4691. // Apply extends and mixins on the child options,
  4692. // but only if it is a raw options object that isn't
  4693. // the result of another mergeOptions call.
  4694. // Only merged options has the _base property.
  4695. if (!child._base) {
  4696. if (child.extends) {
  4697. parent = mergeOptions(parent, child.extends, vm);
  4698. }
  4699. if (child.mixins) {
  4700. for (var i = 0, l = child.mixins.length; i < l; i++) {
  4701. parent = mergeOptions(parent, child.mixins[i], vm);
  4702. }
  4703. }
  4704. }
  4705. var options = {};
  4706. var key;
  4707. for (key in parent) {
  4708. mergeField(key);
  4709. }
  4710. for (key in child) {
  4711. if (!hasOwn(parent, key)) {
  4712. mergeField(key);
  4713. }
  4714. }
  4715. function mergeField (key) {
  4716. var strat = strats[key] || defaultStrat;
  4717. options[key] = strat(parent[key], child[key], vm, key);
  4718. }
  4719. return options
  4720. }
  4721. /**
  4722. * Resolve an asset.
  4723. * This function is used because child instances need access
  4724. * to assets defined in its ancestor chain.
  4725. */
  4726. function resolveAsset (
  4727. options,
  4728. type,
  4729. id,
  4730. warnMissing
  4731. ) {
  4732. /* istanbul ignore if */
  4733. if (typeof id !== 'string') {
  4734. return
  4735. }
  4736. var assets = options[type];
  4737. // check local registration variations first
  4738. if (hasOwn(assets, id)) { return assets[id] }
  4739. var camelizedId = camelize(id);
  4740. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  4741. var PascalCaseId = capitalize(camelizedId);
  4742. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  4743. // fallback to prototype chain
  4744. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  4745. if ( true && warnMissing && !res) {
  4746. warn(
  4747. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  4748. options
  4749. );
  4750. }
  4751. return res
  4752. }
  4753. /* */
  4754. function validateProp (
  4755. key,
  4756. propOptions,
  4757. propsData,
  4758. vm
  4759. ) {
  4760. var prop = propOptions[key];
  4761. var absent = !hasOwn(propsData, key);
  4762. var value = propsData[key];
  4763. // boolean casting
  4764. var booleanIndex = getTypeIndex(Boolean, prop.type);
  4765. if (booleanIndex > -1) {
  4766. if (absent && !hasOwn(prop, 'default')) {
  4767. value = false;
  4768. } else if (value === '' || value === hyphenate(key)) {
  4769. // only cast empty string / same name to boolean if
  4770. // boolean has higher priority
  4771. var stringIndex = getTypeIndex(String, prop.type);
  4772. if (stringIndex < 0 || booleanIndex < stringIndex) {
  4773. value = true;
  4774. }
  4775. }
  4776. }
  4777. // check default value
  4778. if (value === undefined) {
  4779. value = getPropDefaultValue(vm, prop, key);
  4780. // since the default value is a fresh copy,
  4781. // make sure to observe it.
  4782. var prevShouldObserve = shouldObserve;
  4783. toggleObserving(true);
  4784. observe(value);
  4785. toggleObserving(prevShouldObserve);
  4786. }
  4787. if (
  4788. true
  4789. ) {
  4790. assertProp(prop, key, value, vm, absent);
  4791. }
  4792. return value
  4793. }
  4794. /**
  4795. * Get the default value of a prop.
  4796. */
  4797. function getPropDefaultValue (vm, prop, key) {
  4798. // no default, return undefined
  4799. if (!hasOwn(prop, 'default')) {
  4800. return undefined
  4801. }
  4802. var def = prop.default;
  4803. // warn against non-factory defaults for Object & Array
  4804. if ( true && isObject(def)) {
  4805. warn(
  4806. 'Invalid default value for prop "' + key + '": ' +
  4807. 'Props with type Object/Array must use a factory function ' +
  4808. 'to return the default value.',
  4809. vm
  4810. );
  4811. }
  4812. // the raw prop value was also undefined from previous render,
  4813. // return previous default value to avoid unnecessary watcher trigger
  4814. if (vm && vm.$options.propsData &&
  4815. vm.$options.propsData[key] === undefined &&
  4816. vm._props[key] !== undefined
  4817. ) {
  4818. return vm._props[key]
  4819. }
  4820. // call factory function for non-Function types
  4821. // a value is Function if its prototype is function even across different execution context
  4822. return typeof def === 'function' && getType(prop.type) !== 'Function'
  4823. ? def.call(vm)
  4824. : def
  4825. }
  4826. /**
  4827. * Assert whether a prop is valid.
  4828. */
  4829. function assertProp (
  4830. prop,
  4831. name,
  4832. value,
  4833. vm,
  4834. absent
  4835. ) {
  4836. if (prop.required && absent) {
  4837. warn(
  4838. 'Missing required prop: "' + name + '"',
  4839. vm
  4840. );
  4841. return
  4842. }
  4843. if (value == null && !prop.required) {
  4844. return
  4845. }
  4846. var type = prop.type;
  4847. var valid = !type || type === true;
  4848. var expectedTypes = [];
  4849. if (type) {
  4850. if (!Array.isArray(type)) {
  4851. type = [type];
  4852. }
  4853. for (var i = 0; i < type.length && !valid; i++) {
  4854. var assertedType = assertType(value, type[i]);
  4855. expectedTypes.push(assertedType.expectedType || '');
  4856. valid = assertedType.valid;
  4857. }
  4858. }
  4859. if (!valid) {
  4860. warn(
  4861. getInvalidTypeMessage(name, value, expectedTypes),
  4862. vm
  4863. );
  4864. return
  4865. }
  4866. var validator = prop.validator;
  4867. if (validator) {
  4868. if (!validator(value)) {
  4869. warn(
  4870. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  4871. vm
  4872. );
  4873. }
  4874. }
  4875. }
  4876. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  4877. function assertType (value, type) {
  4878. var valid;
  4879. var expectedType = getType(type);
  4880. if (simpleCheckRE.test(expectedType)) {
  4881. var t = typeof value;
  4882. valid = t === expectedType.toLowerCase();
  4883. // for primitive wrapper objects
  4884. if (!valid && t === 'object') {
  4885. valid = value instanceof type;
  4886. }
  4887. } else if (expectedType === 'Object') {
  4888. valid = isPlainObject(value);
  4889. } else if (expectedType === 'Array') {
  4890. valid = Array.isArray(value);
  4891. } else {
  4892. valid = value instanceof type;
  4893. }
  4894. return {
  4895. valid: valid,
  4896. expectedType: expectedType
  4897. }
  4898. }
  4899. /**
  4900. * Use function string name to check built-in types,
  4901. * because a simple equality check will fail when running
  4902. * across different vms / iframes.
  4903. */
  4904. function getType (fn) {
  4905. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  4906. return match ? match[1] : ''
  4907. }
  4908. function isSameType (a, b) {
  4909. return getType(a) === getType(b)
  4910. }
  4911. function getTypeIndex (type, expectedTypes) {
  4912. if (!Array.isArray(expectedTypes)) {
  4913. return isSameType(expectedTypes, type) ? 0 : -1
  4914. }
  4915. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  4916. if (isSameType(expectedTypes[i], type)) {
  4917. return i
  4918. }
  4919. }
  4920. return -1
  4921. }
  4922. function getInvalidTypeMessage (name, value, expectedTypes) {
  4923. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  4924. " Expected " + (expectedTypes.map(capitalize).join(', '));
  4925. var expectedType = expectedTypes[0];
  4926. var receivedType = toRawType(value);
  4927. var expectedValue = styleValue(value, expectedType);
  4928. var receivedValue = styleValue(value, receivedType);
  4929. // check if we need to specify expected value
  4930. if (expectedTypes.length === 1 &&
  4931. isExplicable(expectedType) &&
  4932. !isBoolean(expectedType, receivedType)) {
  4933. message += " with value " + expectedValue;
  4934. }
  4935. message += ", got " + receivedType + " ";
  4936. // check if we need to specify received value
  4937. if (isExplicable(receivedType)) {
  4938. message += "with value " + receivedValue + ".";
  4939. }
  4940. return message
  4941. }
  4942. function styleValue (value, type) {
  4943. if (type === 'String') {
  4944. return ("\"" + value + "\"")
  4945. } else if (type === 'Number') {
  4946. return ("" + (Number(value)))
  4947. } else {
  4948. return ("" + value)
  4949. }
  4950. }
  4951. function isExplicable (value) {
  4952. var explicitTypes = ['string', 'number', 'boolean'];
  4953. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  4954. }
  4955. function isBoolean () {
  4956. var args = [], len = arguments.length;
  4957. while ( len-- ) args[ len ] = arguments[ len ];
  4958. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  4959. }
  4960. /* */
  4961. function handleError (err, vm, info) {
  4962. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  4963. // See: https://github.com/vuejs/vuex/issues/1505
  4964. pushTarget();
  4965. try {
  4966. if (vm) {
  4967. var cur = vm;
  4968. while ((cur = cur.$parent)) {
  4969. var hooks = cur.$options.errorCaptured;
  4970. if (hooks) {
  4971. for (var i = 0; i < hooks.length; i++) {
  4972. try {
  4973. var capture = hooks[i].call(cur, err, vm, info) === false;
  4974. if (capture) { return }
  4975. } catch (e) {
  4976. globalHandleError(e, cur, 'errorCaptured hook');
  4977. }
  4978. }
  4979. }
  4980. }
  4981. }
  4982. globalHandleError(err, vm, info);
  4983. } finally {
  4984. popTarget();
  4985. }
  4986. }
  4987. function invokeWithErrorHandling (
  4988. handler,
  4989. context,
  4990. args,
  4991. vm,
  4992. info
  4993. ) {
  4994. var res;
  4995. try {
  4996. res = args ? handler.apply(context, args) : handler.call(context);
  4997. if (res && !res._isVue && isPromise(res) && !res._handled) {
  4998. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  4999. // issue #9511
  5000. // avoid catch triggering multiple times when nested calls
  5001. res._handled = true;
  5002. }
  5003. } catch (e) {
  5004. handleError(e, vm, info);
  5005. }
  5006. return res
  5007. }
  5008. function globalHandleError (err, vm, info) {
  5009. if (config.errorHandler) {
  5010. try {
  5011. return config.errorHandler.call(null, err, vm, info)
  5012. } catch (e) {
  5013. // if the user intentionally throws the original error in the handler,
  5014. // do not log it twice
  5015. if (e !== err) {
  5016. logError(e, null, 'config.errorHandler');
  5017. }
  5018. }
  5019. }
  5020. logError(err, vm, info);
  5021. }
  5022. function logError (err, vm, info) {
  5023. if (true) {
  5024. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  5025. }
  5026. /* istanbul ignore else */
  5027. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  5028. console.error(err);
  5029. } else {
  5030. throw err
  5031. }
  5032. }
  5033. /* */
  5034. var callbacks = [];
  5035. var pending = false;
  5036. function flushCallbacks () {
  5037. pending = false;
  5038. var copies = callbacks.slice(0);
  5039. callbacks.length = 0;
  5040. for (var i = 0; i < copies.length; i++) {
  5041. copies[i]();
  5042. }
  5043. }
  5044. // Here we have async deferring wrappers using microtasks.
  5045. // In 2.5 we used (macro) tasks (in combination with microtasks).
  5046. // However, it has subtle problems when state is changed right before repaint
  5047. // (e.g. #6813, out-in transitions).
  5048. // Also, using (macro) tasks in event handler would cause some weird behaviors
  5049. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  5050. // So we now use microtasks everywhere, again.
  5051. // A major drawback of this tradeoff is that there are some scenarios
  5052. // where microtasks have too high a priority and fire in between supposedly
  5053. // sequential events (e.g. #4521, #6690, which have workarounds)
  5054. // or even between bubbling of the same event (#6566).
  5055. var timerFunc;
  5056. // The nextTick behavior leverages the microtask queue, which can be accessed
  5057. // via either native Promise.then or MutationObserver.
  5058. // MutationObserver has wider support, however it is seriously bugged in
  5059. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  5060. // completely stops working after triggering a few times... so, if native
  5061. // Promise is available, we will use it:
  5062. /* istanbul ignore next, $flow-disable-line */
  5063. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  5064. var p = Promise.resolve();
  5065. timerFunc = function () {
  5066. p.then(flushCallbacks);
  5067. // In problematic UIWebViews, Promise.then doesn't completely break, but
  5068. // it can get stuck in a weird state where callbacks are pushed into the
  5069. // microtask queue but the queue isn't being flushed, until the browser
  5070. // needs to do some other work, e.g. handle a timer. Therefore we can
  5071. // "force" the microtask queue to be flushed by adding an empty timer.
  5072. if (isIOS) { setTimeout(noop); }
  5073. };
  5074. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  5075. isNative(MutationObserver) ||
  5076. // PhantomJS and iOS 7.x
  5077. MutationObserver.toString() === '[object MutationObserverConstructor]'
  5078. )) {
  5079. // Use MutationObserver where native Promise is not available,
  5080. // e.g. PhantomJS, iOS7, Android 4.4
  5081. // (#6466 MutationObserver is unreliable in IE11)
  5082. var counter = 1;
  5083. var observer = new MutationObserver(flushCallbacks);
  5084. var textNode = document.createTextNode(String(counter));
  5085. observer.observe(textNode, {
  5086. characterData: true
  5087. });
  5088. timerFunc = function () {
  5089. counter = (counter + 1) % 2;
  5090. textNode.data = String(counter);
  5091. };
  5092. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  5093. // Fallback to setImmediate.
  5094. // Technically it leverages the (macro) task queue,
  5095. // but it is still a better choice than setTimeout.
  5096. timerFunc = function () {
  5097. setImmediate(flushCallbacks);
  5098. };
  5099. } else {
  5100. // Fallback to setTimeout.
  5101. timerFunc = function () {
  5102. setTimeout(flushCallbacks, 0);
  5103. };
  5104. }
  5105. function nextTick (cb, ctx) {
  5106. var _resolve;
  5107. callbacks.push(function () {
  5108. if (cb) {
  5109. try {
  5110. cb.call(ctx);
  5111. } catch (e) {
  5112. handleError(e, ctx, 'nextTick');
  5113. }
  5114. } else if (_resolve) {
  5115. _resolve(ctx);
  5116. }
  5117. });
  5118. if (!pending) {
  5119. pending = true;
  5120. timerFunc();
  5121. }
  5122. // $flow-disable-line
  5123. if (!cb && typeof Promise !== 'undefined') {
  5124. return new Promise(function (resolve) {
  5125. _resolve = resolve;
  5126. })
  5127. }
  5128. }
  5129. /* */
  5130. /* not type checking this file because flow doesn't play well with Proxy */
  5131. var initProxy;
  5132. if (true) {
  5133. var allowedGlobals = makeMap(
  5134. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  5135. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  5136. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  5137. 'require' // for Webpack/Browserify
  5138. );
  5139. var warnNonPresent = function (target, key) {
  5140. warn(
  5141. "Property or method \"" + key + "\" is not defined on the instance but " +
  5142. 'referenced during render. Make sure that this property is reactive, ' +
  5143. 'either in the data option, or for class-based components, by ' +
  5144. 'initializing the property. ' +
  5145. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  5146. target
  5147. );
  5148. };
  5149. var warnReservedPrefix = function (target, key) {
  5150. warn(
  5151. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  5152. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  5153. 'prevent conflicts with Vue internals. ' +
  5154. 'See: https://vuejs.org/v2/api/#data',
  5155. target
  5156. );
  5157. };
  5158. var hasProxy =
  5159. typeof Proxy !== 'undefined' && isNative(Proxy);
  5160. if (hasProxy) {
  5161. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  5162. config.keyCodes = new Proxy(config.keyCodes, {
  5163. set: function set (target, key, value) {
  5164. if (isBuiltInModifier(key)) {
  5165. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  5166. return false
  5167. } else {
  5168. target[key] = value;
  5169. return true
  5170. }
  5171. }
  5172. });
  5173. }
  5174. var hasHandler = {
  5175. has: function has (target, key) {
  5176. var has = key in target;
  5177. var isAllowed = allowedGlobals(key) ||
  5178. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  5179. if (!has && !isAllowed) {
  5180. if (key in target.$data) { warnReservedPrefix(target, key); }
  5181. else { warnNonPresent(target, key); }
  5182. }
  5183. return has || !isAllowed
  5184. }
  5185. };
  5186. var getHandler = {
  5187. get: function get (target, key) {
  5188. if (typeof key === 'string' && !(key in target)) {
  5189. if (key in target.$data) { warnReservedPrefix(target, key); }
  5190. else { warnNonPresent(target, key); }
  5191. }
  5192. return target[key]
  5193. }
  5194. };
  5195. initProxy = function initProxy (vm) {
  5196. if (hasProxy) {
  5197. // determine which proxy handler to use
  5198. var options = vm.$options;
  5199. var handlers = options.render && options.render._withStripped
  5200. ? getHandler
  5201. : hasHandler;
  5202. vm._renderProxy = new Proxy(vm, handlers);
  5203. } else {
  5204. vm._renderProxy = vm;
  5205. }
  5206. };
  5207. }
  5208. /* */
  5209. var seenObjects = new _Set();
  5210. /**
  5211. * Recursively traverse an object to evoke all converted
  5212. * getters, so that every nested property inside the object
  5213. * is collected as a "deep" dependency.
  5214. */
  5215. function traverse (val) {
  5216. _traverse(val, seenObjects);
  5217. seenObjects.clear();
  5218. }
  5219. function _traverse (val, seen) {
  5220. var i, keys;
  5221. var isA = Array.isArray(val);
  5222. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  5223. return
  5224. }
  5225. if (val.__ob__) {
  5226. var depId = val.__ob__.dep.id;
  5227. if (seen.has(depId)) {
  5228. return
  5229. }
  5230. seen.add(depId);
  5231. }
  5232. if (isA) {
  5233. i = val.length;
  5234. while (i--) { _traverse(val[i], seen); }
  5235. } else {
  5236. keys = Object.keys(val);
  5237. i = keys.length;
  5238. while (i--) { _traverse(val[keys[i]], seen); }
  5239. }
  5240. }
  5241. var mark;
  5242. var measure;
  5243. if (true) {
  5244. var perf = inBrowser && window.performance;
  5245. /* istanbul ignore if */
  5246. if (
  5247. perf &&
  5248. perf.mark &&
  5249. perf.measure &&
  5250. perf.clearMarks &&
  5251. perf.clearMeasures
  5252. ) {
  5253. mark = function (tag) { return perf.mark(tag); };
  5254. measure = function (name, startTag, endTag) {
  5255. perf.measure(name, startTag, endTag);
  5256. perf.clearMarks(startTag);
  5257. perf.clearMarks(endTag);
  5258. // perf.clearMeasures(name)
  5259. };
  5260. }
  5261. }
  5262. /* */
  5263. var normalizeEvent = cached(function (name) {
  5264. var passive = name.charAt(0) === '&';
  5265. name = passive ? name.slice(1) : name;
  5266. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  5267. name = once$$1 ? name.slice(1) : name;
  5268. var capture = name.charAt(0) === '!';
  5269. name = capture ? name.slice(1) : name;
  5270. return {
  5271. name: name,
  5272. once: once$$1,
  5273. capture: capture,
  5274. passive: passive
  5275. }
  5276. });
  5277. function createFnInvoker (fns, vm) {
  5278. function invoker () {
  5279. var arguments$1 = arguments;
  5280. var fns = invoker.fns;
  5281. if (Array.isArray(fns)) {
  5282. var cloned = fns.slice();
  5283. for (var i = 0; i < cloned.length; i++) {
  5284. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  5285. }
  5286. } else {
  5287. // return handler return value for single handlers
  5288. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  5289. }
  5290. }
  5291. invoker.fns = fns;
  5292. return invoker
  5293. }
  5294. function updateListeners (
  5295. on,
  5296. oldOn,
  5297. add,
  5298. remove$$1,
  5299. createOnceHandler,
  5300. vm
  5301. ) {
  5302. var name, def$$1, cur, old, event;
  5303. for (name in on) {
  5304. def$$1 = cur = on[name];
  5305. old = oldOn[name];
  5306. event = normalizeEvent(name);
  5307. if (isUndef(cur)) {
  5308. true && warn(
  5309. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  5310. vm
  5311. );
  5312. } else if (isUndef(old)) {
  5313. if (isUndef(cur.fns)) {
  5314. cur = on[name] = createFnInvoker(cur, vm);
  5315. }
  5316. if (isTrue(event.once)) {
  5317. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  5318. }
  5319. add(event.name, cur, event.capture, event.passive, event.params);
  5320. } else if (cur !== old) {
  5321. old.fns = cur;
  5322. on[name] = old;
  5323. }
  5324. }
  5325. for (name in oldOn) {
  5326. if (isUndef(on[name])) {
  5327. event = normalizeEvent(name);
  5328. remove$$1(event.name, oldOn[name], event.capture);
  5329. }
  5330. }
  5331. }
  5332. /* */
  5333. /* */
  5334. // fixed by xxxxxx (mp properties)
  5335. function extractPropertiesFromVNodeData(data, Ctor, res, context) {
  5336. var propOptions = Ctor.options.mpOptions && Ctor.options.mpOptions.properties;
  5337. if (isUndef(propOptions)) {
  5338. return res
  5339. }
  5340. var externalClasses = Ctor.options.mpOptions.externalClasses || [];
  5341. var attrs = data.attrs;
  5342. var props = data.props;
  5343. if (isDef(attrs) || isDef(props)) {
  5344. for (var key in propOptions) {
  5345. var altKey = hyphenate(key);
  5346. var result = checkProp(res, props, key, altKey, true) ||
  5347. checkProp(res, attrs, key, altKey, false);
  5348. // externalClass
  5349. if (
  5350. result &&
  5351. res[key] &&
  5352. externalClasses.indexOf(altKey) !== -1 &&
  5353. context[camelize(res[key])]
  5354. ) {
  5355. // 赋值 externalClass 真正的值(模板里 externalClass 的值可能是字符串)
  5356. res[key] = context[camelize(res[key])];
  5357. }
  5358. }
  5359. }
  5360. return res
  5361. }
  5362. function extractPropsFromVNodeData (
  5363. data,
  5364. Ctor,
  5365. tag,
  5366. context// fixed by xxxxxx
  5367. ) {
  5368. // we are only extracting raw values here.
  5369. // validation and default values are handled in the child
  5370. // component itself.
  5371. var propOptions = Ctor.options.props;
  5372. if (isUndef(propOptions)) {
  5373. // fixed by xxxxxx
  5374. return extractPropertiesFromVNodeData(data, Ctor, {}, context)
  5375. }
  5376. var res = {};
  5377. var attrs = data.attrs;
  5378. var props = data.props;
  5379. if (isDef(attrs) || isDef(props)) {
  5380. for (var key in propOptions) {
  5381. var altKey = hyphenate(key);
  5382. if (true) {
  5383. var keyInLowerCase = key.toLowerCase();
  5384. if (
  5385. key !== keyInLowerCase &&
  5386. attrs && hasOwn(attrs, keyInLowerCase)
  5387. ) {
  5388. tip(
  5389. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  5390. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  5391. " \"" + key + "\". " +
  5392. "Note that HTML attributes are case-insensitive and camelCased " +
  5393. "props need to use their kebab-case equivalents when using in-DOM " +
  5394. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  5395. );
  5396. }
  5397. }
  5398. checkProp(res, props, key, altKey, true) ||
  5399. checkProp(res, attrs, key, altKey, false);
  5400. }
  5401. }
  5402. // fixed by xxxxxx
  5403. return extractPropertiesFromVNodeData(data, Ctor, res, context)
  5404. }
  5405. function checkProp (
  5406. res,
  5407. hash,
  5408. key,
  5409. altKey,
  5410. preserve
  5411. ) {
  5412. if (isDef(hash)) {
  5413. if (hasOwn(hash, key)) {
  5414. res[key] = hash[key];
  5415. if (!preserve) {
  5416. delete hash[key];
  5417. }
  5418. return true
  5419. } else if (hasOwn(hash, altKey)) {
  5420. res[key] = hash[altKey];
  5421. if (!preserve) {
  5422. delete hash[altKey];
  5423. }
  5424. return true
  5425. }
  5426. }
  5427. return false
  5428. }
  5429. /* */
  5430. // The template compiler attempts to minimize the need for normalization by
  5431. // statically analyzing the template at compile time.
  5432. //
  5433. // For plain HTML markup, normalization can be completely skipped because the
  5434. // generated render function is guaranteed to return Array<VNode>. There are
  5435. // two cases where extra normalization is needed:
  5436. // 1. When the children contains components - because a functional component
  5437. // may return an Array instead of a single root. In this case, just a simple
  5438. // normalization is needed - if any child is an Array, we flatten the whole
  5439. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  5440. // because functional components already normalize their own children.
  5441. function simpleNormalizeChildren (children) {
  5442. for (var i = 0; i < children.length; i++) {
  5443. if (Array.isArray(children[i])) {
  5444. return Array.prototype.concat.apply([], children)
  5445. }
  5446. }
  5447. return children
  5448. }
  5449. // 2. When the children contains constructs that always generated nested Arrays,
  5450. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  5451. // with hand-written render functions / JSX. In such cases a full normalization
  5452. // is needed to cater to all possible types of children values.
  5453. function normalizeChildren (children) {
  5454. return isPrimitive(children)
  5455. ? [createTextVNode(children)]
  5456. : Array.isArray(children)
  5457. ? normalizeArrayChildren(children)
  5458. : undefined
  5459. }
  5460. function isTextNode (node) {
  5461. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  5462. }
  5463. function normalizeArrayChildren (children, nestedIndex) {
  5464. var res = [];
  5465. var i, c, lastIndex, last;
  5466. for (i = 0; i < children.length; i++) {
  5467. c = children[i];
  5468. if (isUndef(c) || typeof c === 'boolean') { continue }
  5469. lastIndex = res.length - 1;
  5470. last = res[lastIndex];
  5471. // nested
  5472. if (Array.isArray(c)) {
  5473. if (c.length > 0) {
  5474. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  5475. // merge adjacent text nodes
  5476. if (isTextNode(c[0]) && isTextNode(last)) {
  5477. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  5478. c.shift();
  5479. }
  5480. res.push.apply(res, c);
  5481. }
  5482. } else if (isPrimitive(c)) {
  5483. if (isTextNode(last)) {
  5484. // merge adjacent text nodes
  5485. // this is necessary for SSR hydration because text nodes are
  5486. // essentially merged when rendered to HTML strings
  5487. res[lastIndex] = createTextVNode(last.text + c);
  5488. } else if (c !== '') {
  5489. // convert primitive to vnode
  5490. res.push(createTextVNode(c));
  5491. }
  5492. } else {
  5493. if (isTextNode(c) && isTextNode(last)) {
  5494. // merge adjacent text nodes
  5495. res[lastIndex] = createTextVNode(last.text + c.text);
  5496. } else {
  5497. // default key for nested array children (likely generated by v-for)
  5498. if (isTrue(children._isVList) &&
  5499. isDef(c.tag) &&
  5500. isUndef(c.key) &&
  5501. isDef(nestedIndex)) {
  5502. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  5503. }
  5504. res.push(c);
  5505. }
  5506. }
  5507. }
  5508. return res
  5509. }
  5510. /* */
  5511. function initProvide (vm) {
  5512. var provide = vm.$options.provide;
  5513. if (provide) {
  5514. vm._provided = typeof provide === 'function'
  5515. ? provide.call(vm)
  5516. : provide;
  5517. }
  5518. }
  5519. function initInjections (vm) {
  5520. var result = resolveInject(vm.$options.inject, vm);
  5521. if (result) {
  5522. toggleObserving(false);
  5523. Object.keys(result).forEach(function (key) {
  5524. /* istanbul ignore else */
  5525. if (true) {
  5526. defineReactive$$1(vm, key, result[key], function () {
  5527. warn(
  5528. "Avoid mutating an injected value directly since the changes will be " +
  5529. "overwritten whenever the provided component re-renders. " +
  5530. "injection being mutated: \"" + key + "\"",
  5531. vm
  5532. );
  5533. });
  5534. } else {}
  5535. });
  5536. toggleObserving(true);
  5537. }
  5538. }
  5539. function resolveInject (inject, vm) {
  5540. if (inject) {
  5541. // inject is :any because flow is not smart enough to figure out cached
  5542. var result = Object.create(null);
  5543. var keys = hasSymbol
  5544. ? Reflect.ownKeys(inject)
  5545. : Object.keys(inject);
  5546. for (var i = 0; i < keys.length; i++) {
  5547. var key = keys[i];
  5548. // #6574 in case the inject object is observed...
  5549. if (key === '__ob__') { continue }
  5550. var provideKey = inject[key].from;
  5551. var source = vm;
  5552. while (source) {
  5553. if (source._provided && hasOwn(source._provided, provideKey)) {
  5554. result[key] = source._provided[provideKey];
  5555. break
  5556. }
  5557. source = source.$parent;
  5558. }
  5559. if (!source) {
  5560. if ('default' in inject[key]) {
  5561. var provideDefault = inject[key].default;
  5562. result[key] = typeof provideDefault === 'function'
  5563. ? provideDefault.call(vm)
  5564. : provideDefault;
  5565. } else if (true) {
  5566. warn(("Injection \"" + key + "\" not found"), vm);
  5567. }
  5568. }
  5569. }
  5570. return result
  5571. }
  5572. }
  5573. /* */
  5574. /**
  5575. * Runtime helper for resolving raw children VNodes into a slot object.
  5576. */
  5577. function resolveSlots (
  5578. children,
  5579. context
  5580. ) {
  5581. if (!children || !children.length) {
  5582. return {}
  5583. }
  5584. var slots = {};
  5585. for (var i = 0, l = children.length; i < l; i++) {
  5586. var child = children[i];
  5587. var data = child.data;
  5588. // remove slot attribute if the node is resolved as a Vue slot node
  5589. if (data && data.attrs && data.attrs.slot) {
  5590. delete data.attrs.slot;
  5591. }
  5592. // named slots should only be respected if the vnode was rendered in the
  5593. // same context.
  5594. if ((child.context === context || child.fnContext === context) &&
  5595. data && data.slot != null
  5596. ) {
  5597. var name = data.slot;
  5598. var slot = (slots[name] || (slots[name] = []));
  5599. if (child.tag === 'template') {
  5600. slot.push.apply(slot, child.children || []);
  5601. } else {
  5602. slot.push(child);
  5603. }
  5604. } else {
  5605. // fixed by xxxxxx 临时 hack 掉 uni-app 中的异步 name slot page
  5606. if(child.asyncMeta && child.asyncMeta.data && child.asyncMeta.data.slot === 'page'){
  5607. (slots['page'] || (slots['page'] = [])).push(child);
  5608. }else{
  5609. (slots.default || (slots.default = [])).push(child);
  5610. }
  5611. }
  5612. }
  5613. // ignore slots that contains only whitespace
  5614. for (var name$1 in slots) {
  5615. if (slots[name$1].every(isWhitespace)) {
  5616. delete slots[name$1];
  5617. }
  5618. }
  5619. return slots
  5620. }
  5621. function isWhitespace (node) {
  5622. return (node.isComment && !node.asyncFactory) || node.text === ' '
  5623. }
  5624. /* */
  5625. function normalizeScopedSlots (
  5626. slots,
  5627. normalSlots,
  5628. prevSlots
  5629. ) {
  5630. var res;
  5631. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  5632. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  5633. var key = slots && slots.$key;
  5634. if (!slots) {
  5635. res = {};
  5636. } else if (slots._normalized) {
  5637. // fast path 1: child component re-render only, parent did not change
  5638. return slots._normalized
  5639. } else if (
  5640. isStable &&
  5641. prevSlots &&
  5642. prevSlots !== emptyObject &&
  5643. key === prevSlots.$key &&
  5644. !hasNormalSlots &&
  5645. !prevSlots.$hasNormal
  5646. ) {
  5647. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  5648. // only need to normalize once
  5649. return prevSlots
  5650. } else {
  5651. res = {};
  5652. for (var key$1 in slots) {
  5653. if (slots[key$1] && key$1[0] !== '$') {
  5654. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  5655. }
  5656. }
  5657. }
  5658. // expose normal slots on scopedSlots
  5659. for (var key$2 in normalSlots) {
  5660. if (!(key$2 in res)) {
  5661. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  5662. }
  5663. }
  5664. // avoriaz seems to mock a non-extensible $scopedSlots object
  5665. // and when that is passed down this would cause an error
  5666. if (slots && Object.isExtensible(slots)) {
  5667. (slots)._normalized = res;
  5668. }
  5669. def(res, '$stable', isStable);
  5670. def(res, '$key', key);
  5671. def(res, '$hasNormal', hasNormalSlots);
  5672. return res
  5673. }
  5674. function normalizeScopedSlot(normalSlots, key, fn) {
  5675. var normalized = function () {
  5676. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  5677. res = res && typeof res === 'object' && !Array.isArray(res)
  5678. ? [res] // single vnode
  5679. : normalizeChildren(res);
  5680. return res && (
  5681. res.length === 0 ||
  5682. (res.length === 1 && res[0].isComment) // #9658
  5683. ) ? undefined
  5684. : res
  5685. };
  5686. // this is a slot using the new v-slot syntax without scope. although it is
  5687. // compiled as a scoped slot, render fn users would expect it to be present
  5688. // on this.$slots because the usage is semantically a normal slot.
  5689. if (fn.proxy) {
  5690. Object.defineProperty(normalSlots, key, {
  5691. get: normalized,
  5692. enumerable: true,
  5693. configurable: true
  5694. });
  5695. }
  5696. return normalized
  5697. }
  5698. function proxyNormalSlot(slots, key) {
  5699. return function () { return slots[key]; }
  5700. }
  5701. /* */
  5702. /**
  5703. * Runtime helper for rendering v-for lists.
  5704. */
  5705. function renderList (
  5706. val,
  5707. render
  5708. ) {
  5709. var ret, i, l, keys, key;
  5710. if (Array.isArray(val) || typeof val === 'string') {
  5711. ret = new Array(val.length);
  5712. for (i = 0, l = val.length; i < l; i++) {
  5713. ret[i] = render(val[i], i, i, i); // fixed by xxxxxx
  5714. }
  5715. } else if (typeof val === 'number') {
  5716. ret = new Array(val);
  5717. for (i = 0; i < val; i++) {
  5718. ret[i] = render(i + 1, i, i, i); // fixed by xxxxxx
  5719. }
  5720. } else if (isObject(val)) {
  5721. if (hasSymbol && val[Symbol.iterator]) {
  5722. ret = [];
  5723. var iterator = val[Symbol.iterator]();
  5724. var result = iterator.next();
  5725. while (!result.done) {
  5726. ret.push(render(result.value, ret.length, i, i++)); // fixed by xxxxxx
  5727. result = iterator.next();
  5728. }
  5729. } else {
  5730. keys = Object.keys(val);
  5731. ret = new Array(keys.length);
  5732. for (i = 0, l = keys.length; i < l; i++) {
  5733. key = keys[i];
  5734. ret[i] = render(val[key], key, i, i); // fixed by xxxxxx
  5735. }
  5736. }
  5737. }
  5738. if (!isDef(ret)) {
  5739. ret = [];
  5740. }
  5741. (ret)._isVList = true;
  5742. return ret
  5743. }
  5744. /* */
  5745. /**
  5746. * Runtime helper for rendering <slot>
  5747. */
  5748. function renderSlot (
  5749. name,
  5750. fallback,
  5751. props,
  5752. bindObject
  5753. ) {
  5754. var scopedSlotFn = this.$scopedSlots[name];
  5755. var nodes;
  5756. if (scopedSlotFn) { // scoped slot
  5757. props = props || {};
  5758. if (bindObject) {
  5759. if ( true && !isObject(bindObject)) {
  5760. warn(
  5761. 'slot v-bind without argument expects an Object',
  5762. this
  5763. );
  5764. }
  5765. props = extend(extend({}, bindObject), props);
  5766. }
  5767. // fixed by xxxxxx app-plus scopedSlot
  5768. nodes = scopedSlotFn(props, this, props._i) || fallback;
  5769. } else {
  5770. nodes = this.$slots[name] || fallback;
  5771. }
  5772. var target = props && props.slot;
  5773. if (target) {
  5774. return this.$createElement('template', { slot: target }, nodes)
  5775. } else {
  5776. return nodes
  5777. }
  5778. }
  5779. /* */
  5780. /**
  5781. * Runtime helper for resolving filters
  5782. */
  5783. function resolveFilter (id) {
  5784. return resolveAsset(this.$options, 'filters', id, true) || identity
  5785. }
  5786. /* */
  5787. function isKeyNotMatch (expect, actual) {
  5788. if (Array.isArray(expect)) {
  5789. return expect.indexOf(actual) === -1
  5790. } else {
  5791. return expect !== actual
  5792. }
  5793. }
  5794. /**
  5795. * Runtime helper for checking keyCodes from config.
  5796. * exposed as Vue.prototype._k
  5797. * passing in eventKeyName as last argument separately for backwards compat
  5798. */
  5799. function checkKeyCodes (
  5800. eventKeyCode,
  5801. key,
  5802. builtInKeyCode,
  5803. eventKeyName,
  5804. builtInKeyName
  5805. ) {
  5806. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  5807. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  5808. return isKeyNotMatch(builtInKeyName, eventKeyName)
  5809. } else if (mappedKeyCode) {
  5810. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  5811. } else if (eventKeyName) {
  5812. return hyphenate(eventKeyName) !== key
  5813. }
  5814. }
  5815. /* */
  5816. /**
  5817. * Runtime helper for merging v-bind="object" into a VNode's data.
  5818. */
  5819. function bindObjectProps (
  5820. data,
  5821. tag,
  5822. value,
  5823. asProp,
  5824. isSync
  5825. ) {
  5826. if (value) {
  5827. if (!isObject(value)) {
  5828. true && warn(
  5829. 'v-bind without argument expects an Object or Array value',
  5830. this
  5831. );
  5832. } else {
  5833. if (Array.isArray(value)) {
  5834. value = toObject(value);
  5835. }
  5836. var hash;
  5837. var loop = function ( key ) {
  5838. if (
  5839. key === 'class' ||
  5840. key === 'style' ||
  5841. isReservedAttribute(key)
  5842. ) {
  5843. hash = data;
  5844. } else {
  5845. var type = data.attrs && data.attrs.type;
  5846. hash = asProp || config.mustUseProp(tag, type, key)
  5847. ? data.domProps || (data.domProps = {})
  5848. : data.attrs || (data.attrs = {});
  5849. }
  5850. var camelizedKey = camelize(key);
  5851. var hyphenatedKey = hyphenate(key);
  5852. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  5853. hash[key] = value[key];
  5854. if (isSync) {
  5855. var on = data.on || (data.on = {});
  5856. on[("update:" + key)] = function ($event) {
  5857. value[key] = $event;
  5858. };
  5859. }
  5860. }
  5861. };
  5862. for (var key in value) loop( key );
  5863. }
  5864. }
  5865. return data
  5866. }
  5867. /* */
  5868. /**
  5869. * Runtime helper for rendering static trees.
  5870. */
  5871. function renderStatic (
  5872. index,
  5873. isInFor
  5874. ) {
  5875. var cached = this._staticTrees || (this._staticTrees = []);
  5876. var tree = cached[index];
  5877. // if has already-rendered static tree and not inside v-for,
  5878. // we can reuse the same tree.
  5879. if (tree && !isInFor) {
  5880. return tree
  5881. }
  5882. // otherwise, render a fresh tree.
  5883. tree = cached[index] = this.$options.staticRenderFns[index].call(
  5884. this._renderProxy,
  5885. null,
  5886. this // for render fns generated for functional component templates
  5887. );
  5888. markStatic(tree, ("__static__" + index), false);
  5889. return tree
  5890. }
  5891. /**
  5892. * Runtime helper for v-once.
  5893. * Effectively it means marking the node as static with a unique key.
  5894. */
  5895. function markOnce (
  5896. tree,
  5897. index,
  5898. key
  5899. ) {
  5900. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  5901. return tree
  5902. }
  5903. function markStatic (
  5904. tree,
  5905. key,
  5906. isOnce
  5907. ) {
  5908. if (Array.isArray(tree)) {
  5909. for (var i = 0; i < tree.length; i++) {
  5910. if (tree[i] && typeof tree[i] !== 'string') {
  5911. markStaticNode(tree[i], (key + "_" + i), isOnce);
  5912. }
  5913. }
  5914. } else {
  5915. markStaticNode(tree, key, isOnce);
  5916. }
  5917. }
  5918. function markStaticNode (node, key, isOnce) {
  5919. node.isStatic = true;
  5920. node.key = key;
  5921. node.isOnce = isOnce;
  5922. }
  5923. /* */
  5924. function bindObjectListeners (data, value) {
  5925. if (value) {
  5926. if (!isPlainObject(value)) {
  5927. true && warn(
  5928. 'v-on without argument expects an Object value',
  5929. this
  5930. );
  5931. } else {
  5932. var on = data.on = data.on ? extend({}, data.on) : {};
  5933. for (var key in value) {
  5934. var existing = on[key];
  5935. var ours = value[key];
  5936. on[key] = existing ? [].concat(existing, ours) : ours;
  5937. }
  5938. }
  5939. }
  5940. return data
  5941. }
  5942. /* */
  5943. function resolveScopedSlots (
  5944. fns, // see flow/vnode
  5945. res,
  5946. // the following are added in 2.6
  5947. hasDynamicKeys,
  5948. contentHashKey
  5949. ) {
  5950. res = res || { $stable: !hasDynamicKeys };
  5951. for (var i = 0; i < fns.length; i++) {
  5952. var slot = fns[i];
  5953. if (Array.isArray(slot)) {
  5954. resolveScopedSlots(slot, res, hasDynamicKeys);
  5955. } else if (slot) {
  5956. // marker for reverse proxying v-slot without scope on this.$slots
  5957. if (slot.proxy) {
  5958. slot.fn.proxy = true;
  5959. }
  5960. res[slot.key] = slot.fn;
  5961. }
  5962. }
  5963. if (contentHashKey) {
  5964. (res).$key = contentHashKey;
  5965. }
  5966. return res
  5967. }
  5968. /* */
  5969. function bindDynamicKeys (baseObj, values) {
  5970. for (var i = 0; i < values.length; i += 2) {
  5971. var key = values[i];
  5972. if (typeof key === 'string' && key) {
  5973. baseObj[values[i]] = values[i + 1];
  5974. } else if ( true && key !== '' && key !== null) {
  5975. // null is a special value for explicitly removing a binding
  5976. warn(
  5977. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  5978. this
  5979. );
  5980. }
  5981. }
  5982. return baseObj
  5983. }
  5984. // helper to dynamically append modifier runtime markers to event names.
  5985. // ensure only append when value is already string, otherwise it will be cast
  5986. // to string and cause the type check to miss.
  5987. function prependModifier (value, symbol) {
  5988. return typeof value === 'string' ? symbol + value : value
  5989. }
  5990. /* */
  5991. function installRenderHelpers (target) {
  5992. target._o = markOnce;
  5993. target._n = toNumber;
  5994. target._s = toString;
  5995. target._l = renderList;
  5996. target._t = renderSlot;
  5997. target._q = looseEqual;
  5998. target._i = looseIndexOf;
  5999. target._m = renderStatic;
  6000. target._f = resolveFilter;
  6001. target._k = checkKeyCodes;
  6002. target._b = bindObjectProps;
  6003. target._v = createTextVNode;
  6004. target._e = createEmptyVNode;
  6005. target._u = resolveScopedSlots;
  6006. target._g = bindObjectListeners;
  6007. target._d = bindDynamicKeys;
  6008. target._p = prependModifier;
  6009. }
  6010. /* */
  6011. function FunctionalRenderContext (
  6012. data,
  6013. props,
  6014. children,
  6015. parent,
  6016. Ctor
  6017. ) {
  6018. var this$1 = this;
  6019. var options = Ctor.options;
  6020. // ensure the createElement function in functional components
  6021. // gets a unique context - this is necessary for correct named slot check
  6022. var contextVm;
  6023. if (hasOwn(parent, '_uid')) {
  6024. contextVm = Object.create(parent);
  6025. // $flow-disable-line
  6026. contextVm._original = parent;
  6027. } else {
  6028. // the context vm passed in is a functional context as well.
  6029. // in this case we want to make sure we are able to get a hold to the
  6030. // real context instance.
  6031. contextVm = parent;
  6032. // $flow-disable-line
  6033. parent = parent._original;
  6034. }
  6035. var isCompiled = isTrue(options._compiled);
  6036. var needNormalization = !isCompiled;
  6037. this.data = data;
  6038. this.props = props;
  6039. this.children = children;
  6040. this.parent = parent;
  6041. this.listeners = data.on || emptyObject;
  6042. this.injections = resolveInject(options.inject, parent);
  6043. this.slots = function () {
  6044. if (!this$1.$slots) {
  6045. normalizeScopedSlots(
  6046. data.scopedSlots,
  6047. this$1.$slots = resolveSlots(children, parent)
  6048. );
  6049. }
  6050. return this$1.$slots
  6051. };
  6052. Object.defineProperty(this, 'scopedSlots', ({
  6053. enumerable: true,
  6054. get: function get () {
  6055. return normalizeScopedSlots(data.scopedSlots, this.slots())
  6056. }
  6057. }));
  6058. // support for compiled functional template
  6059. if (isCompiled) {
  6060. // exposing $options for renderStatic()
  6061. this.$options = options;
  6062. // pre-resolve slots for renderSlot()
  6063. this.$slots = this.slots();
  6064. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  6065. }
  6066. if (options._scopeId) {
  6067. this._c = function (a, b, c, d) {
  6068. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  6069. if (vnode && !Array.isArray(vnode)) {
  6070. vnode.fnScopeId = options._scopeId;
  6071. vnode.fnContext = parent;
  6072. }
  6073. return vnode
  6074. };
  6075. } else {
  6076. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  6077. }
  6078. }
  6079. installRenderHelpers(FunctionalRenderContext.prototype);
  6080. function createFunctionalComponent (
  6081. Ctor,
  6082. propsData,
  6083. data,
  6084. contextVm,
  6085. children
  6086. ) {
  6087. var options = Ctor.options;
  6088. var props = {};
  6089. var propOptions = options.props;
  6090. if (isDef(propOptions)) {
  6091. for (var key in propOptions) {
  6092. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  6093. }
  6094. } else {
  6095. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  6096. if (isDef(data.props)) { mergeProps(props, data.props); }
  6097. }
  6098. var renderContext = new FunctionalRenderContext(
  6099. data,
  6100. props,
  6101. children,
  6102. contextVm,
  6103. Ctor
  6104. );
  6105. var vnode = options.render.call(null, renderContext._c, renderContext);
  6106. if (vnode instanceof VNode) {
  6107. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  6108. } else if (Array.isArray(vnode)) {
  6109. var vnodes = normalizeChildren(vnode) || [];
  6110. var res = new Array(vnodes.length);
  6111. for (var i = 0; i < vnodes.length; i++) {
  6112. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  6113. }
  6114. return res
  6115. }
  6116. }
  6117. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  6118. // #7817 clone node before setting fnContext, otherwise if the node is reused
  6119. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  6120. // that should not be matched to match.
  6121. var clone = cloneVNode(vnode);
  6122. clone.fnContext = contextVm;
  6123. clone.fnOptions = options;
  6124. if (true) {
  6125. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  6126. }
  6127. if (data.slot) {
  6128. (clone.data || (clone.data = {})).slot = data.slot;
  6129. }
  6130. return clone
  6131. }
  6132. function mergeProps (to, from) {
  6133. for (var key in from) {
  6134. to[camelize(key)] = from[key];
  6135. }
  6136. }
  6137. /* */
  6138. /* */
  6139. /* */
  6140. /* */
  6141. // inline hooks to be invoked on component VNodes during patch
  6142. var componentVNodeHooks = {
  6143. init: function init (vnode, hydrating) {
  6144. if (
  6145. vnode.componentInstance &&
  6146. !vnode.componentInstance._isDestroyed &&
  6147. vnode.data.keepAlive
  6148. ) {
  6149. // kept-alive components, treat as a patch
  6150. var mountedNode = vnode; // work around flow
  6151. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  6152. } else {
  6153. var child = vnode.componentInstance = createComponentInstanceForVnode(
  6154. vnode,
  6155. activeInstance
  6156. );
  6157. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  6158. }
  6159. },
  6160. prepatch: function prepatch (oldVnode, vnode) {
  6161. var options = vnode.componentOptions;
  6162. var child = vnode.componentInstance = oldVnode.componentInstance;
  6163. updateChildComponent(
  6164. child,
  6165. options.propsData, // updated props
  6166. options.listeners, // updated listeners
  6167. vnode, // new parent vnode
  6168. options.children // new children
  6169. );
  6170. },
  6171. insert: function insert (vnode) {
  6172. var context = vnode.context;
  6173. var componentInstance = vnode.componentInstance;
  6174. if (!componentInstance._isMounted) {
  6175. callHook(componentInstance, 'onServiceCreated');
  6176. callHook(componentInstance, 'onServiceAttached');
  6177. componentInstance._isMounted = true;
  6178. callHook(componentInstance, 'mounted');
  6179. }
  6180. if (vnode.data.keepAlive) {
  6181. if (context._isMounted) {
  6182. // vue-router#1212
  6183. // During updates, a kept-alive component's child components may
  6184. // change, so directly walking the tree here may call activated hooks
  6185. // on incorrect children. Instead we push them into a queue which will
  6186. // be processed after the whole patch process ended.
  6187. queueActivatedComponent(componentInstance);
  6188. } else {
  6189. activateChildComponent(componentInstance, true /* direct */);
  6190. }
  6191. }
  6192. },
  6193. destroy: function destroy (vnode) {
  6194. var componentInstance = vnode.componentInstance;
  6195. if (!componentInstance._isDestroyed) {
  6196. if (!vnode.data.keepAlive) {
  6197. componentInstance.$destroy();
  6198. } else {
  6199. deactivateChildComponent(componentInstance, true /* direct */);
  6200. }
  6201. }
  6202. }
  6203. };
  6204. var hooksToMerge = Object.keys(componentVNodeHooks);
  6205. function createComponent (
  6206. Ctor,
  6207. data,
  6208. context,
  6209. children,
  6210. tag
  6211. ) {
  6212. if (isUndef(Ctor)) {
  6213. return
  6214. }
  6215. var baseCtor = context.$options._base;
  6216. // plain options object: turn it into a constructor
  6217. if (isObject(Ctor)) {
  6218. Ctor = baseCtor.extend(Ctor);
  6219. }
  6220. // if at this stage it's not a constructor or an async component factory,
  6221. // reject.
  6222. if (typeof Ctor !== 'function') {
  6223. if (true) {
  6224. warn(("Invalid Component definition: " + (String(Ctor))), context);
  6225. }
  6226. return
  6227. }
  6228. // async component
  6229. var asyncFactory;
  6230. if (isUndef(Ctor.cid)) {
  6231. asyncFactory = Ctor;
  6232. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  6233. if (Ctor === undefined) {
  6234. // return a placeholder node for async component, which is rendered
  6235. // as a comment node but preserves all the raw information for the node.
  6236. // the information will be used for async server-rendering and hydration.
  6237. return createAsyncPlaceholder(
  6238. asyncFactory,
  6239. data,
  6240. context,
  6241. children,
  6242. tag
  6243. )
  6244. }
  6245. }
  6246. data = data || {};
  6247. // resolve constructor options in case global mixins are applied after
  6248. // component constructor creation
  6249. resolveConstructorOptions(Ctor);
  6250. // transform component v-model data into props & events
  6251. if (isDef(data.model)) {
  6252. transformModel(Ctor.options, data);
  6253. }
  6254. // extract props
  6255. var propsData = extractPropsFromVNodeData(data, Ctor, tag, context); // fixed by xxxxxx
  6256. // functional component
  6257. if (isTrue(Ctor.options.functional)) {
  6258. return createFunctionalComponent(Ctor, propsData, data, context, children)
  6259. }
  6260. // extract listeners, since these needs to be treated as
  6261. // child component listeners instead of DOM listeners
  6262. var listeners = data.on;
  6263. // replace with listeners with .native modifier
  6264. // so it gets processed during parent component patch.
  6265. data.on = data.nativeOn;
  6266. if (isTrue(Ctor.options.abstract)) {
  6267. // abstract components do not keep anything
  6268. // other than props & listeners & slot
  6269. // work around flow
  6270. var slot = data.slot;
  6271. data = {};
  6272. if (slot) {
  6273. data.slot = slot;
  6274. }
  6275. }
  6276. // install component management hooks onto the placeholder node
  6277. installComponentHooks(data);
  6278. // return a placeholder vnode
  6279. var name = Ctor.options.name || tag;
  6280. var vnode = new VNode(
  6281. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  6282. data, undefined, undefined, undefined, context,
  6283. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  6284. asyncFactory
  6285. );
  6286. return vnode
  6287. }
  6288. function createComponentInstanceForVnode (
  6289. vnode, // we know it's MountedComponentVNode but flow doesn't
  6290. parent // activeInstance in lifecycle state
  6291. ) {
  6292. var options = {
  6293. _isComponent: true,
  6294. _parentVnode: vnode,
  6295. parent: parent
  6296. };
  6297. // check inline-template render functions
  6298. var inlineTemplate = vnode.data.inlineTemplate;
  6299. if (isDef(inlineTemplate)) {
  6300. options.render = inlineTemplate.render;
  6301. options.staticRenderFns = inlineTemplate.staticRenderFns;
  6302. }
  6303. return new vnode.componentOptions.Ctor(options)
  6304. }
  6305. function installComponentHooks (data) {
  6306. var hooks = data.hook || (data.hook = {});
  6307. for (var i = 0; i < hooksToMerge.length; i++) {
  6308. var key = hooksToMerge[i];
  6309. var existing = hooks[key];
  6310. var toMerge = componentVNodeHooks[key];
  6311. if (existing !== toMerge && !(existing && existing._merged)) {
  6312. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  6313. }
  6314. }
  6315. }
  6316. function mergeHook$1 (f1, f2) {
  6317. var merged = function (a, b) {
  6318. // flow complains about extra args which is why we use any
  6319. f1(a, b);
  6320. f2(a, b);
  6321. };
  6322. merged._merged = true;
  6323. return merged
  6324. }
  6325. // transform component v-model info (value and callback) into
  6326. // prop and event handler respectively.
  6327. function transformModel (options, data) {
  6328. var prop = (options.model && options.model.prop) || 'value';
  6329. var event = (options.model && options.model.event) || 'input'
  6330. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  6331. var on = data.on || (data.on = {});
  6332. var existing = on[event];
  6333. var callback = data.model.callback;
  6334. if (isDef(existing)) {
  6335. if (
  6336. Array.isArray(existing)
  6337. ? existing.indexOf(callback) === -1
  6338. : existing !== callback
  6339. ) {
  6340. on[event] = [callback].concat(existing);
  6341. }
  6342. } else {
  6343. on[event] = callback;
  6344. }
  6345. }
  6346. /* */
  6347. var SIMPLE_NORMALIZE = 1;
  6348. var ALWAYS_NORMALIZE = 2;
  6349. // wrapper function for providing a more flexible interface
  6350. // without getting yelled at by flow
  6351. function createElement (
  6352. context,
  6353. tag,
  6354. data,
  6355. children,
  6356. normalizationType,
  6357. alwaysNormalize
  6358. ) {
  6359. if (Array.isArray(data) || isPrimitive(data)) {
  6360. normalizationType = children;
  6361. children = data;
  6362. data = undefined;
  6363. }
  6364. if (isTrue(alwaysNormalize)) {
  6365. normalizationType = ALWAYS_NORMALIZE;
  6366. }
  6367. return _createElement(context, tag, data, children, normalizationType)
  6368. }
  6369. function _createElement (
  6370. context,
  6371. tag,
  6372. data,
  6373. children,
  6374. normalizationType
  6375. ) {
  6376. if (isDef(data) && isDef((data).__ob__)) {
  6377. true && warn(
  6378. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  6379. 'Always create fresh vnode data objects in each render!',
  6380. context
  6381. );
  6382. return createEmptyVNode()
  6383. }
  6384. // object syntax in v-bind
  6385. if (isDef(data) && isDef(data.is)) {
  6386. tag = data.is;
  6387. }
  6388. if (!tag) {
  6389. // in case of component :is set to falsy value
  6390. return createEmptyVNode()
  6391. }
  6392. // warn against non-primitive key
  6393. if ( true &&
  6394. isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  6395. ) {
  6396. {
  6397. warn(
  6398. 'Avoid using non-primitive value as key, ' +
  6399. 'use string/number value instead.',
  6400. context
  6401. );
  6402. }
  6403. }
  6404. // support single function children as default scoped slot
  6405. if (Array.isArray(children) &&
  6406. typeof children[0] === 'function'
  6407. ) {
  6408. data = data || {};
  6409. data.scopedSlots = { default: children[0] };
  6410. children.length = 0;
  6411. }
  6412. if (normalizationType === ALWAYS_NORMALIZE) {
  6413. children = normalizeChildren(children);
  6414. } else if (normalizationType === SIMPLE_NORMALIZE) {
  6415. children = simpleNormalizeChildren(children);
  6416. }
  6417. var vnode, ns;
  6418. if (typeof tag === 'string') {
  6419. var Ctor;
  6420. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  6421. if (config.isReservedTag(tag)) {
  6422. // platform built-in elements
  6423. if ( true && isDef(data) && isDef(data.nativeOn)) {
  6424. warn(
  6425. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  6426. context
  6427. );
  6428. }
  6429. vnode = new VNode(
  6430. config.parsePlatformTagName(tag), data, children,
  6431. undefined, undefined, context
  6432. );
  6433. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  6434. // component
  6435. vnode = createComponent(Ctor, data, context, children, tag);
  6436. } else {
  6437. // unknown or unlisted namespaced elements
  6438. // check at runtime because it may get assigned a namespace when its
  6439. // parent normalizes children
  6440. vnode = new VNode(
  6441. tag, data, children,
  6442. undefined, undefined, context
  6443. );
  6444. }
  6445. } else {
  6446. // direct component options / constructor
  6447. vnode = createComponent(tag, data, context, children);
  6448. }
  6449. if (Array.isArray(vnode)) {
  6450. return vnode
  6451. } else if (isDef(vnode)) {
  6452. if (isDef(ns)) { applyNS(vnode, ns); }
  6453. if (isDef(data)) { registerDeepBindings(data); }
  6454. return vnode
  6455. } else {
  6456. return createEmptyVNode()
  6457. }
  6458. }
  6459. function applyNS (vnode, ns, force) {
  6460. vnode.ns = ns;
  6461. if (vnode.tag === 'foreignObject') {
  6462. // use default namespace inside foreignObject
  6463. ns = undefined;
  6464. force = true;
  6465. }
  6466. if (isDef(vnode.children)) {
  6467. for (var i = 0, l = vnode.children.length; i < l; i++) {
  6468. var child = vnode.children[i];
  6469. if (isDef(child.tag) && (
  6470. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  6471. applyNS(child, ns, force);
  6472. }
  6473. }
  6474. }
  6475. }
  6476. // ref #5318
  6477. // necessary to ensure parent re-render when deep bindings like :style and
  6478. // :class are used on slot nodes
  6479. function registerDeepBindings (data) {
  6480. if (isObject(data.style)) {
  6481. traverse(data.style);
  6482. }
  6483. if (isObject(data.class)) {
  6484. traverse(data.class);
  6485. }
  6486. }
  6487. /* */
  6488. function initRender (vm) {
  6489. vm._vnode = null; // the root of the child tree
  6490. vm._staticTrees = null; // v-once cached trees
  6491. var options = vm.$options;
  6492. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  6493. var renderContext = parentVnode && parentVnode.context;
  6494. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  6495. vm.$scopedSlots = emptyObject;
  6496. // bind the createElement fn to this instance
  6497. // so that we get proper render context inside it.
  6498. // args order: tag, data, children, normalizationType, alwaysNormalize
  6499. // internal version is used by render functions compiled from templates
  6500. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  6501. // normalization is always applied for the public version, used in
  6502. // user-written render functions.
  6503. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  6504. // $attrs & $listeners are exposed for easier HOC creation.
  6505. // they need to be reactive so that HOCs using them are always updated
  6506. var parentData = parentVnode && parentVnode.data;
  6507. /* istanbul ignore else */
  6508. if (true) {
  6509. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  6510. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  6511. }, true);
  6512. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  6513. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  6514. }, true);
  6515. } else {}
  6516. }
  6517. var currentRenderingInstance = null;
  6518. function renderMixin (Vue) {
  6519. // install runtime convenience helpers
  6520. installRenderHelpers(Vue.prototype);
  6521. Vue.prototype.$nextTick = function (fn) {
  6522. return nextTick(fn, this)
  6523. };
  6524. Vue.prototype._render = function () {
  6525. var vm = this;
  6526. var ref = vm.$options;
  6527. var render = ref.render;
  6528. var _parentVnode = ref._parentVnode;
  6529. if (_parentVnode) {
  6530. vm.$scopedSlots = normalizeScopedSlots(
  6531. _parentVnode.data.scopedSlots,
  6532. vm.$slots,
  6533. vm.$scopedSlots
  6534. );
  6535. }
  6536. // set parent vnode. this allows render functions to have access
  6537. // to the data on the placeholder node.
  6538. vm.$vnode = _parentVnode;
  6539. // render self
  6540. var vnode;
  6541. try {
  6542. // There's no need to maintain a stack because all render fns are called
  6543. // separately from one another. Nested component's render fns are called
  6544. // when parent component is patched.
  6545. currentRenderingInstance = vm;
  6546. vnode = render.call(vm._renderProxy, vm.$createElement);
  6547. } catch (e) {
  6548. handleError(e, vm, "render");
  6549. // return error render result,
  6550. // or previous vnode to prevent render error causing blank component
  6551. /* istanbul ignore else */
  6552. if ( true && vm.$options.renderError) {
  6553. try {
  6554. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  6555. } catch (e) {
  6556. handleError(e, vm, "renderError");
  6557. vnode = vm._vnode;
  6558. }
  6559. } else {
  6560. vnode = vm._vnode;
  6561. }
  6562. } finally {
  6563. currentRenderingInstance = null;
  6564. }
  6565. // if the returned array contains only a single node, allow it
  6566. if (Array.isArray(vnode) && vnode.length === 1) {
  6567. vnode = vnode[0];
  6568. }
  6569. // return empty vnode in case the render function errored out
  6570. if (!(vnode instanceof VNode)) {
  6571. if ( true && Array.isArray(vnode)) {
  6572. warn(
  6573. 'Multiple root nodes returned from render function. Render function ' +
  6574. 'should return a single root node.',
  6575. vm
  6576. );
  6577. }
  6578. vnode = createEmptyVNode();
  6579. }
  6580. // set parent
  6581. vnode.parent = _parentVnode;
  6582. return vnode
  6583. };
  6584. }
  6585. /* */
  6586. function ensureCtor (comp, base) {
  6587. if (
  6588. comp.__esModule ||
  6589. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  6590. ) {
  6591. comp = comp.default;
  6592. }
  6593. return isObject(comp)
  6594. ? base.extend(comp)
  6595. : comp
  6596. }
  6597. function createAsyncPlaceholder (
  6598. factory,
  6599. data,
  6600. context,
  6601. children,
  6602. tag
  6603. ) {
  6604. var node = createEmptyVNode();
  6605. node.asyncFactory = factory;
  6606. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  6607. return node
  6608. }
  6609. function resolveAsyncComponent (
  6610. factory,
  6611. baseCtor
  6612. ) {
  6613. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  6614. return factory.errorComp
  6615. }
  6616. if (isDef(factory.resolved)) {
  6617. return factory.resolved
  6618. }
  6619. var owner = currentRenderingInstance;
  6620. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  6621. // already pending
  6622. factory.owners.push(owner);
  6623. }
  6624. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  6625. return factory.loadingComp
  6626. }
  6627. if (owner && !isDef(factory.owners)) {
  6628. var owners = factory.owners = [owner];
  6629. var sync = true;
  6630. var timerLoading = null;
  6631. var timerTimeout = null
  6632. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  6633. var forceRender = function (renderCompleted) {
  6634. for (var i = 0, l = owners.length; i < l; i++) {
  6635. (owners[i]).$forceUpdate();
  6636. }
  6637. if (renderCompleted) {
  6638. owners.length = 0;
  6639. if (timerLoading !== null) {
  6640. clearTimeout(timerLoading);
  6641. timerLoading = null;
  6642. }
  6643. if (timerTimeout !== null) {
  6644. clearTimeout(timerTimeout);
  6645. timerTimeout = null;
  6646. }
  6647. }
  6648. };
  6649. var resolve = once(function (res) {
  6650. // cache resolved
  6651. factory.resolved = ensureCtor(res, baseCtor);
  6652. // invoke callbacks only if this is not a synchronous resolve
  6653. // (async resolves are shimmed as synchronous during SSR)
  6654. if (!sync) {
  6655. forceRender(true);
  6656. } else {
  6657. owners.length = 0;
  6658. }
  6659. });
  6660. var reject = once(function (reason) {
  6661. true && warn(
  6662. "Failed to resolve async component: " + (String(factory)) +
  6663. (reason ? ("\nReason: " + reason) : '')
  6664. );
  6665. if (isDef(factory.errorComp)) {
  6666. factory.error = true;
  6667. forceRender(true);
  6668. }
  6669. });
  6670. var res = factory(resolve, reject);
  6671. if (isObject(res)) {
  6672. if (isPromise(res)) {
  6673. // () => Promise
  6674. if (isUndef(factory.resolved)) {
  6675. res.then(resolve, reject);
  6676. }
  6677. } else if (isPromise(res.component)) {
  6678. res.component.then(resolve, reject);
  6679. if (isDef(res.error)) {
  6680. factory.errorComp = ensureCtor(res.error, baseCtor);
  6681. }
  6682. if (isDef(res.loading)) {
  6683. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  6684. if (res.delay === 0) {
  6685. factory.loading = true;
  6686. } else {
  6687. timerLoading = setTimeout(function () {
  6688. timerLoading = null;
  6689. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  6690. factory.loading = true;
  6691. forceRender(false);
  6692. }
  6693. }, res.delay || 200);
  6694. }
  6695. }
  6696. if (isDef(res.timeout)) {
  6697. timerTimeout = setTimeout(function () {
  6698. timerTimeout = null;
  6699. if (isUndef(factory.resolved)) {
  6700. reject(
  6701. true
  6702. ? ("timeout (" + (res.timeout) + "ms)")
  6703. : undefined
  6704. );
  6705. }
  6706. }, res.timeout);
  6707. }
  6708. }
  6709. }
  6710. sync = false;
  6711. // return in case resolved synchronously
  6712. return factory.loading
  6713. ? factory.loadingComp
  6714. : factory.resolved
  6715. }
  6716. }
  6717. /* */
  6718. function isAsyncPlaceholder (node) {
  6719. return node.isComment && node.asyncFactory
  6720. }
  6721. /* */
  6722. function getFirstComponentChild (children) {
  6723. if (Array.isArray(children)) {
  6724. for (var i = 0; i < children.length; i++) {
  6725. var c = children[i];
  6726. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  6727. return c
  6728. }
  6729. }
  6730. }
  6731. }
  6732. /* */
  6733. /* */
  6734. function initEvents (vm) {
  6735. vm._events = Object.create(null);
  6736. vm._hasHookEvent = false;
  6737. // init parent attached events
  6738. var listeners = vm.$options._parentListeners;
  6739. if (listeners) {
  6740. updateComponentListeners(vm, listeners);
  6741. }
  6742. }
  6743. var target;
  6744. function add (event, fn) {
  6745. target.$on(event, fn);
  6746. }
  6747. function remove$1 (event, fn) {
  6748. target.$off(event, fn);
  6749. }
  6750. function createOnceHandler (event, fn) {
  6751. var _target = target;
  6752. return function onceHandler () {
  6753. var res = fn.apply(null, arguments);
  6754. if (res !== null) {
  6755. _target.$off(event, onceHandler);
  6756. }
  6757. }
  6758. }
  6759. function updateComponentListeners (
  6760. vm,
  6761. listeners,
  6762. oldListeners
  6763. ) {
  6764. target = vm;
  6765. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  6766. target = undefined;
  6767. }
  6768. function eventsMixin (Vue) {
  6769. var hookRE = /^hook:/;
  6770. Vue.prototype.$on = function (event, fn) {
  6771. var vm = this;
  6772. if (Array.isArray(event)) {
  6773. for (var i = 0, l = event.length; i < l; i++) {
  6774. vm.$on(event[i], fn);
  6775. }
  6776. } else {
  6777. (vm._events[event] || (vm._events[event] = [])).push(fn);
  6778. // optimize hook:event cost by using a boolean flag marked at registration
  6779. // instead of a hash lookup
  6780. if (hookRE.test(event)) {
  6781. vm._hasHookEvent = true;
  6782. }
  6783. }
  6784. return vm
  6785. };
  6786. Vue.prototype.$once = function (event, fn) {
  6787. var vm = this;
  6788. function on () {
  6789. vm.$off(event, on);
  6790. fn.apply(vm, arguments);
  6791. }
  6792. on.fn = fn;
  6793. vm.$on(event, on);
  6794. return vm
  6795. };
  6796. Vue.prototype.$off = function (event, fn) {
  6797. var vm = this;
  6798. // all
  6799. if (!arguments.length) {
  6800. vm._events = Object.create(null);
  6801. return vm
  6802. }
  6803. // array of events
  6804. if (Array.isArray(event)) {
  6805. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  6806. vm.$off(event[i$1], fn);
  6807. }
  6808. return vm
  6809. }
  6810. // specific event
  6811. var cbs = vm._events[event];
  6812. if (!cbs) {
  6813. return vm
  6814. }
  6815. if (!fn) {
  6816. vm._events[event] = null;
  6817. return vm
  6818. }
  6819. // specific handler
  6820. var cb;
  6821. var i = cbs.length;
  6822. while (i--) {
  6823. cb = cbs[i];
  6824. if (cb === fn || cb.fn === fn) {
  6825. cbs.splice(i, 1);
  6826. break
  6827. }
  6828. }
  6829. return vm
  6830. };
  6831. Vue.prototype.$emit = function (event) {
  6832. var vm = this;
  6833. if (true) {
  6834. var lowerCaseEvent = event.toLowerCase();
  6835. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  6836. tip(
  6837. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  6838. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  6839. "Note that HTML attributes are case-insensitive and you cannot use " +
  6840. "v-on to listen to camelCase events when using in-DOM templates. " +
  6841. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  6842. );
  6843. }
  6844. }
  6845. var cbs = vm._events[event];
  6846. if (cbs) {
  6847. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  6848. var args = toArray(arguments, 1);
  6849. var info = "event handler for \"" + event + "\"";
  6850. for (var i = 0, l = cbs.length; i < l; i++) {
  6851. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  6852. }
  6853. }
  6854. return vm
  6855. };
  6856. }
  6857. /* */
  6858. var activeInstance = null;
  6859. var isUpdatingChildComponent = false;
  6860. function setActiveInstance(vm) {
  6861. var prevActiveInstance = activeInstance;
  6862. activeInstance = vm;
  6863. return function () {
  6864. activeInstance = prevActiveInstance;
  6865. }
  6866. }
  6867. function initLifecycle (vm) {
  6868. var options = vm.$options;
  6869. // locate first non-abstract parent
  6870. var parent = options.parent;
  6871. if (parent && !options.abstract) {
  6872. while (parent.$options.abstract && parent.$parent) {
  6873. parent = parent.$parent;
  6874. }
  6875. parent.$children.push(vm);
  6876. }
  6877. vm.$parent = parent;
  6878. vm.$root = parent ? parent.$root : vm;
  6879. vm.$children = [];
  6880. vm.$refs = {};
  6881. vm._watcher = null;
  6882. vm._inactive = null;
  6883. vm._directInactive = false;
  6884. vm._isMounted = false;
  6885. vm._isDestroyed = false;
  6886. vm._isBeingDestroyed = false;
  6887. }
  6888. function lifecycleMixin (Vue) {
  6889. Vue.prototype._update = function (vnode, hydrating) {
  6890. var vm = this;
  6891. var prevEl = vm.$el;
  6892. var prevVnode = vm._vnode;
  6893. var restoreActiveInstance = setActiveInstance(vm);
  6894. vm._vnode = vnode;
  6895. // Vue.prototype.__patch__ is injected in entry points
  6896. // based on the rendering backend used.
  6897. if (!prevVnode) {
  6898. // initial render
  6899. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  6900. } else {
  6901. // updates
  6902. vm.$el = vm.__patch__(prevVnode, vnode);
  6903. }
  6904. restoreActiveInstance();
  6905. // update __vue__ reference
  6906. if (prevEl) {
  6907. prevEl.__vue__ = null;
  6908. }
  6909. if (vm.$el) {
  6910. vm.$el.__vue__ = vm;
  6911. }
  6912. // if parent is an HOC, update its $el as well
  6913. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  6914. vm.$parent.$el = vm.$el;
  6915. }
  6916. // updated hook is called by the scheduler to ensure that children are
  6917. // updated in a parent's updated hook.
  6918. };
  6919. Vue.prototype.$forceUpdate = function () {
  6920. var vm = this;
  6921. if (vm._watcher) {
  6922. vm._watcher.update();
  6923. }
  6924. };
  6925. Vue.prototype.$destroy = function () {
  6926. var vm = this;
  6927. if (vm._isBeingDestroyed) {
  6928. return
  6929. }
  6930. callHook(vm, 'beforeDestroy');
  6931. vm._isBeingDestroyed = true;
  6932. // remove self from parent
  6933. var parent = vm.$parent;
  6934. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  6935. remove(parent.$children, vm);
  6936. }
  6937. // teardown watchers
  6938. if (vm._watcher) {
  6939. vm._watcher.teardown();
  6940. }
  6941. var i = vm._watchers.length;
  6942. while (i--) {
  6943. vm._watchers[i].teardown();
  6944. }
  6945. // remove reference from data ob
  6946. // frozen object may not have observer.
  6947. if (vm._data.__ob__) {
  6948. vm._data.__ob__.vmCount--;
  6949. }
  6950. // call the last hook...
  6951. vm._isDestroyed = true;
  6952. // invoke destroy hooks on current rendered tree
  6953. vm.__patch__(vm._vnode, null);
  6954. // fire destroyed hook
  6955. callHook(vm, 'destroyed');
  6956. // turn off all instance listeners.
  6957. vm.$off();
  6958. // remove __vue__ reference
  6959. if (vm.$el) {
  6960. vm.$el.__vue__ = null;
  6961. }
  6962. // release circular reference (#6759)
  6963. if (vm.$vnode) {
  6964. vm.$vnode.parent = null;
  6965. }
  6966. };
  6967. }
  6968. function updateChildComponent (
  6969. vm,
  6970. propsData,
  6971. listeners,
  6972. parentVnode,
  6973. renderChildren
  6974. ) {
  6975. if (true) {
  6976. isUpdatingChildComponent = true;
  6977. }
  6978. // determine whether component has slot children
  6979. // we need to do this before overwriting $options._renderChildren.
  6980. // check if there are dynamic scopedSlots (hand-written or compiled but with
  6981. // dynamic slot names). Static scoped slots compiled from template has the
  6982. // "$stable" marker.
  6983. var newScopedSlots = parentVnode.data.scopedSlots;
  6984. var oldScopedSlots = vm.$scopedSlots;
  6985. var hasDynamicScopedSlot = !!(
  6986. (newScopedSlots && !newScopedSlots.$stable) ||
  6987. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  6988. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  6989. );
  6990. // Any static slot children from the parent may have changed during parent's
  6991. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  6992. // update is necessary to ensure correctness.
  6993. var needsForceUpdate = !!(
  6994. renderChildren || // has new static slots
  6995. vm.$options._renderChildren || // has old static slots
  6996. hasDynamicScopedSlot
  6997. );
  6998. vm.$options._parentVnode = parentVnode;
  6999. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  7000. if (vm._vnode) { // update child tree's parent
  7001. vm._vnode.parent = parentVnode;
  7002. }
  7003. vm.$options._renderChildren = renderChildren;
  7004. // update $attrs and $listeners hash
  7005. // these are also reactive so they may trigger child update if the child
  7006. // used them during render
  7007. vm.$attrs = parentVnode.data.attrs || emptyObject;
  7008. vm.$listeners = listeners || emptyObject;
  7009. // update props
  7010. if (propsData && vm.$options.props) {
  7011. toggleObserving(false);
  7012. var props = vm._props;
  7013. var propKeys = vm.$options._propKeys || [];
  7014. for (var i = 0; i < propKeys.length; i++) {
  7015. var key = propKeys[i];
  7016. var propOptions = vm.$options.props; // wtf flow?
  7017. props[key] = validateProp(key, propOptions, propsData, vm);
  7018. }
  7019. toggleObserving(true);
  7020. // keep a copy of raw propsData
  7021. vm.$options.propsData = propsData;
  7022. }
  7023. // fixed by xxxxxx update properties(mp runtime)
  7024. vm._$updateProperties && vm._$updateProperties(vm);
  7025. // update listeners
  7026. listeners = listeners || emptyObject;
  7027. var oldListeners = vm.$options._parentListeners;
  7028. vm.$options._parentListeners = listeners;
  7029. updateComponentListeners(vm, listeners, oldListeners);
  7030. // resolve slots + force update if has children
  7031. if (needsForceUpdate) {
  7032. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  7033. vm.$forceUpdate();
  7034. }
  7035. if (true) {
  7036. isUpdatingChildComponent = false;
  7037. }
  7038. }
  7039. function isInInactiveTree (vm) {
  7040. while (vm && (vm = vm.$parent)) {
  7041. if (vm._inactive) { return true }
  7042. }
  7043. return false
  7044. }
  7045. function activateChildComponent (vm, direct) {
  7046. if (direct) {
  7047. vm._directInactive = false;
  7048. if (isInInactiveTree(vm)) {
  7049. return
  7050. }
  7051. } else if (vm._directInactive) {
  7052. return
  7053. }
  7054. if (vm._inactive || vm._inactive === null) {
  7055. vm._inactive = false;
  7056. for (var i = 0; i < vm.$children.length; i++) {
  7057. activateChildComponent(vm.$children[i]);
  7058. }
  7059. callHook(vm, 'activated');
  7060. }
  7061. }
  7062. function deactivateChildComponent (vm, direct) {
  7063. if (direct) {
  7064. vm._directInactive = true;
  7065. if (isInInactiveTree(vm)) {
  7066. return
  7067. }
  7068. }
  7069. if (!vm._inactive) {
  7070. vm._inactive = true;
  7071. for (var i = 0; i < vm.$children.length; i++) {
  7072. deactivateChildComponent(vm.$children[i]);
  7073. }
  7074. callHook(vm, 'deactivated');
  7075. }
  7076. }
  7077. function callHook (vm, hook) {
  7078. // #7573 disable dep collection when invoking lifecycle hooks
  7079. pushTarget();
  7080. var handlers = vm.$options[hook];
  7081. var info = hook + " hook";
  7082. if (handlers) {
  7083. for (var i = 0, j = handlers.length; i < j; i++) {
  7084. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  7085. }
  7086. }
  7087. if (vm._hasHookEvent) {
  7088. vm.$emit('hook:' + hook);
  7089. }
  7090. popTarget();
  7091. }
  7092. /* */
  7093. var MAX_UPDATE_COUNT = 100;
  7094. var queue = [];
  7095. var activatedChildren = [];
  7096. var has = {};
  7097. var circular = {};
  7098. var waiting = false;
  7099. var flushing = false;
  7100. var index = 0;
  7101. /**
  7102. * Reset the scheduler's state.
  7103. */
  7104. function resetSchedulerState () {
  7105. index = queue.length = activatedChildren.length = 0;
  7106. has = {};
  7107. if (true) {
  7108. circular = {};
  7109. }
  7110. waiting = flushing = false;
  7111. }
  7112. // Async edge case #6566 requires saving the timestamp when event listeners are
  7113. // attached. However, calling performance.now() has a perf overhead especially
  7114. // if the page has thousands of event listeners. Instead, we take a timestamp
  7115. // every time the scheduler flushes and use that for all event listeners
  7116. // attached during that flush.
  7117. var currentFlushTimestamp = 0;
  7118. // Async edge case fix requires storing an event listener's attach timestamp.
  7119. var getNow = Date.now;
  7120. // Determine what event timestamp the browser is using. Annoyingly, the
  7121. // timestamp can either be hi-res (relative to page load) or low-res
  7122. // (relative to UNIX epoch), so in order to compare time we have to use the
  7123. // same timestamp type when saving the flush timestamp.
  7124. // All IE versions use low-res event timestamps, and have problematic clock
  7125. // implementations (#9632)
  7126. if (inBrowser && !isIE) {
  7127. var performance = window.performance;
  7128. if (
  7129. performance &&
  7130. typeof performance.now === 'function' &&
  7131. getNow() > document.createEvent('Event').timeStamp
  7132. ) {
  7133. // if the event timestamp, although evaluated AFTER the Date.now(), is
  7134. // smaller than it, it means the event is using a hi-res timestamp,
  7135. // and we need to use the hi-res version for event listener timestamps as
  7136. // well.
  7137. getNow = function () { return performance.now(); };
  7138. }
  7139. }
  7140. /**
  7141. * Flush both queues and run the watchers.
  7142. */
  7143. function flushSchedulerQueue () {
  7144. currentFlushTimestamp = getNow();
  7145. flushing = true;
  7146. var watcher, id;
  7147. // Sort queue before flush.
  7148. // This ensures that:
  7149. // 1. Components are updated from parent to child. (because parent is always
  7150. // created before the child)
  7151. // 2. A component's user watchers are run before its render watcher (because
  7152. // user watchers are created before the render watcher)
  7153. // 3. If a component is destroyed during a parent component's watcher run,
  7154. // its watchers can be skipped.
  7155. queue.sort(function (a, b) { return a.id - b.id; });
  7156. // do not cache length because more watchers might be pushed
  7157. // as we run existing watchers
  7158. for (index = 0; index < queue.length; index++) {
  7159. watcher = queue[index];
  7160. if (watcher.before) {
  7161. watcher.before();
  7162. }
  7163. id = watcher.id;
  7164. has[id] = null;
  7165. watcher.run();
  7166. // in dev build, check and stop circular updates.
  7167. if ( true && has[id] != null) {
  7168. circular[id] = (circular[id] || 0) + 1;
  7169. if (circular[id] > MAX_UPDATE_COUNT) {
  7170. warn(
  7171. 'You may have an infinite update loop ' + (
  7172. watcher.user
  7173. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  7174. : "in a component render function."
  7175. ),
  7176. watcher.vm
  7177. );
  7178. break
  7179. }
  7180. }
  7181. }
  7182. // keep copies of post queues before resetting state
  7183. var activatedQueue = activatedChildren.slice();
  7184. var updatedQueue = queue.slice();
  7185. resetSchedulerState();
  7186. // call component updated and activated hooks
  7187. callActivatedHooks(activatedQueue);
  7188. callUpdatedHooks(updatedQueue);
  7189. // devtool hook
  7190. /* istanbul ignore if */
  7191. if (devtools && config.devtools) {
  7192. devtools.emit('flush');
  7193. }
  7194. }
  7195. function callUpdatedHooks (queue) {
  7196. var i = queue.length;
  7197. while (i--) {
  7198. var watcher = queue[i];
  7199. var vm = watcher.vm;
  7200. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  7201. callHook(vm, 'updated');
  7202. }
  7203. }
  7204. }
  7205. /**
  7206. * Queue a kept-alive component that was activated during patch.
  7207. * The queue will be processed after the entire tree has been patched.
  7208. */
  7209. function queueActivatedComponent (vm) {
  7210. // setting _inactive to false here so that a render function can
  7211. // rely on checking whether it's in an inactive tree (e.g. router-view)
  7212. vm._inactive = false;
  7213. activatedChildren.push(vm);
  7214. }
  7215. function callActivatedHooks (queue) {
  7216. for (var i = 0; i < queue.length; i++) {
  7217. queue[i]._inactive = true;
  7218. activateChildComponent(queue[i], true /* true */);
  7219. }
  7220. }
  7221. /**
  7222. * Push a watcher into the watcher queue.
  7223. * Jobs with duplicate IDs will be skipped unless it's
  7224. * pushed when the queue is being flushed.
  7225. */
  7226. function queueWatcher (watcher) {
  7227. var id = watcher.id;
  7228. if (has[id] == null) {
  7229. has[id] = true;
  7230. if (!flushing) {
  7231. queue.push(watcher);
  7232. } else {
  7233. // if already flushing, splice the watcher based on its id
  7234. // if already past its id, it will be run next immediately.
  7235. var i = queue.length - 1;
  7236. while (i > index && queue[i].id > watcher.id) {
  7237. i--;
  7238. }
  7239. queue.splice(i + 1, 0, watcher);
  7240. }
  7241. // queue the flush
  7242. if (!waiting) {
  7243. waiting = true;
  7244. if ( true && !config.async) {
  7245. flushSchedulerQueue();
  7246. return
  7247. }
  7248. nextTick(flushSchedulerQueue);
  7249. }
  7250. }
  7251. }
  7252. /* */
  7253. var uid$2 = 0;
  7254. /**
  7255. * A watcher parses an expression, collects dependencies,
  7256. * and fires callback when the expression value changes.
  7257. * This is used for both the $watch() api and directives.
  7258. */
  7259. var Watcher = function Watcher (
  7260. vm,
  7261. expOrFn,
  7262. cb,
  7263. options,
  7264. isRenderWatcher
  7265. ) {
  7266. this.vm = vm;
  7267. if (isRenderWatcher) {
  7268. vm._watcher = this;
  7269. }
  7270. vm._watchers.push(this);
  7271. // options
  7272. if (options) {
  7273. this.deep = !!options.deep;
  7274. this.user = !!options.user;
  7275. this.lazy = !!options.lazy;
  7276. this.sync = !!options.sync;
  7277. this.before = options.before;
  7278. } else {
  7279. this.deep = this.user = this.lazy = this.sync = false;
  7280. }
  7281. this.cb = cb;
  7282. this.id = ++uid$2; // uid for batching
  7283. this.active = true;
  7284. this.dirty = this.lazy; // for lazy watchers
  7285. this.deps = [];
  7286. this.newDeps = [];
  7287. this.depIds = new _Set();
  7288. this.newDepIds = new _Set();
  7289. this.expression = true
  7290. ? expOrFn.toString()
  7291. : undefined;
  7292. // parse expression for getter
  7293. if (typeof expOrFn === 'function') {
  7294. this.getter = expOrFn;
  7295. } else {
  7296. this.getter = parsePath(expOrFn);
  7297. if (!this.getter) {
  7298. this.getter = noop;
  7299. true && warn(
  7300. "Failed watching path: \"" + expOrFn + "\" " +
  7301. 'Watcher only accepts simple dot-delimited paths. ' +
  7302. 'For full control, use a function instead.',
  7303. vm
  7304. );
  7305. }
  7306. }
  7307. this.value = this.lazy
  7308. ? undefined
  7309. : this.get();
  7310. };
  7311. /**
  7312. * Evaluate the getter, and re-collect dependencies.
  7313. */
  7314. Watcher.prototype.get = function get () {
  7315. pushTarget(this);
  7316. var value;
  7317. var vm = this.vm;
  7318. try {
  7319. value = this.getter.call(vm, vm);
  7320. } catch (e) {
  7321. if (this.user) {
  7322. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  7323. } else {
  7324. throw e
  7325. }
  7326. } finally {
  7327. // "touch" every property so they are all tracked as
  7328. // dependencies for deep watching
  7329. if (this.deep) {
  7330. traverse(value);
  7331. }
  7332. popTarget();
  7333. this.cleanupDeps();
  7334. }
  7335. return value
  7336. };
  7337. /**
  7338. * Add a dependency to this directive.
  7339. */
  7340. Watcher.prototype.addDep = function addDep (dep) {
  7341. var id = dep.id;
  7342. if (!this.newDepIds.has(id)) {
  7343. this.newDepIds.add(id);
  7344. this.newDeps.push(dep);
  7345. if (!this.depIds.has(id)) {
  7346. dep.addSub(this);
  7347. }
  7348. }
  7349. };
  7350. /**
  7351. * Clean up for dependency collection.
  7352. */
  7353. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  7354. var i = this.deps.length;
  7355. while (i--) {
  7356. var dep = this.deps[i];
  7357. if (!this.newDepIds.has(dep.id)) {
  7358. dep.removeSub(this);
  7359. }
  7360. }
  7361. var tmp = this.depIds;
  7362. this.depIds = this.newDepIds;
  7363. this.newDepIds = tmp;
  7364. this.newDepIds.clear();
  7365. tmp = this.deps;
  7366. this.deps = this.newDeps;
  7367. this.newDeps = tmp;
  7368. this.newDeps.length = 0;
  7369. };
  7370. /**
  7371. * Subscriber interface.
  7372. * Will be called when a dependency changes.
  7373. */
  7374. Watcher.prototype.update = function update () {
  7375. /* istanbul ignore else */
  7376. if (this.lazy) {
  7377. this.dirty = true;
  7378. } else if (this.sync) {
  7379. this.run();
  7380. } else {
  7381. queueWatcher(this);
  7382. }
  7383. };
  7384. /**
  7385. * Scheduler job interface.
  7386. * Will be called by the scheduler.
  7387. */
  7388. Watcher.prototype.run = function run () {
  7389. if (this.active) {
  7390. var value = this.get();
  7391. if (
  7392. value !== this.value ||
  7393. // Deep watchers and watchers on Object/Arrays should fire even
  7394. // when the value is the same, because the value may
  7395. // have mutated.
  7396. isObject(value) ||
  7397. this.deep
  7398. ) {
  7399. // set new value
  7400. var oldValue = this.value;
  7401. this.value = value;
  7402. if (this.user) {
  7403. try {
  7404. this.cb.call(this.vm, value, oldValue);
  7405. } catch (e) {
  7406. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  7407. }
  7408. } else {
  7409. this.cb.call(this.vm, value, oldValue);
  7410. }
  7411. }
  7412. }
  7413. };
  7414. /**
  7415. * Evaluate the value of the watcher.
  7416. * This only gets called for lazy watchers.
  7417. */
  7418. Watcher.prototype.evaluate = function evaluate () {
  7419. this.value = this.get();
  7420. this.dirty = false;
  7421. };
  7422. /**
  7423. * Depend on all deps collected by this watcher.
  7424. */
  7425. Watcher.prototype.depend = function depend () {
  7426. var i = this.deps.length;
  7427. while (i--) {
  7428. this.deps[i].depend();
  7429. }
  7430. };
  7431. /**
  7432. * Remove self from all dependencies' subscriber list.
  7433. */
  7434. Watcher.prototype.teardown = function teardown () {
  7435. if (this.active) {
  7436. // remove self from vm's watcher list
  7437. // this is a somewhat expensive operation so we skip it
  7438. // if the vm is being destroyed.
  7439. if (!this.vm._isBeingDestroyed) {
  7440. remove(this.vm._watchers, this);
  7441. }
  7442. var i = this.deps.length;
  7443. while (i--) {
  7444. this.deps[i].removeSub(this);
  7445. }
  7446. this.active = false;
  7447. }
  7448. };
  7449. /* */
  7450. var sharedPropertyDefinition = {
  7451. enumerable: true,
  7452. configurable: true,
  7453. get: noop,
  7454. set: noop
  7455. };
  7456. function proxy (target, sourceKey, key) {
  7457. sharedPropertyDefinition.get = function proxyGetter () {
  7458. return this[sourceKey][key]
  7459. };
  7460. sharedPropertyDefinition.set = function proxySetter (val) {
  7461. this[sourceKey][key] = val;
  7462. };
  7463. Object.defineProperty(target, key, sharedPropertyDefinition);
  7464. }
  7465. function initState (vm) {
  7466. vm._watchers = [];
  7467. var opts = vm.$options;
  7468. if (opts.props) { initProps(vm, opts.props); }
  7469. if (opts.methods) { initMethods(vm, opts.methods); }
  7470. if (opts.data) {
  7471. initData(vm);
  7472. } else {
  7473. observe(vm._data = {}, true /* asRootData */);
  7474. }
  7475. if (opts.computed) { initComputed(vm, opts.computed); }
  7476. if (opts.watch && opts.watch !== nativeWatch) {
  7477. initWatch(vm, opts.watch);
  7478. }
  7479. }
  7480. function initProps (vm, propsOptions) {
  7481. var propsData = vm.$options.propsData || {};
  7482. var props = vm._props = {};
  7483. // cache prop keys so that future props updates can iterate using Array
  7484. // instead of dynamic object key enumeration.
  7485. var keys = vm.$options._propKeys = [];
  7486. var isRoot = !vm.$parent;
  7487. // root instance props should be converted
  7488. if (!isRoot) {
  7489. toggleObserving(false);
  7490. }
  7491. var loop = function ( key ) {
  7492. keys.push(key);
  7493. var value = validateProp(key, propsOptions, propsData, vm);
  7494. /* istanbul ignore else */
  7495. if (true) {
  7496. var hyphenatedKey = hyphenate(key);
  7497. if (isReservedAttribute(hyphenatedKey) ||
  7498. config.isReservedAttr(hyphenatedKey)) {
  7499. warn(
  7500. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  7501. vm
  7502. );
  7503. }
  7504. defineReactive$$1(props, key, value, function () {
  7505. if (!isRoot && !isUpdatingChildComponent) {
  7506. {
  7507. if(vm.mpHost === 'mp-baidu' || vm.mpHost === 'mp-kuaishou' || vm.mpHost === 'mp-xhs'){//百度、快手、小红书 observer 在 setData callback 之后触发,直接忽略该 warn
  7508. return
  7509. }
  7510. //fixed by xxxxxx __next_tick_pending,uni://form-field 时不告警
  7511. if(
  7512. key === 'value' &&
  7513. Array.isArray(vm.$options.behaviors) &&
  7514. vm.$options.behaviors.indexOf('uni://form-field') !== -1
  7515. ){
  7516. return
  7517. }
  7518. if(vm._getFormData){
  7519. return
  7520. }
  7521. var $parent = vm.$parent;
  7522. while($parent){
  7523. if($parent.__next_tick_pending){
  7524. return
  7525. }
  7526. $parent = $parent.$parent;
  7527. }
  7528. }
  7529. warn(
  7530. "Avoid mutating a prop directly since the value will be " +
  7531. "overwritten whenever the parent component re-renders. " +
  7532. "Instead, use a data or computed property based on the prop's " +
  7533. "value. Prop being mutated: \"" + key + "\"",
  7534. vm
  7535. );
  7536. }
  7537. });
  7538. } else {}
  7539. // static props are already proxied on the component's prototype
  7540. // during Vue.extend(). We only need to proxy props defined at
  7541. // instantiation here.
  7542. if (!(key in vm)) {
  7543. proxy(vm, "_props", key);
  7544. }
  7545. };
  7546. for (var key in propsOptions) loop( key );
  7547. toggleObserving(true);
  7548. }
  7549. function initData (vm) {
  7550. var data = vm.$options.data;
  7551. data = vm._data = typeof data === 'function'
  7552. ? getData(data, vm)
  7553. : data || {};
  7554. if (!isPlainObject(data)) {
  7555. data = {};
  7556. true && warn(
  7557. 'data functions should return an object:\n' +
  7558. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  7559. vm
  7560. );
  7561. }
  7562. // proxy data on instance
  7563. var keys = Object.keys(data);
  7564. var props = vm.$options.props;
  7565. var methods = vm.$options.methods;
  7566. var i = keys.length;
  7567. while (i--) {
  7568. var key = keys[i];
  7569. if (true) {
  7570. if (methods && hasOwn(methods, key)) {
  7571. warn(
  7572. ("Method \"" + key + "\" has already been defined as a data property."),
  7573. vm
  7574. );
  7575. }
  7576. }
  7577. if (props && hasOwn(props, key)) {
  7578. true && warn(
  7579. "The data property \"" + key + "\" is already declared as a prop. " +
  7580. "Use prop default value instead.",
  7581. vm
  7582. );
  7583. } else if (!isReserved(key)) {
  7584. proxy(vm, "_data", key);
  7585. }
  7586. }
  7587. // observe data
  7588. observe(data, true /* asRootData */);
  7589. }
  7590. function getData (data, vm) {
  7591. // #7573 disable dep collection when invoking data getters
  7592. pushTarget();
  7593. try {
  7594. return data.call(vm, vm)
  7595. } catch (e) {
  7596. handleError(e, vm, "data()");
  7597. return {}
  7598. } finally {
  7599. popTarget();
  7600. }
  7601. }
  7602. var computedWatcherOptions = { lazy: true };
  7603. function initComputed (vm, computed) {
  7604. // $flow-disable-line
  7605. var watchers = vm._computedWatchers = Object.create(null);
  7606. // computed properties are just getters during SSR
  7607. var isSSR = isServerRendering();
  7608. for (var key in computed) {
  7609. var userDef = computed[key];
  7610. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  7611. if ( true && getter == null) {
  7612. warn(
  7613. ("Getter is missing for computed property \"" + key + "\"."),
  7614. vm
  7615. );
  7616. }
  7617. if (!isSSR) {
  7618. // create internal watcher for the computed property.
  7619. watchers[key] = new Watcher(
  7620. vm,
  7621. getter || noop,
  7622. noop,
  7623. computedWatcherOptions
  7624. );
  7625. }
  7626. // component-defined computed properties are already defined on the
  7627. // component prototype. We only need to define computed properties defined
  7628. // at instantiation here.
  7629. if (!(key in vm)) {
  7630. defineComputed(vm, key, userDef);
  7631. } else if (true) {
  7632. if (key in vm.$data) {
  7633. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  7634. } else if (vm.$options.props && key in vm.$options.props) {
  7635. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  7636. }
  7637. }
  7638. }
  7639. }
  7640. function defineComputed (
  7641. target,
  7642. key,
  7643. userDef
  7644. ) {
  7645. var shouldCache = !isServerRendering();
  7646. if (typeof userDef === 'function') {
  7647. sharedPropertyDefinition.get = shouldCache
  7648. ? createComputedGetter(key)
  7649. : createGetterInvoker(userDef);
  7650. sharedPropertyDefinition.set = noop;
  7651. } else {
  7652. sharedPropertyDefinition.get = userDef.get
  7653. ? shouldCache && userDef.cache !== false
  7654. ? createComputedGetter(key)
  7655. : createGetterInvoker(userDef.get)
  7656. : noop;
  7657. sharedPropertyDefinition.set = userDef.set || noop;
  7658. }
  7659. if ( true &&
  7660. sharedPropertyDefinition.set === noop) {
  7661. sharedPropertyDefinition.set = function () {
  7662. warn(
  7663. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  7664. this
  7665. );
  7666. };
  7667. }
  7668. Object.defineProperty(target, key, sharedPropertyDefinition);
  7669. }
  7670. function createComputedGetter (key) {
  7671. return function computedGetter () {
  7672. var watcher = this._computedWatchers && this._computedWatchers[key];
  7673. if (watcher) {
  7674. if (watcher.dirty) {
  7675. watcher.evaluate();
  7676. }
  7677. if (Dep.SharedObject.target) {// fixed by xxxxxx
  7678. watcher.depend();
  7679. }
  7680. return watcher.value
  7681. }
  7682. }
  7683. }
  7684. function createGetterInvoker(fn) {
  7685. return function computedGetter () {
  7686. return fn.call(this, this)
  7687. }
  7688. }
  7689. function initMethods (vm, methods) {
  7690. var props = vm.$options.props;
  7691. for (var key in methods) {
  7692. if (true) {
  7693. if (typeof methods[key] !== 'function') {
  7694. warn(
  7695. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  7696. "Did you reference the function correctly?",
  7697. vm
  7698. );
  7699. }
  7700. if (props && hasOwn(props, key)) {
  7701. warn(
  7702. ("Method \"" + key + "\" has already been defined as a prop."),
  7703. vm
  7704. );
  7705. }
  7706. if ((key in vm) && isReserved(key)) {
  7707. warn(
  7708. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  7709. "Avoid defining component methods that start with _ or $."
  7710. );
  7711. }
  7712. }
  7713. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  7714. }
  7715. }
  7716. function initWatch (vm, watch) {
  7717. for (var key in watch) {
  7718. var handler = watch[key];
  7719. if (Array.isArray(handler)) {
  7720. for (var i = 0; i < handler.length; i++) {
  7721. createWatcher(vm, key, handler[i]);
  7722. }
  7723. } else {
  7724. createWatcher(vm, key, handler);
  7725. }
  7726. }
  7727. }
  7728. function createWatcher (
  7729. vm,
  7730. expOrFn,
  7731. handler,
  7732. options
  7733. ) {
  7734. if (isPlainObject(handler)) {
  7735. options = handler;
  7736. handler = handler.handler;
  7737. }
  7738. if (typeof handler === 'string') {
  7739. handler = vm[handler];
  7740. }
  7741. return vm.$watch(expOrFn, handler, options)
  7742. }
  7743. function stateMixin (Vue) {
  7744. // flow somehow has problems with directly declared definition object
  7745. // when using Object.defineProperty, so we have to procedurally build up
  7746. // the object here.
  7747. var dataDef = {};
  7748. dataDef.get = function () { return this._data };
  7749. var propsDef = {};
  7750. propsDef.get = function () { return this._props };
  7751. if (true) {
  7752. dataDef.set = function () {
  7753. warn(
  7754. 'Avoid replacing instance root $data. ' +
  7755. 'Use nested data properties instead.',
  7756. this
  7757. );
  7758. };
  7759. propsDef.set = function () {
  7760. warn("$props is readonly.", this);
  7761. };
  7762. }
  7763. Object.defineProperty(Vue.prototype, '$data', dataDef);
  7764. Object.defineProperty(Vue.prototype, '$props', propsDef);
  7765. Vue.prototype.$set = set;
  7766. Vue.prototype.$delete = del;
  7767. Vue.prototype.$watch = function (
  7768. expOrFn,
  7769. cb,
  7770. options
  7771. ) {
  7772. var vm = this;
  7773. if (isPlainObject(cb)) {
  7774. return createWatcher(vm, expOrFn, cb, options)
  7775. }
  7776. options = options || {};
  7777. options.user = true;
  7778. var watcher = new Watcher(vm, expOrFn, cb, options);
  7779. if (options.immediate) {
  7780. try {
  7781. cb.call(vm, watcher.value);
  7782. } catch (error) {
  7783. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  7784. }
  7785. }
  7786. return function unwatchFn () {
  7787. watcher.teardown();
  7788. }
  7789. };
  7790. }
  7791. /* */
  7792. var uid$3 = 0;
  7793. function initMixin (Vue) {
  7794. Vue.prototype._init = function (options) {
  7795. var vm = this;
  7796. // a uid
  7797. vm._uid = uid$3++;
  7798. var startTag, endTag;
  7799. /* istanbul ignore if */
  7800. if ( true && config.performance && mark) {
  7801. startTag = "vue-perf-start:" + (vm._uid);
  7802. endTag = "vue-perf-end:" + (vm._uid);
  7803. mark(startTag);
  7804. }
  7805. // a flag to avoid this being observed
  7806. vm._isVue = true;
  7807. // merge options
  7808. if (options && options._isComponent) {
  7809. // optimize internal component instantiation
  7810. // since dynamic options merging is pretty slow, and none of the
  7811. // internal component options needs special treatment.
  7812. initInternalComponent(vm, options);
  7813. } else {
  7814. vm.$options = mergeOptions(
  7815. resolveConstructorOptions(vm.constructor),
  7816. options || {},
  7817. vm
  7818. );
  7819. }
  7820. /* istanbul ignore else */
  7821. if (true) {
  7822. initProxy(vm);
  7823. } else {}
  7824. // expose real self
  7825. vm._self = vm;
  7826. initLifecycle(vm);
  7827. initEvents(vm);
  7828. initRender(vm);
  7829. callHook(vm, 'beforeCreate');
  7830. !vm._$fallback && initInjections(vm); // resolve injections before data/props
  7831. initState(vm);
  7832. !vm._$fallback && initProvide(vm); // resolve provide after data/props
  7833. !vm._$fallback && callHook(vm, 'created');
  7834. /* istanbul ignore if */
  7835. if ( true && config.performance && mark) {
  7836. vm._name = formatComponentName(vm, false);
  7837. mark(endTag);
  7838. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  7839. }
  7840. if (vm.$options.el) {
  7841. vm.$mount(vm.$options.el);
  7842. }
  7843. };
  7844. }
  7845. function initInternalComponent (vm, options) {
  7846. var opts = vm.$options = Object.create(vm.constructor.options);
  7847. // doing this because it's faster than dynamic enumeration.
  7848. var parentVnode = options._parentVnode;
  7849. opts.parent = options.parent;
  7850. opts._parentVnode = parentVnode;
  7851. var vnodeComponentOptions = parentVnode.componentOptions;
  7852. opts.propsData = vnodeComponentOptions.propsData;
  7853. opts._parentListeners = vnodeComponentOptions.listeners;
  7854. opts._renderChildren = vnodeComponentOptions.children;
  7855. opts._componentTag = vnodeComponentOptions.tag;
  7856. if (options.render) {
  7857. opts.render = options.render;
  7858. opts.staticRenderFns = options.staticRenderFns;
  7859. }
  7860. }
  7861. function resolveConstructorOptions (Ctor) {
  7862. var options = Ctor.options;
  7863. if (Ctor.super) {
  7864. var superOptions = resolveConstructorOptions(Ctor.super);
  7865. var cachedSuperOptions = Ctor.superOptions;
  7866. if (superOptions !== cachedSuperOptions) {
  7867. // super option changed,
  7868. // need to resolve new options.
  7869. Ctor.superOptions = superOptions;
  7870. // check if there are any late-modified/attached options (#4976)
  7871. var modifiedOptions = resolveModifiedOptions(Ctor);
  7872. // update base extend options
  7873. if (modifiedOptions) {
  7874. extend(Ctor.extendOptions, modifiedOptions);
  7875. }
  7876. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  7877. if (options.name) {
  7878. options.components[options.name] = Ctor;
  7879. }
  7880. }
  7881. }
  7882. return options
  7883. }
  7884. function resolveModifiedOptions (Ctor) {
  7885. var modified;
  7886. var latest = Ctor.options;
  7887. var sealed = Ctor.sealedOptions;
  7888. for (var key in latest) {
  7889. if (latest[key] !== sealed[key]) {
  7890. if (!modified) { modified = {}; }
  7891. modified[key] = latest[key];
  7892. }
  7893. }
  7894. return modified
  7895. }
  7896. function Vue (options) {
  7897. if ( true &&
  7898. !(this instanceof Vue)
  7899. ) {
  7900. warn('Vue is a constructor and should be called with the `new` keyword');
  7901. }
  7902. this._init(options);
  7903. }
  7904. initMixin(Vue);
  7905. stateMixin(Vue);
  7906. eventsMixin(Vue);
  7907. lifecycleMixin(Vue);
  7908. renderMixin(Vue);
  7909. /* */
  7910. function initUse (Vue) {
  7911. Vue.use = function (plugin) {
  7912. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  7913. if (installedPlugins.indexOf(plugin) > -1) {
  7914. return this
  7915. }
  7916. // additional parameters
  7917. var args = toArray(arguments, 1);
  7918. args.unshift(this);
  7919. if (typeof plugin.install === 'function') {
  7920. plugin.install.apply(plugin, args);
  7921. } else if (typeof plugin === 'function') {
  7922. plugin.apply(null, args);
  7923. }
  7924. installedPlugins.push(plugin);
  7925. return this
  7926. };
  7927. }
  7928. /* */
  7929. function initMixin$1 (Vue) {
  7930. Vue.mixin = function (mixin) {
  7931. this.options = mergeOptions(this.options, mixin);
  7932. return this
  7933. };
  7934. }
  7935. /* */
  7936. function initExtend (Vue) {
  7937. /**
  7938. * Each instance constructor, including Vue, has a unique
  7939. * cid. This enables us to create wrapped "child
  7940. * constructors" for prototypal inheritance and cache them.
  7941. */
  7942. Vue.cid = 0;
  7943. var cid = 1;
  7944. /**
  7945. * Class inheritance
  7946. */
  7947. Vue.extend = function (extendOptions) {
  7948. extendOptions = extendOptions || {};
  7949. var Super = this;
  7950. var SuperId = Super.cid;
  7951. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  7952. if (cachedCtors[SuperId]) {
  7953. return cachedCtors[SuperId]
  7954. }
  7955. var name = extendOptions.name || Super.options.name;
  7956. if ( true && name) {
  7957. validateComponentName(name);
  7958. }
  7959. var Sub = function VueComponent (options) {
  7960. this._init(options);
  7961. };
  7962. Sub.prototype = Object.create(Super.prototype);
  7963. Sub.prototype.constructor = Sub;
  7964. Sub.cid = cid++;
  7965. Sub.options = mergeOptions(
  7966. Super.options,
  7967. extendOptions
  7968. );
  7969. Sub['super'] = Super;
  7970. // For props and computed properties, we define the proxy getters on
  7971. // the Vue instances at extension time, on the extended prototype. This
  7972. // avoids Object.defineProperty calls for each instance created.
  7973. if (Sub.options.props) {
  7974. initProps$1(Sub);
  7975. }
  7976. if (Sub.options.computed) {
  7977. initComputed$1(Sub);
  7978. }
  7979. // allow further extension/mixin/plugin usage
  7980. Sub.extend = Super.extend;
  7981. Sub.mixin = Super.mixin;
  7982. Sub.use = Super.use;
  7983. // create asset registers, so extended classes
  7984. // can have their private assets too.
  7985. ASSET_TYPES.forEach(function (type) {
  7986. Sub[type] = Super[type];
  7987. });
  7988. // enable recursive self-lookup
  7989. if (name) {
  7990. Sub.options.components[name] = Sub;
  7991. }
  7992. // keep a reference to the super options at extension time.
  7993. // later at instantiation we can check if Super's options have
  7994. // been updated.
  7995. Sub.superOptions = Super.options;
  7996. Sub.extendOptions = extendOptions;
  7997. Sub.sealedOptions = extend({}, Sub.options);
  7998. // cache constructor
  7999. cachedCtors[SuperId] = Sub;
  8000. return Sub
  8001. };
  8002. }
  8003. function initProps$1 (Comp) {
  8004. var props = Comp.options.props;
  8005. for (var key in props) {
  8006. proxy(Comp.prototype, "_props", key);
  8007. }
  8008. }
  8009. function initComputed$1 (Comp) {
  8010. var computed = Comp.options.computed;
  8011. for (var key in computed) {
  8012. defineComputed(Comp.prototype, key, computed[key]);
  8013. }
  8014. }
  8015. /* */
  8016. function initAssetRegisters (Vue) {
  8017. /**
  8018. * Create asset registration methods.
  8019. */
  8020. ASSET_TYPES.forEach(function (type) {
  8021. Vue[type] = function (
  8022. id,
  8023. definition
  8024. ) {
  8025. if (!definition) {
  8026. return this.options[type + 's'][id]
  8027. } else {
  8028. /* istanbul ignore if */
  8029. if ( true && type === 'component') {
  8030. validateComponentName(id);
  8031. }
  8032. if (type === 'component' && isPlainObject(definition)) {
  8033. definition.name = definition.name || id;
  8034. definition = this.options._base.extend(definition);
  8035. }
  8036. if (type === 'directive' && typeof definition === 'function') {
  8037. definition = { bind: definition, update: definition };
  8038. }
  8039. this.options[type + 's'][id] = definition;
  8040. return definition
  8041. }
  8042. };
  8043. });
  8044. }
  8045. /* */
  8046. function getComponentName (opts) {
  8047. return opts && (opts.Ctor.options.name || opts.tag)
  8048. }
  8049. function matches (pattern, name) {
  8050. if (Array.isArray(pattern)) {
  8051. return pattern.indexOf(name) > -1
  8052. } else if (typeof pattern === 'string') {
  8053. return pattern.split(',').indexOf(name) > -1
  8054. } else if (isRegExp(pattern)) {
  8055. return pattern.test(name)
  8056. }
  8057. /* istanbul ignore next */
  8058. return false
  8059. }
  8060. function pruneCache (keepAliveInstance, filter) {
  8061. var cache = keepAliveInstance.cache;
  8062. var keys = keepAliveInstance.keys;
  8063. var _vnode = keepAliveInstance._vnode;
  8064. for (var key in cache) {
  8065. var cachedNode = cache[key];
  8066. if (cachedNode) {
  8067. var name = getComponentName(cachedNode.componentOptions);
  8068. if (name && !filter(name)) {
  8069. pruneCacheEntry(cache, key, keys, _vnode);
  8070. }
  8071. }
  8072. }
  8073. }
  8074. function pruneCacheEntry (
  8075. cache,
  8076. key,
  8077. keys,
  8078. current
  8079. ) {
  8080. var cached$$1 = cache[key];
  8081. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  8082. cached$$1.componentInstance.$destroy();
  8083. }
  8084. cache[key] = null;
  8085. remove(keys, key);
  8086. }
  8087. var patternTypes = [String, RegExp, Array];
  8088. var KeepAlive = {
  8089. name: 'keep-alive',
  8090. abstract: true,
  8091. props: {
  8092. include: patternTypes,
  8093. exclude: patternTypes,
  8094. max: [String, Number]
  8095. },
  8096. created: function created () {
  8097. this.cache = Object.create(null);
  8098. this.keys = [];
  8099. },
  8100. destroyed: function destroyed () {
  8101. for (var key in this.cache) {
  8102. pruneCacheEntry(this.cache, key, this.keys);
  8103. }
  8104. },
  8105. mounted: function mounted () {
  8106. var this$1 = this;
  8107. this.$watch('include', function (val) {
  8108. pruneCache(this$1, function (name) { return matches(val, name); });
  8109. });
  8110. this.$watch('exclude', function (val) {
  8111. pruneCache(this$1, function (name) { return !matches(val, name); });
  8112. });
  8113. },
  8114. render: function render () {
  8115. var slot = this.$slots.default;
  8116. var vnode = getFirstComponentChild(slot);
  8117. var componentOptions = vnode && vnode.componentOptions;
  8118. if (componentOptions) {
  8119. // check pattern
  8120. var name = getComponentName(componentOptions);
  8121. var ref = this;
  8122. var include = ref.include;
  8123. var exclude = ref.exclude;
  8124. if (
  8125. // not included
  8126. (include && (!name || !matches(include, name))) ||
  8127. // excluded
  8128. (exclude && name && matches(exclude, name))
  8129. ) {
  8130. return vnode
  8131. }
  8132. var ref$1 = this;
  8133. var cache = ref$1.cache;
  8134. var keys = ref$1.keys;
  8135. var key = vnode.key == null
  8136. // same constructor may get registered as different local components
  8137. // so cid alone is not enough (#3269)
  8138. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  8139. : vnode.key;
  8140. if (cache[key]) {
  8141. vnode.componentInstance = cache[key].componentInstance;
  8142. // make current key freshest
  8143. remove(keys, key);
  8144. keys.push(key);
  8145. } else {
  8146. cache[key] = vnode;
  8147. keys.push(key);
  8148. // prune oldest entry
  8149. if (this.max && keys.length > parseInt(this.max)) {
  8150. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  8151. }
  8152. }
  8153. vnode.data.keepAlive = true;
  8154. }
  8155. return vnode || (slot && slot[0])
  8156. }
  8157. };
  8158. var builtInComponents = {
  8159. KeepAlive: KeepAlive
  8160. };
  8161. /* */
  8162. function initGlobalAPI (Vue) {
  8163. // config
  8164. var configDef = {};
  8165. configDef.get = function () { return config; };
  8166. if (true) {
  8167. configDef.set = function () {
  8168. warn(
  8169. 'Do not replace the Vue.config object, set individual fields instead.'
  8170. );
  8171. };
  8172. }
  8173. Object.defineProperty(Vue, 'config', configDef);
  8174. // exposed util methods.
  8175. // NOTE: these are not considered part of the public API - avoid relying on
  8176. // them unless you are aware of the risk.
  8177. Vue.util = {
  8178. warn: warn,
  8179. extend: extend,
  8180. mergeOptions: mergeOptions,
  8181. defineReactive: defineReactive$$1
  8182. };
  8183. Vue.set = set;
  8184. Vue.delete = del;
  8185. Vue.nextTick = nextTick;
  8186. // 2.6 explicit observable API
  8187. Vue.observable = function (obj) {
  8188. observe(obj);
  8189. return obj
  8190. };
  8191. Vue.options = Object.create(null);
  8192. ASSET_TYPES.forEach(function (type) {
  8193. Vue.options[type + 's'] = Object.create(null);
  8194. });
  8195. // this is used to identify the "base" constructor to extend all plain-object
  8196. // components with in Weex's multi-instance scenarios.
  8197. Vue.options._base = Vue;
  8198. extend(Vue.options.components, builtInComponents);
  8199. initUse(Vue);
  8200. initMixin$1(Vue);
  8201. initExtend(Vue);
  8202. initAssetRegisters(Vue);
  8203. }
  8204. initGlobalAPI(Vue);
  8205. Object.defineProperty(Vue.prototype, '$isServer', {
  8206. get: isServerRendering
  8207. });
  8208. Object.defineProperty(Vue.prototype, '$ssrContext', {
  8209. get: function get () {
  8210. /* istanbul ignore next */
  8211. return this.$vnode && this.$vnode.ssrContext
  8212. }
  8213. });
  8214. // expose FunctionalRenderContext for ssr runtime helper installation
  8215. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  8216. value: FunctionalRenderContext
  8217. });
  8218. Vue.version = '2.6.11';
  8219. /**
  8220. * https://raw.githubusercontent.com/Tencent/westore/master/packages/westore/utils/diff.js
  8221. */
  8222. var ARRAYTYPE = '[object Array]';
  8223. var OBJECTTYPE = '[object Object]';
  8224. var NULLTYPE = '[object Null]';
  8225. var UNDEFINEDTYPE = '[object Undefined]';
  8226. // const FUNCTIONTYPE = '[object Function]'
  8227. function diff(current, pre) {
  8228. var result = {};
  8229. syncKeys(current, pre);
  8230. _diff(current, pre, '', result);
  8231. return result
  8232. }
  8233. function syncKeys(current, pre) {
  8234. if (current === pre) { return }
  8235. var rootCurrentType = type(current);
  8236. var rootPreType = type(pre);
  8237. if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) {
  8238. if(Object.keys(current).length >= Object.keys(pre).length){
  8239. for (var key in pre) {
  8240. var currentValue = current[key];
  8241. if (currentValue === undefined) {
  8242. current[key] = null;
  8243. } else {
  8244. syncKeys(currentValue, pre[key]);
  8245. }
  8246. }
  8247. }
  8248. } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {
  8249. if (current.length >= pre.length) {
  8250. pre.forEach(function (item, index) {
  8251. syncKeys(current[index], item);
  8252. });
  8253. }
  8254. }
  8255. }
  8256. function nullOrUndefined(currentType, preType) {
  8257. if(
  8258. (currentType === NULLTYPE || currentType === UNDEFINEDTYPE) &&
  8259. (preType === NULLTYPE || preType === UNDEFINEDTYPE)
  8260. ) {
  8261. return false
  8262. }
  8263. return true
  8264. }
  8265. function _diff(current, pre, path, result) {
  8266. if (current === pre) { return }
  8267. var rootCurrentType = type(current);
  8268. var rootPreType = type(pre);
  8269. if (rootCurrentType == OBJECTTYPE) {
  8270. if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {
  8271. setResult(result, path, current);
  8272. } else {
  8273. var loop = function ( key ) {
  8274. var currentValue = current[key];
  8275. var preValue = pre[key];
  8276. var currentType = type(currentValue);
  8277. var preType = type(preValue);
  8278. if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {
  8279. if (currentValue !== pre[key] && nullOrUndefined(currentType, preType)) {
  8280. setResult(result, (path == '' ? '' : path + ".") + key, currentValue);
  8281. }
  8282. } else if (currentType == ARRAYTYPE) {
  8283. if (preType != ARRAYTYPE) {
  8284. setResult(result, (path == '' ? '' : path + ".") + key, currentValue);
  8285. } else {
  8286. if (currentValue.length < preValue.length) {
  8287. setResult(result, (path == '' ? '' : path + ".") + key, currentValue);
  8288. } else {
  8289. currentValue.forEach(function (item, index) {
  8290. _diff(item, preValue[index], (path == '' ? '' : path + ".") + key + '[' + index + ']', result);
  8291. });
  8292. }
  8293. }
  8294. } else if (currentType == OBJECTTYPE) {
  8295. if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) {
  8296. setResult(result, (path == '' ? '' : path + ".") + key, currentValue);
  8297. } else {
  8298. for (var subKey in currentValue) {
  8299. _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + ".") + key + '.' + subKey, result);
  8300. }
  8301. }
  8302. }
  8303. };
  8304. for (var key in current) loop( key );
  8305. }
  8306. } else if (rootCurrentType == ARRAYTYPE) {
  8307. if (rootPreType != ARRAYTYPE) {
  8308. setResult(result, path, current);
  8309. } else {
  8310. if (current.length < pre.length) {
  8311. setResult(result, path, current);
  8312. } else {
  8313. current.forEach(function (item, index) {
  8314. _diff(item, pre[index], path + '[' + index + ']', result);
  8315. });
  8316. }
  8317. }
  8318. } else {
  8319. setResult(result, path, current);
  8320. }
  8321. }
  8322. function setResult(result, k, v) {
  8323. // if (type(v) != FUNCTIONTYPE) {
  8324. result[k] = v;
  8325. // }
  8326. }
  8327. function type(obj) {
  8328. return Object.prototype.toString.call(obj)
  8329. }
  8330. /* */
  8331. function flushCallbacks$1(vm) {
  8332. if (vm.__next_tick_callbacks && vm.__next_tick_callbacks.length) {
  8333. if (Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"travel_applet","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
  8334. var mpInstance = vm.$scope;
  8335. console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
  8336. ']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']');
  8337. }
  8338. var copies = vm.__next_tick_callbacks.slice(0);
  8339. vm.__next_tick_callbacks.length = 0;
  8340. for (var i = 0; i < copies.length; i++) {
  8341. copies[i]();
  8342. }
  8343. }
  8344. }
  8345. function hasRenderWatcher(vm) {
  8346. return queue.find(function (watcher) { return vm._watcher === watcher; })
  8347. }
  8348. function nextTick$1(vm, cb) {
  8349. //1.nextTick 之前 已 setData 且 setData 还未回调完成
  8350. //2.nextTick 之前存在 render watcher
  8351. if (!vm.__next_tick_pending && !hasRenderWatcher(vm)) {
  8352. if(Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"travel_applet","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG){
  8353. var mpInstance = vm.$scope;
  8354. console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
  8355. ']:nextVueTick');
  8356. }
  8357. return nextTick(cb, vm)
  8358. }else{
  8359. if(Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"travel_applet","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG){
  8360. var mpInstance$1 = vm.$scope;
  8361. console.log('[' + (+new Date) + '][' + (mpInstance$1.is || mpInstance$1.route) + '][' + vm._uid +
  8362. ']:nextMPTick');
  8363. }
  8364. }
  8365. var _resolve;
  8366. if (!vm.__next_tick_callbacks) {
  8367. vm.__next_tick_callbacks = [];
  8368. }
  8369. vm.__next_tick_callbacks.push(function () {
  8370. if (cb) {
  8371. try {
  8372. cb.call(vm);
  8373. } catch (e) {
  8374. handleError(e, vm, 'nextTick');
  8375. }
  8376. } else if (_resolve) {
  8377. _resolve(vm);
  8378. }
  8379. });
  8380. // $flow-disable-line
  8381. if (!cb && typeof Promise !== 'undefined') {
  8382. return new Promise(function (resolve) {
  8383. _resolve = resolve;
  8384. })
  8385. }
  8386. }
  8387. /* */
  8388. function clearInstance(key, value) {
  8389. // 简易去除 Vue 和小程序组件实例
  8390. if (value) {
  8391. if (value._isVue || value.__v_isMPComponent) {
  8392. return {}
  8393. }
  8394. }
  8395. return value
  8396. }
  8397. function cloneWithData(vm) {
  8398. // 确保当前 vm 所有数据被同步
  8399. var ret = Object.create(null);
  8400. var dataKeys = [].concat(
  8401. Object.keys(vm._data || {}),
  8402. Object.keys(vm._computedWatchers || {}));
  8403. dataKeys.reduce(function(ret, key) {
  8404. ret[key] = vm[key];
  8405. return ret
  8406. }, ret);
  8407. // vue-composition-api
  8408. var compositionApiState = vm.__composition_api_state__ || vm.__secret_vfa_state__;
  8409. var rawBindings = compositionApiState && compositionApiState.rawBindings;
  8410. if (rawBindings) {
  8411. Object.keys(rawBindings).forEach(function (key) {
  8412. ret[key] = vm[key];
  8413. });
  8414. }
  8415. //TODO 需要把无用数据处理掉,比如 list=>l0 则 list 需要移除,否则多传输一份数据
  8416. Object.assign(ret, vm.$mp.data || {});
  8417. if (
  8418. Array.isArray(vm.$options.behaviors) &&
  8419. vm.$options.behaviors.indexOf('uni://form-field') !== -1
  8420. ) { //form-field
  8421. ret['name'] = vm.name;
  8422. ret['value'] = vm.value;
  8423. }
  8424. return JSON.parse(JSON.stringify(ret, clearInstance))
  8425. }
  8426. var patch = function(oldVnode, vnode) {
  8427. var this$1 = this;
  8428. if (vnode === null) { //destroy
  8429. return
  8430. }
  8431. if (this.mpType === 'page' || this.mpType === 'component') {
  8432. var mpInstance = this.$scope;
  8433. var data = Object.create(null);
  8434. try {
  8435. data = cloneWithData(this);
  8436. } catch (err) {
  8437. console.error(err);
  8438. }
  8439. data.__webviewId__ = mpInstance.data.__webviewId__;
  8440. var mpData = Object.create(null);
  8441. Object.keys(data).forEach(function (key) { //仅同步 data 中有的数据
  8442. mpData[key] = mpInstance.data[key];
  8443. });
  8444. var diffData = this.$shouldDiffData === false ? data : diff(data, mpData);
  8445. if (Object.keys(diffData).length) {
  8446. if (Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"travel_applet","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
  8447. console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + this._uid +
  8448. ']差量更新',
  8449. JSON.stringify(diffData));
  8450. }
  8451. this.__next_tick_pending = true;
  8452. mpInstance.setData(diffData, function () {
  8453. this$1.__next_tick_pending = false;
  8454. flushCallbacks$1(this$1);
  8455. });
  8456. } else {
  8457. flushCallbacks$1(this);
  8458. }
  8459. }
  8460. };
  8461. /* */
  8462. function createEmptyRender() {
  8463. }
  8464. function mountComponent$1(
  8465. vm,
  8466. el,
  8467. hydrating
  8468. ) {
  8469. if (!vm.mpType) {//main.js 中的 new Vue
  8470. return vm
  8471. }
  8472. if (vm.mpType === 'app') {
  8473. vm.$options.render = createEmptyRender;
  8474. }
  8475. if (!vm.$options.render) {
  8476. vm.$options.render = createEmptyRender;
  8477. if (true) {
  8478. /* istanbul ignore if */
  8479. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  8480. vm.$options.el || el) {
  8481. warn(
  8482. 'You are using the runtime-only build of Vue where the template ' +
  8483. 'compiler is not available. Either pre-compile the templates into ' +
  8484. 'render functions, or use the compiler-included build.',
  8485. vm
  8486. );
  8487. } else {
  8488. warn(
  8489. 'Failed to mount component: template or render function not defined.',
  8490. vm
  8491. );
  8492. }
  8493. }
  8494. }
  8495. !vm._$fallback && callHook(vm, 'beforeMount');
  8496. var updateComponent = function () {
  8497. vm._update(vm._render(), hydrating);
  8498. };
  8499. // we set this to vm._watcher inside the watcher's constructor
  8500. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  8501. // component's mounted hook), which relies on vm._watcher being already defined
  8502. new Watcher(vm, updateComponent, noop, {
  8503. before: function before() {
  8504. if (vm._isMounted && !vm._isDestroyed) {
  8505. callHook(vm, 'beforeUpdate');
  8506. }
  8507. }
  8508. }, true /* isRenderWatcher */);
  8509. hydrating = false;
  8510. return vm
  8511. }
  8512. /* */
  8513. function renderClass (
  8514. staticClass,
  8515. dynamicClass
  8516. ) {
  8517. if (isDef(staticClass) || isDef(dynamicClass)) {
  8518. return concat(staticClass, stringifyClass(dynamicClass))
  8519. }
  8520. /* istanbul ignore next */
  8521. return ''
  8522. }
  8523. function concat (a, b) {
  8524. return a ? b ? (a + ' ' + b) : a : (b || '')
  8525. }
  8526. function stringifyClass (value) {
  8527. if (Array.isArray(value)) {
  8528. return stringifyArray(value)
  8529. }
  8530. if (isObject(value)) {
  8531. return stringifyObject(value)
  8532. }
  8533. if (typeof value === 'string') {
  8534. return value
  8535. }
  8536. /* istanbul ignore next */
  8537. return ''
  8538. }
  8539. function stringifyArray (value) {
  8540. var res = '';
  8541. var stringified;
  8542. for (var i = 0, l = value.length; i < l; i++) {
  8543. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  8544. if (res) { res += ' '; }
  8545. res += stringified;
  8546. }
  8547. }
  8548. return res
  8549. }
  8550. function stringifyObject (value) {
  8551. var res = '';
  8552. for (var key in value) {
  8553. if (value[key]) {
  8554. if (res) { res += ' '; }
  8555. res += key;
  8556. }
  8557. }
  8558. return res
  8559. }
  8560. /* */
  8561. var parseStyleText = cached(function (cssText) {
  8562. var res = {};
  8563. var listDelimiter = /;(?![^(]*\))/g;
  8564. var propertyDelimiter = /:(.+)/;
  8565. cssText.split(listDelimiter).forEach(function (item) {
  8566. if (item) {
  8567. var tmp = item.split(propertyDelimiter);
  8568. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  8569. }
  8570. });
  8571. return res
  8572. });
  8573. // normalize possible array / string values into Object
  8574. function normalizeStyleBinding (bindingStyle) {
  8575. if (Array.isArray(bindingStyle)) {
  8576. return toObject(bindingStyle)
  8577. }
  8578. if (typeof bindingStyle === 'string') {
  8579. return parseStyleText(bindingStyle)
  8580. }
  8581. return bindingStyle
  8582. }
  8583. /* */
  8584. var MP_METHODS = ['createSelectorQuery', 'createIntersectionObserver', 'selectAllComponents', 'selectComponent'];
  8585. function getTarget(obj, path) {
  8586. var parts = path.split('.');
  8587. var key = parts[0];
  8588. if (key.indexOf('__$n') === 0) { //number index
  8589. key = parseInt(key.replace('__$n', ''));
  8590. }
  8591. if (parts.length === 1) {
  8592. return obj[key]
  8593. }
  8594. return getTarget(obj[key], parts.slice(1).join('.'))
  8595. }
  8596. function internalMixin(Vue) {
  8597. Vue.config.errorHandler = function(err, vm, info) {
  8598. Vue.util.warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  8599. console.error(err);
  8600. /* eslint-disable no-undef */
  8601. var app = typeof getApp === 'function' && getApp();
  8602. if (app && app.onError) {
  8603. app.onError(err);
  8604. }
  8605. };
  8606. var oldEmit = Vue.prototype.$emit;
  8607. Vue.prototype.$emit = function(event) {
  8608. if (this.$scope && event) {
  8609. var triggerEvent = this.$scope['_triggerEvent'] || this.$scope['triggerEvent'];
  8610. if (triggerEvent) {
  8611. try {
  8612. triggerEvent.call(this.$scope, event, {
  8613. __args__: toArray(arguments, 1)
  8614. });
  8615. } catch (error) {
  8616. }
  8617. }
  8618. }
  8619. return oldEmit.apply(this, arguments)
  8620. };
  8621. Vue.prototype.$nextTick = function(fn) {
  8622. return nextTick$1(this, fn)
  8623. };
  8624. MP_METHODS.forEach(function (method) {
  8625. Vue.prototype[method] = function(args) {
  8626. if (this.$scope && this.$scope[method]) {
  8627. return this.$scope[method](args)
  8628. }
  8629. // mp-alipay
  8630. if (typeof my === 'undefined') {
  8631. return
  8632. }
  8633. if (method === 'createSelectorQuery') {
  8634. /* eslint-disable no-undef */
  8635. return my.createSelectorQuery(args)
  8636. } else if (method === 'createIntersectionObserver') {
  8637. /* eslint-disable no-undef */
  8638. return my.createIntersectionObserver(args)
  8639. }
  8640. // TODO mp-alipay 暂不支持 selectAllComponents,selectComponent
  8641. };
  8642. });
  8643. Vue.prototype.__init_provide = initProvide;
  8644. Vue.prototype.__init_injections = initInjections;
  8645. Vue.prototype.__call_hook = function(hook, args) {
  8646. var vm = this;
  8647. // #7573 disable dep collection when invoking lifecycle hooks
  8648. pushTarget();
  8649. var handlers = vm.$options[hook];
  8650. var info = hook + " hook";
  8651. var ret;
  8652. if (handlers) {
  8653. for (var i = 0, j = handlers.length; i < j; i++) {
  8654. ret = invokeWithErrorHandling(handlers[i], vm, args ? [args] : null, vm, info);
  8655. }
  8656. }
  8657. if (vm._hasHookEvent) {
  8658. vm.$emit('hook:' + hook, args);
  8659. }
  8660. popTarget();
  8661. return ret
  8662. };
  8663. Vue.prototype.__set_model = function(target, key, value, modifiers) {
  8664. if (Array.isArray(modifiers)) {
  8665. if (modifiers.indexOf('trim') !== -1) {
  8666. value = value.trim();
  8667. }
  8668. if (modifiers.indexOf('number') !== -1) {
  8669. value = this._n(value);
  8670. }
  8671. }
  8672. if (!target) {
  8673. target = this;
  8674. }
  8675. // 解决动态属性添加
  8676. Vue.set(target, key, value);
  8677. };
  8678. Vue.prototype.__set_sync = function(target, key, value) {
  8679. if (!target) {
  8680. target = this;
  8681. }
  8682. // 解决动态属性添加
  8683. Vue.set(target, key, value);
  8684. };
  8685. Vue.prototype.__get_orig = function(item) {
  8686. if (isPlainObject(item)) {
  8687. return item['$orig'] || item
  8688. }
  8689. return item
  8690. };
  8691. Vue.prototype.__get_value = function(dataPath, target) {
  8692. return getTarget(target || this, dataPath)
  8693. };
  8694. Vue.prototype.__get_class = function(dynamicClass, staticClass) {
  8695. return renderClass(staticClass, dynamicClass)
  8696. };
  8697. Vue.prototype.__get_style = function(dynamicStyle, staticStyle) {
  8698. if (!dynamicStyle && !staticStyle) {
  8699. return ''
  8700. }
  8701. var dynamicStyleObj = normalizeStyleBinding(dynamicStyle);
  8702. var styleObj = staticStyle ? extend(staticStyle, dynamicStyleObj) : dynamicStyleObj;
  8703. return Object.keys(styleObj).map(function (name) { return ((hyphenate(name)) + ":" + (styleObj[name])); }).join(';')
  8704. };
  8705. Vue.prototype.__map = function(val, iteratee) {
  8706. //TODO 暂不考虑 string
  8707. var ret, i, l, keys, key;
  8708. if (Array.isArray(val)) {
  8709. ret = new Array(val.length);
  8710. for (i = 0, l = val.length; i < l; i++) {
  8711. ret[i] = iteratee(val[i], i);
  8712. }
  8713. return ret
  8714. } else if (isObject(val)) {
  8715. keys = Object.keys(val);
  8716. ret = Object.create(null);
  8717. for (i = 0, l = keys.length; i < l; i++) {
  8718. key = keys[i];
  8719. ret[key] = iteratee(val[key], key, i);
  8720. }
  8721. return ret
  8722. } else if (typeof val === 'number') {
  8723. ret = new Array(val);
  8724. for (i = 0, l = val; i < l; i++) {
  8725. // 第一个参数暂时仍和小程序一致
  8726. ret[i] = iteratee(i, i);
  8727. }
  8728. return ret
  8729. }
  8730. return []
  8731. };
  8732. }
  8733. /* */
  8734. var LIFECYCLE_HOOKS$1 = [
  8735. //App
  8736. 'onLaunch',
  8737. 'onShow',
  8738. 'onHide',
  8739. 'onUniNViewMessage',
  8740. 'onPageNotFound',
  8741. 'onThemeChange',
  8742. 'onError',
  8743. 'onUnhandledRejection',
  8744. //Page
  8745. 'onInit',
  8746. 'onLoad',
  8747. // 'onShow',
  8748. 'onReady',
  8749. // 'onHide',
  8750. 'onUnload',
  8751. 'onPullDownRefresh',
  8752. 'onReachBottom',
  8753. 'onTabItemTap',
  8754. 'onAddToFavorites',
  8755. 'onShareTimeline',
  8756. 'onShareAppMessage',
  8757. 'onResize',
  8758. 'onPageScroll',
  8759. 'onNavigationBarButtonTap',
  8760. 'onBackPress',
  8761. 'onNavigationBarSearchInputChanged',
  8762. 'onNavigationBarSearchInputConfirmed',
  8763. 'onNavigationBarSearchInputClicked',
  8764. 'onUploadDouyinVideo',
  8765. 'onNFCReadMessage',
  8766. //Component
  8767. // 'onReady', // 兼容旧版本,应该移除该事件
  8768. 'onPageShow',
  8769. 'onPageHide',
  8770. 'onPageResize'
  8771. ];
  8772. function lifecycleMixin$1(Vue) {
  8773. //fixed vue-class-component
  8774. var oldExtend = Vue.extend;
  8775. Vue.extend = function(extendOptions) {
  8776. extendOptions = extendOptions || {};
  8777. var methods = extendOptions.methods;
  8778. if (methods) {
  8779. Object.keys(methods).forEach(function (methodName) {
  8780. if (LIFECYCLE_HOOKS$1.indexOf(methodName)!==-1) {
  8781. extendOptions[methodName] = methods[methodName];
  8782. delete methods[methodName];
  8783. }
  8784. });
  8785. }
  8786. return oldExtend.call(this, extendOptions)
  8787. };
  8788. var strategies = Vue.config.optionMergeStrategies;
  8789. var mergeHook = strategies.created;
  8790. LIFECYCLE_HOOKS$1.forEach(function (hook) {
  8791. strategies[hook] = mergeHook;
  8792. });
  8793. Vue.prototype.__lifecycle_hooks__ = LIFECYCLE_HOOKS$1;
  8794. }
  8795. /* */
  8796. // install platform patch function
  8797. Vue.prototype.__patch__ = patch;
  8798. // public mount method
  8799. Vue.prototype.$mount = function(
  8800. el ,
  8801. hydrating
  8802. ) {
  8803. return mountComponent$1(this, el, hydrating)
  8804. };
  8805. lifecycleMixin$1(Vue);
  8806. internalMixin(Vue);
  8807. /* */
  8808. /* harmony default export */ __webpack_exports__["default"] = (Vue);
  8809. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../../webpack/buildin/global.js */ 3)))
  8810. /***/ }),
  8811. /* 26 */
  8812. /*!*************************************************!*\
  8813. !*** D:/project/神鹿峰旅游/travel_applet/pages.json ***!
  8814. \*************************************************/
  8815. /*! no static exports found */
  8816. /***/ (function(module, exports) {
  8817. /***/ }),
  8818. /* 27 */,
  8819. /* 28 */,
  8820. /* 29 */,
  8821. /* 30 */
  8822. /*!************************************************************************************************!*\
  8823. !*** ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/@babel/runtime/regenerator/index.js ***!
  8824. \************************************************************************************************/
  8825. /*! no static exports found */
  8826. /***/ (function(module, exports, __webpack_require__) {
  8827. // TODO(Babel 8): Remove this file.
  8828. var runtime = __webpack_require__(/*! @babel/runtime/helpers/regeneratorRuntime */ 31)();
  8829. module.exports = runtime;
  8830. /***/ }),
  8831. /* 31 */
  8832. /*!*******************************************************************!*\
  8833. !*** ./node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
  8834. \*******************************************************************/
  8835. /*! no static exports found */
  8836. /***/ (function(module, exports, __webpack_require__) {
  8837. var _typeof = __webpack_require__(/*! ./typeof.js */ 13)["default"];
  8838. function _regeneratorRuntime() {
  8839. "use strict";
  8840. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  8841. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  8842. return exports;
  8843. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  8844. var exports = {},
  8845. Op = Object.prototype,
  8846. hasOwn = Op.hasOwnProperty,
  8847. defineProperty = Object.defineProperty || function (obj, key, desc) {
  8848. obj[key] = desc.value;
  8849. },
  8850. $Symbol = "function" == typeof Symbol ? Symbol : {},
  8851. iteratorSymbol = $Symbol.iterator || "@@iterator",
  8852. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  8853. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  8854. function define(obj, key, value) {
  8855. return Object.defineProperty(obj, key, {
  8856. value: value,
  8857. enumerable: !0,
  8858. configurable: !0,
  8859. writable: !0
  8860. }), obj[key];
  8861. }
  8862. try {
  8863. define({}, "");
  8864. } catch (err) {
  8865. define = function define(obj, key, value) {
  8866. return obj[key] = value;
  8867. };
  8868. }
  8869. function wrap(innerFn, outerFn, self, tryLocsList) {
  8870. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  8871. generator = Object.create(protoGenerator.prototype),
  8872. context = new Context(tryLocsList || []);
  8873. return defineProperty(generator, "_invoke", {
  8874. value: makeInvokeMethod(innerFn, self, context)
  8875. }), generator;
  8876. }
  8877. function tryCatch(fn, obj, arg) {
  8878. try {
  8879. return {
  8880. type: "normal",
  8881. arg: fn.call(obj, arg)
  8882. };
  8883. } catch (err) {
  8884. return {
  8885. type: "throw",
  8886. arg: err
  8887. };
  8888. }
  8889. }
  8890. exports.wrap = wrap;
  8891. var ContinueSentinel = {};
  8892. function Generator() {}
  8893. function GeneratorFunction() {}
  8894. function GeneratorFunctionPrototype() {}
  8895. var IteratorPrototype = {};
  8896. define(IteratorPrototype, iteratorSymbol, function () {
  8897. return this;
  8898. });
  8899. var getProto = Object.getPrototypeOf,
  8900. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  8901. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  8902. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  8903. function defineIteratorMethods(prototype) {
  8904. ["next", "throw", "return"].forEach(function (method) {
  8905. define(prototype, method, function (arg) {
  8906. return this._invoke(method, arg);
  8907. });
  8908. });
  8909. }
  8910. function AsyncIterator(generator, PromiseImpl) {
  8911. function invoke(method, arg, resolve, reject) {
  8912. var record = tryCatch(generator[method], generator, arg);
  8913. if ("throw" !== record.type) {
  8914. var result = record.arg,
  8915. value = result.value;
  8916. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  8917. invoke("next", value, resolve, reject);
  8918. }, function (err) {
  8919. invoke("throw", err, resolve, reject);
  8920. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  8921. result.value = unwrapped, resolve(result);
  8922. }, function (error) {
  8923. return invoke("throw", error, resolve, reject);
  8924. });
  8925. }
  8926. reject(record.arg);
  8927. }
  8928. var previousPromise;
  8929. defineProperty(this, "_invoke", {
  8930. value: function value(method, arg) {
  8931. function callInvokeWithMethodAndArg() {
  8932. return new PromiseImpl(function (resolve, reject) {
  8933. invoke(method, arg, resolve, reject);
  8934. });
  8935. }
  8936. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  8937. }
  8938. });
  8939. }
  8940. function makeInvokeMethod(innerFn, self, context) {
  8941. var state = "suspendedStart";
  8942. return function (method, arg) {
  8943. if ("executing" === state) throw new Error("Generator is already running");
  8944. if ("completed" === state) {
  8945. if ("throw" === method) throw arg;
  8946. return doneResult();
  8947. }
  8948. for (context.method = method, context.arg = arg;;) {
  8949. var delegate = context.delegate;
  8950. if (delegate) {
  8951. var delegateResult = maybeInvokeDelegate(delegate, context);
  8952. if (delegateResult) {
  8953. if (delegateResult === ContinueSentinel) continue;
  8954. return delegateResult;
  8955. }
  8956. }
  8957. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  8958. if ("suspendedStart" === state) throw state = "completed", context.arg;
  8959. context.dispatchException(context.arg);
  8960. } else "return" === context.method && context.abrupt("return", context.arg);
  8961. state = "executing";
  8962. var record = tryCatch(innerFn, self, context);
  8963. if ("normal" === record.type) {
  8964. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  8965. return {
  8966. value: record.arg,
  8967. done: context.done
  8968. };
  8969. }
  8970. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  8971. }
  8972. };
  8973. }
  8974. function maybeInvokeDelegate(delegate, context) {
  8975. var methodName = context.method,
  8976. method = delegate.iterator[methodName];
  8977. if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
  8978. var record = tryCatch(method, delegate.iterator, context.arg);
  8979. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  8980. var info = record.arg;
  8981. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  8982. }
  8983. function pushTryEntry(locs) {
  8984. var entry = {
  8985. tryLoc: locs[0]
  8986. };
  8987. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  8988. }
  8989. function resetTryEntry(entry) {
  8990. var record = entry.completion || {};
  8991. record.type = "normal", delete record.arg, entry.completion = record;
  8992. }
  8993. function Context(tryLocsList) {
  8994. this.tryEntries = [{
  8995. tryLoc: "root"
  8996. }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  8997. }
  8998. function values(iterable) {
  8999. if (iterable) {
  9000. var iteratorMethod = iterable[iteratorSymbol];
  9001. if (iteratorMethod) return iteratorMethod.call(iterable);
  9002. if ("function" == typeof iterable.next) return iterable;
  9003. if (!isNaN(iterable.length)) {
  9004. var i = -1,
  9005. next = function next() {
  9006. for (; ++i < iterable.length;) {
  9007. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  9008. }
  9009. return next.value = undefined, next.done = !0, next;
  9010. };
  9011. return next.next = next;
  9012. }
  9013. }
  9014. return {
  9015. next: doneResult
  9016. };
  9017. }
  9018. function doneResult() {
  9019. return {
  9020. value: undefined,
  9021. done: !0
  9022. };
  9023. }
  9024. return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
  9025. value: GeneratorFunctionPrototype,
  9026. configurable: !0
  9027. }), defineProperty(GeneratorFunctionPrototype, "constructor", {
  9028. value: GeneratorFunction,
  9029. configurable: !0
  9030. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  9031. var ctor = "function" == typeof genFun && genFun.constructor;
  9032. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  9033. }, exports.mark = function (genFun) {
  9034. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
  9035. }, exports.awrap = function (arg) {
  9036. return {
  9037. __await: arg
  9038. };
  9039. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  9040. return this;
  9041. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  9042. void 0 === PromiseImpl && (PromiseImpl = Promise);
  9043. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  9044. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  9045. return result.done ? result.value : iter.next();
  9046. });
  9047. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  9048. return this;
  9049. }), define(Gp, "toString", function () {
  9050. return "[object Generator]";
  9051. }), exports.keys = function (val) {
  9052. var object = Object(val),
  9053. keys = [];
  9054. for (var key in object) {
  9055. keys.push(key);
  9056. }
  9057. return keys.reverse(), function next() {
  9058. for (; keys.length;) {
  9059. var key = keys.pop();
  9060. if (key in object) return next.value = key, next.done = !1, next;
  9061. }
  9062. return next.done = !0, next;
  9063. };
  9064. }, exports.values = values, Context.prototype = {
  9065. constructor: Context,
  9066. reset: function reset(skipTempReset) {
  9067. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
  9068. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
  9069. }
  9070. },
  9071. stop: function stop() {
  9072. this.done = !0;
  9073. var rootRecord = this.tryEntries[0].completion;
  9074. if ("throw" === rootRecord.type) throw rootRecord.arg;
  9075. return this.rval;
  9076. },
  9077. dispatchException: function dispatchException(exception) {
  9078. if (this.done) throw exception;
  9079. var context = this;
  9080. function handle(loc, caught) {
  9081. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  9082. }
  9083. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9084. var entry = this.tryEntries[i],
  9085. record = entry.completion;
  9086. if ("root" === entry.tryLoc) return handle("end");
  9087. if (entry.tryLoc <= this.prev) {
  9088. var hasCatch = hasOwn.call(entry, "catchLoc"),
  9089. hasFinally = hasOwn.call(entry, "finallyLoc");
  9090. if (hasCatch && hasFinally) {
  9091. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  9092. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  9093. } else if (hasCatch) {
  9094. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  9095. } else {
  9096. if (!hasFinally) throw new Error("try statement without catch or finally");
  9097. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  9098. }
  9099. }
  9100. }
  9101. },
  9102. abrupt: function abrupt(type, arg) {
  9103. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9104. var entry = this.tryEntries[i];
  9105. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  9106. var finallyEntry = entry;
  9107. break;
  9108. }
  9109. }
  9110. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  9111. var record = finallyEntry ? finallyEntry.completion : {};
  9112. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  9113. },
  9114. complete: function complete(record, afterLoc) {
  9115. if ("throw" === record.type) throw record.arg;
  9116. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  9117. },
  9118. finish: function finish(finallyLoc) {
  9119. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9120. var entry = this.tryEntries[i];
  9121. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  9122. }
  9123. },
  9124. "catch": function _catch(tryLoc) {
  9125. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9126. var entry = this.tryEntries[i];
  9127. if (entry.tryLoc === tryLoc) {
  9128. var record = entry.completion;
  9129. if ("throw" === record.type) {
  9130. var thrown = record.arg;
  9131. resetTryEntry(entry);
  9132. }
  9133. return thrown;
  9134. }
  9135. }
  9136. throw new Error("illegal catch attempt");
  9137. },
  9138. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  9139. return this.delegate = {
  9140. iterator: values(iterable),
  9141. resultName: resultName,
  9142. nextLoc: nextLoc
  9143. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  9144. }
  9145. }, exports;
  9146. }
  9147. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  9148. /***/ }),
  9149. /* 32 */
  9150. /*!*****************************************************************!*\
  9151. !*** ./node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
  9152. \*****************************************************************/
  9153. /*! no static exports found */
  9154. /***/ (function(module, exports) {
  9155. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  9156. try {
  9157. var info = gen[key](arg);
  9158. var value = info.value;
  9159. } catch (error) {
  9160. reject(error);
  9161. return;
  9162. }
  9163. if (info.done) {
  9164. resolve(value);
  9165. } else {
  9166. Promise.resolve(value).then(_next, _throw);
  9167. }
  9168. }
  9169. function _asyncToGenerator(fn) {
  9170. return function () {
  9171. var self = this,
  9172. args = arguments;
  9173. return new Promise(function (resolve, reject) {
  9174. var gen = fn.apply(self, args);
  9175. function _next(value) {
  9176. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  9177. }
  9178. function _throw(err) {
  9179. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  9180. }
  9181. _next(undefined);
  9182. });
  9183. };
  9184. }
  9185. module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
  9186. /***/ }),
  9187. /* 33 */,
  9188. /* 34 */,
  9189. /* 35 */
  9190. /*!**********************************************************************************************************!*\
  9191. !*** ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/runtime/componentNormalizer.js ***!
  9192. \**********************************************************************************************************/
  9193. /*! exports provided: default */
  9194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9195. "use strict";
  9196. __webpack_require__.r(__webpack_exports__);
  9197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  9198. /* globals __VUE_SSR_CONTEXT__ */
  9199. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  9200. // This module is a runtime utility for cleaner component module output and will
  9201. // be included in the final webpack user bundle.
  9202. function normalizeComponent (
  9203. scriptExports,
  9204. render,
  9205. staticRenderFns,
  9206. functionalTemplate,
  9207. injectStyles,
  9208. scopeId,
  9209. moduleIdentifier, /* server only */
  9210. shadowMode, /* vue-cli only */
  9211. components, // fixed by xxxxxx auto components
  9212. renderjs // fixed by xxxxxx renderjs
  9213. ) {
  9214. // Vue.extend constructor export interop
  9215. var options = typeof scriptExports === 'function'
  9216. ? scriptExports.options
  9217. : scriptExports
  9218. // fixed by xxxxxx auto components
  9219. if (components) {
  9220. if (!options.components) {
  9221. options.components = {}
  9222. }
  9223. var hasOwn = Object.prototype.hasOwnProperty
  9224. for (var name in components) {
  9225. if (hasOwn.call(components, name) && !hasOwn.call(options.components, name)) {
  9226. options.components[name] = components[name]
  9227. }
  9228. }
  9229. }
  9230. // fixed by xxxxxx renderjs
  9231. if (renderjs) {
  9232. if(typeof renderjs.beforeCreate === 'function'){
  9233. renderjs.beforeCreate = [renderjs.beforeCreate]
  9234. }
  9235. (renderjs.beforeCreate || (renderjs.beforeCreate = [])).unshift(function() {
  9236. this[renderjs.__module] = this
  9237. });
  9238. (options.mixins || (options.mixins = [])).push(renderjs)
  9239. }
  9240. // render functions
  9241. if (render) {
  9242. options.render = render
  9243. options.staticRenderFns = staticRenderFns
  9244. options._compiled = true
  9245. }
  9246. // functional template
  9247. if (functionalTemplate) {
  9248. options.functional = true
  9249. }
  9250. // scopedId
  9251. if (scopeId) {
  9252. options._scopeId = 'data-v-' + scopeId
  9253. }
  9254. var hook
  9255. if (moduleIdentifier) { // server build
  9256. hook = function (context) {
  9257. // 2.3 injection
  9258. context =
  9259. context || // cached call
  9260. (this.$vnode && this.$vnode.ssrContext) || // stateful
  9261. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  9262. // 2.2 with runInNewContext: true
  9263. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  9264. context = __VUE_SSR_CONTEXT__
  9265. }
  9266. // inject component styles
  9267. if (injectStyles) {
  9268. injectStyles.call(this, context)
  9269. }
  9270. // register component module identifier for async chunk inferrence
  9271. if (context && context._registeredComponents) {
  9272. context._registeredComponents.add(moduleIdentifier)
  9273. }
  9274. }
  9275. // used by ssr in case component is cached and beforeCreate
  9276. // never gets called
  9277. options._ssrRegister = hook
  9278. } else if (injectStyles) {
  9279. hook = shadowMode
  9280. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  9281. : injectStyles
  9282. }
  9283. if (hook) {
  9284. if (options.functional) {
  9285. // for template-only hot-reload because in that case the render fn doesn't
  9286. // go through the normalizer
  9287. options._injectStyles = hook
  9288. // register for functioal component in vue file
  9289. var originalRender = options.render
  9290. options.render = function renderWithStyleInjection (h, context) {
  9291. hook.call(context)
  9292. return originalRender(h, context)
  9293. }
  9294. } else {
  9295. // inject component registration as beforeCreate hook
  9296. var existing = options.beforeCreate
  9297. options.beforeCreate = existing
  9298. ? [].concat(existing, hook)
  9299. : [hook]
  9300. }
  9301. }
  9302. return {
  9303. exports: scriptExports,
  9304. options: options
  9305. }
  9306. }
  9307. /***/ }),
  9308. /* 36 */
  9309. /*!****************************************************!*\
  9310. !*** D:/project/神鹿峰旅游/travel_applet/common/api.js ***!
  9311. \****************************************************/
  9312. /*! no static exports found */
  9313. /***/ (function(module, exports, __webpack_require__) {
  9314. "use strict";
  9315. /* WEBPACK VAR INJECTION */(function(uni) {
  9316. var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
  9317. Object.defineProperty(exports, "__esModule", {
  9318. value: true
  9319. });
  9320. exports.requestFile = exports.requestBase = exports.getToken = void 0;
  9321. var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ 30));
  9322. var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ 32));
  9323. var _config = _interopRequireDefault(__webpack_require__(/*! ../config.js */ 37));
  9324. var getDomain = function getDomain(uri, method, type) {
  9325. var wx_env = _config.default.wx_miniProgram;
  9326. var system = _config.default.system;
  9327. var url = _config.default.serverUrl;
  9328. var Fileurl = _config.default.serverFile;
  9329. if (type && type == 'file') return Fileurl + "/files" + uri;else return url + "/travel/v1/api" + uri;
  9330. };
  9331. // 获取token
  9332. var getToken = /*#__PURE__*/function () {
  9333. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(uri) {
  9334. var method,
  9335. data,
  9336. type,
  9337. baseUrl,
  9338. header,
  9339. _args = arguments;
  9340. return _regenerator.default.wrap(function _callee$(_context) {
  9341. while (1) {
  9342. switch (_context.prev = _context.next) {
  9343. case 0:
  9344. method = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'GET';
  9345. data = _args.length > 2 ? _args[2] : undefined;
  9346. type = _args.length > 3 ? _args[3] : undefined;
  9347. baseUrl = getDomain(uri, method, type);
  9348. header = {
  9349. token: data.token
  9350. };
  9351. return _context.abrupt("return", new Promise(function (resolve, reject) {
  9352. uni.request({
  9353. url: baseUrl,
  9354. method: method || 'GET',
  9355. data: data || {},
  9356. header: header,
  9357. success: function success(res) {
  9358. resolve(res.data);
  9359. },
  9360. fail: function fail(err) {
  9361. uni.showToast({
  9362. title: '请求接口失败',
  9363. icon: 'fail'
  9364. });
  9365. reject(err.data);
  9366. }
  9367. });
  9368. }));
  9369. case 6:
  9370. case "end":
  9371. return _context.stop();
  9372. }
  9373. }
  9374. }, _callee);
  9375. }));
  9376. return function getToken(_x) {
  9377. return _ref.apply(this, arguments);
  9378. };
  9379. }();
  9380. exports.getToken = getToken;
  9381. var requestBase = /*#__PURE__*/function () {
  9382. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(uri) {
  9383. var method,
  9384. data,
  9385. type,
  9386. baseUrl,
  9387. header,
  9388. token,
  9389. _args2 = arguments;
  9390. return _regenerator.default.wrap(function _callee2$(_context2) {
  9391. while (1) {
  9392. switch (_context2.prev = _context2.next) {
  9393. case 0:
  9394. method = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'GET';
  9395. data = _args2.length > 2 ? _args2[2] : undefined;
  9396. type = _args2.length > 3 ? _args2[3] : undefined;
  9397. baseUrl = getDomain(uri, method, type);
  9398. header = {};
  9399. token = uni.getStorageSync('token');
  9400. if (token) header.token = token;
  9401. return _context2.abrupt("return", new Promise(function (resolve, reject) {
  9402. uni.request({
  9403. url: baseUrl,
  9404. method: method || 'GET',
  9405. data: data || {},
  9406. header: header,
  9407. success: function success(res) {
  9408. resolve(res.data);
  9409. },
  9410. fail: function fail(err) {
  9411. uni.showToast({
  9412. title: '请求接口失败',
  9413. icon: 'fail'
  9414. });
  9415. reject(err.data);
  9416. }
  9417. });
  9418. }));
  9419. case 8:
  9420. case "end":
  9421. return _context2.stop();
  9422. }
  9423. }
  9424. }, _callee2);
  9425. }));
  9426. return function requestBase(_x2) {
  9427. return _ref2.apply(this, arguments);
  9428. };
  9429. }();
  9430. exports.requestBase = requestBase;
  9431. var requestFile = function requestFile(uri, method, data, type) {
  9432. var baseUrl = getDomain(uri, method, type);
  9433. return new Promise(function (resolve, reject) {
  9434. uni.uploadFile({
  9435. url: baseUrl,
  9436. filePath: data,
  9437. name: method || 'file',
  9438. formData: {},
  9439. success: function success(res) {
  9440. var data = JSON.parse(res.data);
  9441. if (data.errcode != '0') {
  9442. return uni.showToast({
  9443. title: data.errmsg,
  9444. icon: 'error'
  9445. });
  9446. }
  9447. resolve(data);
  9448. },
  9449. fail: function fail(err) {
  9450. var data = JSON.parse(err.data);
  9451. uni.showToast({
  9452. title: '请求接口失败',
  9453. icon: 'fail'
  9454. });
  9455. reject(data);
  9456. }
  9457. });
  9458. });
  9459. };
  9460. exports.requestFile = requestFile;
  9461. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
  9462. /***/ }),
  9463. /* 37 */
  9464. /*!************************************************!*\
  9465. !*** D:/project/神鹿峰旅游/travel_applet/config.js ***!
  9466. \************************************************/
  9467. /*! no static exports found */
  9468. /***/ (function(module, exports, __webpack_require__) {
  9469. "use strict";
  9470. /* WEBPACK VAR INJECTION */(function(uni) {
  9471. Object.defineProperty(exports, "__esModule", {
  9472. value: true
  9473. });
  9474. exports.default = void 0;
  9475. // 微信版本
  9476. var wx_min = uni.getAccountInfoSync();
  9477. // 设备信息
  9478. var system = uni.getSystemInfoSync();
  9479. var wx_projectkey = 'travelApp';
  9480. if (system.uniPlatform == 'mp-weixin') {
  9481. var envV = wx_min.miniProgram.envVersion;
  9482. }
  9483. var _default = {
  9484. serverFile: 'https://broadcast.waityou24.cn',
  9485. serverUrl: 'http://192.168.1.113:14001',
  9486. wx_projectkey: wx_projectkey,
  9487. wx_miniProgram: wx_min.miniProgram,
  9488. system: system,
  9489. share: {},
  9490. orderList: [{
  9491. icon: "icon-shenpi",
  9492. title: "待付款",
  9493. status: "0",
  9494. type: "order",
  9495. route: "pagesMy/order/index"
  9496. }, {
  9497. icon: "icon-31daifahuo",
  9498. title: "待使用",
  9499. status: "4",
  9500. type: "order",
  9501. route: "pagesMy/order/index"
  9502. }, {
  9503. icon: "icon-daishouhuo",
  9504. title: "待评价",
  9505. status: "5",
  9506. type: "order",
  9507. route: "pagesMy/order/index"
  9508. }, {
  9509. icon: "icon-transaction",
  9510. title: "退款/售后",
  9511. status: "6",
  9512. type: "order",
  9513. route: "pagesMy/order/index"
  9514. }],
  9515. menuList: [{
  9516. icon: "icon-yonghu",
  9517. title: "账号设置",
  9518. route: "pagesMy/account/index"
  9519. }],
  9520. china: [
  9521. //全国地址
  9522. {
  9523. name: '北京市',
  9524. city: [{
  9525. name: '北京市',
  9526. area: ['东城区', '西城区', '崇文区', '宣武区', '朝阳区', '丰台区', '石景山区', '海淀区', '门头沟区', '房山区', '通州区', '顺义区', '昌平区', '大兴区', '平谷区', '怀柔区', '密云县', '延庆县']
  9527. }]
  9528. }, {
  9529. name: '天津市',
  9530. city: [{
  9531. name: '天津市',
  9532. area: ['和平区', '河东区', '河西区', '南开区', '河北区', '红桥区', '塘沽区', '汉沽区', '大港区', '东丽区', '西青区', '津南区', '北辰区', '武清区', '宝坻区', '宁河县', '静海县', '蓟 县']
  9533. }]
  9534. }, {
  9535. name: '河北省',
  9536. city: [{
  9537. name: '石家庄市',
  9538. area: ['长安区', '桥东区', '桥西区', '新华区', '郊 区', '井陉矿区', '井陉县', '正定县', '栾城县', '行唐县', '灵寿县', '高邑县', '深泽县', '赞皇县', '无极县', '平山县', '元氏县', '赵 县', '辛集市', '藁', '晋州市', '新乐市', '鹿泉市']
  9539. }, {
  9540. name: '唐山市',
  9541. area: ['路南区', '路北区', '古冶区', '开平区', '新 区', '丰润县', '滦 县', '滦南县', '乐亭县', '迁西县', '玉田县', '唐海县', '遵化市', '丰南市', '迁安市']
  9542. }, {
  9543. name: '秦皇岛市',
  9544. area: ['海港区', '山海关区', '北戴河区', '青龙满族自治县', '昌黎县', '抚宁县', '卢龙县']
  9545. }, {
  9546. name: '邯郸市',
  9547. area: ['邯山区', '丛台区', '复兴区', '峰峰矿区', '邯郸县', '临漳县', '成安县', '大名县', '涉 县', '磁 县', '肥乡县', '永年县', '邱 县', '鸡泽县', '广平县', '馆陶县', '魏 县', '曲周县', '武安市']
  9548. }, {
  9549. name: '邢台市',
  9550. area: ['桥东区', '桥西区', '邢台县', '临城县', '内丘县', '柏乡县', '隆尧县', '任 县', '南和县', '宁晋县', '巨鹿县', '新河县', '广宗县', '平乡县', '威 县', '清河县', '临西县', '南宫市', '沙河市']
  9551. }, {
  9552. name: '保定市',
  9553. area: ['新市区', '北市区', '南市区', '满城县', '清苑县', '涞水县', '阜平县', '徐水县', '定兴县', '唐 县', '高阳县', '容城县', '涞源县', '望都县', '安新县', '易 县', '曲阳县', '蠡 县', '顺平县', '博野', '雄县', '涿州市', '定州市', '安国市', '高碑店市']
  9554. }, {
  9555. name: '张家口',
  9556. area: ['桥东区', '桥西区', '宣化区', '下花园区', '宣化县', '张北县', '康保县', '沽源县', '尚义县', '蔚 县', '阳原县', '怀安县', '万全县', '怀来县', '涿鹿县', '赤城县', '崇礼县']
  9557. }, {
  9558. name: '承德市',
  9559. area: ['双桥区', '双滦区', '鹰手营子矿区', '承德县', '兴隆县', '平泉县', '滦平县', '隆化县', '丰宁满族自治县', '宽城满族自治县', '围场满族蒙古族自治县']
  9560. }, {
  9561. name: '沧州市',
  9562. area: ['新华区', '运河区', '沧 县', '青 县', '东光县', '海兴县', '盐山县', '肃宁县', '南皮县', '吴桥县', '献 县', '孟村回族自治县', '泊头市', '任丘市', '黄骅市', '河间市']
  9563. }, {
  9564. name: '廊坊市',
  9565. area: ['安次区', '固安县', '永清县', '香河县', '大城县', '文安县', '大厂回族自治县', '霸州市', '三河市']
  9566. }, {
  9567. name: '衡水市',
  9568. area: ['桃城区', '枣强县', '武邑县', '武强县', '饶阳县', '安平县', '故城县', '景 县', '阜城县', '冀州市', '深州市']
  9569. }]
  9570. }, {
  9571. name: '山西省',
  9572. city: [{
  9573. name: '太原市',
  9574. area: ['小店区', '迎泽区', '杏花岭区', '尖草坪区', '万柏林区', '晋源区', '清徐县', '阳曲县', '娄烦县', '古交市']
  9575. }, {
  9576. name: '大同市',
  9577. area: ['城 区', '矿 区', '南郊区', '新荣区', '阳高县', '天镇县', '广灵县', '灵丘县', '浑源县', '左云县', '大同县']
  9578. }, {
  9579. name: '阳泉市',
  9580. area: ['城 区', '矿 区', '郊 区', '平定县', '盂 县']
  9581. }, {
  9582. name: '长治市',
  9583. area: ['城 区', '郊 区', '长治县', '襄垣县', '屯留县', '平顺县', '黎城县', '壶关县', '长子县', '武乡县', '沁 县', '沁源县', '潞城市']
  9584. }, {
  9585. name: '晋城市',
  9586. area: ['城 区', '沁水县', '阳城县', '陵川县', '泽州县', '高平市']
  9587. }, {
  9588. name: '朔州市',
  9589. area: ['朔城区', '平鲁区', '山阴县', '应 县', '右玉县', '怀仁县']
  9590. }, {
  9591. name: '忻州市',
  9592. area: ['忻府区', '原平市', '定襄县', '五台县', '代 县', '繁峙县', '宁武县', '静乐县', '神池县', '五寨县', '岢岚县', '河曲县', '保德县', '偏关县']
  9593. }, {
  9594. name: '吕梁市',
  9595. area: ['离石区', '孝义市', '汾阳市', '文水县', '交城县', '兴 县', '临 县', '柳林县', '石楼县', '岚 县', '方山县', '中阳县', '交口县']
  9596. }, {
  9597. name: '晋中市',
  9598. area: ['榆次市', '介休市', '榆社县', '左权县', '和顺县', '昔阳县', '寿阳县', '太谷县', '祁 县', '平遥县', '灵石县']
  9599. }, {
  9600. name: '临汾市',
  9601. area: ['临汾市', '侯马市', '霍州市', '曲沃县', '翼城县', '襄汾县', '洪洞县', '古 县', '安泽县', '浮山县', '吉 县', '乡宁县', '蒲 县', '大宁县', '永和县', '隰 县', '汾西县']
  9602. }, {
  9603. name: '运城市',
  9604. area: ['运城市', '永济市', '河津市', '芮城县', '临猗县', '万荣县', '新绛县', '稷山县', '闻喜县', '夏 县', '绛 县', '平陆县', '垣曲县']
  9605. }]
  9606. }, {
  9607. name: '内蒙古',
  9608. city: [{
  9609. name: '呼和浩特市',
  9610. area: ['新城区', '回民区', '玉泉区', '郊 区', '土默特左旗', '托克托县', '和林格尔县', '清水河县', '武川县']
  9611. }, {
  9612. name: '包头市',
  9613. area: ['东河区', '昆都伦区', '青山区', '石拐矿区', '白云矿区', '郊 区', '土默特右旗', '固阳县', '达尔罕茂明安联合旗']
  9614. }, {
  9615. name: '乌海市',
  9616. area: ['海勃湾区', '海南区', '乌达区']
  9617. }, {
  9618. name: '赤峰市',
  9619. area: ['红山区', '元宝山区', '松山区', '阿鲁科尔沁旗', '巴林左旗', '巴林右旗', '林西县', '克什克腾旗', '翁牛特旗', '喀喇沁旗', '宁城县', '敖汉旗']
  9620. }, {
  9621. name: '呼伦贝尔市',
  9622. area: ['海拉尔市', '满洲里市', '扎兰屯市', '牙克石市', '根河市', '额尔古纳市', '阿荣旗', '莫力达瓦达斡尔族自治旗', '鄂伦春自治旗', '鄂温克族自治旗', '新巴尔虎右旗', '新巴尔虎左旗', '陈巴尔虎旗']
  9623. }, {
  9624. name: '兴安盟',
  9625. area: ['乌兰浩特市', '阿尔山市', '科尔沁右翼前旗', '科尔沁右翼中旗', '扎赉特旗', '突泉县']
  9626. }, {
  9627. name: '通辽市',
  9628. area: ['科尔沁区', '霍林郭勒市', '科尔沁左翼中旗', '科尔沁左翼后旗', '开鲁县', '库伦旗', '奈曼旗', '扎鲁特旗']
  9629. }, {
  9630. name: '锡林郭勒盟',
  9631. area: ['二连浩特市', '锡林浩特市', '阿巴嘎旗', '苏尼特左旗', '苏尼特右旗', '东乌珠穆沁旗', '西乌珠穆沁旗', '太仆寺旗', '镶黄旗', '正镶白旗', '正蓝旗', '多伦县']
  9632. }, {
  9633. name: '乌兰察布盟',
  9634. area: ['集宁市', '丰镇市', '卓资县', '化德县', '商都县', '兴和县', '凉城县', '察哈尔右翼前旗', '察哈尔右翼中旗', '察哈尔右翼后旗', '四子王旗']
  9635. }, {
  9636. name: '伊克昭盟',
  9637. area: ['东胜市', '达拉特旗', '准格尔旗', '鄂托克前旗', '鄂托克旗', '杭锦旗', '乌审旗', '伊金霍洛旗']
  9638. }, {
  9639. name: '巴彦淖尔盟',
  9640. area: ['临河市', '五原县', '磴口县', '乌拉特前旗', '乌拉特中旗', '乌拉特后旗', '杭锦后旗']
  9641. }, {
  9642. name: '阿拉善盟',
  9643. area: ['阿拉善左旗', '阿拉善右旗', '额济纳旗']
  9644. }]
  9645. }, {
  9646. name: '辽宁省',
  9647. city: [{
  9648. name: '沈阳市',
  9649. area: ['沈河区', '皇姑区', '和平区', '大东区', '铁西区', '苏家屯区', '东陵区', '于洪区', '新民市', '法库县', '辽中县', '康平县', '新城子区']
  9650. }, {
  9651. name: '大连市',
  9652. area: ['西岗区', '中山区', '沙河口区', '甘井子区', '旅顺口区', '金州区', '瓦房店市', '普兰店市', '庄河市', '长海县']
  9653. }, {
  9654. name: '鞍山市',
  9655. area: ['铁东区', '铁西区', '立山区', '千山区', '海城市', '台安县', '岫岩满族自治县']
  9656. }, {
  9657. name: '抚顺市',
  9658. area: ['顺城区', '新抚区', '东洲区', '望花区', '抚顺县', '清原满族自治县', '新宾满族自治县']
  9659. }, {
  9660. name: '本溪市',
  9661. area: ['平山区', '明山区', '溪湖区', '南芬区', '本溪满族自治县', '桓仁满族自治县']
  9662. }, {
  9663. name: '丹东市',
  9664. area: ['振兴区', '元宝区', '振安区', '东港市', '凤城市', '宽甸满族自治县']
  9665. }, {
  9666. name: '锦州市',
  9667. area: ['太和区', '古塔区', '凌河区', '凌海市', '黑山县', '义县', '北宁市']
  9668. }, {
  9669. name: '营口市',
  9670. area: ['站前区', '西市区', '鲅鱼圈区', '老边区', '大石桥市', '盖州市']
  9671. }, {
  9672. name: '阜新市',
  9673. area: ['海州区', '新邱区', '太平区', '清河门区', '细河区', '彰武县', '阜新蒙古族自治县']
  9674. }, {
  9675. name: '辽阳市',
  9676. area: ['白塔区', '文圣区', '宏伟区', '太子河区', '弓长岭区', '灯塔市', '辽阳县']
  9677. }, {
  9678. name: '盘锦',
  9679. area: ['双台子区', '兴隆台区', '盘山县', '大洼县']
  9680. }, {
  9681. name: '铁岭市',
  9682. area: ['银州区', '清河区', '调兵山市', '开原市', '铁岭县', '昌图县', '西丰县']
  9683. }, {
  9684. name: '朝阳市',
  9685. area: ['双塔区', '龙城区', '凌源市', '北票市', '朝阳县', '建平县', '喀喇沁左翼蒙古族自治县']
  9686. }, {
  9687. name: '葫芦岛市',
  9688. area: ['龙港区', '南票区', '连山区', '兴城市', '绥中县', '建昌县']
  9689. }]
  9690. }, {
  9691. name: '吉林省',
  9692. city: [{
  9693. name: '长春市',
  9694. area: ['朝阳区', '宽城区', '二道区', '南关区', '绿园区', '双阳区', '九台市', '榆树市', '德惠市', '农安县']
  9695. }, {
  9696. name: '吉林市',
  9697. area: ['船营区', '昌邑区', '龙潭区', '丰满区', '舒兰市', '桦甸市', '蛟河市', '磐石市', '永吉县']
  9698. }, {
  9699. name: '四平',
  9700. area: ['铁西区', '铁东区', '公主岭市', '双辽市', '梨树县', '伊通满族自治县']
  9701. }, {
  9702. name: '辽源市',
  9703. area: ['龙山区', '西安区', '东辽县', '东丰县']
  9704. }, {
  9705. name: '通化市',
  9706. area: ['东昌区', '二道江区', '梅河口市', '集安市', '通化县', '辉南县', '柳河县']
  9707. }, {
  9708. name: '白山市',
  9709. area: ['八道江区', '江源区', '临江市', '靖宇县', '抚松县', '长白朝鲜族自治县']
  9710. }, {
  9711. name: '松原市',
  9712. area: ['宁江区', '乾安县', '长岭县', '扶余县', '前郭尔罗斯蒙古族自治县']
  9713. }, {
  9714. name: '白城市',
  9715. area: ['洮北区', '大安市', '洮南市', '镇赉县', '通榆县']
  9716. }, {
  9717. name: '延边朝鲜族自治州',
  9718. area: ['延吉市', '图们市', '敦化市', '龙井市', '珲春市', '和龙市', '安图县', '汪清县']
  9719. }]
  9720. }, {
  9721. name: '黑龙江省',
  9722. city: [{
  9723. name: '哈尔滨市',
  9724. area: ['松北区', '道里区', '南岗区', '平房区', '香坊区', '道外区', '呼兰区', '阿城区', '双城市', '尚志市', '五常市', '宾县', '方正县', '通河县', '巴彦县', '延寿县', '木兰县', '依兰县']
  9725. }, {
  9726. name: '齐齐哈尔市',
  9727. area: ['龙沙区', '昂昂溪区', '铁锋区', '建华区', '富拉尔基区', '碾子山区', '梅里斯达斡尔族区', '讷河市', '富裕县', '拜泉县', '甘南县', '依安县', '克山县', '泰来县', '克东县', '龙江县']
  9728. }, {
  9729. name: '鹤岗市',
  9730. area: ['兴山区', '工农区', '南山区', '兴安区', '向阳区', '东山区', '萝北县', '绥滨县']
  9731. }, {
  9732. name: '双鸭山',
  9733. area: ['尖山区', '岭东区', '四方台区', '宝山区', '集贤县', '宝清县', '友谊县', '饶河县']
  9734. }, {
  9735. name: '鸡西市',
  9736. area: ['鸡冠区', '恒山区', '城子河区', '滴道区', '梨树区', '麻山区', '密山市', '虎林市', '鸡东县']
  9737. }, {
  9738. name: '大庆市',
  9739. area: ['萨尔图区', '红岗区', '龙凤区', '让胡路区', '大同区', '林甸县', '肇州县', '肇源县', '杜尔伯特蒙古族自治县']
  9740. }, {
  9741. name: '伊春市',
  9742. area: ['伊春区', '带岭区', '南岔区', '金山屯区', '西林区', '美溪区', '乌马河区', '翠峦区', '友好区', '上甘岭区', '五营区', '红星区', '新青区', '汤旺河区', '乌伊岭区', '铁力市', '嘉荫县']
  9743. }, {
  9744. name: '牡丹江市',
  9745. area: ['爱民区', '东安区', '阳明区', '西安区', '绥芬河市', '宁安市', '海林市', '穆棱市', '林口县', '东宁县']
  9746. }, {
  9747. name: '佳木斯市',
  9748. area: ['向阳区', '前进区', '东风区', '郊区', '同江市', '富锦市', '桦川县', '抚远县', '桦南县', '汤原县']
  9749. }, {
  9750. name: '七台河市',
  9751. area: ['桃山区', '新兴区', '茄子河区', '勃利县']
  9752. }, {
  9753. name: '黑河市',
  9754. area: ['爱辉区', '北安市', '五大连池市', '逊克县', '嫩江县', '孙吴县']
  9755. }, {
  9756. name: '绥化市',
  9757. area: ['北林区', '安达市', '肇东市', '海伦市', '绥棱县', '兰西县', '明水县', '青冈县', '庆安县', '望奎县']
  9758. }, {
  9759. name: '大兴安岭地区',
  9760. area: ['呼玛县', '塔河县', '漠河县', '大兴安岭辖区']
  9761. }]
  9762. }, {
  9763. name: '上海市',
  9764. city: [{
  9765. name: '上海市',
  9766. area: ['黄浦区', '卢湾区', '徐汇区', '长宁区', '静安区', '普陀区', '闸北区', '虹口区', '杨浦区', '宝山区', '闵行区', '嘉定区', '松江区', '金山区', '青浦区', '南汇区', '奉贤区', '浦东新区', '崇明县']
  9767. }]
  9768. }, {
  9769. name: '江苏省',
  9770. city: [{
  9771. name: '南京市',
  9772. area: ['玄武区', '白下区', '秦淮区', '建邺区', '鼓楼区', '下关区', '栖霞区', '雨花台区', '浦口区', '江宁区', '六合区', '溧水县', '高淳县']
  9773. }, {
  9774. name: '苏州市',
  9775. area: ['金阊区', '平江区', '沧浪区', '虎丘区', '吴中区', '相城区', '常熟市', '张家港市', '昆山市', '吴江市', '太仓市']
  9776. }, {
  9777. name: '无锡市',
  9778. area: ['崇安区', '南长区', '北塘区', '滨湖区', '锡山区', '惠山区', '江阴市', '宜兴市']
  9779. }, {
  9780. name: '常州市',
  9781. area: ['钟楼区', '天宁区', '戚墅堰区', '新北区', '武进区', '金坛市', '溧阳市']
  9782. }, {
  9783. name: '镇江市',
  9784. area: ['京口区', '润州区', '丹徒区', '丹阳市', '扬中市', '句容市']
  9785. }, {
  9786. name: '南通市',
  9787. area: ['崇川区', '港闸区', '通州市', '如皋市', '海门市', '启东市', '海安县', '如东县']
  9788. }, {
  9789. name: '泰州市',
  9790. area: ['海陵区', '高港区', '姜堰市', '泰兴市', '靖江市', '兴化市']
  9791. }, {
  9792. name: '扬州市',
  9793. area: ['广陵区', '维扬区', '邗江区', '江都市', '仪征市', '高邮市', '宝应县']
  9794. }, {
  9795. name: '盐城市',
  9796. area: ['亭湖区', '盐都区', '大丰市', '东台市', '建湖县', '射阳县', '阜宁县', '滨海县', '响水县']
  9797. }, {
  9798. name: '连云港市',
  9799. area: ['新浦区', '海州区', '连云区', '东海县', '灌云县', '赣榆县', '灌南县']
  9800. }, {
  9801. name: '徐州市',
  9802. area: ['云龙区', '鼓楼区', '九里区', '泉山区', '贾汪区', '邳州市', '新沂市', '铜山县', '睢宁县', '沛县', '丰县']
  9803. }, {
  9804. name: '淮安市',
  9805. area: ['清河区', '清浦区', '楚州区', '淮阴区', '涟水县', '洪泽县', '金湖县', '盱眙县']
  9806. }, {
  9807. name: '宿迁市',
  9808. area: ['宿城区', '宿豫区', '沭阳县', '泗阳县', '泗洪县']
  9809. }]
  9810. }, {
  9811. name: '浙江省',
  9812. city: [{
  9813. name: '杭州市',
  9814. area: ['拱墅区', '西湖区', '上城区', '下城区', '江干区', '滨江区', '余杭区', '萧山区', '建德市', '富阳市', '临安市', '桐庐县', '淳安县']
  9815. }, {
  9816. name: '宁波市',
  9817. area: ['海曙区', '江东区', '江北区', '镇海区', '北仑区', '鄞州区', '余姚市', '慈溪市', '奉化市', '宁海县', '象山县']
  9818. }, {
  9819. name: '温州市',
  9820. area: ['鹿城区', '龙湾区', '瓯海区', '瑞安市', '乐清市', '永嘉县', '洞头县', '平阳县', '苍南县', '文成县', '泰顺县']
  9821. }, {
  9822. name: '嘉兴市',
  9823. area: ['秀城区', '秀洲区', '海宁市', '平湖市', '桐乡市', '嘉善县', '海盐县']
  9824. }, {
  9825. name: '湖州市',
  9826. area: ['吴兴区', '南浔区', '长兴县', '德清县', '安吉县']
  9827. }, {
  9828. name: '绍兴市',
  9829. area: ['越城区', '诸暨市', '上虞市', '嵊州市', '绍兴县', '新昌县']
  9830. }, {
  9831. name: '金华市',
  9832. area: ['婺城区', '金东区', '兰溪市', '义乌市', '东阳市', '永康市', '武义县', '浦江县', '磐安县']
  9833. }, {
  9834. name: '衢州市',
  9835. area: ['柯城区', '衢江区', '江山市', '龙游县', '常山县', '开化县']
  9836. }, {
  9837. name: '舟山市',
  9838. area: ['定海区', '普陀区', '岱山县', '嵊泗县']
  9839. }, {
  9840. name: '台州市',
  9841. area: ['椒江区', '黄岩区', '路桥区', '临海市', '温岭市', '玉环县', '天台县', '仙居县', '三门县']
  9842. }, {
  9843. name: '丽水市',
  9844. area: ['莲都区', '龙泉市', '缙云县', '青田县', '云和县', '遂昌县', '松阳县', '庆元县', '景宁畲族自治县']
  9845. }]
  9846. }, {
  9847. name: '安徽省',
  9848. city: [{
  9849. name: '合肥市',
  9850. area: ['庐阳区', '瑶海区', '蜀山区', '包河区', '长丰县', '肥东县', '肥西县']
  9851. }, {
  9852. name: '芜湖市',
  9853. area: ['镜湖区', '弋江区', '鸠江区', '三山区', '芜湖县', '南陵县', '繁昌县']
  9854. }, {
  9855. name: '蚌埠市',
  9856. area: ['蚌山区', '龙子湖区', '禹会区', '淮上区', '怀远县', '固镇县', '五河县']
  9857. }, {
  9858. name: '淮南市',
  9859. area: ['田家庵区', '大通区', '谢家集区', '八公山区', '潘集区', '凤台县']
  9860. }, {
  9861. name: '马鞍山市',
  9862. area: ['雨山区', '花山区', '金家庄区', '当涂县']
  9863. }, {
  9864. name: '淮北市',
  9865. area: ['相山区', '杜集区', '烈山区', '濉溪县']
  9866. }, {
  9867. name: '铜陵市',
  9868. area: ['铜官山区', '狮子山区', '郊区', '铜陵县']
  9869. }, {
  9870. name: '安庆市',
  9871. area: ['迎江区', '大观区', '宜秀区', '桐城市', '宿松县', '枞阳县', '太湖县', '怀宁县', '岳西县', '望江县', '潜山县']
  9872. }, {
  9873. name: '黄山市',
  9874. area: ['屯溪区', '黄山区', '徽州区', '休宁县', '歙县', '祁门县', '黟县']
  9875. }, {
  9876. name: '滁州市',
  9877. area: ['琅琊区', '南谯区', '天长市', '明光市', '全椒县', '来安县', '定远县', '凤阳县']
  9878. }, {
  9879. name: '阜阳市',
  9880. area: ['颍州区', '颍东区', '颍泉区', '界首市', '临泉县', '颍上县', '阜南县', '太和县']
  9881. }, {
  9882. name: '宿州市',
  9883. area: ['埇桥区', '萧县', '泗县', '砀山县', '灵璧县']
  9884. }, {
  9885. name: '巢湖市',
  9886. area: ['居巢区', '含山县', '无为县', '庐江县', '和县']
  9887. }, {
  9888. name: '六安市',
  9889. area: ['金安区', '裕安区', '寿县', '霍山县', '霍邱县', '舒城县', '金寨县']
  9890. }, {
  9891. name: '亳州市',
  9892. area: ['谯城区', '利辛县', '涡阳县', '蒙城县']
  9893. }, {
  9894. name: '池州市',
  9895. area: ['贵池区', '东至县', '石台县', '青阳县']
  9896. }, {
  9897. name: '宣城市',
  9898. area: ['宣州区', '宁国市', '广德县', '郎溪县', '泾县', '旌德县', '绩溪县']
  9899. }]
  9900. }, {
  9901. name: '福建省',
  9902. city: [{
  9903. name: '福州市',
  9904. area: ['鼓楼区', '台江区', '仓山区', '马尾区', '晋安区', '福清市', '长乐市', '闽侯县', '闽清县', '永泰县', '连江县', '罗源县', '平潭县']
  9905. }, {
  9906. name: '厦门市',
  9907. area: ['思明区', '海沧区', '湖里区', '集美区', '同安区', '翔安区']
  9908. }, {
  9909. name: '莆田市',
  9910. area: ['城厢区', '涵江区', '荔城区', '秀屿区', '仙游县']
  9911. }, {
  9912. name: '三明市',
  9913. area: ['梅列区', '三元区', '永安市', '明溪县', '将乐县', '大田县', '宁化县', '建宁县', '沙县', '尤溪县', '清流县', '泰宁县']
  9914. }, {
  9915. name: '泉州市',
  9916. area: ['鲤城区', '丰泽区', '洛江区', '泉港区', '石狮市', '晋江市', '南安市', '惠安县', '永春县', '安溪县', '德化县', '金门县']
  9917. }, {
  9918. name: '漳州市',
  9919. area: ['芗城区', '龙文区', '龙海市', '平和县', '南靖县', '诏安县', '漳浦县', '华安县', '东山县', '长泰县', '云霄县']
  9920. }, {
  9921. name: '南平市',
  9922. area: ['延平区', '建瓯市', '邵武市', '武夷山市', '建阳市', '松溪县', '光泽县', '顺昌县', '浦城县', '政和县']
  9923. }, {
  9924. name: '龙岩市',
  9925. area: ['新罗区', '漳平市', '长汀县', '武平县', '上杭县', '永定县', '连城县']
  9926. }, {
  9927. name: '宁德市',
  9928. area: ['蕉城区', '福安市', '福鼎市', '寿宁县', '霞浦县', '柘荣县', '屏南县', '古田县', '周宁县']
  9929. }]
  9930. }, {
  9931. name: '江西省',
  9932. city: [{
  9933. name: '南昌市',
  9934. area: ['东湖区', '西湖区', '青云谱区', '湾里区', '青山湖区', '新建县', '南昌县', '进贤县', '安义县']
  9935. }, {
  9936. name: '景德镇市',
  9937. area: ['珠山区', '昌江区', '乐平市', '浮梁县']
  9938. }, {
  9939. name: '萍乡市',
  9940. area: ['安源区', '湘东区', '莲花县', '上栗县', '芦溪县']
  9941. }, {
  9942. name: '九江市',
  9943. area: ['浔阳区', '庐山区', '瑞昌市', '九江县', '星子县', '武宁县', '彭泽县', '永修县', '修水县', '湖口县', '德安县', '都昌县']
  9944. }, {
  9945. name: '新余市',
  9946. area: ['渝水区', '分宜县']
  9947. }, {
  9948. name: '鹰潭市',
  9949. area: ['月湖区', '贵溪市', '余江县']
  9950. }, {
  9951. name: '赣州市',
  9952. area: ['章贡区', '瑞金市', '南康市', '石城县', '安远县', '赣县', '宁都县', '寻乌县', '兴国县', '定南县', '上犹县', '于都县', '龙南县', '崇义县', '信丰县', '全南县', '大余县', '会昌县']
  9953. }, {
  9954. name: '吉安市',
  9955. area: ['吉州区', '青原区', '井冈山市', '吉安县', '永丰县', '永新县', '新干县', '泰和县', '峡江县', '遂川县', '安福县', '吉水县', '万安县']
  9956. }, {
  9957. name: '宜春市',
  9958. area: ['袁州区', '丰城市', '樟树市', '高安市', '铜鼓县', '靖安县', '宜丰县', '奉新县', '万载县', '上高县']
  9959. }, {
  9960. name: '抚州市',
  9961. area: ['临川区', '南丰县', '乐安县', '金溪县', '南城县', '东乡县', '资溪县', '宜黄县', '广昌县', '黎川县', '崇仁县']
  9962. }, {
  9963. name: '上饶市',
  9964. area: ['信州区', '德兴市', '上饶县', '广丰县', '鄱阳县', '婺源县', '铅山县', '余干县', '横峰县', '弋阳县', '玉山县', '万年县']
  9965. }]
  9966. }, {
  9967. name: '山东省',
  9968. city: [{
  9969. name: '济南市',
  9970. area: ['市中区', '历下区', '天桥区', '槐荫区', '历城区', '长清区', '章丘市', '平阴县', '济阳县', '商河县']
  9971. }, {
  9972. name: '青岛市',
  9973. area: ['市南区', '市北区', '城阳区', '四方区', '李沧区', '黄岛区', '崂山区', '胶南市', '胶州市', '平度市', '莱西市', '即墨市']
  9974. }, {
  9975. name: '淄博市',
  9976. area: ['张店区', '临淄区', '淄川区', '博山区', '周村区', '桓台县', '高青县', '沂源县']
  9977. }, {
  9978. name: '枣庄市',
  9979. area: ['市中区', '山亭区', '峄城区', '台儿庄区', '薛城区', '滕州市']
  9980. }, {
  9981. name: '东营市',
  9982. area: ['东营区', '河口区', '垦利县', '广饶县', '利津县']
  9983. }, {
  9984. name: '烟台市',
  9985. area: ['芝罘区', '福山区', '牟平区', '莱山区', '龙口市', '莱阳市', '莱州市', '招远市', '蓬莱市', '栖霞市', '海阳市', '长岛县']
  9986. }, {
  9987. name: '潍坊市',
  9988. area: ['潍城区', '寒亭区', '坊子区', '奎文区', '青州市', '诸城市', '寿光市', '安丘市', '高密市', '昌邑市', '昌乐县', '临朐县']
  9989. }, {
  9990. name: '济宁市',
  9991. area: ['市中区', '任城区', '曲阜市', '兖州市', '邹城市', '鱼台县', '金乡县', '嘉祥县', '微山县', '汶上县', '泗水县', '梁山县']
  9992. }, {
  9993. name: '泰安市',
  9994. area: ['泰山区', '岱岳区', '新泰市', '肥城市', '宁阳县', '东平县']
  9995. }, {
  9996. name: '威海市',
  9997. area: ['环翠区', '乳山市', '文登市', '荣成市']
  9998. }, {
  9999. name: '日照市',
  10000. area: ['东港区', '岚山区', '五莲县', '莒县']
  10001. }, {
  10002. name: '莱芜市',
  10003. area: ['莱城区', '钢城区']
  10004. }, {
  10005. name: '临沂市',
  10006. area: ['兰山区', '罗庄区', '河东区', '沂南县', '郯城县', '沂水县', '苍山县', '费县', '平邑县', '莒南县', '蒙阴县', '临沭县']
  10007. }, {
  10008. name: '德州市',
  10009. area: ['德城区', '乐陵市', '禹城市', '陵县', '宁津县', '齐河县', '武城县', '庆云县', '平原县', '夏津县', '临邑县']
  10010. }, {
  10011. name: '聊城市',
  10012. area: ['东昌府区', '临清市', '高唐县', '阳谷县', '茌平县', '莘县', '东阿县', '冠县']
  10013. }, {
  10014. name: '滨州市',
  10015. area: ['滨城区', '邹平县', '沾化县', '惠民县', '博兴县', '阳信县', '无棣县']
  10016. }, {
  10017. name: '菏泽市',
  10018. area: ['牡丹区', '鄄城县', '单县', '郓城县', '曹县', '定陶县', '巨野县', '东明县', '成武县']
  10019. }]
  10020. }, {
  10021. name: '河南省',
  10022. city: [{
  10023. name: '郑州市',
  10024. area: ['中原区', '金水区', '二七区', '管城回族区', '上街区', '惠济区', '巩义市', '新郑市', '新密市', '登封市', '荥阳市', '中牟县']
  10025. }, {
  10026. name: '开封市',
  10027. area: ['鼓楼区', '龙亭区', '顺河回族区', '禹王台区', '金明区', '开封县', '尉氏县', '兰考县', '杞县', '通许县']
  10028. }, {
  10029. name: '洛阳市',
  10030. area: ['西工区', '老城区', '涧西区', '瀍河回族区', '洛龙区', '吉利区', '偃师市', '孟津县', '汝阳县', '伊川县', '洛宁县', '嵩县', '宜阳县', '新安县', '栾川县']
  10031. }, {
  10032. name: '平顶山市',
  10033. area: ['新华区', '卫东区', '湛河区', '石龙区', '汝州市', '舞钢市', '宝丰县', '叶县', '郏县', '鲁山县']
  10034. }, {
  10035. name: '安阳市',
  10036. area: ['北关区', '文峰区', '殷都区', '龙安区', '林州市', '安阳县', '滑县', '内黄县', '汤阴县']
  10037. }, {
  10038. name: '鹤壁市',
  10039. area: ['淇滨区', '山城区', '鹤山区', '浚县', '淇县']
  10040. }, {
  10041. name: '新乡市',
  10042. area: ['卫滨区', '红旗区', '凤泉区', '牧野区', '卫辉市', '辉县市', '新乡县', '获嘉县', '原阳县', '长垣县', '封丘县', '延津县']
  10043. }, {
  10044. name: '焦作市',
  10045. area: ['解放区', '中站区', '马村区', '山阳区', '沁阳市', '孟州市', '修武县', '温县', '武陟县', '博爱县']
  10046. }, {
  10047. name: '濮阳市',
  10048. area: ['华龙区', '濮阳县', '南乐县', '台前县', '清丰县', '范县']
  10049. }, {
  10050. name: '许昌市',
  10051. area: ['魏都区', '禹州市', '长葛市', '许昌县', '鄢陵县', '襄城县']
  10052. }, {
  10053. name: '漯河市',
  10054. area: ['源汇区', '郾城区', '召陵区', '临颍县', '舞阳县']
  10055. }, {
  10056. name: '三门峡市',
  10057. area: ['湖滨区', '义马市', '灵宝市', '渑池县', '卢氏县', '陕县']
  10058. }, {
  10059. name: '南阳市',
  10060. area: ['卧龙区', '宛城区', '邓州市', '桐柏县', '方城县', '淅川县', '镇平县', '唐河县', '南召县', '内乡县', '新野县', '社旗县', '西峡县']
  10061. }, {
  10062. name: '商丘市',
  10063. area: ['梁园区', '睢阳区', '永城市', '宁陵县', '虞城县', '民权县', '夏邑县', '柘城县', '睢县']
  10064. }, {
  10065. name: '信阳市',
  10066. area: ['浉河区', '平桥区', '潢川县', '淮滨县', '息县', '新县', '商城县', '固始县', '罗山县', '光山县']
  10067. }, {
  10068. name: '周口市',
  10069. area: ['川汇区', '项城市', '商水县', '淮阳县', '太康县', '鹿邑县', '西华县', '扶沟县', '沈丘县', '郸城县']
  10070. }, {
  10071. name: '驻马店市',
  10072. area: ['驿城区', '确山县', '新蔡县', '上蔡县', '西平县', '泌阳县', '平舆县', '汝南县', '遂平县', '正阳县']
  10073. }, {
  10074. name: '焦作市',
  10075. area: ['济源市']
  10076. }]
  10077. }, {
  10078. name: '湖北省',
  10079. city: [{
  10080. name: '武汉市',
  10081. area: ['江岸区', '武昌区', '江汉区', '硚口区', '汉阳区', '青山区', '洪山区', '东西湖区', '汉南区', '蔡甸区', '江夏区', '黄陂区', '新洲区']
  10082. }, {
  10083. name: '黄石市',
  10084. area: ['黄石港区', '西塞山区', '下陆区', '铁山区', '大冶市', '阳新县']
  10085. }, {
  10086. name: '十堰市',
  10087. area: ['张湾区', '茅箭区', '丹江口市', '郧县', '竹山县', '房县', '郧西县', '竹溪县']
  10088. }, {
  10089. name: '荆州市',
  10090. area: ['沙市区', '荆州区', '洪湖市', '石首市', '松滋市', '监利县', '公安县', '江陵县']
  10091. }, {
  10092. name: '宜昌市',
  10093. area: ['西陵区', '伍家岗区', '点军区', '猇亭区', '夷陵区', '宜都市', '当阳市', '枝江市', '秭归县', '远安县', '兴山县', '五峰土家族自治县', '长阳土家族自治县']
  10094. }, {
  10095. name: '襄樊市',
  10096. area: ['襄城区', '樊城区', '襄阳区', '老河口市', '枣阳市', '宜城市', '南漳县', '谷城县', '保康县']
  10097. }, {
  10098. name: '鄂州市',
  10099. area: ['鄂城区', '华容区', '梁子湖区']
  10100. }, {
  10101. name: '荆门市',
  10102. area: ['东宝区', '掇刀区', '钟祥市', '京山县', '沙洋县']
  10103. }, {
  10104. name: '孝感市',
  10105. area: ['孝南区', '应城市', '安陆市', '汉川市', '云梦县', '大悟县', '孝昌县']
  10106. }, {
  10107. name: '黄冈市',
  10108. area: ['黄州区', '麻城市', '武穴市', '红安县', '罗田县', '浠水县', '蕲春县', '黄梅县', '英山县', '团风县']
  10109. }, {
  10110. name: '咸宁市',
  10111. area: ['咸安区', '赤壁市', '嘉鱼县', '通山县', '崇阳县', '通城县']
  10112. }, {
  10113. name: '随州市',
  10114. area: ['曾都区', '广水市']
  10115. }, {
  10116. name: '恩施土家族苗族自治州',
  10117. area: ['恩施市', '利川市', '建始县', '来凤县', '巴东县', '鹤峰县', '宣恩县', '咸丰县']
  10118. }, {
  10119. name: '仙桃市',
  10120. area: ['仙桃']
  10121. }, {
  10122. name: '天门市',
  10123. area: ['天门']
  10124. }, {
  10125. name: '潜江市',
  10126. area: ['潜江']
  10127. }, {
  10128. name: '神农架林区',
  10129. area: ['神农架林区']
  10130. }]
  10131. }, {
  10132. name: '湖南省',
  10133. city: [{
  10134. name: '长沙市',
  10135. area: ['岳麓区', '芙蓉区', '天心区', '开福区', '雨花区', '浏阳市', '长沙县', '望城县', '宁乡县']
  10136. }, {
  10137. name: '株洲市',
  10138. area: ['天元区', '荷塘区', '芦淞区', '石峰区', '醴陵市', '株洲县', '炎陵县', '茶陵县', '攸县']
  10139. }, {
  10140. name: '湘潭市',
  10141. area: ['岳塘区', '雨湖区', '湘乡市', '韶山市', '湘潭县']
  10142. }, {
  10143. name: '衡阳市',
  10144. area: ['雁峰区', '珠晖区', '石鼓区', '蒸湘区', '南岳区', '耒阳市', '常宁市', '衡阳县', '衡东县', '衡山县', '衡南县', '祁东县']
  10145. }, {
  10146. name: '邵阳市',
  10147. area: ['双清区', '大祥区', '北塔区', '武冈市', '邵东县', '洞口县', '新邵县', '绥宁县', '新宁县', '邵阳县', '隆回县', '城步苗族自治县']
  10148. }, {
  10149. name: '岳阳市',
  10150. area: ['岳阳楼区', '云溪区', '君山区', '临湘市', '汨罗市', '岳阳县', '湘阴县', '平江县', '华容县']
  10151. }, {
  10152. name: '常德市',
  10153. area: ['武陵区', '鼎城区', '津市市', '澧县', '临澧县', '桃源县', '汉寿县', '安乡县', '石门县']
  10154. }, {
  10155. name: '张家界市',
  10156. area: ['永定区', '武陵源区', '慈利县', '桑植县']
  10157. }, {
  10158. name: '益阳市',
  10159. area: ['赫山区', '资阳区', '沅江市', '桃江县', '南县', '安化县']
  10160. }, {
  10161. name: '郴州市',
  10162. area: ['北湖区', '苏仙区', '资兴市', '宜章县', '汝城县', '安仁县', '嘉禾县', '临武县', '桂东县', '永兴县', '桂阳县']
  10163. }, {
  10164. name: '永州市',
  10165. area: ['冷水滩区', '零陵区', '祁阳县', '蓝山县', '宁远县', '新田县', '东安县', '江永县', '道县', '双牌县', '江华瑶族自治县']
  10166. }, {
  10167. name: '怀化市',
  10168. area: ['鹤城区', '洪江市', '会同县', '沅陵县', '辰溪县', '溆浦县', '中方县', '新晃侗族自治县', '芷江侗族自治县', '通道侗族自治县', '靖州苗族侗族自治县', '麻阳苗族自治县']
  10169. }, {
  10170. name: '娄底市',
  10171. area: ['娄星区', '冷水江市', '涟源市', '新化县', '双峰县']
  10172. }, {
  10173. name: '湘西土家族苗族自治州',
  10174. area: ['吉首市', '古丈县', '龙山县', '永顺县', '凤凰县', '泸溪县', '保靖县', '花垣县']
  10175. }]
  10176. }, {
  10177. name: '广东省',
  10178. city: [{
  10179. name: '广州市',
  10180. area: ['越秀区', '荔湾区', '海珠区', '天河区', '白云区', '黄埔区', '番禺区', '花都区', '南沙区', '萝岗区', '增城市', '从化市']
  10181. }, {
  10182. name: '深圳市',
  10183. area: ['福田区', '罗湖区', '南山区', '宝安区', '龙岗区', '盐田区']
  10184. }, {
  10185. name: '东莞市',
  10186. area: ['莞城', '常平', '塘厦', '塘厦', '塘厦']
  10187. }, {
  10188. name: '中山市',
  10189. area: ['中山']
  10190. }, {
  10191. name: '潮州市',
  10192. area: ['湘桥区', '潮安县', '饶平县']
  10193. }, {
  10194. name: '揭阳市',
  10195. area: ['榕城区', '揭东县', '揭西县', '惠来县', '普宁市']
  10196. }, {
  10197. name: '云浮市',
  10198. area: ['云城区', '新兴县', '郁南县', '云安县', '罗定市']
  10199. }, {
  10200. name: '珠海市',
  10201. area: ['香洲区', '斗门区', '金湾区']
  10202. }, {
  10203. name: '汕头市',
  10204. area: ['金平区', '濠江区', '龙湖区', '潮阳区', '潮南区', '澄海区', '南澳县']
  10205. }, {
  10206. name: '韶关市',
  10207. area: ['浈江区', '武江区', '曲江区', '乐昌市', '南雄市', '始兴县', '仁化县', '翁源县', '新丰县', '乳源瑶族自治县']
  10208. }, {
  10209. name: '佛山市',
  10210. area: ['禅城区', '南海区', '顺德区', '三水区', '高明区']
  10211. }, {
  10212. name: '江门市',
  10213. area: ['蓬江区', '江海区', '新会区', '恩平市', '台山市', '开平市', '鹤山市']
  10214. }, {
  10215. name: '湛江市',
  10216. area: ['赤坎区', '霞山区', '坡头区', '麻章区', '吴川市', '廉江市', '雷州市', '遂溪县', '徐闻县']
  10217. }, {
  10218. name: '茂名市',
  10219. area: ['茂南区', '茂港区', '化州市', '信宜市', '高州市', '电白县']
  10220. }, {
  10221. name: '肇庆市',
  10222. area: ['端州区', '鼎湖区', '高要市', '四会市', '广宁县', '怀集县', '封开县', '德庆县']
  10223. }, {
  10224. name: '惠州市',
  10225. area: ['惠城区', '惠阳区', '博罗县', '惠东县', '龙门县']
  10226. }, {
  10227. name: '梅州市',
  10228. area: ['梅江区', '兴宁市', '梅县', '大埔县', '丰顺县', '五华县', '平远县', '蕉岭县']
  10229. }, {
  10230. name: '汕尾市',
  10231. area: ['城区', '陆丰市', '海丰县', '陆河县']
  10232. }, {
  10233. name: '河源市',
  10234. area: ['源城区', '紫金县', '龙川县', '连平县', '和平县', '东源县']
  10235. }, {
  10236. name: '阳江市',
  10237. area: ['江城区', '阳春市', '阳西县', '阳东县']
  10238. }, {
  10239. name: '清远市',
  10240. area: ['清城区', '英德市', '连州市', '佛冈县', '阳山县', '清新县', '连山壮族瑶族自治县', '连南瑶族自治县']
  10241. }]
  10242. }, {
  10243. name: '广西',
  10244. city: [{
  10245. name: '南宁市',
  10246. area: ['青秀区', '兴宁区', '西乡塘区', '良庆区', '江南区', '邕宁区', '武鸣县', '隆安县', '马山县', '上林县', '宾阳县', '横县']
  10247. }, {
  10248. name: '柳州市',
  10249. area: ['城中区', '鱼峰区', '柳北区', '柳南区', '柳江县', '柳城县', '鹿寨县', '融安县', '融水苗族自治县', '三江侗族自治县']
  10250. }, {
  10251. name: '桂林市',
  10252. area: ['象山区', '秀峰区', '叠彩区', '七星区', '雁山区', '阳朔县', '临桂县', '灵川县', '全州县', '平乐县', '兴安县', '灌阳县', '荔浦县', '资源县', '永福县', '龙胜各族自治县', '恭城瑶族自治县']
  10253. }, {
  10254. name: '梧州市',
  10255. area: ['万秀区', '蝶山区', '长洲区', '岑溪市', '苍梧县', '藤县', '蒙山县']
  10256. }, {
  10257. name: '北海市',
  10258. area: ['海城区', '银海区', '铁山港区', '合浦县']
  10259. }, {
  10260. name: '防城港市',
  10261. area: ['港口区', '防城区', '东兴市', '上思县']
  10262. }, {
  10263. name: '钦州市',
  10264. area: ['钦南区', '钦北区', '灵山县', '浦北县']
  10265. }, {
  10266. name: '贵港市',
  10267. area: ['港北区', '港南区', '覃塘区', '桂平市', '平南县']
  10268. }, {
  10269. name: '玉林市',
  10270. area: ['玉州区', '北流市', '容县', '陆川县', '博白县', '兴业县']
  10271. }, {
  10272. name: '百色市',
  10273. area: ['右江区', '凌云县', '平果县', '西林县', '乐业县', '德保县', '田林县', '田阳县', '靖西县', '田东县', '那坡县', '隆林各族自治县']
  10274. }, {
  10275. name: '贺州市',
  10276. area: ['八步区', '钟山县', '昭平县', '富川瑶族自治县']
  10277. }, {
  10278. name: '河池市',
  10279. area: ['金城江区', '宜州市', '天峨县', '凤山县', '南丹县', '东兰县', '都安瑶族自治县', '罗城仫佬族自治县', '巴马瑶族自治县', '环江毛南族自治县', '大化瑶族自治县']
  10280. }, {
  10281. name: '来宾市',
  10282. area: ['兴宾区', '合山市', '象州县', '武宣县', '忻城县', '金秀瑶族自治县']
  10283. }, {
  10284. name: '崇左市',
  10285. area: ['江州区', '凭祥市', '宁明县', '扶绥县', '龙州县', '大新县', '天等县']
  10286. }]
  10287. }, {
  10288. name: '海南省',
  10289. city: [{
  10290. name: '海口市',
  10291. area: ['龙华区', '秀英区', '琼山区', '美兰区']
  10292. }, {
  10293. name: '三亚市',
  10294. area: ['三亚市']
  10295. }, {
  10296. name: '五指山市',
  10297. area: ['五指山']
  10298. }, {
  10299. name: '琼海市',
  10300. area: ['琼海']
  10301. }, {
  10302. name: '儋州市',
  10303. area: ['儋州']
  10304. }, {
  10305. name: '文昌市',
  10306. area: ['文昌']
  10307. }, {
  10308. name: '万宁市',
  10309. area: ['万宁']
  10310. }, {
  10311. name: '东方市',
  10312. area: ['东方']
  10313. }, {
  10314. name: '澄迈县',
  10315. area: ['澄迈县']
  10316. }, {
  10317. name: '定安县',
  10318. area: ['定安县']
  10319. }, {
  10320. name: '屯昌县',
  10321. area: ['屯昌县']
  10322. }, {
  10323. name: '临高县',
  10324. area: ['临高县']
  10325. }, {
  10326. name: '白沙黎族自治县',
  10327. area: ['白沙黎族自治县']
  10328. }, {
  10329. name: '昌江黎族自治县',
  10330. area: ['昌江黎族自治县']
  10331. }, {
  10332. name: '乐东黎族自治县',
  10333. area: ['乐东黎族自治县']
  10334. }, {
  10335. name: '陵水黎族自治县',
  10336. area: ['陵水黎族自治县']
  10337. }, {
  10338. name: '保亭黎族苗族自治县',
  10339. area: ['保亭黎族苗族自治县']
  10340. }, {
  10341. name: '琼中黎族苗族自治县',
  10342. area: ['琼中黎族苗族自治县']
  10343. }]
  10344. }, {
  10345. name: '重庆市',
  10346. city: [{
  10347. name: '重庆市',
  10348. area: ['渝中区', '大渡口区', '江北区', '南岸区', '北碚区', '渝北区', '巴南区', '长寿区', '双桥区', '沙坪坝区', '万盛区', '万州区', '涪陵区', '黔江区', '永川区', '合川区', '江津区', '九龙坡区', '南川区', '綦江县', '潼南县', '荣昌县', '璧山县', '大足县', '铜梁县', '梁平县', '开县', '忠县', '城口县', '垫江县', '武隆县', '丰都县', '奉节县', '云阳县', '巫溪县', '巫山县', '石柱土家族自治县', '秀山土家族苗族自治县', '酉阳土家族苗族自治县', '彭水苗族土家族自治县']
  10349. }]
  10350. }, {
  10351. name: '四川省',
  10352. city: [{
  10353. name: '成都市',
  10354. area: ['青羊区', '锦江区', '金牛区', '武侯区', '成华区', '龙泉驿区', '青白江区', '新都区', '温江区', '都江堰市', '彭州市', '邛崃市', '崇州市', '金堂县', '郫县', '新津县', '双流县', '蒲江县', '大邑县']
  10355. }, {
  10356. name: '自贡市',
  10357. area: ['大安区', '自流井区', '贡井区', '沿滩区', '荣县', '富顺县']
  10358. }, {
  10359. name: '攀枝花市',
  10360. area: ['仁和区', '米易县', '盐边县', '东区', '西区']
  10361. }, {
  10362. name: '泸州市',
  10363. area: ['江阳区', '纳溪区', '龙马潭区', '泸县', '合江县', '叙永县', '古蔺县']
  10364. }, {
  10365. name: '德阳市',
  10366. area: ['旌阳区', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县']
  10367. }, {
  10368. name: '绵阳市',
  10369. area: ['涪城区', '游仙区', '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '北川羌族自治县']
  10370. }, {
  10371. name: '广元市',
  10372. area: ['元坝区', '朝天区', '青川县', '旺苍县', '剑阁县', '苍溪县', '市中区']
  10373. }, {
  10374. name: '遂宁市',
  10375. area: ['船山区', '安居区', '射洪县', '蓬溪县', '大英县']
  10376. }, {
  10377. name: '内江市',
  10378. area: ['市中区', '东兴区', '资中县', '隆昌县', '威远县']
  10379. }, {
  10380. name: '乐山市',
  10381. area: ['市中区', '五通桥区', '沙湾区', '金口河区', '峨眉山市', '夹江县', '井研县', '犍为县', '沐川县', '马边彝族自治县', '峨边彝族自治县']
  10382. }, {
  10383. name: '南充',
  10384. area: ['顺庆区', '高坪区', '嘉陵区', '阆中市', '营山县', '蓬安县', '仪陇县', '南部县', '西充县']
  10385. }, {
  10386. name: '眉山市',
  10387. area: ['东坡区', '仁寿县', '彭山县', '洪雅县', '丹棱县', '青神县']
  10388. }, {
  10389. name: '宜宾市',
  10390. area: ['翠屏区', '宜宾县', '兴文县', '南溪县', '珙县', '长宁县', '高县', '江安县', '筠连县', '屏山县']
  10391. }, {
  10392. name: '广安市',
  10393. area: ['广安区', '华蓥市', '岳池县', '邻水县', '武胜县']
  10394. }, {
  10395. name: '达州市',
  10396. area: ['通川区', '万源市', '达县', '渠县', '宣汉县', '开江县', '大竹县']
  10397. }, {
  10398. name: '雅安市',
  10399. area: ['雨城区', '芦山县', '石棉县', '名山县', '天全县', '荥经县', '宝兴县', '汉源县']
  10400. }, {
  10401. name: '巴中市',
  10402. area: ['巴州区', '南江县', '平昌县', '通江县']
  10403. }, {
  10404. name: '资阳市',
  10405. area: ['雁江区', '简阳市', '安岳县', '乐至县']
  10406. }, {
  10407. name: '阿坝藏族羌族自治州',
  10408. area: ['马尔康县', '九寨沟县', '红原县', '汶川县', '阿坝县', '理县', '若尔盖县', '小金县', '黑水县', '金川县', '松潘县', '壤塘县', '茂县']
  10409. }, {
  10410. name: '甘孜藏族自治州',
  10411. area: ['康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', '色达县', '巴塘县', '泸定县', '得荣县']
  10412. }, {
  10413. name: '凉山彝族自治州',
  10414. area: ['西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', '德昌县', '冕宁县', '木里藏族自治县']
  10415. }]
  10416. }, {
  10417. name: '贵州省',
  10418. city: [{
  10419. name: '贵阳市',
  10420. area: ['南明区', '云岩区', '花溪区', '乌当区', '白云区', '小河区', '清镇市', '开阳县', '修文县', '息烽县']
  10421. }, {
  10422. name: '六盘水市',
  10423. area: ['钟山区', '水城县', '盘县', '六枝特区']
  10424. }, {
  10425. name: '遵义市',
  10426. area: ['红花岗区', '汇川区', '赤水市', '仁怀市', '遵义县', '绥阳县', '桐梓县', '习水县', '凤冈县', '正安县', '余庆县', '湄潭县', '道真仡佬族苗族自治县', '务川仡佬族苗族自治县']
  10427. }, {
  10428. name: '安顺市',
  10429. area: ['西秀区', '普定县', '平坝县', '镇宁布依族苗族自治县', '紫云苗族布依族自治县', '关岭布依族苗族自治县']
  10430. }, {
  10431. name: '铜仁地区',
  10432. area: ['铜仁市', '德江县', '江口县', '思南县', '石阡县', '玉屏侗族自治县', '松桃苗族自治县', '印江土家族苗族自治县', '沿河土家族自治县', '万山特区']
  10433. }, {
  10434. name: '毕节地区',
  10435. area: ['毕节市', '黔西县', '大方县', '织金县', '金沙县', '赫章县', '纳雍县', '威宁彝族回族苗族自治县']
  10436. }, {
  10437. name: '黔西南布依族苗族自治州',
  10438. area: ['兴义市', '望谟县', '兴仁县', '普安县', '册亨县', '晴隆县', '贞丰县', '安龙县']
  10439. }, {
  10440. name: '黔东南苗族侗族自治州',
  10441. area: ['凯里市', '施秉县', '从江县', '锦屏县', '镇远县', '麻江县', '台江县', '天柱县', '黄平县', '榕江县', '剑河县', '三穗县', '雷山县', '黎平县', '岑巩县', '丹寨县']
  10442. }, {
  10443. name: '黔南布依族苗族自治州',
  10444. area: ['都匀市', '福泉市', '贵定县', '惠水县', '罗甸县', '瓮安县', '荔波县', '龙里县', '平塘县', '长顺县', '独山县', '三都水族自治县']
  10445. }]
  10446. }, {
  10447. name: '云南省',
  10448. city: [{
  10449. name: '昆明市',
  10450. area: ['盘龙区', '五华区', '官渡区', '西山区', '东川区', '安宁市', '呈贡县', '晋宁县', '富民县', '宜良县', '嵩明县', '石林彝族自治县', '禄劝彝族苗族自治县', '寻甸回族彝族自治县']
  10451. }, {
  10452. name: '曲靖市',
  10453. area: ['麒麟区', '宣威市', '马龙县', '沾益县', '富源县', '罗平县', '师宗县', '陆良县', '会泽县']
  10454. }, {
  10455. name: '玉溪市',
  10456. area: ['红塔区', '江川县', '澄江县', '通海县', '华宁县', '易门县', '峨山彝族自治县', '新平彝族傣族自治县', '元江哈尼族彝族傣族自治县']
  10457. }, {
  10458. name: '保山市',
  10459. area: ['隆阳区', '施甸县', '腾冲县', '龙陵县', '昌宁县']
  10460. }, {
  10461. name: '昭通市',
  10462. area: ['昭阳区', '鲁甸县', '巧家县', '盐津县', '大关县', '永善县', '绥江县', '镇雄县', '彝良县', '威信县', '水富县']
  10463. }, {
  10464. name: '丽江市',
  10465. area: ['古城区', '永胜县', '华坪县', '玉龙纳西族自治县', '宁蒗彝族自治县']
  10466. }, {
  10467. name: '普洱市',
  10468. area: ['思茅区', '普洱哈尼族彝族自治县', '墨江哈尼族自治县', '景东彝族自治县', '景谷傣族彝族自治县', '镇沅彝族哈尼族拉祜族自治县', '江城哈尼族彝族自治县', '孟连傣族拉祜族佤族自治县', '澜沧拉祜族自治县', '西盟佤族自治县']
  10469. }, {
  10470. name: '临沧市',
  10471. area: ['临翔区', '凤庆县', '云县', '永德县', '镇康县', '双江拉祜族佤族布朗族傣族自治县', '耿马傣族佤族自治县', '沧源佤族自治县']
  10472. }, {
  10473. name: '德宏傣族景颇族自治州',
  10474. area: ['潞西市', '瑞丽市', '梁河县', '盈江县', '陇川县']
  10475. }, {
  10476. name: '怒江傈僳族自治州',
  10477. area: ['泸水县', '福贡县', '贡山独龙族怒族自治县', '兰坪白族普米族自治县']
  10478. }, {
  10479. name: '迪庆藏族自治州',
  10480. area: ['香格里拉县', '德钦县', '维西傈僳族自治县']
  10481. }, {
  10482. name: '大理白族自治州',
  10483. area: ['大理市', '祥云县', '宾川县', '弥渡县', '永平县', '云龙县', '洱源县', '剑川县', '鹤庆县', '漾濞彝族自治县', '南涧彝族自治县', '巍山彝族回族自治县']
  10484. }, {
  10485. name: '楚雄彝族自治州',
  10486. area: ['楚雄市', '双柏县', '牟定县', '南华县', '姚安县', '大姚县', '永仁县', '元谋县', '武定县', '禄丰县']
  10487. }, {
  10488. name: '红河哈尼族彝族自治州',
  10489. area: ['蒙自县', '个旧市', '开远市', '绿春县', '建水县', '石屏县', '弥勒县', '泸西县', '元阳县', '红河县', '金平苗族瑶族傣族自治县', '河口瑶族自治县', '屏边苗族自治县']
  10490. }, {
  10491. name: '文山壮族苗族自治州',
  10492. area: ['文山县', '砚山县', '西畴县', '麻栗坡县', '马关县', '丘北县', '广南县', '富宁县']
  10493. }, {
  10494. name: '西双版纳傣族自治州',
  10495. area: ['景洪市', '勐海县', '勐腊县']
  10496. }]
  10497. }, {
  10498. name: '西藏',
  10499. city: [{
  10500. name: '拉萨市',
  10501. area: ['城关区', '林周县', '当雄县', '尼木县', '曲水县', '堆龙德庆县', '达孜县', '墨竹工卡县']
  10502. }, {
  10503. name: '那曲地区',
  10504. area: ['那曲县', '嘉黎县', '比如县', '聂荣县', '安多县', '申扎县', '索县', '班戈县', '巴青县', '尼玛县']
  10505. }, {
  10506. name: '昌都地区',
  10507. area: ['昌都县', '江达县', '贡觉县', '类乌齐县', '丁青县', '察雅县', '八宿县', '左贡县', '芒康县', '洛隆县', '边坝县']
  10508. }, {
  10509. name: '林芝地区',
  10510. area: ['林芝县', '工布江达县', '米林县', '墨脱县', '波密县', '察隅县', '朗县']
  10511. }, {
  10512. name: '山南地区',
  10513. area: ['乃东县', '扎囊县', '贡嘎县', '桑日县', '琼结县', '曲松县', '措美县', '洛扎县', '加查县', '隆子县', '错那县', '浪卡子县']
  10514. }, {
  10515. name: '日喀则地区',
  10516. area: ['日喀则市', '南木林县', '江孜县', '定日县', '萨迦县', '拉孜县', '昂仁县', '谢通门县', '白朗县', '仁布县', '康马县', '定结县', '仲巴县', '亚东县', '吉隆县', '聂拉木县', '萨嘎县', '岗巴县']
  10517. }, {
  10518. name: '阿里地区',
  10519. area: ['噶尔县', '普兰县', '札达县', '日土县', '革吉县', '改则县', '措勤县']
  10520. }]
  10521. }, {
  10522. name: '陕西省',
  10523. city: [{
  10524. name: '西安市',
  10525. area: ['莲湖区', '新城区', '碑林区', '雁塔区', '灞桥区', '未央区', '阎良区', '临潼区', '长安区', '高陵县', '蓝田县', '户县', '周至县']
  10526. }, {
  10527. name: '铜川市',
  10528. area: ['耀州区', '王益区', '印台区', '宜君县']
  10529. }, {
  10530. name: '宝鸡市',
  10531. area: ['渭滨区', '金台区', '陈仓区', '岐山县', '凤翔县', '陇县', '太白县', '麟游县', '扶风县', '千阳县', '眉县', '凤县']
  10532. }, {
  10533. name: '咸阳市',
  10534. area: ['秦都区', '渭城区', '杨陵区', '兴平市', '礼泉县', '泾阳县', '永寿县', '三原县', '彬县', '旬邑县', '长武县', '乾县', '武功县', '淳化县']
  10535. }, {
  10536. name: '渭南市',
  10537. area: ['临渭区', '韩城市', '华阴市', '蒲城县', '潼关县', '白水县', '澄城县', '华县', '合阳县', '富平县', '大荔县']
  10538. }, {
  10539. name: '延安市',
  10540. area: ['宝塔区', '安塞县', '洛川县', '子长县', '黄陵县', '延川县', '富县', '延长县', '甘泉县', '宜川县', '志丹县', '黄龙县', '吴起县']
  10541. }, {
  10542. name: '汉中市',
  10543. area: ['汉台区', '留坝县', '镇巴县', '城固县', '南郑县', '洋县', '宁强县', '佛坪县', '勉县', '西乡县', '略阳县']
  10544. }, {
  10545. name: '榆林市',
  10546. area: ['榆阳区', '清涧县', '绥德县', '神木县', '佳县', '府谷县', '子洲县', '靖边县', '横山县', '米脂县', '吴堡县', '定边县']
  10547. }, {
  10548. name: '安康市',
  10549. area: ['汉滨区', '紫阳县', '岚皋县', '旬阳县', '镇坪县', '平利县', '石泉县', '宁陕县', '白河县', '汉阴县']
  10550. }, {
  10551. name: '商洛市',
  10552. area: ['商州区', '镇安县', '山阳县', '洛南县', '商南县', '丹凤县', '柞水县']
  10553. }]
  10554. }, {
  10555. name: '甘肃省',
  10556. city: [{
  10557. name: '兰州市',
  10558. area: ['城关区', '七里河区', '西固区', '安宁区', '红古区', '永登县', '皋兰县', '榆中县']
  10559. }, {
  10560. name: '嘉峪关市',
  10561. area: ['嘉峪关市']
  10562. }, {
  10563. name: '金昌市',
  10564. area: ['金川区', '永昌县']
  10565. }, {
  10566. name: '白银市',
  10567. area: ['白银区', '平川区', '靖远县', '会宁县', '景泰县']
  10568. }, {
  10569. name: '天水市',
  10570. area: ['清水县', '秦安县', '甘谷县', '武山县', '张家川回族自治县', '北道区', '秦城区']
  10571. }, {
  10572. name: '武威市',
  10573. area: ['凉州区', '民勤县', '古浪县', '天祝藏族自治县']
  10574. }, {
  10575. name: '酒泉市',
  10576. area: ['肃州区', '玉门市', '敦煌市', '金塔县', '肃北蒙古族自治县', '阿克塞哈萨克族自治县', '安西县']
  10577. }, {
  10578. name: '张掖市',
  10579. area: ['甘州区', '民乐县', '临泽县', '高台县', '山丹县', '肃南裕固族自治县']
  10580. }, {
  10581. name: '庆阳市',
  10582. area: ['西峰区', '庆城县', '环县', '华池县', '合水县', '正宁县', '宁县', '镇原县']
  10583. }, {
  10584. name: '平凉市',
  10585. area: ['崆峒区', '泾川县', '灵台县', '崇信县', '华亭县', '庄浪县', '静宁县']
  10586. }, {
  10587. name: '定西市',
  10588. area: ['安定区', '通渭县', '临洮县', '漳县', '岷县', '渭源县', '陇西县']
  10589. }, {
  10590. name: '陇南市',
  10591. area: ['武都区', '成县', '宕昌县', '康县', '文县', '西和县', '礼县', '两当县', '徽县']
  10592. }, {
  10593. name: '临夏回族自治州',
  10594. area: ['临夏市', '临夏县', '康乐县', '永靖县', '广河县', '和政县', '东乡族自治县', '积石山保安族东乡族撒拉族自治县']
  10595. }, {
  10596. name: '甘南藏族自治州',
  10597. area: ['合作市', '临潭县', '卓尼县', '舟曲县', '迭部县', '玛曲县', '碌曲县', '夏河县']
  10598. }]
  10599. }, {
  10600. name: '青海省',
  10601. city: [{
  10602. name: '西宁市',
  10603. area: ['城中区', '城东区', '城西区', '城北区', '湟源县', '湟中县', '大通回族土族自治县']
  10604. }, {
  10605. name: '海东地区',
  10606. area: ['平安县', '乐都县', '民和回族土族自治县', '互助土族自治县', '化隆回族自治县', '循化撒拉族自治县']
  10607. }, {
  10608. name: '海北藏族自治州',
  10609. area: ['海晏县', '祁连县', '刚察县', '门源回族自治县']
  10610. }, {
  10611. name: '海南藏族自治州',
  10612. area: ['共和县', '同德县', '贵德县', '兴海县', '贵南县']
  10613. }, {
  10614. name: '黄南藏族自治州',
  10615. area: ['同仁县', '尖扎县', '泽库县', '河南蒙古族自治县']
  10616. }, {
  10617. name: '果洛藏族自治州',
  10618. area: ['玛沁县', '班玛县', '甘德县', '达日县', '久治县', '玛多县']
  10619. }, {
  10620. name: '玉树藏族自治州',
  10621. area: ['玉树县', '杂多县', '称多县', '治多县', '囊谦县', '曲麻莱县']
  10622. }, {
  10623. name: '海西蒙古族藏族自治州',
  10624. area: ['德令哈市', '格尔木市', '乌兰县', '都兰县', '天峻县']
  10625. }]
  10626. }, {
  10627. name: '宁夏',
  10628. city: [{
  10629. name: '银川市',
  10630. area: ['兴庆区', '西夏区', '金凤区', '灵武市', '永宁县', '贺兰县']
  10631. }, {
  10632. name: '石嘴山市',
  10633. area: ['大武口区', '惠农区', '平罗县']
  10634. }, {
  10635. name: '吴忠市',
  10636. area: ['利通区', '青铜峡市', '盐池县', '同心县']
  10637. }, {
  10638. name: '固原市',
  10639. area: ['原州区', '西吉县', '隆德县', '泾源县', '彭阳县']
  10640. }, {
  10641. name: '中卫市',
  10642. area: ['沙坡头区', '中宁县', '海原县']
  10643. }]
  10644. }, {
  10645. name: '新疆',
  10646. city: [{
  10647. name: '乌鲁木齐市',
  10648. area: ['天山区', '沙依巴克区', '新市区', '水磨沟区', '头屯河区', '达坂城区', '东山区', '乌鲁木齐县']
  10649. }, {
  10650. name: '克拉玛依市',
  10651. area: ['克拉玛依区', '独山子区', '白碱滩区', '乌尔禾区']
  10652. }, {
  10653. name: '吐鲁番地区',
  10654. area: ['吐鲁番市', '托克逊县', '鄯善县']
  10655. }, {
  10656. name: '哈密地区',
  10657. area: ['哈密市', '伊吾县', '巴里坤哈萨克自治县']
  10658. }, {
  10659. name: '和田地区',
  10660. area: ['和田市', '和田县', '洛浦县', '民丰县', '皮山县', '策勒县', '于田县', '墨玉县']
  10661. }, {
  10662. name: '阿克苏地区',
  10663. area: ['阿克苏市', '温宿县', '沙雅县', '拜城县', '阿瓦提县', '库车县', '柯坪县', '新和县', '乌什县']
  10664. }, {
  10665. name: '喀什地区',
  10666. area: ['喀什市', '巴楚县', '泽普县', '伽师县', '叶城县', '岳普湖县', '疏勒县', '麦盖提县', '英吉沙县', '莎车县', '疏附县', '塔什库尔干塔吉克自治县']
  10667. }, {
  10668. name: '克孜勒苏柯尔克孜自治州',
  10669. area: ['阿图什市', '阿合奇县', '乌恰县', '阿克陶县']
  10670. }, {
  10671. name: '巴音郭楞蒙古自治州',
  10672. area: ['库尔勒市', '和静县', '尉犁县', '和硕县', '且末县', '博湖县', '轮台县', '若羌县', '焉耆回族自治县']
  10673. }, {
  10674. name: '昌吉回族自治州',
  10675. area: ['昌吉市', '阜康市', '奇台县', '玛纳斯县', '吉木萨尔县', '呼图壁县', '木垒哈萨克自治县', '米泉市']
  10676. }, {
  10677. name: '博尔塔拉蒙古自治州',
  10678. area: ['博乐市', '精河县', '温泉县']
  10679. }, {
  10680. name: '石河子',
  10681. area: ['石河子']
  10682. }, {
  10683. name: '阿拉尔',
  10684. area: ['阿拉尔']
  10685. }, {
  10686. name: '图木舒克',
  10687. area: ['图木舒克']
  10688. }, {
  10689. name: '五家渠',
  10690. area: ['五家渠']
  10691. }, {
  10692. name: '伊犁哈萨克自治州',
  10693. area: ['伊宁市', '奎屯市', '伊宁县', '特克斯县', '尼勒克县', '昭苏县', '新源县', '霍城县', '巩留县', '察布查尔锡伯自治县', '塔城地区', '阿勒泰地区']
  10694. }]
  10695. }, {
  10696. name: '台湾省',
  10697. city: [{
  10698. name: '台北市',
  10699. area: ['内湖区', '南港区', '中正区', '万华区', '大同区', '中山区', '松山区', '大安区', '信义区', '文山区', '士林区', '北投区']
  10700. }, {
  10701. name: '新北市',
  10702. area: ['板桥区', '汐止区', '新店区']
  10703. }, {
  10704. name: '桃园市',
  10705. area: ['其他']
  10706. }, {
  10707. name: '台中市',
  10708. area: ['其他']
  10709. }, {
  10710. name: '台南市',
  10711. area: ['其他']
  10712. }, {
  10713. name: '高雄市',
  10714. area: ['其他']
  10715. }]
  10716. }, {
  10717. name: '澳门',
  10718. city: [{
  10719. name: '澳门',
  10720. area: ['花地玛堂区', '圣安多尼堂区', '大堂区', '望德堂区', '风顺堂区', '嘉模堂区', '圣方济各堂区', '路凼']
  10721. }]
  10722. }, {
  10723. name: '香港',
  10724. city: [{
  10725. name: '香港',
  10726. area: ['深水埗区', '油尖旺区', '九龙城区', '黄大仙区', '观塘区', '北区', '大埔区', '沙田区', '西贡区', '元朗区', '屯门区', '荃湾区', '葵青区', '离岛区', '中西区', '湾仔区', '东区', '南区']
  10727. }]
  10728. }],
  10729. debug: true
  10730. };
  10731. exports.default = _default;
  10732. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
  10733. /***/ }),
  10734. /* 38 */
  10735. /*!*********************************************************!*\
  10736. !*** D:/project/神鹿峰旅游/travel_applet/common/computed.js ***!
  10737. \*********************************************************/
  10738. /*! no static exports found */
  10739. /***/ (function(module, exports, __webpack_require__) {
  10740. "use strict";
  10741. var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
  10742. var _vue = _interopRequireDefault(__webpack_require__(/*! vue */ 25));
  10743. var _decimal = _interopRequireDefault(__webpack_require__(/*! decimal.js */ 39));
  10744. var toNumber = function toNumber(num) {
  10745. return new _decimal.default(num).toNumber();
  10746. };
  10747. var plus = function plus() {
  10748. var n1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10749. var n2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  10750. var number1 = new _decimal.default(n1);
  10751. var number2 = new _decimal.default(n2);
  10752. var result = number1.add(number2);
  10753. result = result.toFixed(2, _decimal.default.ROUND_DOWN);
  10754. return toNumber(result);
  10755. };
  10756. var minus = function minus() {
  10757. var n1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10758. var n2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  10759. var number1 = new _decimal.default(n1);
  10760. var number2 = new _decimal.default(n2);
  10761. var result = number1.minus(number2);
  10762. result = result.toFixed(2, _decimal.default.ROUND_DOWN);
  10763. return toNumber(result);
  10764. };
  10765. var multiply = function multiply() {
  10766. var n1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10767. var n2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  10768. var number1 = new _decimal.default(n1);
  10769. var number2 = new _decimal.default(n2);
  10770. var result = number1.mul(number2);
  10771. result = result.toFixed(2, _decimal.default.ROUND_DOWN);
  10772. return toNumber(result);
  10773. };
  10774. var divide = function divide() {
  10775. var n1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10776. var n2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  10777. var number1 = new _decimal.default(n1);
  10778. var number2 = new _decimal.default(n2);
  10779. var result = number1.div(number2);
  10780. result = result.toFixed(2, _decimal.default.ROUND_DOWN);
  10781. return toNumber(result);
  10782. };
  10783. _vue.default.prototype.$plus = plus;
  10784. _vue.default.prototype.$minus = minus;
  10785. _vue.default.prototype.$multiply = multiply;
  10786. _vue.default.prototype.$divide = divide;
  10787. /***/ }),
  10788. /* 39 */
  10789. /*!*************************************************************************!*\
  10790. !*** D:/project/神鹿峰旅游/travel_applet/node_modules/decimal.js/decimal.js ***!
  10791. \*************************************************************************/
  10792. /*! no static exports found */
  10793. /***/ (function(module, exports, __webpack_require__) {
  10794. var __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ 13);
  10795. ;
  10796. (function (globalScope) {
  10797. 'use strict';
  10798. /*!
  10799. * decimal.js v10.4.3
  10800. * An arbitrary-precision Decimal type for JavaScript.
  10801. * https://github.com/MikeMcl/decimal.js
  10802. * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
  10803. * MIT Licence
  10804. */
  10805. // ----------------------------------- EDITABLE DEFAULTS ------------------------------------ //
  10806. // The maximum exponent magnitude.
  10807. // The limit on the value of `toExpNeg`, `toExpPos`, `minE` and `maxE`.
  10808. var EXP_LIMIT = 9e15,
  10809. // 0 to 9e15
  10810. // The limit on the value of `precision`, and on the value of the first argument to
  10811. // `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`.
  10812. MAX_DIGITS = 1e9,
  10813. // 0 to 1e9
  10814. // Base conversion alphabet.
  10815. NUMERALS = '0123456789abcdef',
  10816. // The natural logarithm of 10 (1025 digits).
  10817. LN10 = '2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058',
  10818. // Pi (1025 digits).
  10819. PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789',
  10820. // The initial configuration properties of the Decimal constructor.
  10821. DEFAULTS = {
  10822. // These values must be integers within the stated ranges (inclusive).
  10823. // Most of these values can be changed at run-time using the `Decimal.config` method.
  10824. // The maximum number of significant digits of the result of a calculation or base conversion.
  10825. // E.g. `Decimal.config({ precision: 20 });`
  10826. precision: 20,
  10827. // 1 to MAX_DIGITS
  10828. // The rounding mode used when rounding to `precision`.
  10829. //
  10830. // ROUND_UP 0 Away from zero.
  10831. // ROUND_DOWN 1 Towards zero.
  10832. // ROUND_CEIL 2 Towards +Infinity.
  10833. // ROUND_FLOOR 3 Towards -Infinity.
  10834. // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
  10835. // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
  10836. // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
  10837. // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
  10838. // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  10839. //
  10840. // E.g.
  10841. // `Decimal.rounding = 4;`
  10842. // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
  10843. rounding: 4,
  10844. // 0 to 8
  10845. // The modulo mode used when calculating the modulus: a mod n.
  10846. // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  10847. // The remainder (r) is calculated as: r = a - n * q.
  10848. //
  10849. // UP 0 The remainder is positive if the dividend is negative, else is negative.
  10850. // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
  10851. // FLOOR 3 The remainder has the same sign as the divisor (Python %).
  10852. // HALF_EVEN 6 The IEEE 754 remainder function.
  10853. // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
  10854. //
  10855. // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
  10856. // division (9) are commonly used for the modulus operation. The other rounding modes can also
  10857. // be used, but they may not give useful results.
  10858. modulo: 1,
  10859. // 0 to 9
  10860. // The exponent value at and beneath which `toString` returns exponential notation.
  10861. // JavaScript numbers: -7
  10862. toExpNeg: -7,
  10863. // 0 to -EXP_LIMIT
  10864. // The exponent value at and above which `toString` returns exponential notation.
  10865. // JavaScript numbers: 21
  10866. toExpPos: 21,
  10867. // 0 to EXP_LIMIT
  10868. // The minimum exponent value, beneath which underflow to zero occurs.
  10869. // JavaScript numbers: -324 (5e-324)
  10870. minE: -EXP_LIMIT,
  10871. // -1 to -EXP_LIMIT
  10872. // The maximum exponent value, above which overflow to Infinity occurs.
  10873. // JavaScript numbers: 308 (1.7976931348623157e+308)
  10874. maxE: EXP_LIMIT,
  10875. // 1 to EXP_LIMIT
  10876. // Whether to use cryptographically-secure random number generation, if available.
  10877. crypto: false // true/false
  10878. },
  10879. // ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- //
  10880. Decimal,
  10881. inexact,
  10882. noConflict,
  10883. quadrant,
  10884. external = true,
  10885. decimalError = '[DecimalError] ',
  10886. invalidArgument = decimalError + 'Invalid argument: ',
  10887. precisionLimitExceeded = decimalError + 'Precision limit exceeded',
  10888. cryptoUnavailable = decimalError + 'crypto unavailable',
  10889. tag = '[object Decimal]',
  10890. mathfloor = Math.floor,
  10891. mathpow = Math.pow,
  10892. isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,
  10893. isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,
  10894. isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,
  10895. isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
  10896. BASE = 1e7,
  10897. LOG_BASE = 7,
  10898. MAX_SAFE_INTEGER = 9007199254740991,
  10899. LN10_PRECISION = LN10.length - 1,
  10900. PI_PRECISION = PI.length - 1,
  10901. // Decimal.prototype object
  10902. P = {
  10903. toStringTag: tag
  10904. };
  10905. // Decimal prototype methods
  10906. /*
  10907. * absoluteValue abs
  10908. * ceil
  10909. * clampedTo clamp
  10910. * comparedTo cmp
  10911. * cosine cos
  10912. * cubeRoot cbrt
  10913. * decimalPlaces dp
  10914. * dividedBy div
  10915. * dividedToIntegerBy divToInt
  10916. * equals eq
  10917. * floor
  10918. * greaterThan gt
  10919. * greaterThanOrEqualTo gte
  10920. * hyperbolicCosine cosh
  10921. * hyperbolicSine sinh
  10922. * hyperbolicTangent tanh
  10923. * inverseCosine acos
  10924. * inverseHyperbolicCosine acosh
  10925. * inverseHyperbolicSine asinh
  10926. * inverseHyperbolicTangent atanh
  10927. * inverseSine asin
  10928. * inverseTangent atan
  10929. * isFinite
  10930. * isInteger isInt
  10931. * isNaN
  10932. * isNegative isNeg
  10933. * isPositive isPos
  10934. * isZero
  10935. * lessThan lt
  10936. * lessThanOrEqualTo lte
  10937. * logarithm log
  10938. * [maximum] [max]
  10939. * [minimum] [min]
  10940. * minus sub
  10941. * modulo mod
  10942. * naturalExponential exp
  10943. * naturalLogarithm ln
  10944. * negated neg
  10945. * plus add
  10946. * precision sd
  10947. * round
  10948. * sine sin
  10949. * squareRoot sqrt
  10950. * tangent tan
  10951. * times mul
  10952. * toBinary
  10953. * toDecimalPlaces toDP
  10954. * toExponential
  10955. * toFixed
  10956. * toFraction
  10957. * toHexadecimal toHex
  10958. * toNearest
  10959. * toNumber
  10960. * toOctal
  10961. * toPower pow
  10962. * toPrecision
  10963. * toSignificantDigits toSD
  10964. * toString
  10965. * truncated trunc
  10966. * valueOf toJSON
  10967. */
  10968. /*
  10969. * Return a new Decimal whose value is the absolute value of this Decimal.
  10970. *
  10971. */
  10972. P.absoluteValue = P.abs = function () {
  10973. var x = new this.constructor(this);
  10974. if (x.s < 0) x.s = 1;
  10975. return finalise(x);
  10976. };
  10977. /*
  10978. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
  10979. * direction of positive Infinity.
  10980. *
  10981. */
  10982. P.ceil = function () {
  10983. return finalise(new this.constructor(this), this.e + 1, 2);
  10984. };
  10985. /*
  10986. * Return a new Decimal whose value is the value of this Decimal clamped to the range
  10987. * delineated by `min` and `max`.
  10988. *
  10989. * min {number|string|Decimal}
  10990. * max {number|string|Decimal}
  10991. *
  10992. */
  10993. P.clampedTo = P.clamp = function (min, max) {
  10994. var k,
  10995. x = this,
  10996. Ctor = x.constructor;
  10997. min = new Ctor(min);
  10998. max = new Ctor(max);
  10999. if (!min.s || !max.s) return new Ctor(NaN);
  11000. if (min.gt(max)) throw Error(invalidArgument + max);
  11001. k = x.cmp(min);
  11002. return k < 0 ? min : x.cmp(max) > 0 ? max : new Ctor(x);
  11003. };
  11004. /*
  11005. * Return
  11006. * 1 if the value of this Decimal is greater than the value of `y`,
  11007. * -1 if the value of this Decimal is less than the value of `y`,
  11008. * 0 if they have the same value,
  11009. * NaN if the value of either Decimal is NaN.
  11010. *
  11011. */
  11012. P.comparedTo = P.cmp = function (y) {
  11013. var i,
  11014. j,
  11015. xdL,
  11016. ydL,
  11017. x = this,
  11018. xd = x.d,
  11019. yd = (y = new x.constructor(y)).d,
  11020. xs = x.s,
  11021. ys = y.s;
  11022. // Either NaN or ±Infinity?
  11023. if (!xd || !yd) {
  11024. return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
  11025. }
  11026. // Either zero?
  11027. if (!xd[0] || !yd[0]) return xd[0] ? xs : yd[0] ? -ys : 0;
  11028. // Signs differ?
  11029. if (xs !== ys) return xs;
  11030. // Compare exponents.
  11031. if (x.e !== y.e) return x.e > y.e ^ xs < 0 ? 1 : -1;
  11032. xdL = xd.length;
  11033. ydL = yd.length;
  11034. // Compare digit by digit.
  11035. for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
  11036. if (xd[i] !== yd[i]) return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
  11037. }
  11038. // Compare lengths.
  11039. return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
  11040. };
  11041. /*
  11042. * Return a new Decimal whose value is the cosine of the value in radians of this Decimal.
  11043. *
  11044. * Domain: [-Infinity, Infinity]
  11045. * Range: [-1, 1]
  11046. *
  11047. * cos(0) = 1
  11048. * cos(-0) = 1
  11049. * cos(Infinity) = NaN
  11050. * cos(-Infinity) = NaN
  11051. * cos(NaN) = NaN
  11052. *
  11053. */
  11054. P.cosine = P.cos = function () {
  11055. var pr,
  11056. rm,
  11057. x = this,
  11058. Ctor = x.constructor;
  11059. if (!x.d) return new Ctor(NaN);
  11060. // cos(0) = cos(-0) = 1
  11061. if (!x.d[0]) return new Ctor(1);
  11062. pr = Ctor.precision;
  11063. rm = Ctor.rounding;
  11064. Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
  11065. Ctor.rounding = 1;
  11066. x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
  11067. Ctor.precision = pr;
  11068. Ctor.rounding = rm;
  11069. return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
  11070. };
  11071. /*
  11072. *
  11073. * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to
  11074. * `precision` significant digits using rounding mode `rounding`.
  11075. *
  11076. * cbrt(0) = 0
  11077. * cbrt(-0) = -0
  11078. * cbrt(1) = 1
  11079. * cbrt(-1) = -1
  11080. * cbrt(N) = N
  11081. * cbrt(-I) = -I
  11082. * cbrt(I) = I
  11083. *
  11084. * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3))
  11085. *
  11086. */
  11087. P.cubeRoot = P.cbrt = function () {
  11088. var e,
  11089. m,
  11090. n,
  11091. r,
  11092. rep,
  11093. s,
  11094. sd,
  11095. t,
  11096. t3,
  11097. t3plusx,
  11098. x = this,
  11099. Ctor = x.constructor;
  11100. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  11101. external = false;
  11102. // Initial estimate.
  11103. s = x.s * mathpow(x.s * x, 1 / 3);
  11104. // Math.cbrt underflow/overflow?
  11105. // Pass x to Math.pow as integer, then adjust the exponent of the result.
  11106. if (!s || Math.abs(s) == 1 / 0) {
  11107. n = digitsToString(x.d);
  11108. e = x.e;
  11109. // Adjust n exponent so it is a multiple of 3 away from x exponent.
  11110. if (s = (e - n.length + 1) % 3) n += s == 1 || s == -2 ? '0' : '00';
  11111. s = mathpow(n, 1 / 3);
  11112. // Rarely, e may be one less than the result exponent value.
  11113. e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
  11114. if (s == 1 / 0) {
  11115. n = '5e' + e;
  11116. } else {
  11117. n = s.toExponential();
  11118. n = n.slice(0, n.indexOf('e') + 1) + e;
  11119. }
  11120. r = new Ctor(n);
  11121. r.s = x.s;
  11122. } else {
  11123. r = new Ctor(s.toString());
  11124. }
  11125. sd = (e = Ctor.precision) + 3;
  11126. // Halley's method.
  11127. // TODO? Compare Newton's method.
  11128. for (;;) {
  11129. t = r;
  11130. t3 = t.times(t).times(t);
  11131. t3plusx = t3.plus(x);
  11132. r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
  11133. // TODO? Replace with for-loop and checkRoundingDigits.
  11134. if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
  11135. n = n.slice(sd - 3, sd + 1);
  11136. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or 4999
  11137. // , i.e. approaching a rounding boundary, continue the iteration.
  11138. if (n == '9999' || !rep && n == '4999') {
  11139. // On the first iteration only, check to see if rounding up gives the exact result as the
  11140. // nines may infinitely repeat.
  11141. if (!rep) {
  11142. finalise(t, e + 1, 0);
  11143. if (t.times(t).times(t).eq(x)) {
  11144. r = t;
  11145. break;
  11146. }
  11147. }
  11148. sd += 4;
  11149. rep = 1;
  11150. } else {
  11151. // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
  11152. // If not, then there are further digits and m will be truthy.
  11153. if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
  11154. // Truncate to the first rounding digit.
  11155. finalise(r, e + 1, 1);
  11156. m = !r.times(r).times(r).eq(x);
  11157. }
  11158. break;
  11159. }
  11160. }
  11161. }
  11162. external = true;
  11163. return finalise(r, e, Ctor.rounding, m);
  11164. };
  11165. /*
  11166. * Return the number of decimal places of the value of this Decimal.
  11167. *
  11168. */
  11169. P.decimalPlaces = P.dp = function () {
  11170. var w,
  11171. d = this.d,
  11172. n = NaN;
  11173. if (d) {
  11174. w = d.length - 1;
  11175. n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
  11176. // Subtract the number of trailing zeros of the last word.
  11177. w = d[w];
  11178. if (w) for (; w % 10 == 0; w /= 10) {
  11179. n--;
  11180. }
  11181. if (n < 0) n = 0;
  11182. }
  11183. return n;
  11184. };
  11185. /*
  11186. * n / 0 = I
  11187. * n / N = N
  11188. * n / I = 0
  11189. * 0 / n = 0
  11190. * 0 / 0 = N
  11191. * 0 / N = N
  11192. * 0 / I = 0
  11193. * N / n = N
  11194. * N / 0 = N
  11195. * N / N = N
  11196. * N / I = N
  11197. * I / n = I
  11198. * I / 0 = I
  11199. * I / N = N
  11200. * I / I = N
  11201. *
  11202. * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to
  11203. * `precision` significant digits using rounding mode `rounding`.
  11204. *
  11205. */
  11206. P.dividedBy = P.div = function (y) {
  11207. return divide(this, new this.constructor(y));
  11208. };
  11209. /*
  11210. * Return a new Decimal whose value is the integer part of dividing the value of this Decimal
  11211. * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`.
  11212. *
  11213. */
  11214. P.dividedToIntegerBy = P.divToInt = function (y) {
  11215. var x = this,
  11216. Ctor = x.constructor;
  11217. return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
  11218. };
  11219. /*
  11220. * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false.
  11221. *
  11222. */
  11223. P.equals = P.eq = function (y) {
  11224. return this.cmp(y) === 0;
  11225. };
  11226. /*
  11227. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
  11228. * direction of negative Infinity.
  11229. *
  11230. */
  11231. P.floor = function () {
  11232. return finalise(new this.constructor(this), this.e + 1, 3);
  11233. };
  11234. /*
  11235. * Return true if the value of this Decimal is greater than the value of `y`, otherwise return
  11236. * false.
  11237. *
  11238. */
  11239. P.greaterThan = P.gt = function (y) {
  11240. return this.cmp(y) > 0;
  11241. };
  11242. /*
  11243. * Return true if the value of this Decimal is greater than or equal to the value of `y`,
  11244. * otherwise return false.
  11245. *
  11246. */
  11247. P.greaterThanOrEqualTo = P.gte = function (y) {
  11248. var k = this.cmp(y);
  11249. return k == 1 || k === 0;
  11250. };
  11251. /*
  11252. * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this
  11253. * Decimal.
  11254. *
  11255. * Domain: [-Infinity, Infinity]
  11256. * Range: [1, Infinity]
  11257. *
  11258. * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ...
  11259. *
  11260. * cosh(0) = 1
  11261. * cosh(-0) = 1
  11262. * cosh(Infinity) = Infinity
  11263. * cosh(-Infinity) = Infinity
  11264. * cosh(NaN) = NaN
  11265. *
  11266. * x time taken (ms) result
  11267. * 1000 9 9.8503555700852349694e+433
  11268. * 10000 25 4.4034091128314607936e+4342
  11269. * 100000 171 1.4033316802130615897e+43429
  11270. * 1000000 3817 1.5166076984010437725e+434294
  11271. * 10000000 abandoned after 2 minute wait
  11272. *
  11273. * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x))
  11274. *
  11275. */
  11276. P.hyperbolicCosine = P.cosh = function () {
  11277. var k,
  11278. n,
  11279. pr,
  11280. rm,
  11281. len,
  11282. x = this,
  11283. Ctor = x.constructor,
  11284. one = new Ctor(1);
  11285. if (!x.isFinite()) return new Ctor(x.s ? 1 / 0 : NaN);
  11286. if (x.isZero()) return one;
  11287. pr = Ctor.precision;
  11288. rm = Ctor.rounding;
  11289. Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
  11290. Ctor.rounding = 1;
  11291. len = x.d.length;
  11292. // Argument reduction: cos(4x) = 1 - 8cos^2(x) + 8cos^4(x) + 1
  11293. // i.e. cos(x) = 1 - cos^2(x/4)(8 - 8cos^2(x/4))
  11294. // Estimate the optimum number of times to use the argument reduction.
  11295. // TODO? Estimation reused from cosine() and may not be optimal here.
  11296. if (len < 32) {
  11297. k = Math.ceil(len / 3);
  11298. n = (1 / tinyPow(4, k)).toString();
  11299. } else {
  11300. k = 16;
  11301. n = '2.3283064365386962890625e-10';
  11302. }
  11303. x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
  11304. // Reverse argument reduction
  11305. var cosh2_x,
  11306. i = k,
  11307. d8 = new Ctor(8);
  11308. for (; i--;) {
  11309. cosh2_x = x.times(x);
  11310. x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
  11311. }
  11312. return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
  11313. };
  11314. /*
  11315. * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this
  11316. * Decimal.
  11317. *
  11318. * Domain: [-Infinity, Infinity]
  11319. * Range: [-Infinity, Infinity]
  11320. *
  11321. * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ...
  11322. *
  11323. * sinh(0) = 0
  11324. * sinh(-0) = -0
  11325. * sinh(Infinity) = Infinity
  11326. * sinh(-Infinity) = -Infinity
  11327. * sinh(NaN) = NaN
  11328. *
  11329. * x time taken (ms)
  11330. * 10 2 ms
  11331. * 100 5 ms
  11332. * 1000 14 ms
  11333. * 10000 82 ms
  11334. * 100000 886 ms 1.4033316802130615897e+43429
  11335. * 200000 2613 ms
  11336. * 300000 5407 ms
  11337. * 400000 8824 ms
  11338. * 500000 13026 ms 8.7080643612718084129e+217146
  11339. * 1000000 48543 ms
  11340. *
  11341. * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x))
  11342. *
  11343. */
  11344. P.hyperbolicSine = P.sinh = function () {
  11345. var k,
  11346. pr,
  11347. rm,
  11348. len,
  11349. x = this,
  11350. Ctor = x.constructor;
  11351. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  11352. pr = Ctor.precision;
  11353. rm = Ctor.rounding;
  11354. Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
  11355. Ctor.rounding = 1;
  11356. len = x.d.length;
  11357. if (len < 3) {
  11358. x = taylorSeries(Ctor, 2, x, x, true);
  11359. } else {
  11360. // Alternative argument reduction: sinh(3x) = sinh(x)(3 + 4sinh^2(x))
  11361. // i.e. sinh(x) = sinh(x/3)(3 + 4sinh^2(x/3))
  11362. // 3 multiplications and 1 addition
  11363. // Argument reduction: sinh(5x) = sinh(x)(5 + sinh^2(x)(20 + 16sinh^2(x)))
  11364. // i.e. sinh(x) = sinh(x/5)(5 + sinh^2(x/5)(20 + 16sinh^2(x/5)))
  11365. // 4 multiplications and 2 additions
  11366. // Estimate the optimum number of times to use the argument reduction.
  11367. k = 1.4 * Math.sqrt(len);
  11368. k = k > 16 ? 16 : k | 0;
  11369. x = x.times(1 / tinyPow(5, k));
  11370. x = taylorSeries(Ctor, 2, x, x, true);
  11371. // Reverse argument reduction
  11372. var sinh2_x,
  11373. d5 = new Ctor(5),
  11374. d16 = new Ctor(16),
  11375. d20 = new Ctor(20);
  11376. for (; k--;) {
  11377. sinh2_x = x.times(x);
  11378. x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
  11379. }
  11380. }
  11381. Ctor.precision = pr;
  11382. Ctor.rounding = rm;
  11383. return finalise(x, pr, rm, true);
  11384. };
  11385. /*
  11386. * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this
  11387. * Decimal.
  11388. *
  11389. * Domain: [-Infinity, Infinity]
  11390. * Range: [-1, 1]
  11391. *
  11392. * tanh(x) = sinh(x) / cosh(x)
  11393. *
  11394. * tanh(0) = 0
  11395. * tanh(-0) = -0
  11396. * tanh(Infinity) = 1
  11397. * tanh(-Infinity) = -1
  11398. * tanh(NaN) = NaN
  11399. *
  11400. */
  11401. P.hyperbolicTangent = P.tanh = function () {
  11402. var pr,
  11403. rm,
  11404. x = this,
  11405. Ctor = x.constructor;
  11406. if (!x.isFinite()) return new Ctor(x.s);
  11407. if (x.isZero()) return new Ctor(x);
  11408. pr = Ctor.precision;
  11409. rm = Ctor.rounding;
  11410. Ctor.precision = pr + 7;
  11411. Ctor.rounding = 1;
  11412. return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
  11413. };
  11414. /*
  11415. * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of
  11416. * this Decimal.
  11417. *
  11418. * Domain: [-1, 1]
  11419. * Range: [0, pi]
  11420. *
  11421. * acos(x) = pi/2 - asin(x)
  11422. *
  11423. * acos(0) = pi/2
  11424. * acos(-0) = pi/2
  11425. * acos(1) = 0
  11426. * acos(-1) = pi
  11427. * acos(1/2) = pi/3
  11428. * acos(-1/2) = 2*pi/3
  11429. * acos(|x| > 1) = NaN
  11430. * acos(NaN) = NaN
  11431. *
  11432. */
  11433. P.inverseCosine = P.acos = function () {
  11434. var halfPi,
  11435. x = this,
  11436. Ctor = x.constructor,
  11437. k = x.abs().cmp(1),
  11438. pr = Ctor.precision,
  11439. rm = Ctor.rounding;
  11440. if (k !== -1) {
  11441. return k === 0
  11442. // |x| is 1
  11443. ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0)
  11444. // |x| > 1 or x is NaN
  11445. : new Ctor(NaN);
  11446. }
  11447. if (x.isZero()) return getPi(Ctor, pr + 4, rm).times(0.5);
  11448. // TODO? Special case acos(0.5) = pi/3 and acos(-0.5) = 2*pi/3
  11449. Ctor.precision = pr + 6;
  11450. Ctor.rounding = 1;
  11451. x = x.asin();
  11452. halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
  11453. Ctor.precision = pr;
  11454. Ctor.rounding = rm;
  11455. return halfPi.minus(x);
  11456. };
  11457. /*
  11458. * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the
  11459. * value of this Decimal.
  11460. *
  11461. * Domain: [1, Infinity]
  11462. * Range: [0, Infinity]
  11463. *
  11464. * acosh(x) = ln(x + sqrt(x^2 - 1))
  11465. *
  11466. * acosh(x < 1) = NaN
  11467. * acosh(NaN) = NaN
  11468. * acosh(Infinity) = Infinity
  11469. * acosh(-Infinity) = NaN
  11470. * acosh(0) = NaN
  11471. * acosh(-0) = NaN
  11472. * acosh(1) = 0
  11473. * acosh(-1) = NaN
  11474. *
  11475. */
  11476. P.inverseHyperbolicCosine = P.acosh = function () {
  11477. var pr,
  11478. rm,
  11479. x = this,
  11480. Ctor = x.constructor;
  11481. if (x.lte(1)) return new Ctor(x.eq(1) ? 0 : NaN);
  11482. if (!x.isFinite()) return new Ctor(x);
  11483. pr = Ctor.precision;
  11484. rm = Ctor.rounding;
  11485. Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
  11486. Ctor.rounding = 1;
  11487. external = false;
  11488. x = x.times(x).minus(1).sqrt().plus(x);
  11489. external = true;
  11490. Ctor.precision = pr;
  11491. Ctor.rounding = rm;
  11492. return x.ln();
  11493. };
  11494. /*
  11495. * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value
  11496. * of this Decimal.
  11497. *
  11498. * Domain: [-Infinity, Infinity]
  11499. * Range: [-Infinity, Infinity]
  11500. *
  11501. * asinh(x) = ln(x + sqrt(x^2 + 1))
  11502. *
  11503. * asinh(NaN) = NaN
  11504. * asinh(Infinity) = Infinity
  11505. * asinh(-Infinity) = -Infinity
  11506. * asinh(0) = 0
  11507. * asinh(-0) = -0
  11508. *
  11509. */
  11510. P.inverseHyperbolicSine = P.asinh = function () {
  11511. var pr,
  11512. rm,
  11513. x = this,
  11514. Ctor = x.constructor;
  11515. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  11516. pr = Ctor.precision;
  11517. rm = Ctor.rounding;
  11518. Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
  11519. Ctor.rounding = 1;
  11520. external = false;
  11521. x = x.times(x).plus(1).sqrt().plus(x);
  11522. external = true;
  11523. Ctor.precision = pr;
  11524. Ctor.rounding = rm;
  11525. return x.ln();
  11526. };
  11527. /*
  11528. * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the
  11529. * value of this Decimal.
  11530. *
  11531. * Domain: [-1, 1]
  11532. * Range: [-Infinity, Infinity]
  11533. *
  11534. * atanh(x) = 0.5 * ln((1 + x) / (1 - x))
  11535. *
  11536. * atanh(|x| > 1) = NaN
  11537. * atanh(NaN) = NaN
  11538. * atanh(Infinity) = NaN
  11539. * atanh(-Infinity) = NaN
  11540. * atanh(0) = 0
  11541. * atanh(-0) = -0
  11542. * atanh(1) = Infinity
  11543. * atanh(-1) = -Infinity
  11544. *
  11545. */
  11546. P.inverseHyperbolicTangent = P.atanh = function () {
  11547. var pr,
  11548. rm,
  11549. wpr,
  11550. xsd,
  11551. x = this,
  11552. Ctor = x.constructor;
  11553. if (!x.isFinite()) return new Ctor(NaN);
  11554. if (x.e >= 0) return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
  11555. pr = Ctor.precision;
  11556. rm = Ctor.rounding;
  11557. xsd = x.sd();
  11558. if (Math.max(xsd, pr) < 2 * -x.e - 1) return finalise(new Ctor(x), pr, rm, true);
  11559. Ctor.precision = wpr = xsd - x.e;
  11560. x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
  11561. Ctor.precision = pr + 4;
  11562. Ctor.rounding = 1;
  11563. x = x.ln();
  11564. Ctor.precision = pr;
  11565. Ctor.rounding = rm;
  11566. return x.times(0.5);
  11567. };
  11568. /*
  11569. * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this
  11570. * Decimal.
  11571. *
  11572. * Domain: [-Infinity, Infinity]
  11573. * Range: [-pi/2, pi/2]
  11574. *
  11575. * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2)))
  11576. *
  11577. * asin(0) = 0
  11578. * asin(-0) = -0
  11579. * asin(1/2) = pi/6
  11580. * asin(-1/2) = -pi/6
  11581. * asin(1) = pi/2
  11582. * asin(-1) = -pi/2
  11583. * asin(|x| > 1) = NaN
  11584. * asin(NaN) = NaN
  11585. *
  11586. * TODO? Compare performance of Taylor series.
  11587. *
  11588. */
  11589. P.inverseSine = P.asin = function () {
  11590. var halfPi,
  11591. k,
  11592. pr,
  11593. rm,
  11594. x = this,
  11595. Ctor = x.constructor;
  11596. if (x.isZero()) return new Ctor(x);
  11597. k = x.abs().cmp(1);
  11598. pr = Ctor.precision;
  11599. rm = Ctor.rounding;
  11600. if (k !== -1) {
  11601. // |x| is 1
  11602. if (k === 0) {
  11603. halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
  11604. halfPi.s = x.s;
  11605. return halfPi;
  11606. }
  11607. // |x| > 1 or x is NaN
  11608. return new Ctor(NaN);
  11609. }
  11610. // TODO? Special case asin(1/2) = pi/6 and asin(-1/2) = -pi/6
  11611. Ctor.precision = pr + 6;
  11612. Ctor.rounding = 1;
  11613. x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
  11614. Ctor.precision = pr;
  11615. Ctor.rounding = rm;
  11616. return x.times(2);
  11617. };
  11618. /*
  11619. * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value
  11620. * of this Decimal.
  11621. *
  11622. * Domain: [-Infinity, Infinity]
  11623. * Range: [-pi/2, pi/2]
  11624. *
  11625. * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
  11626. *
  11627. * atan(0) = 0
  11628. * atan(-0) = -0
  11629. * atan(1) = pi/4
  11630. * atan(-1) = -pi/4
  11631. * atan(Infinity) = pi/2
  11632. * atan(-Infinity) = -pi/2
  11633. * atan(NaN) = NaN
  11634. *
  11635. */
  11636. P.inverseTangent = P.atan = function () {
  11637. var i,
  11638. j,
  11639. k,
  11640. n,
  11641. px,
  11642. t,
  11643. r,
  11644. wpr,
  11645. x2,
  11646. x = this,
  11647. Ctor = x.constructor,
  11648. pr = Ctor.precision,
  11649. rm = Ctor.rounding;
  11650. if (!x.isFinite()) {
  11651. if (!x.s) return new Ctor(NaN);
  11652. if (pr + 4 <= PI_PRECISION) {
  11653. r = getPi(Ctor, pr + 4, rm).times(0.5);
  11654. r.s = x.s;
  11655. return r;
  11656. }
  11657. } else if (x.isZero()) {
  11658. return new Ctor(x);
  11659. } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
  11660. r = getPi(Ctor, pr + 4, rm).times(0.25);
  11661. r.s = x.s;
  11662. return r;
  11663. }
  11664. Ctor.precision = wpr = pr + 10;
  11665. Ctor.rounding = 1;
  11666. // TODO? if (x >= 1 && pr <= PI_PRECISION) atan(x) = halfPi * x.s - atan(1 / x);
  11667. // Argument reduction
  11668. // Ensure |x| < 0.42
  11669. // atan(x) = 2 * atan(x / (1 + sqrt(1 + x^2)))
  11670. k = Math.min(28, wpr / LOG_BASE + 2 | 0);
  11671. for (i = k; i; --i) {
  11672. x = x.div(x.times(x).plus(1).sqrt().plus(1));
  11673. }
  11674. external = false;
  11675. j = Math.ceil(wpr / LOG_BASE);
  11676. n = 1;
  11677. x2 = x.times(x);
  11678. r = new Ctor(x);
  11679. px = x;
  11680. // atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
  11681. for (; i !== -1;) {
  11682. px = px.times(x2);
  11683. t = r.minus(px.div(n += 2));
  11684. px = px.times(x2);
  11685. r = t.plus(px.div(n += 2));
  11686. if (r.d[j] !== void 0) for (i = j; r.d[i] === t.d[i] && i--;) {
  11687. ;
  11688. }
  11689. }
  11690. if (k) r = r.times(2 << k - 1);
  11691. external = true;
  11692. return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
  11693. };
  11694. /*
  11695. * Return true if the value of this Decimal is a finite number, otherwise return false.
  11696. *
  11697. */
  11698. P.isFinite = function () {
  11699. return !!this.d;
  11700. };
  11701. /*
  11702. * Return true if the value of this Decimal is an integer, otherwise return false.
  11703. *
  11704. */
  11705. P.isInteger = P.isInt = function () {
  11706. return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
  11707. };
  11708. /*
  11709. * Return true if the value of this Decimal is NaN, otherwise return false.
  11710. *
  11711. */
  11712. P.isNaN = function () {
  11713. return !this.s;
  11714. };
  11715. /*
  11716. * Return true if the value of this Decimal is negative, otherwise return false.
  11717. *
  11718. */
  11719. P.isNegative = P.isNeg = function () {
  11720. return this.s < 0;
  11721. };
  11722. /*
  11723. * Return true if the value of this Decimal is positive, otherwise return false.
  11724. *
  11725. */
  11726. P.isPositive = P.isPos = function () {
  11727. return this.s > 0;
  11728. };
  11729. /*
  11730. * Return true if the value of this Decimal is 0 or -0, otherwise return false.
  11731. *
  11732. */
  11733. P.isZero = function () {
  11734. return !!this.d && this.d[0] === 0;
  11735. };
  11736. /*
  11737. * Return true if the value of this Decimal is less than `y`, otherwise return false.
  11738. *
  11739. */
  11740. P.lessThan = P.lt = function (y) {
  11741. return this.cmp(y) < 0;
  11742. };
  11743. /*
  11744. * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false.
  11745. *
  11746. */
  11747. P.lessThanOrEqualTo = P.lte = function (y) {
  11748. return this.cmp(y) < 1;
  11749. };
  11750. /*
  11751. * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision`
  11752. * significant digits using rounding mode `rounding`.
  11753. *
  11754. * If no base is specified, return log[10](arg).
  11755. *
  11756. * log[base](arg) = ln(arg) / ln(base)
  11757. *
  11758. * The result will always be correctly rounded if the base of the log is 10, and 'almost always'
  11759. * otherwise:
  11760. *
  11761. * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen
  11762. * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error
  11763. * between the result and the correctly rounded result will be one ulp (unit in the last place).
  11764. *
  11765. * log[-b](a) = NaN
  11766. * log[0](a) = NaN
  11767. * log[1](a) = NaN
  11768. * log[NaN](a) = NaN
  11769. * log[Infinity](a) = NaN
  11770. * log[b](0) = -Infinity
  11771. * log[b](-0) = -Infinity
  11772. * log[b](-a) = NaN
  11773. * log[b](1) = 0
  11774. * log[b](Infinity) = Infinity
  11775. * log[b](NaN) = NaN
  11776. *
  11777. * [base] {number|string|Decimal} The base of the logarithm.
  11778. *
  11779. */
  11780. P.logarithm = P.log = function (base) {
  11781. var isBase10,
  11782. d,
  11783. denominator,
  11784. k,
  11785. inf,
  11786. num,
  11787. sd,
  11788. r,
  11789. arg = this,
  11790. Ctor = arg.constructor,
  11791. pr = Ctor.precision,
  11792. rm = Ctor.rounding,
  11793. guard = 5;
  11794. // Default base is 10.
  11795. if (base == null) {
  11796. base = new Ctor(10);
  11797. isBase10 = true;
  11798. } else {
  11799. base = new Ctor(base);
  11800. d = base.d;
  11801. // Return NaN if base is negative, or non-finite, or is 0 or 1.
  11802. if (base.s < 0 || !d || !d[0] || base.eq(1)) return new Ctor(NaN);
  11803. isBase10 = base.eq(10);
  11804. }
  11805. d = arg.d;
  11806. // Is arg negative, non-finite, 0 or 1?
  11807. if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
  11808. return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
  11809. }
  11810. // The result will have a non-terminating decimal expansion if base is 10 and arg is not an
  11811. // integer power of 10.
  11812. if (isBase10) {
  11813. if (d.length > 1) {
  11814. inf = true;
  11815. } else {
  11816. for (k = d[0]; k % 10 === 0;) {
  11817. k /= 10;
  11818. }
  11819. inf = k !== 1;
  11820. }
  11821. }
  11822. external = false;
  11823. sd = pr + guard;
  11824. num = naturalLogarithm(arg, sd);
  11825. denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
  11826. // The result will have 5 rounding digits.
  11827. r = divide(num, denominator, sd, 1);
  11828. // If at a rounding boundary, i.e. the result's rounding digits are [49]9999 or [50]0000,
  11829. // calculate 10 further digits.
  11830. //
  11831. // If the result is known to have an infinite decimal expansion, repeat this until it is clear
  11832. // that the result is above or below the boundary. Otherwise, if after calculating the 10
  11833. // further digits, the last 14 are nines, round up and assume the result is exact.
  11834. // Also assume the result is exact if the last 14 are zero.
  11835. //
  11836. // Example of a result that will be incorrectly rounded:
  11837. // log[1048576](4503599627370502) = 2.60000000000000009610279511444746...
  11838. // The above result correctly rounded using ROUND_CEIL to 1 decimal place should be 2.7, but it
  11839. // will be given as 2.6 as there are 15 zeros immediately after the requested decimal place, so
  11840. // the exact result would be assumed to be 2.6, which rounded using ROUND_CEIL to 1 decimal
  11841. // place is still 2.6.
  11842. if (checkRoundingDigits(r.d, k = pr, rm)) {
  11843. do {
  11844. sd += 10;
  11845. num = naturalLogarithm(arg, sd);
  11846. denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
  11847. r = divide(num, denominator, sd, 1);
  11848. if (!inf) {
  11849. // Check for 14 nines from the 2nd rounding digit, as the first may be 4.
  11850. if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
  11851. r = finalise(r, pr + 1, 0);
  11852. }
  11853. break;
  11854. }
  11855. } while (checkRoundingDigits(r.d, k += 10, rm));
  11856. }
  11857. external = true;
  11858. return finalise(r, pr, rm);
  11859. };
  11860. /*
  11861. * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal.
  11862. *
  11863. * arguments {number|string|Decimal}
  11864. *
  11865. P.max = function () {
  11866. Array.prototype.push.call(arguments, this);
  11867. return maxOrMin(this.constructor, arguments, 'lt');
  11868. };
  11869. */
  11870. /*
  11871. * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal.
  11872. *
  11873. * arguments {number|string|Decimal}
  11874. *
  11875. P.min = function () {
  11876. Array.prototype.push.call(arguments, this);
  11877. return maxOrMin(this.constructor, arguments, 'gt');
  11878. };
  11879. */
  11880. /*
  11881. * n - 0 = n
  11882. * n - N = N
  11883. * n - I = -I
  11884. * 0 - n = -n
  11885. * 0 - 0 = 0
  11886. * 0 - N = N
  11887. * 0 - I = -I
  11888. * N - n = N
  11889. * N - 0 = N
  11890. * N - N = N
  11891. * N - I = N
  11892. * I - n = I
  11893. * I - 0 = I
  11894. * I - N = N
  11895. * I - I = N
  11896. *
  11897. * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision`
  11898. * significant digits using rounding mode `rounding`.
  11899. *
  11900. */
  11901. P.minus = P.sub = function (y) {
  11902. var d,
  11903. e,
  11904. i,
  11905. j,
  11906. k,
  11907. len,
  11908. pr,
  11909. rm,
  11910. xd,
  11911. xe,
  11912. xLTy,
  11913. yd,
  11914. x = this,
  11915. Ctor = x.constructor;
  11916. y = new Ctor(y);
  11917. // If either is not finite...
  11918. if (!x.d || !y.d) {
  11919. // Return NaN if either is NaN.
  11920. if (!x.s || !y.s) y = new Ctor(NaN);
  11921. // Return y negated if x is finite and y is ±Infinity.
  11922. else if (x.d) y.s = -y.s;
  11923. // Return x if y is finite and x is ±Infinity.
  11924. // Return x if both are ±Infinity with different signs.
  11925. // Return NaN if both are ±Infinity with the same sign.
  11926. else y = new Ctor(y.d || x.s !== y.s ? x : NaN);
  11927. return y;
  11928. }
  11929. // If signs differ...
  11930. if (x.s != y.s) {
  11931. y.s = -y.s;
  11932. return x.plus(y);
  11933. }
  11934. xd = x.d;
  11935. yd = y.d;
  11936. pr = Ctor.precision;
  11937. rm = Ctor.rounding;
  11938. // If either is zero...
  11939. if (!xd[0] || !yd[0]) {
  11940. // Return y negated if x is zero and y is non-zero.
  11941. if (yd[0]) y.s = -y.s;
  11942. // Return x if y is zero and x is non-zero.
  11943. else if (xd[0]) y = new Ctor(x);
  11944. // Return zero if both are zero.
  11945. // From IEEE 754 (2008) 6.3: 0 - 0 = -0 - -0 = -0 when rounding to -Infinity.
  11946. else return new Ctor(rm === 3 ? -0 : 0);
  11947. return external ? finalise(y, pr, rm) : y;
  11948. }
  11949. // x and y are finite, non-zero numbers with the same sign.
  11950. // Calculate base 1e7 exponents.
  11951. e = mathfloor(y.e / LOG_BASE);
  11952. xe = mathfloor(x.e / LOG_BASE);
  11953. xd = xd.slice();
  11954. k = xe - e;
  11955. // If base 1e7 exponents differ...
  11956. if (k) {
  11957. xLTy = k < 0;
  11958. if (xLTy) {
  11959. d = xd;
  11960. k = -k;
  11961. len = yd.length;
  11962. } else {
  11963. d = yd;
  11964. e = xe;
  11965. len = xd.length;
  11966. }
  11967. // Numbers with massively different exponents would result in a very high number of
  11968. // zeros needing to be prepended, but this can be avoided while still ensuring correct
  11969. // rounding by limiting the number of zeros to `Math.ceil(pr / LOG_BASE) + 2`.
  11970. i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
  11971. if (k > i) {
  11972. k = i;
  11973. d.length = 1;
  11974. }
  11975. // Prepend zeros to equalise exponents.
  11976. d.reverse();
  11977. for (i = k; i--;) {
  11978. d.push(0);
  11979. }
  11980. d.reverse();
  11981. // Base 1e7 exponents equal.
  11982. } else {
  11983. // Check digits to determine which is the bigger number.
  11984. i = xd.length;
  11985. len = yd.length;
  11986. xLTy = i < len;
  11987. if (xLTy) len = i;
  11988. for (i = 0; i < len; i++) {
  11989. if (xd[i] != yd[i]) {
  11990. xLTy = xd[i] < yd[i];
  11991. break;
  11992. }
  11993. }
  11994. k = 0;
  11995. }
  11996. if (xLTy) {
  11997. d = xd;
  11998. xd = yd;
  11999. yd = d;
  12000. y.s = -y.s;
  12001. }
  12002. len = xd.length;
  12003. // Append zeros to `xd` if shorter.
  12004. // Don't add zeros to `yd` if shorter as subtraction only needs to start at `yd` length.
  12005. for (i = yd.length - len; i > 0; --i) {
  12006. xd[len++] = 0;
  12007. }
  12008. // Subtract yd from xd.
  12009. for (i = yd.length; i > k;) {
  12010. if (xd[--i] < yd[i]) {
  12011. for (j = i; j && xd[--j] === 0;) {
  12012. xd[j] = BASE - 1;
  12013. }
  12014. --xd[j];
  12015. xd[i] += BASE;
  12016. }
  12017. xd[i] -= yd[i];
  12018. }
  12019. // Remove trailing zeros.
  12020. for (; xd[--len] === 0;) {
  12021. xd.pop();
  12022. }
  12023. // Remove leading zeros and adjust exponent accordingly.
  12024. for (; xd[0] === 0; xd.shift()) {
  12025. --e;
  12026. }
  12027. // Zero?
  12028. if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0);
  12029. y.d = xd;
  12030. y.e = getBase10Exponent(xd, e);
  12031. return external ? finalise(y, pr, rm) : y;
  12032. };
  12033. /*
  12034. * n % 0 = N
  12035. * n % N = N
  12036. * n % I = n
  12037. * 0 % n = 0
  12038. * -0 % n = -0
  12039. * 0 % 0 = N
  12040. * 0 % N = N
  12041. * 0 % I = 0
  12042. * N % n = N
  12043. * N % 0 = N
  12044. * N % N = N
  12045. * N % I = N
  12046. * I % n = N
  12047. * I % 0 = N
  12048. * I % N = N
  12049. * I % I = N
  12050. *
  12051. * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to
  12052. * `precision` significant digits using rounding mode `rounding`.
  12053. *
  12054. * The result depends on the modulo mode.
  12055. *
  12056. */
  12057. P.modulo = P.mod = function (y) {
  12058. var q,
  12059. x = this,
  12060. Ctor = x.constructor;
  12061. y = new Ctor(y);
  12062. // Return NaN if x is ±Infinity or NaN, or y is NaN or ±0.
  12063. if (!x.d || !y.s || y.d && !y.d[0]) return new Ctor(NaN);
  12064. // Return x if y is ±Infinity or x is ±0.
  12065. if (!y.d || x.d && !x.d[0]) {
  12066. return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
  12067. }
  12068. // Prevent rounding of intermediate calculations.
  12069. external = false;
  12070. if (Ctor.modulo == 9) {
  12071. // Euclidian division: q = sign(y) * floor(x / abs(y))
  12072. // result = x - q * y where 0 <= result < abs(y)
  12073. q = divide(x, y.abs(), 0, 3, 1);
  12074. q.s *= y.s;
  12075. } else {
  12076. q = divide(x, y, 0, Ctor.modulo, 1);
  12077. }
  12078. q = q.times(y);
  12079. external = true;
  12080. return x.minus(q);
  12081. };
  12082. /*
  12083. * Return a new Decimal whose value is the natural exponential of the value of this Decimal,
  12084. * i.e. the base e raised to the power the value of this Decimal, rounded to `precision`
  12085. * significant digits using rounding mode `rounding`.
  12086. *
  12087. */
  12088. P.naturalExponential = P.exp = function () {
  12089. return naturalExponential(this);
  12090. };
  12091. /*
  12092. * Return a new Decimal whose value is the natural logarithm of the value of this Decimal,
  12093. * rounded to `precision` significant digits using rounding mode `rounding`.
  12094. *
  12095. */
  12096. P.naturalLogarithm = P.ln = function () {
  12097. return naturalLogarithm(this);
  12098. };
  12099. /*
  12100. * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by
  12101. * -1.
  12102. *
  12103. */
  12104. P.negated = P.neg = function () {
  12105. var x = new this.constructor(this);
  12106. x.s = -x.s;
  12107. return finalise(x);
  12108. };
  12109. /*
  12110. * n + 0 = n
  12111. * n + N = N
  12112. * n + I = I
  12113. * 0 + n = n
  12114. * 0 + 0 = 0
  12115. * 0 + N = N
  12116. * 0 + I = I
  12117. * N + n = N
  12118. * N + 0 = N
  12119. * N + N = N
  12120. * N + I = N
  12121. * I + n = I
  12122. * I + 0 = I
  12123. * I + N = N
  12124. * I + I = I
  12125. *
  12126. * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision`
  12127. * significant digits using rounding mode `rounding`.
  12128. *
  12129. */
  12130. P.plus = P.add = function (y) {
  12131. var carry,
  12132. d,
  12133. e,
  12134. i,
  12135. k,
  12136. len,
  12137. pr,
  12138. rm,
  12139. xd,
  12140. yd,
  12141. x = this,
  12142. Ctor = x.constructor;
  12143. y = new Ctor(y);
  12144. // If either is not finite...
  12145. if (!x.d || !y.d) {
  12146. // Return NaN if either is NaN.
  12147. if (!x.s || !y.s) y = new Ctor(NaN);
  12148. // Return x if y is finite and x is ±Infinity.
  12149. // Return x if both are ±Infinity with the same sign.
  12150. // Return NaN if both are ±Infinity with different signs.
  12151. // Return y if x is finite and y is ±Infinity.
  12152. else if (!x.d) y = new Ctor(y.d || x.s === y.s ? x : NaN);
  12153. return y;
  12154. }
  12155. // If signs differ...
  12156. if (x.s != y.s) {
  12157. y.s = -y.s;
  12158. return x.minus(y);
  12159. }
  12160. xd = x.d;
  12161. yd = y.d;
  12162. pr = Ctor.precision;
  12163. rm = Ctor.rounding;
  12164. // If either is zero...
  12165. if (!xd[0] || !yd[0]) {
  12166. // Return x if y is zero.
  12167. // Return y if y is non-zero.
  12168. if (!yd[0]) y = new Ctor(x);
  12169. return external ? finalise(y, pr, rm) : y;
  12170. }
  12171. // x and y are finite, non-zero numbers with the same sign.
  12172. // Calculate base 1e7 exponents.
  12173. k = mathfloor(x.e / LOG_BASE);
  12174. e = mathfloor(y.e / LOG_BASE);
  12175. xd = xd.slice();
  12176. i = k - e;
  12177. // If base 1e7 exponents differ...
  12178. if (i) {
  12179. if (i < 0) {
  12180. d = xd;
  12181. i = -i;
  12182. len = yd.length;
  12183. } else {
  12184. d = yd;
  12185. e = k;
  12186. len = xd.length;
  12187. }
  12188. // Limit number of zeros prepended to max(ceil(pr / LOG_BASE), len) + 1.
  12189. k = Math.ceil(pr / LOG_BASE);
  12190. len = k > len ? k + 1 : len + 1;
  12191. if (i > len) {
  12192. i = len;
  12193. d.length = 1;
  12194. }
  12195. // Prepend zeros to equalise exponents. Note: Faster to use reverse then do unshifts.
  12196. d.reverse();
  12197. for (; i--;) {
  12198. d.push(0);
  12199. }
  12200. d.reverse();
  12201. }
  12202. len = xd.length;
  12203. i = yd.length;
  12204. // If yd is longer than xd, swap xd and yd so xd points to the longer array.
  12205. if (len - i < 0) {
  12206. i = len;
  12207. d = yd;
  12208. yd = xd;
  12209. xd = d;
  12210. }
  12211. // Only start adding at yd.length - 1 as the further digits of xd can be left as they are.
  12212. for (carry = 0; i;) {
  12213. carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
  12214. xd[i] %= BASE;
  12215. }
  12216. if (carry) {
  12217. xd.unshift(carry);
  12218. ++e;
  12219. }
  12220. // Remove trailing zeros.
  12221. // No need to check for zero, as +x + +y != 0 && -x + -y != 0
  12222. for (len = xd.length; xd[--len] == 0;) {
  12223. xd.pop();
  12224. }
  12225. y.d = xd;
  12226. y.e = getBase10Exponent(xd, e);
  12227. return external ? finalise(y, pr, rm) : y;
  12228. };
  12229. /*
  12230. * Return the number of significant digits of the value of this Decimal.
  12231. *
  12232. * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
  12233. *
  12234. */
  12235. P.precision = P.sd = function (z) {
  12236. var k,
  12237. x = this;
  12238. if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z);
  12239. if (x.d) {
  12240. k = getPrecision(x.d);
  12241. if (z && x.e + 1 > k) k = x.e + 1;
  12242. } else {
  12243. k = NaN;
  12244. }
  12245. return k;
  12246. };
  12247. /*
  12248. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using
  12249. * rounding mode `rounding`.
  12250. *
  12251. */
  12252. P.round = function () {
  12253. var x = this,
  12254. Ctor = x.constructor;
  12255. return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
  12256. };
  12257. /*
  12258. * Return a new Decimal whose value is the sine of the value in radians of this Decimal.
  12259. *
  12260. * Domain: [-Infinity, Infinity]
  12261. * Range: [-1, 1]
  12262. *
  12263. * sin(x) = x - x^3/3! + x^5/5! - ...
  12264. *
  12265. * sin(0) = 0
  12266. * sin(-0) = -0
  12267. * sin(Infinity) = NaN
  12268. * sin(-Infinity) = NaN
  12269. * sin(NaN) = NaN
  12270. *
  12271. */
  12272. P.sine = P.sin = function () {
  12273. var pr,
  12274. rm,
  12275. x = this,
  12276. Ctor = x.constructor;
  12277. if (!x.isFinite()) return new Ctor(NaN);
  12278. if (x.isZero()) return new Ctor(x);
  12279. pr = Ctor.precision;
  12280. rm = Ctor.rounding;
  12281. Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
  12282. Ctor.rounding = 1;
  12283. x = sine(Ctor, toLessThanHalfPi(Ctor, x));
  12284. Ctor.precision = pr;
  12285. Ctor.rounding = rm;
  12286. return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
  12287. };
  12288. /*
  12289. * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision`
  12290. * significant digits using rounding mode `rounding`.
  12291. *
  12292. * sqrt(-n) = N
  12293. * sqrt(N) = N
  12294. * sqrt(-I) = N
  12295. * sqrt(I) = I
  12296. * sqrt(0) = 0
  12297. * sqrt(-0) = -0
  12298. *
  12299. */
  12300. P.squareRoot = P.sqrt = function () {
  12301. var m,
  12302. n,
  12303. sd,
  12304. r,
  12305. rep,
  12306. t,
  12307. x = this,
  12308. d = x.d,
  12309. e = x.e,
  12310. s = x.s,
  12311. Ctor = x.constructor;
  12312. // Negative/NaN/Infinity/zero?
  12313. if (s !== 1 || !d || !d[0]) {
  12314. return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
  12315. }
  12316. external = false;
  12317. // Initial estimate.
  12318. s = Math.sqrt(+x);
  12319. // Math.sqrt underflow/overflow?
  12320. // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
  12321. if (s == 0 || s == 1 / 0) {
  12322. n = digitsToString(d);
  12323. if ((n.length + e) % 2 == 0) n += '0';
  12324. s = Math.sqrt(n);
  12325. e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
  12326. if (s == 1 / 0) {
  12327. n = '5e' + e;
  12328. } else {
  12329. n = s.toExponential();
  12330. n = n.slice(0, n.indexOf('e') + 1) + e;
  12331. }
  12332. r = new Ctor(n);
  12333. } else {
  12334. r = new Ctor(s.toString());
  12335. }
  12336. sd = (e = Ctor.precision) + 3;
  12337. // Newton-Raphson iteration.
  12338. for (;;) {
  12339. t = r;
  12340. r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
  12341. // TODO? Replace with for-loop and checkRoundingDigits.
  12342. if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
  12343. n = n.slice(sd - 3, sd + 1);
  12344. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or
  12345. // 4999, i.e. approaching a rounding boundary, continue the iteration.
  12346. if (n == '9999' || !rep && n == '4999') {
  12347. // On the first iteration only, check to see if rounding up gives the exact result as the
  12348. // nines may infinitely repeat.
  12349. if (!rep) {
  12350. finalise(t, e + 1, 0);
  12351. if (t.times(t).eq(x)) {
  12352. r = t;
  12353. break;
  12354. }
  12355. }
  12356. sd += 4;
  12357. rep = 1;
  12358. } else {
  12359. // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
  12360. // If not, then there are further digits and m will be truthy.
  12361. if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
  12362. // Truncate to the first rounding digit.
  12363. finalise(r, e + 1, 1);
  12364. m = !r.times(r).eq(x);
  12365. }
  12366. break;
  12367. }
  12368. }
  12369. }
  12370. external = true;
  12371. return finalise(r, e, Ctor.rounding, m);
  12372. };
  12373. /*
  12374. * Return a new Decimal whose value is the tangent of the value in radians of this Decimal.
  12375. *
  12376. * Domain: [-Infinity, Infinity]
  12377. * Range: [-Infinity, Infinity]
  12378. *
  12379. * tan(0) = 0
  12380. * tan(-0) = -0
  12381. * tan(Infinity) = NaN
  12382. * tan(-Infinity) = NaN
  12383. * tan(NaN) = NaN
  12384. *
  12385. */
  12386. P.tangent = P.tan = function () {
  12387. var pr,
  12388. rm,
  12389. x = this,
  12390. Ctor = x.constructor;
  12391. if (!x.isFinite()) return new Ctor(NaN);
  12392. if (x.isZero()) return new Ctor(x);
  12393. pr = Ctor.precision;
  12394. rm = Ctor.rounding;
  12395. Ctor.precision = pr + 10;
  12396. Ctor.rounding = 1;
  12397. x = x.sin();
  12398. x.s = 1;
  12399. x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
  12400. Ctor.precision = pr;
  12401. Ctor.rounding = rm;
  12402. return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
  12403. };
  12404. /*
  12405. * n * 0 = 0
  12406. * n * N = N
  12407. * n * I = I
  12408. * 0 * n = 0
  12409. * 0 * 0 = 0
  12410. * 0 * N = N
  12411. * 0 * I = N
  12412. * N * n = N
  12413. * N * 0 = N
  12414. * N * N = N
  12415. * N * I = N
  12416. * I * n = I
  12417. * I * 0 = N
  12418. * I * N = N
  12419. * I * I = I
  12420. *
  12421. * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant
  12422. * digits using rounding mode `rounding`.
  12423. *
  12424. */
  12425. P.times = P.mul = function (y) {
  12426. var carry,
  12427. e,
  12428. i,
  12429. k,
  12430. r,
  12431. rL,
  12432. t,
  12433. xdL,
  12434. ydL,
  12435. x = this,
  12436. Ctor = x.constructor,
  12437. xd = x.d,
  12438. yd = (y = new Ctor(y)).d;
  12439. y.s *= x.s;
  12440. // If either is NaN, ±Infinity or ±0...
  12441. if (!xd || !xd[0] || !yd || !yd[0]) {
  12442. return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd
  12443. // Return NaN if either is NaN.
  12444. // Return NaN if x is ±0 and y is ±Infinity, or y is ±0 and x is ±Infinity.
  12445. ? NaN
  12446. // Return ±Infinity if either is ±Infinity.
  12447. // Return ±0 if either is ±0.
  12448. : !xd || !yd ? y.s / 0 : y.s * 0);
  12449. }
  12450. e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
  12451. xdL = xd.length;
  12452. ydL = yd.length;
  12453. // Ensure xd points to the longer array.
  12454. if (xdL < ydL) {
  12455. r = xd;
  12456. xd = yd;
  12457. yd = r;
  12458. rL = xdL;
  12459. xdL = ydL;
  12460. ydL = rL;
  12461. }
  12462. // Initialise the result array with zeros.
  12463. r = [];
  12464. rL = xdL + ydL;
  12465. for (i = rL; i--;) {
  12466. r.push(0);
  12467. }
  12468. // Multiply!
  12469. for (i = ydL; --i >= 0;) {
  12470. carry = 0;
  12471. for (k = xdL + i; k > i;) {
  12472. t = r[k] + yd[i] * xd[k - i - 1] + carry;
  12473. r[k--] = t % BASE | 0;
  12474. carry = t / BASE | 0;
  12475. }
  12476. r[k] = (r[k] + carry) % BASE | 0;
  12477. }
  12478. // Remove trailing zeros.
  12479. for (; !r[--rL];) {
  12480. r.pop();
  12481. }
  12482. if (carry) ++e;else r.shift();
  12483. y.d = r;
  12484. y.e = getBase10Exponent(r, e);
  12485. return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
  12486. };
  12487. /*
  12488. * Return a string representing the value of this Decimal in base 2, round to `sd` significant
  12489. * digits using rounding mode `rm`.
  12490. *
  12491. * If the optional `sd` argument is present then return binary exponential notation.
  12492. *
  12493. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  12494. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12495. *
  12496. */
  12497. P.toBinary = function (sd, rm) {
  12498. return toStringBinary(this, 2, sd, rm);
  12499. };
  12500. /*
  12501. * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp`
  12502. * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted.
  12503. *
  12504. * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal.
  12505. *
  12506. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  12507. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12508. *
  12509. */
  12510. P.toDecimalPlaces = P.toDP = function (dp, rm) {
  12511. var x = this,
  12512. Ctor = x.constructor;
  12513. x = new Ctor(x);
  12514. if (dp === void 0) return x;
  12515. checkInt32(dp, 0, MAX_DIGITS);
  12516. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  12517. return finalise(x, dp + x.e + 1, rm);
  12518. };
  12519. /*
  12520. * Return a string representing the value of this Decimal in exponential notation rounded to
  12521. * `dp` fixed decimal places using rounding mode `rounding`.
  12522. *
  12523. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  12524. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12525. *
  12526. */
  12527. P.toExponential = function (dp, rm) {
  12528. var str,
  12529. x = this,
  12530. Ctor = x.constructor;
  12531. if (dp === void 0) {
  12532. str = finiteToString(x, true);
  12533. } else {
  12534. checkInt32(dp, 0, MAX_DIGITS);
  12535. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  12536. x = finalise(new Ctor(x), dp + 1, rm);
  12537. str = finiteToString(x, true, dp + 1);
  12538. }
  12539. return x.isNeg() && !x.isZero() ? '-' + str : str;
  12540. };
  12541. /*
  12542. * Return a string representing the value of this Decimal in normal (fixed-point) notation to
  12543. * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is
  12544. * omitted.
  12545. *
  12546. * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'.
  12547. *
  12548. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  12549. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12550. *
  12551. * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
  12552. * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
  12553. * (-0).toFixed(3) is '0.000'.
  12554. * (-0.5).toFixed(0) is '-0'.
  12555. *
  12556. */
  12557. P.toFixed = function (dp, rm) {
  12558. var str,
  12559. y,
  12560. x = this,
  12561. Ctor = x.constructor;
  12562. if (dp === void 0) {
  12563. str = finiteToString(x);
  12564. } else {
  12565. checkInt32(dp, 0, MAX_DIGITS);
  12566. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  12567. y = finalise(new Ctor(x), dp + x.e + 1, rm);
  12568. str = finiteToString(y, false, dp + y.e + 1);
  12569. }
  12570. // To determine whether to add the minus sign look at the value before it was rounded,
  12571. // i.e. look at `x` rather than `y`.
  12572. return x.isNeg() && !x.isZero() ? '-' + str : str;
  12573. };
  12574. /*
  12575. * Return an array representing the value of this Decimal as a simple fraction with an integer
  12576. * numerator and an integer denominator.
  12577. *
  12578. * The denominator will be a positive non-zero value less than or equal to the specified maximum
  12579. * denominator. If a maximum denominator is not specified, the denominator will be the lowest
  12580. * value necessary to represent the number exactly.
  12581. *
  12582. * [maxD] {number|string|Decimal} Maximum denominator. Integer >= 1 and < Infinity.
  12583. *
  12584. */
  12585. P.toFraction = function (maxD) {
  12586. var d,
  12587. d0,
  12588. d1,
  12589. d2,
  12590. e,
  12591. k,
  12592. n,
  12593. n0,
  12594. n1,
  12595. pr,
  12596. q,
  12597. r,
  12598. x = this,
  12599. xd = x.d,
  12600. Ctor = x.constructor;
  12601. if (!xd) return new Ctor(x);
  12602. n1 = d0 = new Ctor(1);
  12603. d1 = n0 = new Ctor(0);
  12604. d = new Ctor(d1);
  12605. e = d.e = getPrecision(xd) - x.e - 1;
  12606. k = e % LOG_BASE;
  12607. d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
  12608. if (maxD == null) {
  12609. // d is 10**e, the minimum max-denominator needed.
  12610. maxD = e > 0 ? d : n1;
  12611. } else {
  12612. n = new Ctor(maxD);
  12613. if (!n.isInt() || n.lt(n1)) throw Error(invalidArgument + n);
  12614. maxD = n.gt(d) ? e > 0 ? d : n1 : n;
  12615. }
  12616. external = false;
  12617. n = new Ctor(digitsToString(xd));
  12618. pr = Ctor.precision;
  12619. Ctor.precision = e = xd.length * LOG_BASE * 2;
  12620. for (;;) {
  12621. q = divide(n, d, 0, 1, 1);
  12622. d2 = d0.plus(q.times(d1));
  12623. if (d2.cmp(maxD) == 1) break;
  12624. d0 = d1;
  12625. d1 = d2;
  12626. d2 = n1;
  12627. n1 = n0.plus(q.times(d2));
  12628. n0 = d2;
  12629. d2 = d;
  12630. d = n.minus(q.times(d2));
  12631. n = d2;
  12632. }
  12633. d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
  12634. n0 = n0.plus(d2.times(n1));
  12635. d0 = d0.plus(d2.times(d1));
  12636. n0.s = n1.s = x.s;
  12637. // Determine which fraction is closer to x, n0/d0 or n1/d1?
  12638. r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
  12639. Ctor.precision = pr;
  12640. external = true;
  12641. return r;
  12642. };
  12643. /*
  12644. * Return a string representing the value of this Decimal in base 16, round to `sd` significant
  12645. * digits using rounding mode `rm`.
  12646. *
  12647. * If the optional `sd` argument is present then return binary exponential notation.
  12648. *
  12649. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  12650. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12651. *
  12652. */
  12653. P.toHexadecimal = P.toHex = function (sd, rm) {
  12654. return toStringBinary(this, 16, sd, rm);
  12655. };
  12656. /*
  12657. * Returns a new Decimal whose value is the nearest multiple of `y` in the direction of rounding
  12658. * mode `rm`, or `Decimal.rounding` if `rm` is omitted, to the value of this Decimal.
  12659. *
  12660. * The return value will always have the same sign as this Decimal, unless either this Decimal
  12661. * or `y` is NaN, in which case the return value will be also be NaN.
  12662. *
  12663. * The return value is not affected by the value of `precision`.
  12664. *
  12665. * y {number|string|Decimal} The magnitude to round to a multiple of.
  12666. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12667. *
  12668. * 'toNearest() rounding mode not an integer: {rm}'
  12669. * 'toNearest() rounding mode out of range: {rm}'
  12670. *
  12671. */
  12672. P.toNearest = function (y, rm) {
  12673. var x = this,
  12674. Ctor = x.constructor;
  12675. x = new Ctor(x);
  12676. if (y == null) {
  12677. // If x is not finite, return x.
  12678. if (!x.d) return x;
  12679. y = new Ctor(1);
  12680. rm = Ctor.rounding;
  12681. } else {
  12682. y = new Ctor(y);
  12683. if (rm === void 0) {
  12684. rm = Ctor.rounding;
  12685. } else {
  12686. checkInt32(rm, 0, 8);
  12687. }
  12688. // If x is not finite, return x if y is not NaN, else NaN.
  12689. if (!x.d) return y.s ? x : y;
  12690. // If y is not finite, return Infinity with the sign of x if y is Infinity, else NaN.
  12691. if (!y.d) {
  12692. if (y.s) y.s = x.s;
  12693. return y;
  12694. }
  12695. }
  12696. // If y is not zero, calculate the nearest multiple of y to x.
  12697. if (y.d[0]) {
  12698. external = false;
  12699. x = divide(x, y, 0, rm, 1).times(y);
  12700. external = true;
  12701. finalise(x);
  12702. // If y is zero, return zero with the sign of x.
  12703. } else {
  12704. y.s = x.s;
  12705. x = y;
  12706. }
  12707. return x;
  12708. };
  12709. /*
  12710. * Return the value of this Decimal converted to a number primitive.
  12711. * Zero keeps its sign.
  12712. *
  12713. */
  12714. P.toNumber = function () {
  12715. return +this;
  12716. };
  12717. /*
  12718. * Return a string representing the value of this Decimal in base 8, round to `sd` significant
  12719. * digits using rounding mode `rm`.
  12720. *
  12721. * If the optional `sd` argument is present then return binary exponential notation.
  12722. *
  12723. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  12724. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12725. *
  12726. */
  12727. P.toOctal = function (sd, rm) {
  12728. return toStringBinary(this, 8, sd, rm);
  12729. };
  12730. /*
  12731. * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded
  12732. * to `precision` significant digits using rounding mode `rounding`.
  12733. *
  12734. * ECMAScript compliant.
  12735. *
  12736. * pow(x, NaN) = NaN
  12737. * pow(x, ±0) = 1
  12738. * pow(NaN, non-zero) = NaN
  12739. * pow(abs(x) > 1, +Infinity) = +Infinity
  12740. * pow(abs(x) > 1, -Infinity) = +0
  12741. * pow(abs(x) == 1, ±Infinity) = NaN
  12742. * pow(abs(x) < 1, +Infinity) = +0
  12743. * pow(abs(x) < 1, -Infinity) = +Infinity
  12744. * pow(+Infinity, y > 0) = +Infinity
  12745. * pow(+Infinity, y < 0) = +0
  12746. * pow(-Infinity, odd integer > 0) = -Infinity
  12747. * pow(-Infinity, even integer > 0) = +Infinity
  12748. * pow(-Infinity, odd integer < 0) = -0
  12749. * pow(-Infinity, even integer < 0) = +0
  12750. * pow(+0, y > 0) = +0
  12751. * pow(+0, y < 0) = +Infinity
  12752. * pow(-0, odd integer > 0) = -0
  12753. * pow(-0, even integer > 0) = +0
  12754. * pow(-0, odd integer < 0) = -Infinity
  12755. * pow(-0, even integer < 0) = +Infinity
  12756. * pow(finite x < 0, finite non-integer) = NaN
  12757. *
  12758. * For non-integer or very large exponents pow(x, y) is calculated using
  12759. *
  12760. * x^y = exp(y*ln(x))
  12761. *
  12762. * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the
  12763. * probability of an incorrectly rounded result
  12764. * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14
  12765. * i.e. 1 in 250,000,000,000,000
  12766. *
  12767. * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place).
  12768. *
  12769. * y {number|string|Decimal} The power to which to raise this Decimal.
  12770. *
  12771. */
  12772. P.toPower = P.pow = function (y) {
  12773. var e,
  12774. k,
  12775. pr,
  12776. r,
  12777. rm,
  12778. s,
  12779. x = this,
  12780. Ctor = x.constructor,
  12781. yn = +(y = new Ctor(y));
  12782. // Either ±Infinity, NaN or ±0?
  12783. if (!x.d || !y.d || !x.d[0] || !y.d[0]) return new Ctor(mathpow(+x, yn));
  12784. x = new Ctor(x);
  12785. if (x.eq(1)) return x;
  12786. pr = Ctor.precision;
  12787. rm = Ctor.rounding;
  12788. if (y.eq(1)) return finalise(x, pr, rm);
  12789. // y exponent
  12790. e = mathfloor(y.e / LOG_BASE);
  12791. // If y is a small integer use the 'exponentiation by squaring' algorithm.
  12792. if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
  12793. r = intPow(Ctor, x, k, pr);
  12794. return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
  12795. }
  12796. s = x.s;
  12797. // if x is negative
  12798. if (s < 0) {
  12799. // if y is not an integer
  12800. if (e < y.d.length - 1) return new Ctor(NaN);
  12801. // Result is positive if x is negative and the last digit of integer y is even.
  12802. if ((y.d[e] & 1) == 0) s = 1;
  12803. // if x.eq(-1)
  12804. if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
  12805. x.s = s;
  12806. return x;
  12807. }
  12808. }
  12809. // Estimate result exponent.
  12810. // x^y = 10^e, where e = y * log10(x)
  12811. // log10(x) = log10(x_significand) + x_exponent
  12812. // log10(x_significand) = ln(x_significand) / ln(10)
  12813. k = mathpow(+x, yn);
  12814. e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log('0.' + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + '').e;
  12815. // Exponent estimate may be incorrect e.g. x: 0.999999999999999999, y: 2.29, e: 0, r.e: -1.
  12816. // Overflow/underflow?
  12817. if (e > Ctor.maxE + 1 || e < Ctor.minE - 1) return new Ctor(e > 0 ? s / 0 : 0);
  12818. external = false;
  12819. Ctor.rounding = x.s = 1;
  12820. // Estimate the extra guard digits needed to ensure five correct rounding digits from
  12821. // naturalLogarithm(x). Example of failure without these extra digits (precision: 10):
  12822. // new Decimal(2.32456).pow('2087987436534566.46411')
  12823. // should be 1.162377823e+764914905173815, but is 1.162355823e+764914905173815
  12824. k = Math.min(12, (e + '').length);
  12825. // r = x^y = exp(y*ln(x))
  12826. r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
  12827. // r may be Infinity, e.g. (0.9999999999999999).pow(-1e+40)
  12828. if (r.d) {
  12829. // Truncate to the required precision plus five rounding digits.
  12830. r = finalise(r, pr + 5, 1);
  12831. // If the rounding digits are [49]9999 or [50]0000 increase the precision by 10 and recalculate
  12832. // the result.
  12833. if (checkRoundingDigits(r.d, pr, rm)) {
  12834. e = pr + 10;
  12835. // Truncate to the increased precision plus five rounding digits.
  12836. r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
  12837. // Check for 14 nines from the 2nd rounding digit (the first rounding digit may be 4 or 9).
  12838. if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
  12839. r = finalise(r, pr + 1, 0);
  12840. }
  12841. }
  12842. }
  12843. r.s = s;
  12844. external = true;
  12845. Ctor.rounding = rm;
  12846. return finalise(r, pr, rm);
  12847. };
  12848. /*
  12849. * Return a string representing the value of this Decimal rounded to `sd` significant digits
  12850. * using rounding mode `rounding`.
  12851. *
  12852. * Return exponential notation if `sd` is less than the number of digits necessary to represent
  12853. * the integer part of the value in normal notation.
  12854. *
  12855. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  12856. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12857. *
  12858. */
  12859. P.toPrecision = function (sd, rm) {
  12860. var str,
  12861. x = this,
  12862. Ctor = x.constructor;
  12863. if (sd === void 0) {
  12864. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  12865. } else {
  12866. checkInt32(sd, 1, MAX_DIGITS);
  12867. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  12868. x = finalise(new Ctor(x), sd, rm);
  12869. str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
  12870. }
  12871. return x.isNeg() && !x.isZero() ? '-' + str : str;
  12872. };
  12873. /*
  12874. * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd`
  12875. * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if
  12876. * omitted.
  12877. *
  12878. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  12879. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  12880. *
  12881. * 'toSD() digits out of range: {sd}'
  12882. * 'toSD() digits not an integer: {sd}'
  12883. * 'toSD() rounding mode not an integer: {rm}'
  12884. * 'toSD() rounding mode out of range: {rm}'
  12885. *
  12886. */
  12887. P.toSignificantDigits = P.toSD = function (sd, rm) {
  12888. var x = this,
  12889. Ctor = x.constructor;
  12890. if (sd === void 0) {
  12891. sd = Ctor.precision;
  12892. rm = Ctor.rounding;
  12893. } else {
  12894. checkInt32(sd, 1, MAX_DIGITS);
  12895. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  12896. }
  12897. return finalise(new Ctor(x), sd, rm);
  12898. };
  12899. /*
  12900. * Return a string representing the value of this Decimal.
  12901. *
  12902. * Return exponential notation if this Decimal has a positive exponent equal to or greater than
  12903. * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
  12904. *
  12905. */
  12906. P.toString = function () {
  12907. var x = this,
  12908. Ctor = x.constructor,
  12909. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  12910. return x.isNeg() && !x.isZero() ? '-' + str : str;
  12911. };
  12912. /*
  12913. * Return a new Decimal whose value is the value of this Decimal truncated to a whole number.
  12914. *
  12915. */
  12916. P.truncated = P.trunc = function () {
  12917. return finalise(new this.constructor(this), this.e + 1, 1);
  12918. };
  12919. /*
  12920. * Return a string representing the value of this Decimal.
  12921. * Unlike `toString`, negative zero will include the minus sign.
  12922. *
  12923. */
  12924. P.valueOf = P.toJSON = function () {
  12925. var x = this,
  12926. Ctor = x.constructor,
  12927. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  12928. return x.isNeg() ? '-' + str : str;
  12929. };
  12930. // Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers.
  12931. /*
  12932. * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toPower,
  12933. * finiteToString, naturalExponential, naturalLogarithm
  12934. * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest,
  12935. * P.toPrecision, P.toSignificantDigits, toStringBinary, random
  12936. * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm
  12937. * convertBase toStringBinary, parseOther
  12938. * cos P.cos
  12939. * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy,
  12940. * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction,
  12941. * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm,
  12942. * taylorSeries, atan2, parseOther
  12943. * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh,
  12944. * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus,
  12945. * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot,
  12946. * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed,
  12947. * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits,
  12948. * P.truncated, divide, getLn10, getPi, naturalExponential,
  12949. * naturalLogarithm, ceil, floor, round, trunc
  12950. * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf,
  12951. * toStringBinary
  12952. * getBase10Exponent P.minus, P.plus, P.times, parseOther
  12953. * getLn10 P.logarithm, naturalLogarithm
  12954. * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2
  12955. * getPrecision P.precision, P.toFraction
  12956. * getZeroString digitsToString, finiteToString
  12957. * intPow P.toPower, parseOther
  12958. * isOdd toLessThanHalfPi
  12959. * maxOrMin max, min
  12960. * naturalExponential P.naturalExponential, P.toPower
  12961. * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm,
  12962. * P.toPower, naturalExponential
  12963. * nonFiniteToString finiteToString, toStringBinary
  12964. * parseDecimal Decimal
  12965. * parseOther Decimal
  12966. * sin P.sin
  12967. * taylorSeries P.cosh, P.sinh, cos, sin
  12968. * toLessThanHalfPi P.cos, P.sin
  12969. * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal
  12970. * truncate intPow
  12971. *
  12972. * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi,
  12973. * naturalLogarithm, config, parseOther, random, Decimal
  12974. */
  12975. function digitsToString(d) {
  12976. var i,
  12977. k,
  12978. ws,
  12979. indexOfLastWord = d.length - 1,
  12980. str = '',
  12981. w = d[0];
  12982. if (indexOfLastWord > 0) {
  12983. str += w;
  12984. for (i = 1; i < indexOfLastWord; i++) {
  12985. ws = d[i] + '';
  12986. k = LOG_BASE - ws.length;
  12987. if (k) str += getZeroString(k);
  12988. str += ws;
  12989. }
  12990. w = d[i];
  12991. ws = w + '';
  12992. k = LOG_BASE - ws.length;
  12993. if (k) str += getZeroString(k);
  12994. } else if (w === 0) {
  12995. return '0';
  12996. }
  12997. // Remove trailing zeros of last w.
  12998. for (; w % 10 === 0;) {
  12999. w /= 10;
  13000. }
  13001. return str + w;
  13002. }
  13003. function checkInt32(i, min, max) {
  13004. if (i !== ~~i || i < min || i > max) {
  13005. throw Error(invalidArgument + i);
  13006. }
  13007. }
  13008. /*
  13009. * Check 5 rounding digits if `repeating` is null, 4 otherwise.
  13010. * `repeating == null` if caller is `log` or `pow`,
  13011. * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`.
  13012. */
  13013. function checkRoundingDigits(d, i, rm, repeating) {
  13014. var di, k, r, rd;
  13015. // Get the length of the first word of the array d.
  13016. for (k = d[0]; k >= 10; k /= 10) {
  13017. --i;
  13018. }
  13019. // Is the rounding digit in the first word of d?
  13020. if (--i < 0) {
  13021. i += LOG_BASE;
  13022. di = 0;
  13023. } else {
  13024. di = Math.ceil((i + 1) / LOG_BASE);
  13025. i %= LOG_BASE;
  13026. }
  13027. // i is the index (0 - 6) of the rounding digit.
  13028. // E.g. if within the word 3487563 the first rounding digit is 5,
  13029. // then i = 4, k = 1000, rd = 3487563 % 1000 = 563
  13030. k = mathpow(10, LOG_BASE - i);
  13031. rd = d[di] % k | 0;
  13032. if (repeating == null) {
  13033. if (i < 3) {
  13034. if (i == 0) rd = rd / 100 | 0;else if (i == 1) rd = rd / 10 | 0;
  13035. r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
  13036. } else {
  13037. r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
  13038. }
  13039. } else {
  13040. if (i < 4) {
  13041. if (i == 0) rd = rd / 1000 | 0;else if (i == 1) rd = rd / 100 | 0;else if (i == 2) rd = rd / 10 | 0;
  13042. r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
  13043. } else {
  13044. r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1;
  13045. }
  13046. }
  13047. return r;
  13048. }
  13049. // Convert string of `baseIn` to an array of numbers of `baseOut`.
  13050. // Eg. convertBase('255', 10, 16) returns [15, 15].
  13051. // Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
  13052. function convertBase(str, baseIn, baseOut) {
  13053. var j,
  13054. arr = [0],
  13055. arrL,
  13056. i = 0,
  13057. strL = str.length;
  13058. for (; i < strL;) {
  13059. for (arrL = arr.length; arrL--;) {
  13060. arr[arrL] *= baseIn;
  13061. }
  13062. arr[0] += NUMERALS.indexOf(str.charAt(i++));
  13063. for (j = 0; j < arr.length; j++) {
  13064. if (arr[j] > baseOut - 1) {
  13065. if (arr[j + 1] === void 0) arr[j + 1] = 0;
  13066. arr[j + 1] += arr[j] / baseOut | 0;
  13067. arr[j] %= baseOut;
  13068. }
  13069. }
  13070. }
  13071. return arr.reverse();
  13072. }
  13073. /*
  13074. * cos(x) = 1 - x^2/2! + x^4/4! - ...
  13075. * |x| < pi/2
  13076. *
  13077. */
  13078. function cosine(Ctor, x) {
  13079. var k, len, y;
  13080. if (x.isZero()) return x;
  13081. // Argument reduction: cos(4x) = 8*(cos^4(x) - cos^2(x)) + 1
  13082. // i.e. cos(x) = 8*(cos^4(x/4) - cos^2(x/4)) + 1
  13083. // Estimate the optimum number of times to use the argument reduction.
  13084. len = x.d.length;
  13085. if (len < 32) {
  13086. k = Math.ceil(len / 3);
  13087. y = (1 / tinyPow(4, k)).toString();
  13088. } else {
  13089. k = 16;
  13090. y = '2.3283064365386962890625e-10';
  13091. }
  13092. Ctor.precision += k;
  13093. x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
  13094. // Reverse argument reduction
  13095. for (var i = k; i--;) {
  13096. var cos2x = x.times(x);
  13097. x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
  13098. }
  13099. Ctor.precision -= k;
  13100. return x;
  13101. }
  13102. /*
  13103. * Perform division in the specified base.
  13104. */
  13105. var divide = function () {
  13106. // Assumes non-zero x and k, and hence non-zero result.
  13107. function multiplyInteger(x, k, base) {
  13108. var temp,
  13109. carry = 0,
  13110. i = x.length;
  13111. for (x = x.slice(); i--;) {
  13112. temp = x[i] * k + carry;
  13113. x[i] = temp % base | 0;
  13114. carry = temp / base | 0;
  13115. }
  13116. if (carry) x.unshift(carry);
  13117. return x;
  13118. }
  13119. function compare(a, b, aL, bL) {
  13120. var i, r;
  13121. if (aL != bL) {
  13122. r = aL > bL ? 1 : -1;
  13123. } else {
  13124. for (i = r = 0; i < aL; i++) {
  13125. if (a[i] != b[i]) {
  13126. r = a[i] > b[i] ? 1 : -1;
  13127. break;
  13128. }
  13129. }
  13130. }
  13131. return r;
  13132. }
  13133. function subtract(a, b, aL, base) {
  13134. var i = 0;
  13135. // Subtract b from a.
  13136. for (; aL--;) {
  13137. a[aL] -= i;
  13138. i = a[aL] < b[aL] ? 1 : 0;
  13139. a[aL] = i * base + a[aL] - b[aL];
  13140. }
  13141. // Remove leading zeros.
  13142. for (; !a[0] && a.length > 1;) {
  13143. a.shift();
  13144. }
  13145. }
  13146. return function (x, y, pr, rm, dp, base) {
  13147. var cmp,
  13148. e,
  13149. i,
  13150. k,
  13151. logBase,
  13152. more,
  13153. prod,
  13154. prodL,
  13155. q,
  13156. qd,
  13157. rem,
  13158. remL,
  13159. rem0,
  13160. sd,
  13161. t,
  13162. xi,
  13163. xL,
  13164. yd0,
  13165. yL,
  13166. yz,
  13167. Ctor = x.constructor,
  13168. sign = x.s == y.s ? 1 : -1,
  13169. xd = x.d,
  13170. yd = y.d;
  13171. // Either NaN, Infinity or 0?
  13172. if (!xd || !xd[0] || !yd || !yd[0]) {
  13173. return new Ctor(
  13174. // Return NaN if either NaN, or both Infinity or 0.
  13175. !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN :
  13176. // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
  13177. xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
  13178. }
  13179. if (base) {
  13180. logBase = 1;
  13181. e = x.e - y.e;
  13182. } else {
  13183. base = BASE;
  13184. logBase = LOG_BASE;
  13185. e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
  13186. }
  13187. yL = yd.length;
  13188. xL = xd.length;
  13189. q = new Ctor(sign);
  13190. qd = q.d = [];
  13191. // Result exponent may be one less than e.
  13192. // The digit array of a Decimal from toStringBinary may have trailing zeros.
  13193. for (i = 0; yd[i] == (xd[i] || 0); i++) {
  13194. ;
  13195. }
  13196. if (yd[i] > (xd[i] || 0)) e--;
  13197. if (pr == null) {
  13198. sd = pr = Ctor.precision;
  13199. rm = Ctor.rounding;
  13200. } else if (dp) {
  13201. sd = pr + (x.e - y.e) + 1;
  13202. } else {
  13203. sd = pr;
  13204. }
  13205. if (sd < 0) {
  13206. qd.push(1);
  13207. more = true;
  13208. } else {
  13209. // Convert precision in number of base 10 digits to base 1e7 digits.
  13210. sd = sd / logBase + 2 | 0;
  13211. i = 0;
  13212. // divisor < 1e7
  13213. if (yL == 1) {
  13214. k = 0;
  13215. yd = yd[0];
  13216. sd++;
  13217. // k is the carry.
  13218. for (; (i < xL || k) && sd--; i++) {
  13219. t = k * base + (xd[i] || 0);
  13220. qd[i] = t / yd | 0;
  13221. k = t % yd | 0;
  13222. }
  13223. more = k || i < xL;
  13224. // divisor >= 1e7
  13225. } else {
  13226. // Normalise xd and yd so highest order digit of yd is >= base/2
  13227. k = base / (yd[0] + 1) | 0;
  13228. if (k > 1) {
  13229. yd = multiplyInteger(yd, k, base);
  13230. xd = multiplyInteger(xd, k, base);
  13231. yL = yd.length;
  13232. xL = xd.length;
  13233. }
  13234. xi = yL;
  13235. rem = xd.slice(0, yL);
  13236. remL = rem.length;
  13237. // Add zeros to make remainder as long as divisor.
  13238. for (; remL < yL;) {
  13239. rem[remL++] = 0;
  13240. }
  13241. yz = yd.slice();
  13242. yz.unshift(0);
  13243. yd0 = yd[0];
  13244. if (yd[1] >= base / 2) ++yd0;
  13245. do {
  13246. k = 0;
  13247. // Compare divisor and remainder.
  13248. cmp = compare(yd, rem, yL, remL);
  13249. // If divisor < remainder.
  13250. if (cmp < 0) {
  13251. // Calculate trial digit, k.
  13252. rem0 = rem[0];
  13253. if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
  13254. // k will be how many times the divisor goes into the current remainder.
  13255. k = rem0 / yd0 | 0;
  13256. // Algorithm:
  13257. // 1. product = divisor * trial digit (k)
  13258. // 2. if product > remainder: product -= divisor, k--
  13259. // 3. remainder -= product
  13260. // 4. if product was < remainder at 2:
  13261. // 5. compare new remainder and divisor
  13262. // 6. If remainder > divisor: remainder -= divisor, k++
  13263. if (k > 1) {
  13264. if (k >= base) k = base - 1;
  13265. // product = divisor * trial digit.
  13266. prod = multiplyInteger(yd, k, base);
  13267. prodL = prod.length;
  13268. remL = rem.length;
  13269. // Compare product and remainder.
  13270. cmp = compare(prod, rem, prodL, remL);
  13271. // product > remainder.
  13272. if (cmp == 1) {
  13273. k--;
  13274. // Subtract divisor from product.
  13275. subtract(prod, yL < prodL ? yz : yd, prodL, base);
  13276. }
  13277. } else {
  13278. // cmp is -1.
  13279. // If k is 0, there is no need to compare yd and rem again below, so change cmp to 1
  13280. // to avoid it. If k is 1 there is a need to compare yd and rem again below.
  13281. if (k == 0) cmp = k = 1;
  13282. prod = yd.slice();
  13283. }
  13284. prodL = prod.length;
  13285. if (prodL < remL) prod.unshift(0);
  13286. // Subtract product from remainder.
  13287. subtract(rem, prod, remL, base);
  13288. // If product was < previous remainder.
  13289. if (cmp == -1) {
  13290. remL = rem.length;
  13291. // Compare divisor and new remainder.
  13292. cmp = compare(yd, rem, yL, remL);
  13293. // If divisor < new remainder, subtract divisor from remainder.
  13294. if (cmp < 1) {
  13295. k++;
  13296. // Subtract divisor from remainder.
  13297. subtract(rem, yL < remL ? yz : yd, remL, base);
  13298. }
  13299. }
  13300. remL = rem.length;
  13301. } else if (cmp === 0) {
  13302. k++;
  13303. rem = [0];
  13304. } // if cmp === 1, k will be 0
  13305. // Add the next digit, k, to the result array.
  13306. qd[i++] = k;
  13307. // Update the remainder.
  13308. if (cmp && rem[0]) {
  13309. rem[remL++] = xd[xi] || 0;
  13310. } else {
  13311. rem = [xd[xi]];
  13312. remL = 1;
  13313. }
  13314. } while ((xi++ < xL || rem[0] !== void 0) && sd--);
  13315. more = rem[0] !== void 0;
  13316. }
  13317. // Leading zero?
  13318. if (!qd[0]) qd.shift();
  13319. }
  13320. // logBase is 1 when divide is being used for base conversion.
  13321. if (logBase == 1) {
  13322. q.e = e;
  13323. inexact = more;
  13324. } else {
  13325. // To calculate q.e, first get the number of digits of qd[0].
  13326. for (i = 1, k = qd[0]; k >= 10; k /= 10) {
  13327. i++;
  13328. }
  13329. q.e = i + e * logBase - 1;
  13330. finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
  13331. }
  13332. return q;
  13333. };
  13334. }();
  13335. /*
  13336. * Round `x` to `sd` significant digits using rounding mode `rm`.
  13337. * Check for over/under-flow.
  13338. */
  13339. function finalise(x, sd, rm, isTruncated) {
  13340. var digits,
  13341. i,
  13342. j,
  13343. k,
  13344. rd,
  13345. roundUp,
  13346. w,
  13347. xd,
  13348. xdi,
  13349. Ctor = x.constructor;
  13350. // Don't round if sd is null or undefined.
  13351. out: if (sd != null) {
  13352. xd = x.d;
  13353. // Infinity/NaN.
  13354. if (!xd) return x;
  13355. // rd: the rounding digit, i.e. the digit after the digit that may be rounded up.
  13356. // w: the word of xd containing rd, a base 1e7 number.
  13357. // xdi: the index of w within xd.
  13358. // digits: the number of digits of w.
  13359. // i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if
  13360. // they had leading zeros)
  13361. // j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
  13362. // Get the length of the first word of the digits array xd.
  13363. for (digits = 1, k = xd[0]; k >= 10; k /= 10) {
  13364. digits++;
  13365. }
  13366. i = sd - digits;
  13367. // Is the rounding digit in the first word of xd?
  13368. if (i < 0) {
  13369. i += LOG_BASE;
  13370. j = sd;
  13371. w = xd[xdi = 0];
  13372. // Get the rounding digit at index j of w.
  13373. rd = w / mathpow(10, digits - j - 1) % 10 | 0;
  13374. } else {
  13375. xdi = Math.ceil((i + 1) / LOG_BASE);
  13376. k = xd.length;
  13377. if (xdi >= k) {
  13378. if (isTruncated) {
  13379. // Needed by `naturalExponential`, `naturalLogarithm` and `squareRoot`.
  13380. for (; k++ <= xdi;) {
  13381. xd.push(0);
  13382. }
  13383. w = rd = 0;
  13384. digits = 1;
  13385. i %= LOG_BASE;
  13386. j = i - LOG_BASE + 1;
  13387. } else {
  13388. break out;
  13389. }
  13390. } else {
  13391. w = k = xd[xdi];
  13392. // Get the number of digits of w.
  13393. for (digits = 1; k >= 10; k /= 10) {
  13394. digits++;
  13395. }
  13396. // Get the index of rd within w.
  13397. i %= LOG_BASE;
  13398. // Get the index of rd within w, adjusted for leading zeros.
  13399. // The number of leading zeros of w is given by LOG_BASE - digits.
  13400. j = i - LOG_BASE + digits;
  13401. // Get the rounding digit at index j of w.
  13402. rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
  13403. }
  13404. }
  13405. // Are there any non-zero digits after the rounding digit?
  13406. isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
  13407. // The expression `w % mathpow(10, digits - j - 1)` returns all the digits of w to the right
  13408. // of the digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression
  13409. // will give 714.
  13410. roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 &&
  13411. // Check whether the digit to the left of the rounding digit is odd.
  13412. (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
  13413. if (sd < 1 || !xd[0]) {
  13414. xd.length = 0;
  13415. if (roundUp) {
  13416. // Convert sd to decimal places.
  13417. sd -= x.e + 1;
  13418. // 1, 0.1, 0.01, 0.001, 0.0001 etc.
  13419. xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
  13420. x.e = -sd || 0;
  13421. } else {
  13422. // Zero.
  13423. xd[0] = x.e = 0;
  13424. }
  13425. return x;
  13426. }
  13427. // Remove excess digits.
  13428. if (i == 0) {
  13429. xd.length = xdi;
  13430. k = 1;
  13431. xdi--;
  13432. } else {
  13433. xd.length = xdi + 1;
  13434. k = mathpow(10, LOG_BASE - i);
  13435. // E.g. 56700 becomes 56000 if 7 is the rounding digit.
  13436. // j > 0 means i > number of leading zeros of w.
  13437. xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
  13438. }
  13439. if (roundUp) {
  13440. for (;;) {
  13441. // Is the digit to be rounded up in the first word of xd?
  13442. if (xdi == 0) {
  13443. // i will be the length of xd[0] before k is added.
  13444. for (i = 1, j = xd[0]; j >= 10; j /= 10) {
  13445. i++;
  13446. }
  13447. j = xd[0] += k;
  13448. for (k = 1; j >= 10; j /= 10) {
  13449. k++;
  13450. }
  13451. // if i != k the length has increased.
  13452. if (i != k) {
  13453. x.e++;
  13454. if (xd[0] == BASE) xd[0] = 1;
  13455. }
  13456. break;
  13457. } else {
  13458. xd[xdi] += k;
  13459. if (xd[xdi] != BASE) break;
  13460. xd[xdi--] = 0;
  13461. k = 1;
  13462. }
  13463. }
  13464. }
  13465. // Remove trailing zeros.
  13466. for (i = xd.length; xd[--i] === 0;) {
  13467. xd.pop();
  13468. }
  13469. }
  13470. if (external) {
  13471. // Overflow?
  13472. if (x.e > Ctor.maxE) {
  13473. // Infinity.
  13474. x.d = null;
  13475. x.e = NaN;
  13476. // Underflow?
  13477. } else if (x.e < Ctor.minE) {
  13478. // Zero.
  13479. x.e = 0;
  13480. x.d = [0];
  13481. // Ctor.underflow = true;
  13482. } // else Ctor.underflow = false;
  13483. }
  13484. return x;
  13485. }
  13486. function finiteToString(x, isExp, sd) {
  13487. if (!x.isFinite()) return nonFiniteToString(x);
  13488. var k,
  13489. e = x.e,
  13490. str = digitsToString(x.d),
  13491. len = str.length;
  13492. if (isExp) {
  13493. if (sd && (k = sd - len) > 0) {
  13494. str = str.charAt(0) + '.' + str.slice(1) + getZeroString(k);
  13495. } else if (len > 1) {
  13496. str = str.charAt(0) + '.' + str.slice(1);
  13497. }
  13498. str = str + (x.e < 0 ? 'e' : 'e+') + x.e;
  13499. } else if (e < 0) {
  13500. str = '0.' + getZeroString(-e - 1) + str;
  13501. if (sd && (k = sd - len) > 0) str += getZeroString(k);
  13502. } else if (e >= len) {
  13503. str += getZeroString(e + 1 - len);
  13504. if (sd && (k = sd - e - 1) > 0) str = str + '.' + getZeroString(k);
  13505. } else {
  13506. if ((k = e + 1) < len) str = str.slice(0, k) + '.' + str.slice(k);
  13507. if (sd && (k = sd - len) > 0) {
  13508. if (e + 1 === len) str += '.';
  13509. str += getZeroString(k);
  13510. }
  13511. }
  13512. return str;
  13513. }
  13514. // Calculate the base 10 exponent from the base 1e7 exponent.
  13515. function getBase10Exponent(digits, e) {
  13516. var w = digits[0];
  13517. // Add the number of digits of the first word of the digits array.
  13518. for (e *= LOG_BASE; w >= 10; w /= 10) {
  13519. e++;
  13520. }
  13521. return e;
  13522. }
  13523. function getLn10(Ctor, sd, pr) {
  13524. if (sd > LN10_PRECISION) {
  13525. // Reset global state in case the exception is caught.
  13526. external = true;
  13527. if (pr) Ctor.precision = pr;
  13528. throw Error(precisionLimitExceeded);
  13529. }
  13530. return finalise(new Ctor(LN10), sd, 1, true);
  13531. }
  13532. function getPi(Ctor, sd, rm) {
  13533. if (sd > PI_PRECISION) throw Error(precisionLimitExceeded);
  13534. return finalise(new Ctor(PI), sd, rm, true);
  13535. }
  13536. function getPrecision(digits) {
  13537. var w = digits.length - 1,
  13538. len = w * LOG_BASE + 1;
  13539. w = digits[w];
  13540. // If non-zero...
  13541. if (w) {
  13542. // Subtract the number of trailing zeros of the last word.
  13543. for (; w % 10 == 0; w /= 10) {
  13544. len--;
  13545. }
  13546. // Add the number of digits of the first word.
  13547. for (w = digits[0]; w >= 10; w /= 10) {
  13548. len++;
  13549. }
  13550. }
  13551. return len;
  13552. }
  13553. function getZeroString(k) {
  13554. var zs = '';
  13555. for (; k--;) {
  13556. zs += '0';
  13557. }
  13558. return zs;
  13559. }
  13560. /*
  13561. * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an
  13562. * integer of type number.
  13563. *
  13564. * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`.
  13565. *
  13566. */
  13567. function intPow(Ctor, x, n, pr) {
  13568. var isTruncated,
  13569. r = new Ctor(1),
  13570. // Max n of 9007199254740991 takes 53 loop iterations.
  13571. // Maximum digits array length; leaves [28, 34] guard digits.
  13572. k = Math.ceil(pr / LOG_BASE + 4);
  13573. external = false;
  13574. for (;;) {
  13575. if (n % 2) {
  13576. r = r.times(x);
  13577. if (truncate(r.d, k)) isTruncated = true;
  13578. }
  13579. n = mathfloor(n / 2);
  13580. if (n === 0) {
  13581. // To ensure correct rounding when r.d is truncated, increment the last word if it is zero.
  13582. n = r.d.length - 1;
  13583. if (isTruncated && r.d[n] === 0) ++r.d[n];
  13584. break;
  13585. }
  13586. x = x.times(x);
  13587. truncate(x.d, k);
  13588. }
  13589. external = true;
  13590. return r;
  13591. }
  13592. function isOdd(n) {
  13593. return n.d[n.d.length - 1] & 1;
  13594. }
  13595. /*
  13596. * Handle `max` and `min`. `ltgt` is 'lt' or 'gt'.
  13597. */
  13598. function maxOrMin(Ctor, args, ltgt) {
  13599. var y,
  13600. x = new Ctor(args[0]),
  13601. i = 0;
  13602. for (; ++i < args.length;) {
  13603. y = new Ctor(args[i]);
  13604. if (!y.s) {
  13605. x = y;
  13606. break;
  13607. } else if (x[ltgt](y)) {
  13608. x = y;
  13609. }
  13610. }
  13611. return x;
  13612. }
  13613. /*
  13614. * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant
  13615. * digits.
  13616. *
  13617. * Taylor/Maclaurin series.
  13618. *
  13619. * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ...
  13620. *
  13621. * Argument reduction:
  13622. * Repeat x = x / 32, k += 5, until |x| < 0.1
  13623. * exp(x) = exp(x / 2^k)^(2^k)
  13624. *
  13625. * Previously, the argument was initially reduced by
  13626. * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10)
  13627. * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was
  13628. * found to be slower than just dividing repeatedly by 32 as above.
  13629. *
  13630. * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000
  13631. * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000
  13632. * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324)
  13633. *
  13634. * exp(Infinity) = Infinity
  13635. * exp(-Infinity) = 0
  13636. * exp(NaN) = NaN
  13637. * exp(±0) = 1
  13638. *
  13639. * exp(x) is non-terminating for any finite, non-zero x.
  13640. *
  13641. * The result will always be correctly rounded.
  13642. *
  13643. */
  13644. function naturalExponential(x, sd) {
  13645. var denominator,
  13646. guard,
  13647. j,
  13648. pow,
  13649. sum,
  13650. t,
  13651. wpr,
  13652. rep = 0,
  13653. i = 0,
  13654. k = 0,
  13655. Ctor = x.constructor,
  13656. rm = Ctor.rounding,
  13657. pr = Ctor.precision;
  13658. // 0/NaN/Infinity?
  13659. if (!x.d || !x.d[0] || x.e > 17) {
  13660. return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
  13661. }
  13662. if (sd == null) {
  13663. external = false;
  13664. wpr = pr;
  13665. } else {
  13666. wpr = sd;
  13667. }
  13668. t = new Ctor(0.03125);
  13669. // while abs(x) >= 0.1
  13670. while (x.e > -2) {
  13671. // x = x / 2^5
  13672. x = x.times(t);
  13673. k += 5;
  13674. }
  13675. // Use 2 * log10(2^k) + 5 (empirically derived) to estimate the increase in precision
  13676. // necessary to ensure the first 4 rounding digits are correct.
  13677. guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
  13678. wpr += guard;
  13679. denominator = pow = sum = new Ctor(1);
  13680. Ctor.precision = wpr;
  13681. for (;;) {
  13682. pow = finalise(pow.times(x), wpr, 1);
  13683. denominator = denominator.times(++i);
  13684. t = sum.plus(divide(pow, denominator, wpr, 1));
  13685. if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
  13686. j = k;
  13687. while (j--) {
  13688. sum = finalise(sum.times(sum), wpr, 1);
  13689. }
  13690. // Check to see if the first 4 rounding digits are [49]999.
  13691. // If so, repeat the summation with a higher precision, otherwise
  13692. // e.g. with precision: 18, rounding: 1
  13693. // exp(18.404272462595034083567793919843761) = 98372560.1229999999 (should be 98372560.123)
  13694. // `wpr - guard` is the index of first rounding digit.
  13695. if (sd == null) {
  13696. if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
  13697. Ctor.precision = wpr += 10;
  13698. denominator = pow = t = new Ctor(1);
  13699. i = 0;
  13700. rep++;
  13701. } else {
  13702. return finalise(sum, Ctor.precision = pr, rm, external = true);
  13703. }
  13704. } else {
  13705. Ctor.precision = pr;
  13706. return sum;
  13707. }
  13708. }
  13709. sum = t;
  13710. }
  13711. }
  13712. /*
  13713. * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant
  13714. * digits.
  13715. *
  13716. * ln(-n) = NaN
  13717. * ln(0) = -Infinity
  13718. * ln(-0) = -Infinity
  13719. * ln(1) = 0
  13720. * ln(Infinity) = Infinity
  13721. * ln(-Infinity) = NaN
  13722. * ln(NaN) = NaN
  13723. *
  13724. * ln(n) (n != 1) is non-terminating.
  13725. *
  13726. */
  13727. function naturalLogarithm(y, sd) {
  13728. var c,
  13729. c0,
  13730. denominator,
  13731. e,
  13732. numerator,
  13733. rep,
  13734. sum,
  13735. t,
  13736. wpr,
  13737. x1,
  13738. x2,
  13739. n = 1,
  13740. guard = 10,
  13741. x = y,
  13742. xd = x.d,
  13743. Ctor = x.constructor,
  13744. rm = Ctor.rounding,
  13745. pr = Ctor.precision;
  13746. // Is x negative or Infinity, NaN, 0 or 1?
  13747. if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
  13748. return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
  13749. }
  13750. if (sd == null) {
  13751. external = false;
  13752. wpr = pr;
  13753. } else {
  13754. wpr = sd;
  13755. }
  13756. Ctor.precision = wpr += guard;
  13757. c = digitsToString(xd);
  13758. c0 = c.charAt(0);
  13759. if (Math.abs(e = x.e) < 1.5e15) {
  13760. // Argument reduction.
  13761. // The series converges faster the closer the argument is to 1, so using
  13762. // ln(a^b) = b * ln(a), ln(a) = ln(a^b) / b
  13763. // multiply the argument by itself until the leading digits of the significand are 7, 8, 9,
  13764. // 10, 11, 12 or 13, recording the number of multiplications so the sum of the series can
  13765. // later be divided by this number, then separate out the power of 10 using
  13766. // ln(a*10^b) = ln(a) + b*ln(10).
  13767. // max n is 21 (gives 0.9, 1.0 or 1.1) (9e15 / 21 = 4.2e14).
  13768. //while (c0 < 9 && c0 != 1 || c0 == 1 && c.charAt(1) > 1) {
  13769. // max n is 6 (gives 0.7 - 1.3)
  13770. while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
  13771. x = x.times(y);
  13772. c = digitsToString(x.d);
  13773. c0 = c.charAt(0);
  13774. n++;
  13775. }
  13776. e = x.e;
  13777. if (c0 > 1) {
  13778. x = new Ctor('0.' + c);
  13779. e++;
  13780. } else {
  13781. x = new Ctor(c0 + '.' + c.slice(1));
  13782. }
  13783. } else {
  13784. // The argument reduction method above may result in overflow if the argument y is a massive
  13785. // number with exponent >= 1500000000000000 (9e15 / 6 = 1.5e15), so instead recall this
  13786. // function using ln(x*10^e) = ln(x) + e*ln(10).
  13787. t = getLn10(Ctor, wpr + 2, pr).times(e + '');
  13788. x = naturalLogarithm(new Ctor(c0 + '.' + c.slice(1)), wpr - guard).plus(t);
  13789. Ctor.precision = pr;
  13790. return sd == null ? finalise(x, pr, rm, external = true) : x;
  13791. }
  13792. // x1 is x reduced to a value near 1.
  13793. x1 = x;
  13794. // Taylor series.
  13795. // ln(y) = ln((1 + x)/(1 - x)) = 2(x + x^3/3 + x^5/5 + x^7/7 + ...)
  13796. // where x = (y - 1)/(y + 1) (|x| < 1)
  13797. sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
  13798. x2 = finalise(x.times(x), wpr, 1);
  13799. denominator = 3;
  13800. for (;;) {
  13801. numerator = finalise(numerator.times(x2), wpr, 1);
  13802. t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
  13803. if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
  13804. sum = sum.times(2);
  13805. // Reverse the argument reduction. Check that e is not 0 because, besides preventing an
  13806. // unnecessary calculation, -0 + 0 = +0 and to ensure correct rounding -0 needs to stay -0.
  13807. if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ''));
  13808. sum = divide(sum, new Ctor(n), wpr, 1);
  13809. // Is rm > 3 and the first 4 rounding digits 4999, or rm < 4 (or the summation has
  13810. // been repeated previously) and the first 4 rounding digits 9999?
  13811. // If so, restart the summation with a higher precision, otherwise
  13812. // e.g. with precision: 12, rounding: 1
  13813. // ln(135520028.6126091714265381533) = 18.7246299999 when it should be 18.72463.
  13814. // `wpr - guard` is the index of first rounding digit.
  13815. if (sd == null) {
  13816. if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
  13817. Ctor.precision = wpr += guard;
  13818. t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
  13819. x2 = finalise(x.times(x), wpr, 1);
  13820. denominator = rep = 1;
  13821. } else {
  13822. return finalise(sum, Ctor.precision = pr, rm, external = true);
  13823. }
  13824. } else {
  13825. Ctor.precision = pr;
  13826. return sum;
  13827. }
  13828. }
  13829. sum = t;
  13830. denominator += 2;
  13831. }
  13832. }
  13833. // ±Infinity, NaN.
  13834. function nonFiniteToString(x) {
  13835. // Unsigned.
  13836. return String(x.s * x.s / 0);
  13837. }
  13838. /*
  13839. * Parse the value of a new Decimal `x` from string `str`.
  13840. */
  13841. function parseDecimal(x, str) {
  13842. var e, i, len;
  13843. // Decimal point?
  13844. if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
  13845. // Exponential form?
  13846. if ((i = str.search(/e/i)) > 0) {
  13847. // Determine exponent.
  13848. if (e < 0) e = i;
  13849. e += +str.slice(i + 1);
  13850. str = str.substring(0, i);
  13851. } else if (e < 0) {
  13852. // Integer.
  13853. e = str.length;
  13854. }
  13855. // Determine leading zeros.
  13856. for (i = 0; str.charCodeAt(i) === 48; i++) {
  13857. ;
  13858. }
  13859. // Determine trailing zeros.
  13860. for (len = str.length; str.charCodeAt(len - 1) === 48; --len) {
  13861. ;
  13862. }
  13863. str = str.slice(i, len);
  13864. if (str) {
  13865. len -= i;
  13866. x.e = e = e - i - 1;
  13867. x.d = [];
  13868. // Transform base
  13869. // e is the base 10 exponent.
  13870. // i is where to slice str to get the first word of the digits array.
  13871. i = (e + 1) % LOG_BASE;
  13872. if (e < 0) i += LOG_BASE;
  13873. if (i < len) {
  13874. if (i) x.d.push(+str.slice(0, i));
  13875. for (len -= LOG_BASE; i < len;) {
  13876. x.d.push(+str.slice(i, i += LOG_BASE));
  13877. }
  13878. str = str.slice(i);
  13879. i = LOG_BASE - str.length;
  13880. } else {
  13881. i -= len;
  13882. }
  13883. for (; i--;) {
  13884. str += '0';
  13885. }
  13886. x.d.push(+str);
  13887. if (external) {
  13888. // Overflow?
  13889. if (x.e > x.constructor.maxE) {
  13890. // Infinity.
  13891. x.d = null;
  13892. x.e = NaN;
  13893. // Underflow?
  13894. } else if (x.e < x.constructor.minE) {
  13895. // Zero.
  13896. x.e = 0;
  13897. x.d = [0];
  13898. // x.constructor.underflow = true;
  13899. } // else x.constructor.underflow = false;
  13900. }
  13901. } else {
  13902. // Zero.
  13903. x.e = 0;
  13904. x.d = [0];
  13905. }
  13906. return x;
  13907. }
  13908. /*
  13909. * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value.
  13910. */
  13911. function parseOther(x, str) {
  13912. var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
  13913. if (str.indexOf('_') > -1) {
  13914. str = str.replace(/(\d)_(?=\d)/g, '$1');
  13915. if (isDecimal.test(str)) return parseDecimal(x, str);
  13916. } else if (str === 'Infinity' || str === 'NaN') {
  13917. if (!+str) x.s = NaN;
  13918. x.e = NaN;
  13919. x.d = null;
  13920. return x;
  13921. }
  13922. if (isHex.test(str)) {
  13923. base = 16;
  13924. str = str.toLowerCase();
  13925. } else if (isBinary.test(str)) {
  13926. base = 2;
  13927. } else if (isOctal.test(str)) {
  13928. base = 8;
  13929. } else {
  13930. throw Error(invalidArgument + str);
  13931. }
  13932. // Is there a binary exponent part?
  13933. i = str.search(/p/i);
  13934. if (i > 0) {
  13935. p = +str.slice(i + 1);
  13936. str = str.substring(2, i);
  13937. } else {
  13938. str = str.slice(2);
  13939. }
  13940. // Convert `str` as an integer then divide the result by `base` raised to a power such that the
  13941. // fraction part will be restored.
  13942. i = str.indexOf('.');
  13943. isFloat = i >= 0;
  13944. Ctor = x.constructor;
  13945. if (isFloat) {
  13946. str = str.replace('.', '');
  13947. len = str.length;
  13948. i = len - i;
  13949. // log[10](16) = 1.2041... , log[10](88) = 1.9444....
  13950. divisor = intPow(Ctor, new Ctor(base), i, i * 2);
  13951. }
  13952. xd = convertBase(str, base, BASE);
  13953. xe = xd.length - 1;
  13954. // Remove trailing zeros.
  13955. for (i = xe; xd[i] === 0; --i) {
  13956. xd.pop();
  13957. }
  13958. if (i < 0) return new Ctor(x.s * 0);
  13959. x.e = getBase10Exponent(xd, xe);
  13960. x.d = xd;
  13961. external = false;
  13962. // At what precision to perform the division to ensure exact conversion?
  13963. // maxDecimalIntegerPartDigitCount = ceil(log[10](b) * otherBaseIntegerPartDigitCount)
  13964. // log[10](2) = 0.30103, log[10](8) = 0.90309, log[10](16) = 1.20412
  13965. // E.g. ceil(1.2 * 3) = 4, so up to 4 decimal digits are needed to represent 3 hex int digits.
  13966. // maxDecimalFractionPartDigitCount = {Hex:4|Oct:3|Bin:1} * otherBaseFractionPartDigitCount
  13967. // Therefore using 4 * the number of digits of str will always be enough.
  13968. if (isFloat) x = divide(x, divisor, len * 4);
  13969. // Multiply by the binary exponent part if present.
  13970. if (p) x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
  13971. external = true;
  13972. return x;
  13973. }
  13974. /*
  13975. * sin(x) = x - x^3/3! + x^5/5! - ...
  13976. * |x| < pi/2
  13977. *
  13978. */
  13979. function sine(Ctor, x) {
  13980. var k,
  13981. len = x.d.length;
  13982. if (len < 3) {
  13983. return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
  13984. }
  13985. // Argument reduction: sin(5x) = 16*sin^5(x) - 20*sin^3(x) + 5*sin(x)
  13986. // i.e. sin(x) = 16*sin^5(x/5) - 20*sin^3(x/5) + 5*sin(x/5)
  13987. // and sin(x) = sin(x/5)(5 + sin^2(x/5)(16sin^2(x/5) - 20))
  13988. // Estimate the optimum number of times to use the argument reduction.
  13989. k = 1.4 * Math.sqrt(len);
  13990. k = k > 16 ? 16 : k | 0;
  13991. x = x.times(1 / tinyPow(5, k));
  13992. x = taylorSeries(Ctor, 2, x, x);
  13993. // Reverse argument reduction
  13994. var sin2_x,
  13995. d5 = new Ctor(5),
  13996. d16 = new Ctor(16),
  13997. d20 = new Ctor(20);
  13998. for (; k--;) {
  13999. sin2_x = x.times(x);
  14000. x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
  14001. }
  14002. return x;
  14003. }
  14004. // Calculate Taylor series for `cos`, `cosh`, `sin` and `sinh`.
  14005. function taylorSeries(Ctor, n, x, y, isHyperbolic) {
  14006. var j,
  14007. t,
  14008. u,
  14009. x2,
  14010. i = 1,
  14011. pr = Ctor.precision,
  14012. k = Math.ceil(pr / LOG_BASE);
  14013. external = false;
  14014. x2 = x.times(x);
  14015. u = new Ctor(y);
  14016. for (;;) {
  14017. t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
  14018. u = isHyperbolic ? y.plus(t) : y.minus(t);
  14019. y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
  14020. t = u.plus(y);
  14021. if (t.d[k] !== void 0) {
  14022. for (j = k; t.d[j] === u.d[j] && j--;) {
  14023. ;
  14024. }
  14025. if (j == -1) break;
  14026. }
  14027. j = u;
  14028. u = y;
  14029. y = t;
  14030. t = j;
  14031. i++;
  14032. }
  14033. external = true;
  14034. t.d.length = k + 1;
  14035. return t;
  14036. }
  14037. // Exponent e must be positive and non-zero.
  14038. function tinyPow(b, e) {
  14039. var n = b;
  14040. while (--e) {
  14041. n *= b;
  14042. }
  14043. return n;
  14044. }
  14045. // Return the absolute value of `x` reduced to less than or equal to half pi.
  14046. function toLessThanHalfPi(Ctor, x) {
  14047. var t,
  14048. isNeg = x.s < 0,
  14049. pi = getPi(Ctor, Ctor.precision, 1),
  14050. halfPi = pi.times(0.5);
  14051. x = x.abs();
  14052. if (x.lte(halfPi)) {
  14053. quadrant = isNeg ? 4 : 1;
  14054. return x;
  14055. }
  14056. t = x.divToInt(pi);
  14057. if (t.isZero()) {
  14058. quadrant = isNeg ? 3 : 2;
  14059. } else {
  14060. x = x.minus(t.times(pi));
  14061. // 0 <= x < pi
  14062. if (x.lte(halfPi)) {
  14063. quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
  14064. return x;
  14065. }
  14066. quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
  14067. }
  14068. return x.minus(pi).abs();
  14069. }
  14070. /*
  14071. * Return the value of Decimal `x` as a string in base `baseOut`.
  14072. *
  14073. * If the optional `sd` argument is present include a binary exponent suffix.
  14074. */
  14075. function toStringBinary(x, baseOut, sd, rm) {
  14076. var base,
  14077. e,
  14078. i,
  14079. k,
  14080. len,
  14081. roundUp,
  14082. str,
  14083. xd,
  14084. y,
  14085. Ctor = x.constructor,
  14086. isExp = sd !== void 0;
  14087. if (isExp) {
  14088. checkInt32(sd, 1, MAX_DIGITS);
  14089. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  14090. } else {
  14091. sd = Ctor.precision;
  14092. rm = Ctor.rounding;
  14093. }
  14094. if (!x.isFinite()) {
  14095. str = nonFiniteToString(x);
  14096. } else {
  14097. str = finiteToString(x);
  14098. i = str.indexOf('.');
  14099. // Use exponential notation according to `toExpPos` and `toExpNeg`? No, but if required:
  14100. // maxBinaryExponent = floor((decimalExponent + 1) * log[2](10))
  14101. // minBinaryExponent = floor(decimalExponent * log[2](10))
  14102. // log[2](10) = 3.321928094887362347870319429489390175864
  14103. if (isExp) {
  14104. base = 2;
  14105. if (baseOut == 16) {
  14106. sd = sd * 4 - 3;
  14107. } else if (baseOut == 8) {
  14108. sd = sd * 3 - 2;
  14109. }
  14110. } else {
  14111. base = baseOut;
  14112. }
  14113. // Convert the number as an integer then divide the result by its base raised to a power such
  14114. // that the fraction part will be restored.
  14115. // Non-integer.
  14116. if (i >= 0) {
  14117. str = str.replace('.', '');
  14118. y = new Ctor(1);
  14119. y.e = str.length - i;
  14120. y.d = convertBase(finiteToString(y), 10, base);
  14121. y.e = y.d.length;
  14122. }
  14123. xd = convertBase(str, 10, base);
  14124. e = len = xd.length;
  14125. // Remove trailing zeros.
  14126. for (; xd[--len] == 0;) {
  14127. xd.pop();
  14128. }
  14129. if (!xd[0]) {
  14130. str = isExp ? '0p+0' : '0';
  14131. } else {
  14132. if (i < 0) {
  14133. e--;
  14134. } else {
  14135. x = new Ctor(x);
  14136. x.d = xd;
  14137. x.e = e;
  14138. x = divide(x, y, sd, rm, 0, base);
  14139. xd = x.d;
  14140. e = x.e;
  14141. roundUp = inexact;
  14142. }
  14143. // The rounding digit, i.e. the digit after the digit that may be rounded up.
  14144. i = xd[sd];
  14145. k = base / 2;
  14146. roundUp = roundUp || xd[sd + 1] !== void 0;
  14147. roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
  14148. xd.length = sd;
  14149. if (roundUp) {
  14150. // Rounding up may mean the previous digit has to be rounded up and so on.
  14151. for (; ++xd[--sd] > base - 1;) {
  14152. xd[sd] = 0;
  14153. if (!sd) {
  14154. ++e;
  14155. xd.unshift(1);
  14156. }
  14157. }
  14158. }
  14159. // Determine trailing zeros.
  14160. for (len = xd.length; !xd[len - 1]; --len) {
  14161. ;
  14162. }
  14163. // E.g. [4, 11, 15] becomes 4bf.
  14164. for (i = 0, str = ''; i < len; i++) {
  14165. str += NUMERALS.charAt(xd[i]);
  14166. }
  14167. // Add binary exponent suffix?
  14168. if (isExp) {
  14169. if (len > 1) {
  14170. if (baseOut == 16 || baseOut == 8) {
  14171. i = baseOut == 16 ? 4 : 3;
  14172. for (--len; len % i; len++) {
  14173. str += '0';
  14174. }
  14175. xd = convertBase(str, base, baseOut);
  14176. for (len = xd.length; !xd[len - 1]; --len) {
  14177. ;
  14178. }
  14179. // xd[0] will always be be 1
  14180. for (i = 1, str = '1.'; i < len; i++) {
  14181. str += NUMERALS.charAt(xd[i]);
  14182. }
  14183. } else {
  14184. str = str.charAt(0) + '.' + str.slice(1);
  14185. }
  14186. }
  14187. str = str + (e < 0 ? 'p' : 'p+') + e;
  14188. } else if (e < 0) {
  14189. for (; ++e;) {
  14190. str = '0' + str;
  14191. }
  14192. str = '0.' + str;
  14193. } else {
  14194. if (++e > len) for (e -= len; e--;) {
  14195. str += '0';
  14196. } else if (e < len) str = str.slice(0, e) + '.' + str.slice(e);
  14197. }
  14198. }
  14199. str = (baseOut == 16 ? '0x' : baseOut == 2 ? '0b' : baseOut == 8 ? '0o' : '') + str;
  14200. }
  14201. return x.s < 0 ? '-' + str : str;
  14202. }
  14203. // Does not strip trailing zeros.
  14204. function truncate(arr, len) {
  14205. if (arr.length > len) {
  14206. arr.length = len;
  14207. return true;
  14208. }
  14209. }
  14210. // Decimal methods
  14211. /*
  14212. * abs
  14213. * acos
  14214. * acosh
  14215. * add
  14216. * asin
  14217. * asinh
  14218. * atan
  14219. * atanh
  14220. * atan2
  14221. * cbrt
  14222. * ceil
  14223. * clamp
  14224. * clone
  14225. * config
  14226. * cos
  14227. * cosh
  14228. * div
  14229. * exp
  14230. * floor
  14231. * hypot
  14232. * ln
  14233. * log
  14234. * log2
  14235. * log10
  14236. * max
  14237. * min
  14238. * mod
  14239. * mul
  14240. * pow
  14241. * random
  14242. * round
  14243. * set
  14244. * sign
  14245. * sin
  14246. * sinh
  14247. * sqrt
  14248. * sub
  14249. * sum
  14250. * tan
  14251. * tanh
  14252. * trunc
  14253. */
  14254. /*
  14255. * Return a new Decimal whose value is the absolute value of `x`.
  14256. *
  14257. * x {number|string|Decimal}
  14258. *
  14259. */
  14260. function abs(x) {
  14261. return new this(x).abs();
  14262. }
  14263. /*
  14264. * Return a new Decimal whose value is the arccosine in radians of `x`.
  14265. *
  14266. * x {number|string|Decimal}
  14267. *
  14268. */
  14269. function acos(x) {
  14270. return new this(x).acos();
  14271. }
  14272. /*
  14273. * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to
  14274. * `precision` significant digits using rounding mode `rounding`.
  14275. *
  14276. * x {number|string|Decimal} A value in radians.
  14277. *
  14278. */
  14279. function acosh(x) {
  14280. return new this(x).acosh();
  14281. }
  14282. /*
  14283. * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant
  14284. * digits using rounding mode `rounding`.
  14285. *
  14286. * x {number|string|Decimal}
  14287. * y {number|string|Decimal}
  14288. *
  14289. */
  14290. function add(x, y) {
  14291. return new this(x).plus(y);
  14292. }
  14293. /*
  14294. * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision`
  14295. * significant digits using rounding mode `rounding`.
  14296. *
  14297. * x {number|string|Decimal}
  14298. *
  14299. */
  14300. function asin(x) {
  14301. return new this(x).asin();
  14302. }
  14303. /*
  14304. * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to
  14305. * `precision` significant digits using rounding mode `rounding`.
  14306. *
  14307. * x {number|string|Decimal} A value in radians.
  14308. *
  14309. */
  14310. function asinh(x) {
  14311. return new this(x).asinh();
  14312. }
  14313. /*
  14314. * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision`
  14315. * significant digits using rounding mode `rounding`.
  14316. *
  14317. * x {number|string|Decimal}
  14318. *
  14319. */
  14320. function atan(x) {
  14321. return new this(x).atan();
  14322. }
  14323. /*
  14324. * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to
  14325. * `precision` significant digits using rounding mode `rounding`.
  14326. *
  14327. * x {number|string|Decimal} A value in radians.
  14328. *
  14329. */
  14330. function atanh(x) {
  14331. return new this(x).atanh();
  14332. }
  14333. /*
  14334. * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi
  14335. * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`.
  14336. *
  14337. * Domain: [-Infinity, Infinity]
  14338. * Range: [-pi, pi]
  14339. *
  14340. * y {number|string|Decimal} The y-coordinate.
  14341. * x {number|string|Decimal} The x-coordinate.
  14342. *
  14343. * atan2(±0, -0) = ±pi
  14344. * atan2(±0, +0) = ±0
  14345. * atan2(±0, -x) = ±pi for x > 0
  14346. * atan2(±0, x) = ±0 for x > 0
  14347. * atan2(-y, ±0) = -pi/2 for y > 0
  14348. * atan2(y, ±0) = pi/2 for y > 0
  14349. * atan2(±y, -Infinity) = ±pi for finite y > 0
  14350. * atan2(±y, +Infinity) = ±0 for finite y > 0
  14351. * atan2(±Infinity, x) = ±pi/2 for finite x
  14352. * atan2(±Infinity, -Infinity) = ±3*pi/4
  14353. * atan2(±Infinity, +Infinity) = ±pi/4
  14354. * atan2(NaN, x) = NaN
  14355. * atan2(y, NaN) = NaN
  14356. *
  14357. */
  14358. function atan2(y, x) {
  14359. y = new this(y);
  14360. x = new this(x);
  14361. var r,
  14362. pr = this.precision,
  14363. rm = this.rounding,
  14364. wpr = pr + 4;
  14365. // Either NaN
  14366. if (!y.s || !x.s) {
  14367. r = new this(NaN);
  14368. // Both ±Infinity
  14369. } else if (!y.d && !x.d) {
  14370. r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
  14371. r.s = y.s;
  14372. // x is ±Infinity or y is ±0
  14373. } else if (!x.d || y.isZero()) {
  14374. r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
  14375. r.s = y.s;
  14376. // y is ±Infinity or x is ±0
  14377. } else if (!y.d || x.isZero()) {
  14378. r = getPi(this, wpr, 1).times(0.5);
  14379. r.s = y.s;
  14380. // Both non-zero and finite
  14381. } else if (x.s < 0) {
  14382. this.precision = wpr;
  14383. this.rounding = 1;
  14384. r = this.atan(divide(y, x, wpr, 1));
  14385. x = getPi(this, wpr, 1);
  14386. this.precision = pr;
  14387. this.rounding = rm;
  14388. r = y.s < 0 ? r.minus(x) : r.plus(x);
  14389. } else {
  14390. r = this.atan(divide(y, x, wpr, 1));
  14391. }
  14392. return r;
  14393. }
  14394. /*
  14395. * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant
  14396. * digits using rounding mode `rounding`.
  14397. *
  14398. * x {number|string|Decimal}
  14399. *
  14400. */
  14401. function cbrt(x) {
  14402. return new this(x).cbrt();
  14403. }
  14404. /*
  14405. * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`.
  14406. *
  14407. * x {number|string|Decimal}
  14408. *
  14409. */
  14410. function ceil(x) {
  14411. return finalise(x = new this(x), x.e + 1, 2);
  14412. }
  14413. /*
  14414. * Return a new Decimal whose value is `x` clamped to the range delineated by `min` and `max`.
  14415. *
  14416. * x {number|string|Decimal}
  14417. * min {number|string|Decimal}
  14418. * max {number|string|Decimal}
  14419. *
  14420. */
  14421. function clamp(x, min, max) {
  14422. return new this(x).clamp(min, max);
  14423. }
  14424. /*
  14425. * Configure global settings for a Decimal constructor.
  14426. *
  14427. * `obj` is an object with one or more of the following properties,
  14428. *
  14429. * precision {number}
  14430. * rounding {number}
  14431. * toExpNeg {number}
  14432. * toExpPos {number}
  14433. * maxE {number}
  14434. * minE {number}
  14435. * modulo {number}
  14436. * crypto {boolean|number}
  14437. * defaults {true}
  14438. *
  14439. * E.g. Decimal.config({ precision: 20, rounding: 4 })
  14440. *
  14441. */
  14442. function config(obj) {
  14443. if (!obj || _typeof(obj) !== 'object') throw Error(decimalError + 'Object expected');
  14444. var i,
  14445. p,
  14446. v,
  14447. useDefaults = obj.defaults === true,
  14448. ps = ['precision', 1, MAX_DIGITS, 'rounding', 0, 8, 'toExpNeg', -EXP_LIMIT, 0, 'toExpPos', 0, EXP_LIMIT, 'maxE', 0, EXP_LIMIT, 'minE', -EXP_LIMIT, 0, 'modulo', 0, 9];
  14449. for (i = 0; i < ps.length; i += 3) {
  14450. if (p = ps[i], useDefaults) this[p] = DEFAULTS[p];
  14451. if ((v = obj[p]) !== void 0) {
  14452. if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;else throw Error(invalidArgument + p + ': ' + v);
  14453. }
  14454. }
  14455. if (p = 'crypto', useDefaults) this[p] = DEFAULTS[p];
  14456. if ((v = obj[p]) !== void 0) {
  14457. if (v === true || v === false || v === 0 || v === 1) {
  14458. if (v) {
  14459. if (typeof crypto != 'undefined' && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
  14460. this[p] = true;
  14461. } else {
  14462. throw Error(cryptoUnavailable);
  14463. }
  14464. } else {
  14465. this[p] = false;
  14466. }
  14467. } else {
  14468. throw Error(invalidArgument + p + ': ' + v);
  14469. }
  14470. }
  14471. return this;
  14472. }
  14473. /*
  14474. * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant
  14475. * digits using rounding mode `rounding`.
  14476. *
  14477. * x {number|string|Decimal} A value in radians.
  14478. *
  14479. */
  14480. function cos(x) {
  14481. return new this(x).cos();
  14482. }
  14483. /*
  14484. * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision
  14485. * significant digits using rounding mode `rounding`.
  14486. *
  14487. * x {number|string|Decimal} A value in radians.
  14488. *
  14489. */
  14490. function cosh(x) {
  14491. return new this(x).cosh();
  14492. }
  14493. /*
  14494. * Create and return a Decimal constructor with the same configuration properties as this Decimal
  14495. * constructor.
  14496. *
  14497. */
  14498. function clone(obj) {
  14499. var i, p, ps;
  14500. /*
  14501. * The Decimal constructor and exported function.
  14502. * Return a new Decimal instance.
  14503. *
  14504. * v {number|string|Decimal} A numeric value.
  14505. *
  14506. */
  14507. function Decimal(v) {
  14508. var e,
  14509. i,
  14510. t,
  14511. x = this;
  14512. // Decimal called without new.
  14513. if (!(x instanceof Decimal)) return new Decimal(v);
  14514. // Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor
  14515. // which points to Object.
  14516. x.constructor = Decimal;
  14517. // Duplicate.
  14518. if (isDecimalInstance(v)) {
  14519. x.s = v.s;
  14520. if (external) {
  14521. if (!v.d || v.e > Decimal.maxE) {
  14522. // Infinity.
  14523. x.e = NaN;
  14524. x.d = null;
  14525. } else if (v.e < Decimal.minE) {
  14526. // Zero.
  14527. x.e = 0;
  14528. x.d = [0];
  14529. } else {
  14530. x.e = v.e;
  14531. x.d = v.d.slice();
  14532. }
  14533. } else {
  14534. x.e = v.e;
  14535. x.d = v.d ? v.d.slice() : v.d;
  14536. }
  14537. return;
  14538. }
  14539. t = _typeof(v);
  14540. if (t === 'number') {
  14541. if (v === 0) {
  14542. x.s = 1 / v < 0 ? -1 : 1;
  14543. x.e = 0;
  14544. x.d = [0];
  14545. return;
  14546. }
  14547. if (v < 0) {
  14548. v = -v;
  14549. x.s = -1;
  14550. } else {
  14551. x.s = 1;
  14552. }
  14553. // Fast path for small integers.
  14554. if (v === ~~v && v < 1e7) {
  14555. for (e = 0, i = v; i >= 10; i /= 10) {
  14556. e++;
  14557. }
  14558. if (external) {
  14559. if (e > Decimal.maxE) {
  14560. x.e = NaN;
  14561. x.d = null;
  14562. } else if (e < Decimal.minE) {
  14563. x.e = 0;
  14564. x.d = [0];
  14565. } else {
  14566. x.e = e;
  14567. x.d = [v];
  14568. }
  14569. } else {
  14570. x.e = e;
  14571. x.d = [v];
  14572. }
  14573. return;
  14574. // Infinity, NaN.
  14575. } else if (v * 0 !== 0) {
  14576. if (!v) x.s = NaN;
  14577. x.e = NaN;
  14578. x.d = null;
  14579. return;
  14580. }
  14581. return parseDecimal(x, v.toString());
  14582. } else if (t !== 'string') {
  14583. throw Error(invalidArgument + v);
  14584. }
  14585. // Minus sign?
  14586. if ((i = v.charCodeAt(0)) === 45) {
  14587. v = v.slice(1);
  14588. x.s = -1;
  14589. } else {
  14590. // Plus sign?
  14591. if (i === 43) v = v.slice(1);
  14592. x.s = 1;
  14593. }
  14594. return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
  14595. }
  14596. Decimal.prototype = P;
  14597. Decimal.ROUND_UP = 0;
  14598. Decimal.ROUND_DOWN = 1;
  14599. Decimal.ROUND_CEIL = 2;
  14600. Decimal.ROUND_FLOOR = 3;
  14601. Decimal.ROUND_HALF_UP = 4;
  14602. Decimal.ROUND_HALF_DOWN = 5;
  14603. Decimal.ROUND_HALF_EVEN = 6;
  14604. Decimal.ROUND_HALF_CEIL = 7;
  14605. Decimal.ROUND_HALF_FLOOR = 8;
  14606. Decimal.EUCLID = 9;
  14607. Decimal.config = Decimal.set = config;
  14608. Decimal.clone = clone;
  14609. Decimal.isDecimal = isDecimalInstance;
  14610. Decimal.abs = abs;
  14611. Decimal.acos = acos;
  14612. Decimal.acosh = acosh; // ES6
  14613. Decimal.add = add;
  14614. Decimal.asin = asin;
  14615. Decimal.asinh = asinh; // ES6
  14616. Decimal.atan = atan;
  14617. Decimal.atanh = atanh; // ES6
  14618. Decimal.atan2 = atan2;
  14619. Decimal.cbrt = cbrt; // ES6
  14620. Decimal.ceil = ceil;
  14621. Decimal.clamp = clamp;
  14622. Decimal.cos = cos;
  14623. Decimal.cosh = cosh; // ES6
  14624. Decimal.div = div;
  14625. Decimal.exp = exp;
  14626. Decimal.floor = floor;
  14627. Decimal.hypot = hypot; // ES6
  14628. Decimal.ln = ln;
  14629. Decimal.log = log;
  14630. Decimal.log10 = log10; // ES6
  14631. Decimal.log2 = log2; // ES6
  14632. Decimal.max = max;
  14633. Decimal.min = min;
  14634. Decimal.mod = mod;
  14635. Decimal.mul = mul;
  14636. Decimal.pow = pow;
  14637. Decimal.random = random;
  14638. Decimal.round = round;
  14639. Decimal.sign = sign; // ES6
  14640. Decimal.sin = sin;
  14641. Decimal.sinh = sinh; // ES6
  14642. Decimal.sqrt = sqrt;
  14643. Decimal.sub = sub;
  14644. Decimal.sum = sum;
  14645. Decimal.tan = tan;
  14646. Decimal.tanh = tanh; // ES6
  14647. Decimal.trunc = trunc; // ES6
  14648. if (obj === void 0) obj = {};
  14649. if (obj) {
  14650. if (obj.defaults !== true) {
  14651. ps = ['precision', 'rounding', 'toExpNeg', 'toExpPos', 'maxE', 'minE', 'modulo', 'crypto'];
  14652. for (i = 0; i < ps.length;) {
  14653. if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p];
  14654. }
  14655. }
  14656. }
  14657. Decimal.config(obj);
  14658. return Decimal;
  14659. }
  14660. /*
  14661. * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant
  14662. * digits using rounding mode `rounding`.
  14663. *
  14664. * x {number|string|Decimal}
  14665. * y {number|string|Decimal}
  14666. *
  14667. */
  14668. function div(x, y) {
  14669. return new this(x).div(y);
  14670. }
  14671. /*
  14672. * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision`
  14673. * significant digits using rounding mode `rounding`.
  14674. *
  14675. * x {number|string|Decimal} The power to which to raise the base of the natural log.
  14676. *
  14677. */
  14678. function exp(x) {
  14679. return new this(x).exp();
  14680. }
  14681. /*
  14682. * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`.
  14683. *
  14684. * x {number|string|Decimal}
  14685. *
  14686. */
  14687. function floor(x) {
  14688. return finalise(x = new this(x), x.e + 1, 3);
  14689. }
  14690. /*
  14691. * Return a new Decimal whose value is the square root of the sum of the squares of the arguments,
  14692. * rounded to `precision` significant digits using rounding mode `rounding`.
  14693. *
  14694. * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...)
  14695. *
  14696. * arguments {number|string|Decimal}
  14697. *
  14698. */
  14699. function hypot() {
  14700. var i,
  14701. n,
  14702. t = new this(0);
  14703. external = false;
  14704. for (i = 0; i < arguments.length;) {
  14705. n = new this(arguments[i++]);
  14706. if (!n.d) {
  14707. if (n.s) {
  14708. external = true;
  14709. return new this(1 / 0);
  14710. }
  14711. t = n;
  14712. } else if (t.d) {
  14713. t = t.plus(n.times(n));
  14714. }
  14715. }
  14716. external = true;
  14717. return t.sqrt();
  14718. }
  14719. /*
  14720. * Return true if object is a Decimal instance (where Decimal is any Decimal constructor),
  14721. * otherwise return false.
  14722. *
  14723. */
  14724. function isDecimalInstance(obj) {
  14725. return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
  14726. }
  14727. /*
  14728. * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision`
  14729. * significant digits using rounding mode `rounding`.
  14730. *
  14731. * x {number|string|Decimal}
  14732. *
  14733. */
  14734. function ln(x) {
  14735. return new this(x).ln();
  14736. }
  14737. /*
  14738. * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base
  14739. * is specified, rounded to `precision` significant digits using rounding mode `rounding`.
  14740. *
  14741. * log[y](x)
  14742. *
  14743. * x {number|string|Decimal} The argument of the logarithm.
  14744. * y {number|string|Decimal} The base of the logarithm.
  14745. *
  14746. */
  14747. function log(x, y) {
  14748. return new this(x).log(y);
  14749. }
  14750. /*
  14751. * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision`
  14752. * significant digits using rounding mode `rounding`.
  14753. *
  14754. * x {number|string|Decimal}
  14755. *
  14756. */
  14757. function log2(x) {
  14758. return new this(x).log(2);
  14759. }
  14760. /*
  14761. * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision`
  14762. * significant digits using rounding mode `rounding`.
  14763. *
  14764. * x {number|string|Decimal}
  14765. *
  14766. */
  14767. function log10(x) {
  14768. return new this(x).log(10);
  14769. }
  14770. /*
  14771. * Return a new Decimal whose value is the maximum of the arguments.
  14772. *
  14773. * arguments {number|string|Decimal}
  14774. *
  14775. */
  14776. function max() {
  14777. return maxOrMin(this, arguments, 'lt');
  14778. }
  14779. /*
  14780. * Return a new Decimal whose value is the minimum of the arguments.
  14781. *
  14782. * arguments {number|string|Decimal}
  14783. *
  14784. */
  14785. function min() {
  14786. return maxOrMin(this, arguments, 'gt');
  14787. }
  14788. /*
  14789. * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits
  14790. * using rounding mode `rounding`.
  14791. *
  14792. * x {number|string|Decimal}
  14793. * y {number|string|Decimal}
  14794. *
  14795. */
  14796. function mod(x, y) {
  14797. return new this(x).mod(y);
  14798. }
  14799. /*
  14800. * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant
  14801. * digits using rounding mode `rounding`.
  14802. *
  14803. * x {number|string|Decimal}
  14804. * y {number|string|Decimal}
  14805. *
  14806. */
  14807. function mul(x, y) {
  14808. return new this(x).mul(y);
  14809. }
  14810. /*
  14811. * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision
  14812. * significant digits using rounding mode `rounding`.
  14813. *
  14814. * x {number|string|Decimal} The base.
  14815. * y {number|string|Decimal} The exponent.
  14816. *
  14817. */
  14818. function pow(x, y) {
  14819. return new this(x).pow(y);
  14820. }
  14821. /*
  14822. * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with
  14823. * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros
  14824. * are produced).
  14825. *
  14826. * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive.
  14827. *
  14828. */
  14829. function random(sd) {
  14830. var d,
  14831. e,
  14832. k,
  14833. n,
  14834. i = 0,
  14835. r = new this(1),
  14836. rd = [];
  14837. if (sd === void 0) sd = this.precision;else checkInt32(sd, 1, MAX_DIGITS);
  14838. k = Math.ceil(sd / LOG_BASE);
  14839. if (!this.crypto) {
  14840. for (; i < k;) {
  14841. rd[i++] = Math.random() * 1e7 | 0;
  14842. }
  14843. // Browsers supporting crypto.getRandomValues.
  14844. } else if (crypto.getRandomValues) {
  14845. d = crypto.getRandomValues(new Uint32Array(k));
  14846. for (; i < k;) {
  14847. n = d[i];
  14848. // 0 <= n < 4294967296
  14849. // Probability n >= 4.29e9, is 4967296 / 4294967296 = 0.00116 (1 in 865).
  14850. if (n >= 4.29e9) {
  14851. d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
  14852. } else {
  14853. // 0 <= n <= 4289999999
  14854. // 0 <= (n % 1e7) <= 9999999
  14855. rd[i++] = n % 1e7;
  14856. }
  14857. }
  14858. // Node.js supporting crypto.randomBytes.
  14859. } else if (crypto.randomBytes) {
  14860. // buffer
  14861. d = crypto.randomBytes(k *= 4);
  14862. for (; i < k;) {
  14863. // 0 <= n < 2147483648
  14864. n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 0x7f) << 24);
  14865. // Probability n >= 2.14e9, is 7483648 / 2147483648 = 0.0035 (1 in 286).
  14866. if (n >= 2.14e9) {
  14867. crypto.randomBytes(4).copy(d, i);
  14868. } else {
  14869. // 0 <= n <= 2139999999
  14870. // 0 <= (n % 1e7) <= 9999999
  14871. rd.push(n % 1e7);
  14872. i += 4;
  14873. }
  14874. }
  14875. i = k / 4;
  14876. } else {
  14877. throw Error(cryptoUnavailable);
  14878. }
  14879. k = rd[--i];
  14880. sd %= LOG_BASE;
  14881. // Convert trailing digits to zeros according to sd.
  14882. if (k && sd) {
  14883. n = mathpow(10, LOG_BASE - sd);
  14884. rd[i] = (k / n | 0) * n;
  14885. }
  14886. // Remove trailing words which are zero.
  14887. for (; rd[i] === 0; i--) {
  14888. rd.pop();
  14889. }
  14890. // Zero?
  14891. if (i < 0) {
  14892. e = 0;
  14893. rd = [0];
  14894. } else {
  14895. e = -1;
  14896. // Remove leading words which are zero and adjust exponent accordingly.
  14897. for (; rd[0] === 0; e -= LOG_BASE) {
  14898. rd.shift();
  14899. }
  14900. // Count the digits of the first word of rd to determine leading zeros.
  14901. for (k = 1, n = rd[0]; n >= 10; n /= 10) {
  14902. k++;
  14903. }
  14904. // Adjust the exponent for leading zeros of the first word of rd.
  14905. if (k < LOG_BASE) e -= LOG_BASE - k;
  14906. }
  14907. r.e = e;
  14908. r.d = rd;
  14909. return r;
  14910. }
  14911. /*
  14912. * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`.
  14913. *
  14914. * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL).
  14915. *
  14916. * x {number|string|Decimal}
  14917. *
  14918. */
  14919. function round(x) {
  14920. return finalise(x = new this(x), x.e + 1, this.rounding);
  14921. }
  14922. /*
  14923. * Return
  14924. * 1 if x > 0,
  14925. * -1 if x < 0,
  14926. * 0 if x is 0,
  14927. * -0 if x is -0,
  14928. * NaN otherwise
  14929. *
  14930. * x {number|string|Decimal}
  14931. *
  14932. */
  14933. function sign(x) {
  14934. x = new this(x);
  14935. return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
  14936. }
  14937. /*
  14938. * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits
  14939. * using rounding mode `rounding`.
  14940. *
  14941. * x {number|string|Decimal} A value in radians.
  14942. *
  14943. */
  14944. function sin(x) {
  14945. return new this(x).sin();
  14946. }
  14947. /*
  14948. * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision`
  14949. * significant digits using rounding mode `rounding`.
  14950. *
  14951. * x {number|string|Decimal} A value in radians.
  14952. *
  14953. */
  14954. function sinh(x) {
  14955. return new this(x).sinh();
  14956. }
  14957. /*
  14958. * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant
  14959. * digits using rounding mode `rounding`.
  14960. *
  14961. * x {number|string|Decimal}
  14962. *
  14963. */
  14964. function sqrt(x) {
  14965. return new this(x).sqrt();
  14966. }
  14967. /*
  14968. * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits
  14969. * using rounding mode `rounding`.
  14970. *
  14971. * x {number|string|Decimal}
  14972. * y {number|string|Decimal}
  14973. *
  14974. */
  14975. function sub(x, y) {
  14976. return new this(x).sub(y);
  14977. }
  14978. /*
  14979. * Return a new Decimal whose value is the sum of the arguments, rounded to `precision`
  14980. * significant digits using rounding mode `rounding`.
  14981. *
  14982. * Only the result is rounded, not the intermediate calculations.
  14983. *
  14984. * arguments {number|string|Decimal}
  14985. *
  14986. */
  14987. function sum() {
  14988. var i = 0,
  14989. args = arguments,
  14990. x = new this(args[i]);
  14991. external = false;
  14992. for (; x.s && ++i < args.length;) {
  14993. x = x.plus(args[i]);
  14994. }
  14995. external = true;
  14996. return finalise(x, this.precision, this.rounding);
  14997. }
  14998. /*
  14999. * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant
  15000. * digits using rounding mode `rounding`.
  15001. *
  15002. * x {number|string|Decimal} A value in radians.
  15003. *
  15004. */
  15005. function tan(x) {
  15006. return new this(x).tan();
  15007. }
  15008. /*
  15009. * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision`
  15010. * significant digits using rounding mode `rounding`.
  15011. *
  15012. * x {number|string|Decimal} A value in radians.
  15013. *
  15014. */
  15015. function tanh(x) {
  15016. return new this(x).tanh();
  15017. }
  15018. /*
  15019. * Return a new Decimal whose value is `x` truncated to an integer.
  15020. *
  15021. * x {number|string|Decimal}
  15022. *
  15023. */
  15024. function trunc(x) {
  15025. return finalise(x = new this(x), x.e + 1, 1);
  15026. }
  15027. // Create and configure initial Decimal constructor.
  15028. Decimal = clone(DEFAULTS);
  15029. Decimal.prototype.constructor = Decimal;
  15030. Decimal['default'] = Decimal.Decimal = Decimal;
  15031. // Create the internal constants from their string values.
  15032. LN10 = new Decimal(LN10);
  15033. PI = new Decimal(PI);
  15034. // Export.
  15035. // AMD.
  15036. if (true) {
  15037. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  15038. return Decimal;
  15039. }).call(exports, __webpack_require__, exports, module),
  15040. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15041. // Node and other environments that support module.exports.
  15042. } else {}
  15043. })(this);
  15044. /***/ })
  15045. ]]);
  15046. //# sourceMappingURL=../../.sourcemap/mp-weixin/common/vendor.js.map