yvan-ext.js 589 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786
  1. define(['exports', 'axios', 'qs', 'lodash', 'jquery', 'recast', 'lay-excel', 'xlsx'], function (exports, axios, Qs, _, $$1, recast, LAY_EXCEL, XLSX) { 'use strict';
  2. var axios__default = 'default' in axios ? axios['default'] : axios;
  3. Qs = Qs && Object.prototype.hasOwnProperty.call(Qs, 'default') ? Qs['default'] : Qs;
  4. _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
  5. $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
  6. LAY_EXCEL = LAY_EXCEL && Object.prototype.hasOwnProperty.call(LAY_EXCEL, 'default') ? LAY_EXCEL['default'] : LAY_EXCEL;
  7. XLSX = XLSX && Object.prototype.hasOwnProperty.call(XLSX, 'default') ? XLSX['default'] : XLSX;
  8. var labelWidth = 80;
  9. var windows = {
  10. modal: true,
  11. width: 900,
  12. height: 600,
  13. maximizable: true,
  14. constrain: true,
  15. shadow: false,
  16. };
  17. var date = {
  18. labelAlign: 'right',
  19. labelWidth: labelWidth,
  20. };
  21. var combo = {
  22. labelAlign: 'right',
  23. labelWidth: labelWidth,
  24. valueField: 'id',
  25. displayField: 'text',
  26. autoLoad: true,
  27. mode: 'local',
  28. forceSelection: true,
  29. triggerAction: 'all',
  30. enableKeyEvents: true,
  31. };
  32. var comboGrid = {
  33. selectOnTab: true,
  34. pickerHeight: 500,
  35. pickerWidth: 850,
  36. editEnable: null,
  37. };
  38. var comboGridPicker = {
  39. xtype: 'yvgrid',
  40. layout: 'fit',
  41. selModel: {
  42. selType: 'rowmodel',
  43. mode: 'SINGLE'
  44. },
  45. };
  46. var comboGridMulti = {
  47. selectOnTab: true,
  48. pickerHeight: 500,
  49. pickerWidth: 850,
  50. editEnable: null,
  51. splitChar: ',',
  52. displayField: 'text',
  53. valueField: 'id',
  54. autoLoad: true,
  55. };
  56. var comboGridMultiPicker = {
  57. selType: 'checkboxmodel',
  58. selModel: {
  59. type: 'checkboxmodel',
  60. checkOnly: false
  61. },
  62. };
  63. var numberfield = {
  64. labelAlign: 'right',
  65. decimalPrecision: 6,
  66. labelWidth: labelWidth,
  67. };
  68. var checkbox = {
  69. labelAlign: 'right',
  70. labelWidth: labelWidth,
  71. checkedValue: true,
  72. uncheckedValue: false,
  73. };
  74. var checkboxgroup = {
  75. labelAlign: 'right',
  76. labelWidth: labelWidth,
  77. };
  78. var radio = {
  79. labelAlign: 'right',
  80. labelWidth: labelWidth,
  81. };
  82. var radiogroup = {
  83. labelAlign: 'right',
  84. labelWidth: labelWidth,
  85. simpleValue: true,
  86. layout: 'hbox',
  87. defaults: {
  88. xtype: 'radio',
  89. name: 'type',
  90. margin: '0 15 0 0'
  91. },
  92. };
  93. var form = {
  94. margin: '5 5 0 0',
  95. border: false,
  96. defaults: {
  97. margin: '0 0 5 0',
  98. border: false,
  99. },
  100. };
  101. var column = {
  102. filter: { type: 'string' },
  103. };
  104. var grid = {
  105. border: true,
  106. columnLines: true,
  107. rowLines: true,
  108. plugins: {
  109. cellediting: {
  110. clicksToEdit: 1,
  111. },
  112. gridfilters: true
  113. },
  114. multiColumnSort: true,
  115. viewConfig: {
  116. enableTextSelection: true,
  117. sortOnClick: false,
  118. emptyText: '没有数据'
  119. },
  120. selModel: {
  121. type: 'checkboxmodel',
  122. checkOnly: false
  123. },
  124. pagination: true,
  125. pageSize: 50,
  126. pageSizeOption: ['20', '50', '100', '200', '300', '500', '1000'],
  127. hideFootbar: false,
  128. hideRefresh: false,
  129. hideExport: false,
  130. hideAutoSize: false,
  131. hideClearFilter: false,
  132. hideSaveGridUIConfig: false,
  133. hideClearGridUIConfig: false,
  134. autoLoad: true,
  135. remoteSort: false,
  136. remoteFilter: false,
  137. enableLocking: true,
  138. syncRowHeight: false,
  139. enableColumnMove: true,
  140. enableColumnHide: true,
  141. enableColumnResize: true,
  142. hidden: false,
  143. disabled: false,
  144. exportExcelPageSize: 100,
  145. exportExcelCurrentPage: 1,
  146. exportExcelTotal: 0,
  147. };
  148. var fieldContainer = {
  149. labelAlign: 'right',
  150. labelWidth: labelWidth,
  151. layout: 'hbox',
  152. defaults: {
  153. flex: 1,
  154. }
  155. };
  156. var tree = {
  157. autoLoad: true,
  158. hideFilter: false,
  159. hideToolbar: false,
  160. hideRefresh: false,
  161. hideExpand: false,
  162. hideCollapse: false,
  163. };
  164. var search = {
  165. labelAlign: 'right',
  166. labelWidth: labelWidth,
  167. };
  168. var text = {
  169. labelAlign: 'right',
  170. labelWidth: labelWidth,
  171. msgTarget: 'qtip',
  172. };
  173. var toolbar = {
  174. overflowHandler: 'menu',
  175. };
  176. var tbfill = {};
  177. var tbseparator = {};
  178. var button = {};
  179. var fieldSet = {
  180. margin: '5 5 0 0',
  181. border: false,
  182. defaults: {
  183. margin: '0 0 5 0',
  184. border: false,
  185. },
  186. };
  187. var storeAjax = {
  188. timeout: 60000
  189. };
  190. var panel = {};
  191. var splitter = {};
  192. var maintab = {};
  193. var rows = {};
  194. var cols = {
  195. defaults: {
  196. flex: 1
  197. },
  198. };
  199. var bpmn = {
  200. hideRefresh: false,
  201. autoLoad: true,
  202. dataSource: '',
  203. bpmnConfig: {}
  204. };
  205. var Defaults = /*#__PURE__*/Object.freeze({
  206. __proto__: null,
  207. windows: windows,
  208. date: date,
  209. combo: combo,
  210. comboGrid: comboGrid,
  211. comboGridPicker: comboGridPicker,
  212. comboGridMulti: comboGridMulti,
  213. comboGridMultiPicker: comboGridMultiPicker,
  214. numberfield: numberfield,
  215. checkbox: checkbox,
  216. checkboxgroup: checkboxgroup,
  217. radio: radio,
  218. radiogroup: radiogroup,
  219. form: form,
  220. column: column,
  221. grid: grid,
  222. fieldContainer: fieldContainer,
  223. tree: tree,
  224. search: search,
  225. text: text,
  226. toolbar: toolbar,
  227. tbfill: tbfill,
  228. tbseparator: tbseparator,
  229. button: button,
  230. fieldSet: fieldSet,
  231. storeAjax: storeAjax,
  232. panel: panel,
  233. splitter: splitter,
  234. maintab: maintab,
  235. rows: rows,
  236. cols: cols,
  237. bpmn: bpmn
  238. });
  239. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  240. function commonjsRequire () {
  241. throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
  242. }
  243. function createCommonjsModule(fn, module) {
  244. return module = { exports: {} }, fn(module, module.exports), module.exports;
  245. }
  246. var dist = createCommonjsModule(function (module, exports) {
  247. (function (global, factory) {
  248. module.exports = factory() ;
  249. }(commonjsGlobal, (function () {
  250. function createCommonjsModule(fn, module) {
  251. return module = { exports: {} }, fn(module, module.exports), module.exports;
  252. }
  253. var _global = createCommonjsModule(function (module) {
  254. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  255. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  256. ? window : typeof self != 'undefined' && self.Math == Math ? self
  257. // eslint-disable-next-line no-new-func
  258. : Function('return this')();
  259. if (typeof __g == 'number') { __g = global; } // eslint-disable-line no-undef
  260. });
  261. var _core = createCommonjsModule(function (module) {
  262. var core = module.exports = { version: '2.6.5' };
  263. if (typeof __e == 'number') { __e = core; } // eslint-disable-line no-undef
  264. });
  265. var _core_1 = _core.version;
  266. var _isObject = function (it) {
  267. return typeof it === 'object' ? it !== null : typeof it === 'function';
  268. };
  269. var _anObject = function (it) {
  270. if (!_isObject(it)) { throw TypeError(it + ' is not an object!'); }
  271. return it;
  272. };
  273. var _fails = function (exec) {
  274. try {
  275. return !!exec();
  276. } catch (e) {
  277. return true;
  278. }
  279. };
  280. // Thank's IE8 for his funny defineProperty
  281. var _descriptors = !_fails(function () {
  282. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  283. });
  284. var document = _global.document;
  285. // typeof document.createElement is 'object' in old IE
  286. var is = _isObject(document) && _isObject(document.createElement);
  287. var _domCreate = function (it) {
  288. return is ? document.createElement(it) : {};
  289. };
  290. var _ie8DomDefine = !_descriptors && !_fails(function () {
  291. return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
  292. });
  293. // 7.1.1 ToPrimitive(input [, PreferredType])
  294. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  295. // and the second argument - flag - preferred type is a string
  296. var _toPrimitive = function (it, S) {
  297. if (!_isObject(it)) { return it; }
  298. var fn, val;
  299. if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  300. if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  301. if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  302. throw TypeError("Can't convert object to primitive value");
  303. };
  304. var dP = Object.defineProperty;
  305. var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  306. _anObject(O);
  307. P = _toPrimitive(P, true);
  308. _anObject(Attributes);
  309. if (_ie8DomDefine) { try {
  310. return dP(O, P, Attributes);
  311. } catch (e) { /* empty */ } }
  312. if ('get' in Attributes || 'set' in Attributes) { throw TypeError('Accessors not supported!'); }
  313. if ('value' in Attributes) { O[P] = Attributes.value; }
  314. return O;
  315. };
  316. var _objectDp = {
  317. f: f
  318. };
  319. var _propertyDesc = function (bitmap, value) {
  320. return {
  321. enumerable: !(bitmap & 1),
  322. configurable: !(bitmap & 2),
  323. writable: !(bitmap & 4),
  324. value: value
  325. };
  326. };
  327. var _hide = _descriptors ? function (object, key, value) {
  328. return _objectDp.f(object, key, _propertyDesc(1, value));
  329. } : function (object, key, value) {
  330. object[key] = value;
  331. return object;
  332. };
  333. var hasOwnProperty = {}.hasOwnProperty;
  334. var _has = function (it, key) {
  335. return hasOwnProperty.call(it, key);
  336. };
  337. var id = 0;
  338. var px = Math.random();
  339. var _uid = function (key) {
  340. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  341. };
  342. var _shared = createCommonjsModule(function (module) {
  343. var SHARED = '__core-js_shared__';
  344. var store = _global[SHARED] || (_global[SHARED] = {});
  345. (module.exports = function (key, value) {
  346. return store[key] || (store[key] = value !== undefined ? value : {});
  347. })('versions', []).push({
  348. version: _core.version,
  349. mode: 'global',
  350. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  351. });
  352. });
  353. var _functionToString = _shared('native-function-to-string', Function.toString);
  354. var _redefine = createCommonjsModule(function (module) {
  355. var SRC = _uid('src');
  356. var TO_STRING = 'toString';
  357. var TPL = ('' + _functionToString).split(TO_STRING);
  358. _core.inspectSource = function (it) {
  359. return _functionToString.call(it);
  360. };
  361. (module.exports = function (O, key, val, safe) {
  362. var isFunction = typeof val == 'function';
  363. if (isFunction) { _has(val, 'name') || _hide(val, 'name', key); }
  364. if (O[key] === val) { return; }
  365. if (isFunction) { _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); }
  366. if (O === _global) {
  367. O[key] = val;
  368. } else if (!safe) {
  369. delete O[key];
  370. _hide(O, key, val);
  371. } else if (O[key]) {
  372. O[key] = val;
  373. } else {
  374. _hide(O, key, val);
  375. }
  376. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  377. })(Function.prototype, TO_STRING, function toString() {
  378. return typeof this == 'function' && this[SRC] || _functionToString.call(this);
  379. });
  380. });
  381. var _aFunction = function (it) {
  382. if (typeof it != 'function') { throw TypeError(it + ' is not a function!'); }
  383. return it;
  384. };
  385. // optional / simple context binding
  386. var _ctx = function (fn, that, length) {
  387. _aFunction(fn);
  388. if (that === undefined) { return fn; }
  389. switch (length) {
  390. case 1: return function (a) {
  391. return fn.call(that, a);
  392. };
  393. case 2: return function (a, b) {
  394. return fn.call(that, a, b);
  395. };
  396. case 3: return function (a, b, c) {
  397. return fn.call(that, a, b, c);
  398. };
  399. }
  400. return function (/* ...args */) {
  401. return fn.apply(that, arguments);
  402. };
  403. };
  404. var PROTOTYPE = 'prototype';
  405. var $export = function (type, name, source) {
  406. var IS_FORCED = type & $export.F;
  407. var IS_GLOBAL = type & $export.G;
  408. var IS_STATIC = type & $export.S;
  409. var IS_PROTO = type & $export.P;
  410. var IS_BIND = type & $export.B;
  411. var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
  412. var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
  413. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  414. var key, own, out, exp;
  415. if (IS_GLOBAL) { source = name; }
  416. for (key in source) {
  417. // contains in native
  418. own = !IS_FORCED && target && target[key] !== undefined;
  419. // export native or passed
  420. out = (own ? target : source)[key];
  421. // bind timers to global for call from export context
  422. exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
  423. // extend global
  424. if (target) { _redefine(target, key, out, type & $export.U); }
  425. // export
  426. if (exports[key] != out) { _hide(exports, key, exp); }
  427. if (IS_PROTO && expProto[key] != out) { expProto[key] = out; }
  428. }
  429. };
  430. _global.core = _core;
  431. // type bitmap
  432. $export.F = 1; // forced
  433. $export.G = 2; // global
  434. $export.S = 4; // static
  435. $export.P = 8; // proto
  436. $export.B = 16; // bind
  437. $export.W = 32; // wrap
  438. $export.U = 64; // safe
  439. $export.R = 128; // real proto method for `library`
  440. var _export = $export;
  441. // 7.1.4 ToInteger
  442. var ceil = Math.ceil;
  443. var floor = Math.floor;
  444. var _toInteger = function (it) {
  445. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  446. };
  447. // 7.2.1 RequireObjectCoercible(argument)
  448. var _defined = function (it) {
  449. if (it == undefined) { throw TypeError("Can't call method on " + it); }
  450. return it;
  451. };
  452. // true -> String#at
  453. // false -> String#codePointAt
  454. var _stringAt = function (TO_STRING) {
  455. return function (that, pos) {
  456. var s = String(_defined(that));
  457. var i = _toInteger(pos);
  458. var l = s.length;
  459. var a, b;
  460. if (i < 0 || i >= l) { return TO_STRING ? '' : undefined; }
  461. a = s.charCodeAt(i);
  462. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  463. ? TO_STRING ? s.charAt(i) : a
  464. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  465. };
  466. };
  467. var $at = _stringAt(false);
  468. _export(_export.P, 'String', {
  469. // 21.1.3.3 String.prototype.codePointAt(pos)
  470. codePointAt: function codePointAt(pos) {
  471. return $at(this, pos);
  472. }
  473. });
  474. var codePointAt = _core.String.codePointAt;
  475. var max = Math.max;
  476. var min = Math.min;
  477. var _toAbsoluteIndex = function (index, length) {
  478. index = _toInteger(index);
  479. return index < 0 ? max(index + length, 0) : min(index, length);
  480. };
  481. var fromCharCode = String.fromCharCode;
  482. var $fromCodePoint = String.fromCodePoint;
  483. // length should be 1, old FF problem
  484. _export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  485. // 21.1.2.2 String.fromCodePoint(...codePoints)
  486. fromCodePoint: function fromCodePoint(x) {
  487. var arguments$1 = arguments;
  488. // eslint-disable-line no-unused-vars
  489. var res = [];
  490. var aLen = arguments.length;
  491. var i = 0;
  492. var code;
  493. while (aLen > i) {
  494. code = +arguments$1[i++];
  495. if (_toAbsoluteIndex(code, 0x10ffff) !== code) { throw RangeError(code + ' is not a valid code point'); }
  496. res.push(code < 0x10000
  497. ? fromCharCode(code)
  498. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  499. );
  500. } return res.join('');
  501. }
  502. });
  503. var fromCodePoint = _core.String.fromCodePoint;
  504. // This is a generated file. Do not edit.
  505. var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  506. var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
  507. var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
  508. var unicode = {
  509. Space_Separator: Space_Separator,
  510. ID_Start: ID_Start,
  511. ID_Continue: ID_Continue
  512. };
  513. var util = {
  514. isSpaceSeparator: function isSpaceSeparator (c) {
  515. return typeof c === 'string' && unicode.Space_Separator.test(c)
  516. },
  517. isIdStartChar: function isIdStartChar (c) {
  518. return typeof c === 'string' && (
  519. (c >= 'a' && c <= 'z') ||
  520. (c >= 'A' && c <= 'Z') ||
  521. (c === '$') || (c === '_') ||
  522. unicode.ID_Start.test(c)
  523. )
  524. },
  525. isIdContinueChar: function isIdContinueChar (c) {
  526. return typeof c === 'string' && (
  527. (c >= 'a' && c <= 'z') ||
  528. (c >= 'A' && c <= 'Z') ||
  529. (c >= '0' && c <= '9') ||
  530. (c === '$') || (c === '_') ||
  531. (c === '\u200C') || (c === '\u200D') ||
  532. unicode.ID_Continue.test(c)
  533. )
  534. },
  535. isDigit: function isDigit (c) {
  536. return typeof c === 'string' && /[0-9]/.test(c)
  537. },
  538. isHexDigit: function isHexDigit (c) {
  539. return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
  540. },
  541. };
  542. var source;
  543. var parseState;
  544. var stack;
  545. var pos;
  546. var line;
  547. var column;
  548. var token;
  549. var key;
  550. var root;
  551. var parse = function parse (text, reviver) {
  552. source = String(text);
  553. parseState = 'start';
  554. stack = [];
  555. pos = 0;
  556. line = 1;
  557. column = 0;
  558. token = undefined;
  559. key = undefined;
  560. root = undefined;
  561. do {
  562. token = lex();
  563. // This code is unreachable.
  564. // if (!parseStates[parseState]) {
  565. // throw invalidParseState()
  566. // }
  567. parseStates[parseState]();
  568. } while (token.type !== 'eof')
  569. if (typeof reviver === 'function') {
  570. return internalize({'': root}, '', reviver)
  571. }
  572. return root
  573. };
  574. function internalize (holder, name, reviver) {
  575. var value = holder[name];
  576. if (value != null && typeof value === 'object') {
  577. for (var key in value) {
  578. var replacement = internalize(value, key, reviver);
  579. if (replacement === undefined) {
  580. delete value[key];
  581. } else {
  582. value[key] = replacement;
  583. }
  584. }
  585. }
  586. return reviver.call(holder, name, value)
  587. }
  588. var lexState;
  589. var buffer;
  590. var doubleQuote;
  591. var sign;
  592. var c;
  593. function lex () {
  594. lexState = 'default';
  595. buffer = '';
  596. doubleQuote = false;
  597. sign = 1;
  598. for (;;) {
  599. c = peek();
  600. // This code is unreachable.
  601. // if (!lexStates[lexState]) {
  602. // throw invalidLexState(lexState)
  603. // }
  604. var token = lexStates[lexState]();
  605. if (token) {
  606. return token
  607. }
  608. }
  609. }
  610. function peek () {
  611. if (source[pos]) {
  612. return String.fromCodePoint(source.codePointAt(pos))
  613. }
  614. }
  615. function read () {
  616. var c = peek();
  617. if (c === '\n') {
  618. line++;
  619. column = 0;
  620. } else if (c) {
  621. column += c.length;
  622. } else {
  623. column++;
  624. }
  625. if (c) {
  626. pos += c.length;
  627. }
  628. return c
  629. }
  630. var lexStates = {
  631. default: function default$1 () {
  632. switch (c) {
  633. case '\t':
  634. case '\v':
  635. case '\f':
  636. case ' ':
  637. case '\u00A0':
  638. case '\uFEFF':
  639. case '\n':
  640. case '\r':
  641. case '\u2028':
  642. case '\u2029':
  643. read();
  644. return
  645. case '/':
  646. read();
  647. lexState = 'comment';
  648. return
  649. case undefined:
  650. read();
  651. return newToken('eof')
  652. }
  653. if (util.isSpaceSeparator(c)) {
  654. read();
  655. return
  656. }
  657. // This code is unreachable.
  658. // if (!lexStates[parseState]) {
  659. // throw invalidLexState(parseState)
  660. // }
  661. return lexStates[parseState]()
  662. },
  663. comment: function comment () {
  664. switch (c) {
  665. case '*':
  666. read();
  667. lexState = 'multiLineComment';
  668. return
  669. case '/':
  670. read();
  671. lexState = 'singleLineComment';
  672. return
  673. }
  674. throw invalidChar(read())
  675. },
  676. multiLineComment: function multiLineComment () {
  677. switch (c) {
  678. case '*':
  679. read();
  680. lexState = 'multiLineCommentAsterisk';
  681. return
  682. case undefined:
  683. throw invalidChar(read())
  684. }
  685. read();
  686. },
  687. multiLineCommentAsterisk: function multiLineCommentAsterisk () {
  688. switch (c) {
  689. case '*':
  690. read();
  691. return
  692. case '/':
  693. read();
  694. lexState = 'default';
  695. return
  696. case undefined:
  697. throw invalidChar(read())
  698. }
  699. read();
  700. lexState = 'multiLineComment';
  701. },
  702. singleLineComment: function singleLineComment () {
  703. switch (c) {
  704. case '\n':
  705. case '\r':
  706. case '\u2028':
  707. case '\u2029':
  708. read();
  709. lexState = 'default';
  710. return
  711. case undefined:
  712. read();
  713. return newToken('eof')
  714. }
  715. read();
  716. },
  717. value: function value () {
  718. switch (c) {
  719. case '{':
  720. case '[':
  721. return newToken('punctuator', read())
  722. case 'n':
  723. read();
  724. literal('ull');
  725. return newToken('null', null)
  726. case 't':
  727. read();
  728. literal('rue');
  729. return newToken('boolean', true)
  730. case 'f':
  731. read();
  732. literal('alse');
  733. return newToken('boolean', false)
  734. case '-':
  735. case '+':
  736. if (read() === '-') {
  737. sign = -1;
  738. }
  739. lexState = 'sign';
  740. return
  741. case '.':
  742. buffer = read();
  743. lexState = 'decimalPointLeading';
  744. return
  745. case '0':
  746. buffer = read();
  747. lexState = 'zero';
  748. return
  749. case '1':
  750. case '2':
  751. case '3':
  752. case '4':
  753. case '5':
  754. case '6':
  755. case '7':
  756. case '8':
  757. case '9':
  758. buffer = read();
  759. lexState = 'decimalInteger';
  760. return
  761. case 'I':
  762. read();
  763. literal('nfinity');
  764. return newToken('numeric', Infinity)
  765. case 'N':
  766. read();
  767. literal('aN');
  768. return newToken('numeric', NaN)
  769. case '"':
  770. case "'":
  771. doubleQuote = (read() === '"');
  772. buffer = '';
  773. lexState = 'string';
  774. return
  775. }
  776. throw invalidChar(read())
  777. },
  778. identifierNameStartEscape: function identifierNameStartEscape () {
  779. if (c !== 'u') {
  780. throw invalidChar(read())
  781. }
  782. read();
  783. var u = unicodeEscape();
  784. switch (u) {
  785. case '$':
  786. case '_':
  787. break
  788. default:
  789. if (!util.isIdStartChar(u)) {
  790. throw invalidIdentifier()
  791. }
  792. break
  793. }
  794. buffer += u;
  795. lexState = 'identifierName';
  796. },
  797. identifierName: function identifierName () {
  798. switch (c) {
  799. case '$':
  800. case '_':
  801. case '\u200C':
  802. case '\u200D':
  803. buffer += read();
  804. return
  805. case '\\':
  806. read();
  807. lexState = 'identifierNameEscape';
  808. return
  809. }
  810. if (util.isIdContinueChar(c)) {
  811. buffer += read();
  812. return
  813. }
  814. return newToken('identifier', buffer)
  815. },
  816. identifierNameEscape: function identifierNameEscape () {
  817. if (c !== 'u') {
  818. throw invalidChar(read())
  819. }
  820. read();
  821. var u = unicodeEscape();
  822. switch (u) {
  823. case '$':
  824. case '_':
  825. case '\u200C':
  826. case '\u200D':
  827. break
  828. default:
  829. if (!util.isIdContinueChar(u)) {
  830. throw invalidIdentifier()
  831. }
  832. break
  833. }
  834. buffer += u;
  835. lexState = 'identifierName';
  836. },
  837. sign: function sign$1 () {
  838. switch (c) {
  839. case '.':
  840. buffer = read();
  841. lexState = 'decimalPointLeading';
  842. return
  843. case '0':
  844. buffer = read();
  845. lexState = 'zero';
  846. return
  847. case '1':
  848. case '2':
  849. case '3':
  850. case '4':
  851. case '5':
  852. case '6':
  853. case '7':
  854. case '8':
  855. case '9':
  856. buffer = read();
  857. lexState = 'decimalInteger';
  858. return
  859. case 'I':
  860. read();
  861. literal('nfinity');
  862. return newToken('numeric', sign * Infinity)
  863. case 'N':
  864. read();
  865. literal('aN');
  866. return newToken('numeric', NaN)
  867. }
  868. throw invalidChar(read())
  869. },
  870. zero: function zero () {
  871. switch (c) {
  872. case '.':
  873. buffer += read();
  874. lexState = 'decimalPoint';
  875. return
  876. case 'e':
  877. case 'E':
  878. buffer += read();
  879. lexState = 'decimalExponent';
  880. return
  881. case 'x':
  882. case 'X':
  883. buffer += read();
  884. lexState = 'hexadecimal';
  885. return
  886. }
  887. return newToken('numeric', sign * 0)
  888. },
  889. decimalInteger: function decimalInteger () {
  890. switch (c) {
  891. case '.':
  892. buffer += read();
  893. lexState = 'decimalPoint';
  894. return
  895. case 'e':
  896. case 'E':
  897. buffer += read();
  898. lexState = 'decimalExponent';
  899. return
  900. }
  901. if (util.isDigit(c)) {
  902. buffer += read();
  903. return
  904. }
  905. return newToken('numeric', sign * Number(buffer))
  906. },
  907. decimalPointLeading: function decimalPointLeading () {
  908. if (util.isDigit(c)) {
  909. buffer += read();
  910. lexState = 'decimalFraction';
  911. return
  912. }
  913. throw invalidChar(read())
  914. },
  915. decimalPoint: function decimalPoint () {
  916. switch (c) {
  917. case 'e':
  918. case 'E':
  919. buffer += read();
  920. lexState = 'decimalExponent';
  921. return
  922. }
  923. if (util.isDigit(c)) {
  924. buffer += read();
  925. lexState = 'decimalFraction';
  926. return
  927. }
  928. return newToken('numeric', sign * Number(buffer))
  929. },
  930. decimalFraction: function decimalFraction () {
  931. switch (c) {
  932. case 'e':
  933. case 'E':
  934. buffer += read();
  935. lexState = 'decimalExponent';
  936. return
  937. }
  938. if (util.isDigit(c)) {
  939. buffer += read();
  940. return
  941. }
  942. return newToken('numeric', sign * Number(buffer))
  943. },
  944. decimalExponent: function decimalExponent () {
  945. switch (c) {
  946. case '+':
  947. case '-':
  948. buffer += read();
  949. lexState = 'decimalExponentSign';
  950. return
  951. }
  952. if (util.isDigit(c)) {
  953. buffer += read();
  954. lexState = 'decimalExponentInteger';
  955. return
  956. }
  957. throw invalidChar(read())
  958. },
  959. decimalExponentSign: function decimalExponentSign () {
  960. if (util.isDigit(c)) {
  961. buffer += read();
  962. lexState = 'decimalExponentInteger';
  963. return
  964. }
  965. throw invalidChar(read())
  966. },
  967. decimalExponentInteger: function decimalExponentInteger () {
  968. if (util.isDigit(c)) {
  969. buffer += read();
  970. return
  971. }
  972. return newToken('numeric', sign * Number(buffer))
  973. },
  974. hexadecimal: function hexadecimal () {
  975. if (util.isHexDigit(c)) {
  976. buffer += read();
  977. lexState = 'hexadecimalInteger';
  978. return
  979. }
  980. throw invalidChar(read())
  981. },
  982. hexadecimalInteger: function hexadecimalInteger () {
  983. if (util.isHexDigit(c)) {
  984. buffer += read();
  985. return
  986. }
  987. return newToken('numeric', sign * Number(buffer))
  988. },
  989. string: function string () {
  990. switch (c) {
  991. case '\\':
  992. read();
  993. buffer += escape();
  994. return
  995. case '"':
  996. if (doubleQuote) {
  997. read();
  998. return newToken('string', buffer)
  999. }
  1000. buffer += read();
  1001. return
  1002. case "'":
  1003. if (!doubleQuote) {
  1004. read();
  1005. return newToken('string', buffer)
  1006. }
  1007. buffer += read();
  1008. return
  1009. case '\n':
  1010. case '\r':
  1011. throw invalidChar(read())
  1012. case '\u2028':
  1013. case '\u2029':
  1014. separatorChar(c);
  1015. break
  1016. case undefined:
  1017. throw invalidChar(read())
  1018. }
  1019. buffer += read();
  1020. },
  1021. start: function start () {
  1022. switch (c) {
  1023. case '{':
  1024. case '[':
  1025. return newToken('punctuator', read())
  1026. // This code is unreachable since the default lexState handles eof.
  1027. // case undefined:
  1028. // return newToken('eof')
  1029. }
  1030. lexState = 'value';
  1031. },
  1032. beforePropertyName: function beforePropertyName () {
  1033. switch (c) {
  1034. case '$':
  1035. case '_':
  1036. buffer = read();
  1037. lexState = 'identifierName';
  1038. return
  1039. case '\\':
  1040. read();
  1041. lexState = 'identifierNameStartEscape';
  1042. return
  1043. case '}':
  1044. return newToken('punctuator', read())
  1045. case '"':
  1046. case "'":
  1047. doubleQuote = (read() === '"');
  1048. lexState = 'string';
  1049. return
  1050. }
  1051. if (util.isIdStartChar(c)) {
  1052. buffer += read();
  1053. lexState = 'identifierName';
  1054. return
  1055. }
  1056. throw invalidChar(read())
  1057. },
  1058. afterPropertyName: function afterPropertyName () {
  1059. if (c === ':') {
  1060. return newToken('punctuator', read())
  1061. }
  1062. throw invalidChar(read())
  1063. },
  1064. beforePropertyValue: function beforePropertyValue () {
  1065. lexState = 'value';
  1066. },
  1067. afterPropertyValue: function afterPropertyValue () {
  1068. switch (c) {
  1069. case ',':
  1070. case '}':
  1071. return newToken('punctuator', read())
  1072. }
  1073. throw invalidChar(read())
  1074. },
  1075. beforeArrayValue: function beforeArrayValue () {
  1076. if (c === ']') {
  1077. return newToken('punctuator', read())
  1078. }
  1079. lexState = 'value';
  1080. },
  1081. afterArrayValue: function afterArrayValue () {
  1082. switch (c) {
  1083. case ',':
  1084. case ']':
  1085. return newToken('punctuator', read())
  1086. }
  1087. throw invalidChar(read())
  1088. },
  1089. end: function end () {
  1090. // This code is unreachable since it's handled by the default lexState.
  1091. // if (c === undefined) {
  1092. // read()
  1093. // return newToken('eof')
  1094. // }
  1095. throw invalidChar(read())
  1096. },
  1097. };
  1098. function newToken (type, value) {
  1099. return {
  1100. type: type,
  1101. value: value,
  1102. line: line,
  1103. column: column,
  1104. }
  1105. }
  1106. function literal (s) {
  1107. for (var i = 0, list = s; i < list.length; i += 1) {
  1108. var c = list[i];
  1109. var p = peek();
  1110. if (p !== c) {
  1111. throw invalidChar(read())
  1112. }
  1113. read();
  1114. }
  1115. }
  1116. function escape () {
  1117. var c = peek();
  1118. switch (c) {
  1119. case 'b':
  1120. read();
  1121. return '\b'
  1122. case 'f':
  1123. read();
  1124. return '\f'
  1125. case 'n':
  1126. read();
  1127. return '\n'
  1128. case 'r':
  1129. read();
  1130. return '\r'
  1131. case 't':
  1132. read();
  1133. return '\t'
  1134. case 'v':
  1135. read();
  1136. return '\v'
  1137. case '0':
  1138. read();
  1139. if (util.isDigit(peek())) {
  1140. throw invalidChar(read())
  1141. }
  1142. return '\0'
  1143. case 'x':
  1144. read();
  1145. return hexEscape()
  1146. case 'u':
  1147. read();
  1148. return unicodeEscape()
  1149. case '\n':
  1150. case '\u2028':
  1151. case '\u2029':
  1152. read();
  1153. return ''
  1154. case '\r':
  1155. read();
  1156. if (peek() === '\n') {
  1157. read();
  1158. }
  1159. return ''
  1160. case '1':
  1161. case '2':
  1162. case '3':
  1163. case '4':
  1164. case '5':
  1165. case '6':
  1166. case '7':
  1167. case '8':
  1168. case '9':
  1169. throw invalidChar(read())
  1170. case undefined:
  1171. throw invalidChar(read())
  1172. }
  1173. return read()
  1174. }
  1175. function hexEscape () {
  1176. var buffer = '';
  1177. var c = peek();
  1178. if (!util.isHexDigit(c)) {
  1179. throw invalidChar(read())
  1180. }
  1181. buffer += read();
  1182. c = peek();
  1183. if (!util.isHexDigit(c)) {
  1184. throw invalidChar(read())
  1185. }
  1186. buffer += read();
  1187. return String.fromCodePoint(parseInt(buffer, 16))
  1188. }
  1189. function unicodeEscape () {
  1190. var buffer = '';
  1191. var count = 4;
  1192. while (count-- > 0) {
  1193. var c = peek();
  1194. if (!util.isHexDigit(c)) {
  1195. throw invalidChar(read())
  1196. }
  1197. buffer += read();
  1198. }
  1199. return String.fromCodePoint(parseInt(buffer, 16))
  1200. }
  1201. var parseStates = {
  1202. start: function start () {
  1203. if (token.type === 'eof') {
  1204. throw invalidEOF()
  1205. }
  1206. push();
  1207. },
  1208. beforePropertyName: function beforePropertyName () {
  1209. switch (token.type) {
  1210. case 'identifier':
  1211. case 'string':
  1212. key = token.value;
  1213. parseState = 'afterPropertyName';
  1214. return
  1215. case 'punctuator':
  1216. // This code is unreachable since it's handled by the lexState.
  1217. // if (token.value !== '}') {
  1218. // throw invalidToken()
  1219. // }
  1220. pop();
  1221. return
  1222. case 'eof':
  1223. throw invalidEOF()
  1224. }
  1225. // This code is unreachable since it's handled by the lexState.
  1226. // throw invalidToken()
  1227. },
  1228. afterPropertyName: function afterPropertyName () {
  1229. // This code is unreachable since it's handled by the lexState.
  1230. // if (token.type !== 'punctuator' || token.value !== ':') {
  1231. // throw invalidToken()
  1232. // }
  1233. if (token.type === 'eof') {
  1234. throw invalidEOF()
  1235. }
  1236. parseState = 'beforePropertyValue';
  1237. },
  1238. beforePropertyValue: function beforePropertyValue () {
  1239. if (token.type === 'eof') {
  1240. throw invalidEOF()
  1241. }
  1242. push();
  1243. },
  1244. beforeArrayValue: function beforeArrayValue () {
  1245. if (token.type === 'eof') {
  1246. throw invalidEOF()
  1247. }
  1248. if (token.type === 'punctuator' && token.value === ']') {
  1249. pop();
  1250. return
  1251. }
  1252. push();
  1253. },
  1254. afterPropertyValue: function afterPropertyValue () {
  1255. // This code is unreachable since it's handled by the lexState.
  1256. // if (token.type !== 'punctuator') {
  1257. // throw invalidToken()
  1258. // }
  1259. if (token.type === 'eof') {
  1260. throw invalidEOF()
  1261. }
  1262. switch (token.value) {
  1263. case ',':
  1264. parseState = 'beforePropertyName';
  1265. return
  1266. case '}':
  1267. pop();
  1268. }
  1269. // This code is unreachable since it's handled by the lexState.
  1270. // throw invalidToken()
  1271. },
  1272. afterArrayValue: function afterArrayValue () {
  1273. // This code is unreachable since it's handled by the lexState.
  1274. // if (token.type !== 'punctuator') {
  1275. // throw invalidToken()
  1276. // }
  1277. if (token.type === 'eof') {
  1278. throw invalidEOF()
  1279. }
  1280. switch (token.value) {
  1281. case ',':
  1282. parseState = 'beforeArrayValue';
  1283. return
  1284. case ']':
  1285. pop();
  1286. }
  1287. // This code is unreachable since it's handled by the lexState.
  1288. // throw invalidToken()
  1289. },
  1290. end: function end () {
  1291. // This code is unreachable since it's handled by the lexState.
  1292. // if (token.type !== 'eof') {
  1293. // throw invalidToken()
  1294. // }
  1295. },
  1296. };
  1297. function push () {
  1298. var value;
  1299. switch (token.type) {
  1300. case 'punctuator':
  1301. switch (token.value) {
  1302. case '{':
  1303. value = {};
  1304. break
  1305. case '[':
  1306. value = [];
  1307. break
  1308. }
  1309. break
  1310. case 'null':
  1311. case 'boolean':
  1312. case 'numeric':
  1313. case 'string':
  1314. value = token.value;
  1315. break
  1316. // This code is unreachable.
  1317. // default:
  1318. // throw invalidToken()
  1319. }
  1320. if (root === undefined) {
  1321. root = value;
  1322. } else {
  1323. var parent = stack[stack.length - 1];
  1324. if (Array.isArray(parent)) {
  1325. parent.push(value);
  1326. } else {
  1327. parent[key] = value;
  1328. }
  1329. }
  1330. if (value !== null && typeof value === 'object') {
  1331. stack.push(value);
  1332. if (Array.isArray(value)) {
  1333. parseState = 'beforeArrayValue';
  1334. } else {
  1335. parseState = 'beforePropertyName';
  1336. }
  1337. } else {
  1338. var current = stack[stack.length - 1];
  1339. if (current == null) {
  1340. parseState = 'end';
  1341. } else if (Array.isArray(current)) {
  1342. parseState = 'afterArrayValue';
  1343. } else {
  1344. parseState = 'afterPropertyValue';
  1345. }
  1346. }
  1347. }
  1348. function pop () {
  1349. stack.pop();
  1350. var current = stack[stack.length - 1];
  1351. if (current == null) {
  1352. parseState = 'end';
  1353. } else if (Array.isArray(current)) {
  1354. parseState = 'afterArrayValue';
  1355. } else {
  1356. parseState = 'afterPropertyValue';
  1357. }
  1358. }
  1359. // This code is unreachable.
  1360. // function invalidParseState () {
  1361. // return new Error(`JSON5: invalid parse state '${parseState}'`)
  1362. // }
  1363. // This code is unreachable.
  1364. // function invalidLexState (state) {
  1365. // return new Error(`JSON5: invalid lex state '${state}'`)
  1366. // }
  1367. function invalidChar (c) {
  1368. if (c === undefined) {
  1369. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  1370. }
  1371. return syntaxError(("JSON5: invalid character '" + (formatChar(c)) + "' at " + line + ":" + column))
  1372. }
  1373. function invalidEOF () {
  1374. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  1375. }
  1376. // This code is unreachable.
  1377. // function invalidToken () {
  1378. // if (token.type === 'eof') {
  1379. // return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
  1380. // }
  1381. // const c = String.fromCodePoint(token.value.codePointAt(0))
  1382. // return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
  1383. // }
  1384. function invalidIdentifier () {
  1385. column -= 5;
  1386. return syntaxError(("JSON5: invalid identifier character at " + line + ":" + column))
  1387. }
  1388. function separatorChar (c) {
  1389. console.warn(("JSON5: '" + (formatChar(c)) + "' in strings is not valid ECMAScript; consider escaping"));
  1390. }
  1391. function formatChar (c) {
  1392. var replacements = {
  1393. "'": "\\'",
  1394. '"': '\\"',
  1395. '\\': '\\\\',
  1396. '\b': '\\b',
  1397. '\f': '\\f',
  1398. '\n': '\\n',
  1399. '\r': '\\r',
  1400. '\t': '\\t',
  1401. '\v': '\\v',
  1402. '\0': '\\0',
  1403. '\u2028': '\\u2028',
  1404. '\u2029': '\\u2029',
  1405. };
  1406. if (replacements[c]) {
  1407. return replacements[c]
  1408. }
  1409. if (c < ' ') {
  1410. var hexString = c.charCodeAt(0).toString(16);
  1411. return '\\x' + ('00' + hexString).substring(hexString.length)
  1412. }
  1413. return c
  1414. }
  1415. function syntaxError (message) {
  1416. var err = new SyntaxError(message);
  1417. err.lineNumber = line;
  1418. err.columnNumber = column;
  1419. return err
  1420. }
  1421. var stringify = function stringify (value, replacer, space) {
  1422. var stack = [];
  1423. var indent = '';
  1424. var propertyList;
  1425. var replacerFunc;
  1426. var gap = '';
  1427. var quote;
  1428. if (
  1429. replacer != null &&
  1430. typeof replacer === 'object' &&
  1431. !Array.isArray(replacer)
  1432. ) {
  1433. space = replacer.space;
  1434. quote = replacer.quote;
  1435. replacer = replacer.replacer;
  1436. }
  1437. if (typeof replacer === 'function') {
  1438. replacerFunc = replacer;
  1439. } else if (Array.isArray(replacer)) {
  1440. propertyList = [];
  1441. for (var i = 0, list = replacer; i < list.length; i += 1) {
  1442. var v = list[i];
  1443. var item = (void 0);
  1444. if (typeof v === 'string') {
  1445. item = v;
  1446. } else if (
  1447. typeof v === 'number' ||
  1448. v instanceof String ||
  1449. v instanceof Number
  1450. ) {
  1451. item = String(v);
  1452. }
  1453. if (item !== undefined && propertyList.indexOf(item) < 0) {
  1454. propertyList.push(item);
  1455. }
  1456. }
  1457. }
  1458. if (space instanceof Number) {
  1459. space = Number(space);
  1460. } else if (space instanceof String) {
  1461. space = String(space);
  1462. }
  1463. if (typeof space === 'number') {
  1464. if (space > 0) {
  1465. space = Math.min(10, Math.floor(space));
  1466. gap = ' '.substr(0, space);
  1467. }
  1468. } else if (typeof space === 'string') {
  1469. gap = space.substr(0, 10);
  1470. }
  1471. return serializeProperty('', {'': value})
  1472. function serializeProperty (key, holder) {
  1473. var value = holder[key];
  1474. if (value != null) {
  1475. if (typeof value.toJSON5 === 'function') {
  1476. value = value.toJSON5(key);
  1477. } else if (typeof value.toJSON === 'function') {
  1478. value = value.toJSON(key);
  1479. }
  1480. }
  1481. if (replacerFunc) {
  1482. value = replacerFunc.call(holder, key, value);
  1483. }
  1484. if (value instanceof Number) {
  1485. value = Number(value);
  1486. } else if (value instanceof String) {
  1487. value = String(value);
  1488. } else if (value instanceof Boolean) {
  1489. value = value.valueOf();
  1490. }
  1491. switch (value) {
  1492. case null: return 'null'
  1493. case true: return 'true'
  1494. case false: return 'false'
  1495. }
  1496. if (typeof value === 'string') {
  1497. return quoteString(value)
  1498. }
  1499. if (typeof value === 'number') {
  1500. return String(value)
  1501. }
  1502. if (typeof value === 'object') {
  1503. return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
  1504. }
  1505. return undefined
  1506. }
  1507. function quoteString (value) {
  1508. var quotes = {
  1509. "'": 0.1,
  1510. '"': 0.2,
  1511. };
  1512. var replacements = {
  1513. "'": "\\'",
  1514. '"': '\\"',
  1515. '\\': '\\\\',
  1516. '\b': '\\b',
  1517. '\f': '\\f',
  1518. '\n': '\\n',
  1519. '\r': '\\r',
  1520. '\t': '\\t',
  1521. '\v': '\\v',
  1522. '\0': '\\0',
  1523. '\u2028': '\\u2028',
  1524. '\u2029': '\\u2029',
  1525. };
  1526. var product = '';
  1527. for (var i = 0; i < value.length; i++) {
  1528. var c = value[i];
  1529. switch (c) {
  1530. case "'":
  1531. case '"':
  1532. quotes[c]++;
  1533. product += c;
  1534. continue
  1535. case '\0':
  1536. if (util.isDigit(value[i + 1])) {
  1537. product += '\\x00';
  1538. continue
  1539. }
  1540. }
  1541. if (replacements[c]) {
  1542. product += replacements[c];
  1543. continue
  1544. }
  1545. if (c < ' ') {
  1546. var hexString = c.charCodeAt(0).toString(16);
  1547. product += '\\x' + ('00' + hexString).substring(hexString.length);
  1548. continue
  1549. }
  1550. product += c;
  1551. }
  1552. var quoteChar = quote || Object.keys(quotes).reduce(function (a, b) { return (quotes[a] < quotes[b]) ? a : b; });
  1553. product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
  1554. return quoteChar + product + quoteChar
  1555. }
  1556. function serializeObject (value) {
  1557. if (stack.indexOf(value) >= 0) {
  1558. throw TypeError('Converting circular structure to JSON5')
  1559. }
  1560. stack.push(value);
  1561. var stepback = indent;
  1562. indent = indent + gap;
  1563. var keys = propertyList || Object.keys(value);
  1564. var partial = [];
  1565. for (var i = 0, list = keys; i < list.length; i += 1) {
  1566. var key = list[i];
  1567. var propertyString = serializeProperty(key, value);
  1568. if (propertyString !== undefined) {
  1569. var member = serializeKey(key) + ':';
  1570. if (gap !== '') {
  1571. member += ' ';
  1572. }
  1573. member += propertyString;
  1574. partial.push(member);
  1575. }
  1576. }
  1577. var final;
  1578. if (partial.length === 0) {
  1579. final = '{}';
  1580. } else {
  1581. var properties;
  1582. if (gap === '') {
  1583. properties = partial.join(',');
  1584. final = '{' + properties + '}';
  1585. } else {
  1586. var separator = ',\n' + indent;
  1587. properties = partial.join(separator);
  1588. final = '{\n' + indent + properties + ',\n' + stepback + '}';
  1589. }
  1590. }
  1591. stack.pop();
  1592. indent = stepback;
  1593. return final
  1594. }
  1595. function serializeKey (key) {
  1596. if (key.length === 0) {
  1597. return quoteString(key)
  1598. }
  1599. var firstChar = String.fromCodePoint(key.codePointAt(0));
  1600. if (!util.isIdStartChar(firstChar)) {
  1601. return quoteString(key)
  1602. }
  1603. for (var i = firstChar.length; i < key.length; i++) {
  1604. if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
  1605. return quoteString(key)
  1606. }
  1607. }
  1608. return key
  1609. }
  1610. function serializeArray (value) {
  1611. if (stack.indexOf(value) >= 0) {
  1612. throw TypeError('Converting circular structure to JSON5')
  1613. }
  1614. stack.push(value);
  1615. var stepback = indent;
  1616. indent = indent + gap;
  1617. var partial = [];
  1618. for (var i = 0; i < value.length; i++) {
  1619. var propertyString = serializeProperty(String(i), value);
  1620. partial.push((propertyString !== undefined) ? propertyString : 'null');
  1621. }
  1622. var final;
  1623. if (partial.length === 0) {
  1624. final = '[]';
  1625. } else {
  1626. if (gap === '') {
  1627. var properties = partial.join(',');
  1628. final = '[' + properties + ']';
  1629. } else {
  1630. var separator = ',\n' + indent;
  1631. var properties$1 = partial.join(separator);
  1632. final = '[\n' + indent + properties$1 + ',\n' + stepback + ']';
  1633. }
  1634. }
  1635. stack.pop();
  1636. indent = stepback;
  1637. return final
  1638. }
  1639. };
  1640. var JSON5 = {
  1641. parse: parse,
  1642. stringify: stringify,
  1643. };
  1644. var lib = JSON5;
  1645. var es5 = lib;
  1646. return es5;
  1647. })));
  1648. });
  1649. var moment$1 = createCommonjsModule(function (module, exports) {
  1650. (function (global, factory) {
  1651. module.exports = factory() ;
  1652. }(commonjsGlobal, (function () {
  1653. var hookCallback;
  1654. function hooks() {
  1655. return hookCallback.apply(null, arguments);
  1656. }
  1657. // This is done to register the method called with moment()
  1658. // without creating circular dependencies.
  1659. function setHookCallback(callback) {
  1660. hookCallback = callback;
  1661. }
  1662. function isArray(input) {
  1663. return (
  1664. input instanceof Array ||
  1665. Object.prototype.toString.call(input) === '[object Array]'
  1666. );
  1667. }
  1668. function isObject(input) {
  1669. // IE8 will treat undefined and null as object if it wasn't for
  1670. // input != null
  1671. return (
  1672. input != null &&
  1673. Object.prototype.toString.call(input) === '[object Object]'
  1674. );
  1675. }
  1676. function hasOwnProp(a, b) {
  1677. return Object.prototype.hasOwnProperty.call(a, b);
  1678. }
  1679. function isObjectEmpty(obj) {
  1680. if (Object.getOwnPropertyNames) {
  1681. return Object.getOwnPropertyNames(obj).length === 0;
  1682. } else {
  1683. var k;
  1684. for (k in obj) {
  1685. if (hasOwnProp(obj, k)) {
  1686. return false;
  1687. }
  1688. }
  1689. return true;
  1690. }
  1691. }
  1692. function isUndefined(input) {
  1693. return input === void 0;
  1694. }
  1695. function isNumber(input) {
  1696. return (
  1697. typeof input === 'number' ||
  1698. Object.prototype.toString.call(input) === '[object Number]'
  1699. );
  1700. }
  1701. function isDate(input) {
  1702. return (
  1703. input instanceof Date ||
  1704. Object.prototype.toString.call(input) === '[object Date]'
  1705. );
  1706. }
  1707. function map(arr, fn) {
  1708. var res = [],
  1709. i;
  1710. for (i = 0; i < arr.length; ++i) {
  1711. res.push(fn(arr[i], i));
  1712. }
  1713. return res;
  1714. }
  1715. function extend(a, b) {
  1716. for (var i in b) {
  1717. if (hasOwnProp(b, i)) {
  1718. a[i] = b[i];
  1719. }
  1720. }
  1721. if (hasOwnProp(b, 'toString')) {
  1722. a.toString = b.toString;
  1723. }
  1724. if (hasOwnProp(b, 'valueOf')) {
  1725. a.valueOf = b.valueOf;
  1726. }
  1727. return a;
  1728. }
  1729. function createUTC(input, format, locale, strict) {
  1730. return createLocalOrUTC(input, format, locale, strict, true).utc();
  1731. }
  1732. function defaultParsingFlags() {
  1733. // We need to deep clone this object.
  1734. return {
  1735. empty: false,
  1736. unusedTokens: [],
  1737. unusedInput: [],
  1738. overflow: -2,
  1739. charsLeftOver: 0,
  1740. nullInput: false,
  1741. invalidEra: null,
  1742. invalidMonth: null,
  1743. invalidFormat: false,
  1744. userInvalidated: false,
  1745. iso: false,
  1746. parsedDateParts: [],
  1747. era: null,
  1748. meridiem: null,
  1749. rfc2822: false,
  1750. weekdayMismatch: false,
  1751. };
  1752. }
  1753. function getParsingFlags(m) {
  1754. if (m._pf == null) {
  1755. m._pf = defaultParsingFlags();
  1756. }
  1757. return m._pf;
  1758. }
  1759. var some;
  1760. if (Array.prototype.some) {
  1761. some = Array.prototype.some;
  1762. } else {
  1763. some = function (fun) {
  1764. var t = Object(this),
  1765. len = t.length >>> 0,
  1766. i;
  1767. for (i = 0; i < len; i++) {
  1768. if (i in t && fun.call(this, t[i], i, t)) {
  1769. return true;
  1770. }
  1771. }
  1772. return false;
  1773. };
  1774. }
  1775. function isValid(m) {
  1776. if (m._isValid == null) {
  1777. var flags = getParsingFlags(m),
  1778. parsedParts = some.call(flags.parsedDateParts, function (i) {
  1779. return i != null;
  1780. }),
  1781. isNowValid =
  1782. !isNaN(m._d.getTime()) &&
  1783. flags.overflow < 0 &&
  1784. !flags.empty &&
  1785. !flags.invalidEra &&
  1786. !flags.invalidMonth &&
  1787. !flags.invalidWeekday &&
  1788. !flags.weekdayMismatch &&
  1789. !flags.nullInput &&
  1790. !flags.invalidFormat &&
  1791. !flags.userInvalidated &&
  1792. (!flags.meridiem || (flags.meridiem && parsedParts));
  1793. if (m._strict) {
  1794. isNowValid =
  1795. isNowValid &&
  1796. flags.charsLeftOver === 0 &&
  1797. flags.unusedTokens.length === 0 &&
  1798. flags.bigHour === undefined;
  1799. }
  1800. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  1801. m._isValid = isNowValid;
  1802. } else {
  1803. return isNowValid;
  1804. }
  1805. }
  1806. return m._isValid;
  1807. }
  1808. function createInvalid(flags) {
  1809. var m = createUTC(NaN);
  1810. if (flags != null) {
  1811. extend(getParsingFlags(m), flags);
  1812. } else {
  1813. getParsingFlags(m).userInvalidated = true;
  1814. }
  1815. return m;
  1816. }
  1817. // Plugins that add properties should also add the key here (null value),
  1818. // so we can properly clone ourselves.
  1819. var momentProperties = (hooks.momentProperties = []),
  1820. updateInProgress = false;
  1821. function copyConfig(to, from) {
  1822. var i, prop, val;
  1823. if (!isUndefined(from._isAMomentObject)) {
  1824. to._isAMomentObject = from._isAMomentObject;
  1825. }
  1826. if (!isUndefined(from._i)) {
  1827. to._i = from._i;
  1828. }
  1829. if (!isUndefined(from._f)) {
  1830. to._f = from._f;
  1831. }
  1832. if (!isUndefined(from._l)) {
  1833. to._l = from._l;
  1834. }
  1835. if (!isUndefined(from._strict)) {
  1836. to._strict = from._strict;
  1837. }
  1838. if (!isUndefined(from._tzm)) {
  1839. to._tzm = from._tzm;
  1840. }
  1841. if (!isUndefined(from._isUTC)) {
  1842. to._isUTC = from._isUTC;
  1843. }
  1844. if (!isUndefined(from._offset)) {
  1845. to._offset = from._offset;
  1846. }
  1847. if (!isUndefined(from._pf)) {
  1848. to._pf = getParsingFlags(from);
  1849. }
  1850. if (!isUndefined(from._locale)) {
  1851. to._locale = from._locale;
  1852. }
  1853. if (momentProperties.length > 0) {
  1854. for (i = 0; i < momentProperties.length; i++) {
  1855. prop = momentProperties[i];
  1856. val = from[prop];
  1857. if (!isUndefined(val)) {
  1858. to[prop] = val;
  1859. }
  1860. }
  1861. }
  1862. return to;
  1863. }
  1864. // Moment prototype object
  1865. function Moment(config) {
  1866. copyConfig(this, config);
  1867. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  1868. if (!this.isValid()) {
  1869. this._d = new Date(NaN);
  1870. }
  1871. // Prevent infinite loop in case updateOffset creates new moment
  1872. // objects.
  1873. if (updateInProgress === false) {
  1874. updateInProgress = true;
  1875. hooks.updateOffset(this);
  1876. updateInProgress = false;
  1877. }
  1878. }
  1879. function isMoment(obj) {
  1880. return (
  1881. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  1882. );
  1883. }
  1884. function warn(msg) {
  1885. if (
  1886. hooks.suppressDeprecationWarnings === false &&
  1887. typeof console !== 'undefined' &&
  1888. console.warn
  1889. ) {
  1890. console.warn('Deprecation warning: ' + msg);
  1891. }
  1892. }
  1893. function deprecate(msg, fn) {
  1894. var firstTime = true;
  1895. return extend(function () {
  1896. if (hooks.deprecationHandler != null) {
  1897. hooks.deprecationHandler(null, msg);
  1898. }
  1899. if (firstTime) {
  1900. var args = [],
  1901. arg,
  1902. i,
  1903. key;
  1904. for (i = 0; i < arguments.length; i++) {
  1905. arg = '';
  1906. if (typeof arguments[i] === 'object') {
  1907. arg += '\n[' + i + '] ';
  1908. for (key in arguments[0]) {
  1909. if (hasOwnProp(arguments[0], key)) {
  1910. arg += key + ': ' + arguments[0][key] + ', ';
  1911. }
  1912. }
  1913. arg = arg.slice(0, -2); // Remove trailing comma and space
  1914. } else {
  1915. arg = arguments[i];
  1916. }
  1917. args.push(arg);
  1918. }
  1919. warn(
  1920. msg +
  1921. '\nArguments: ' +
  1922. Array.prototype.slice.call(args).join('') +
  1923. '\n' +
  1924. new Error().stack
  1925. );
  1926. firstTime = false;
  1927. }
  1928. return fn.apply(this, arguments);
  1929. }, fn);
  1930. }
  1931. var deprecations = {};
  1932. function deprecateSimple(name, msg) {
  1933. if (hooks.deprecationHandler != null) {
  1934. hooks.deprecationHandler(name, msg);
  1935. }
  1936. if (!deprecations[name]) {
  1937. warn(msg);
  1938. deprecations[name] = true;
  1939. }
  1940. }
  1941. hooks.suppressDeprecationWarnings = false;
  1942. hooks.deprecationHandler = null;
  1943. function isFunction(input) {
  1944. return (
  1945. (typeof Function !== 'undefined' && input instanceof Function) ||
  1946. Object.prototype.toString.call(input) === '[object Function]'
  1947. );
  1948. }
  1949. function set(config) {
  1950. var prop, i;
  1951. for (i in config) {
  1952. if (hasOwnProp(config, i)) {
  1953. prop = config[i];
  1954. if (isFunction(prop)) {
  1955. this[i] = prop;
  1956. } else {
  1957. this['_' + i] = prop;
  1958. }
  1959. }
  1960. }
  1961. this._config = config;
  1962. // Lenient ordinal parsing accepts just a number in addition to
  1963. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  1964. // TODO: Remove "ordinalParse" fallback in next major release.
  1965. this._dayOfMonthOrdinalParseLenient = new RegExp(
  1966. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  1967. '|' +
  1968. /\d{1,2}/.source
  1969. );
  1970. }
  1971. function mergeConfigs(parentConfig, childConfig) {
  1972. var res = extend({}, parentConfig),
  1973. prop;
  1974. for (prop in childConfig) {
  1975. if (hasOwnProp(childConfig, prop)) {
  1976. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  1977. res[prop] = {};
  1978. extend(res[prop], parentConfig[prop]);
  1979. extend(res[prop], childConfig[prop]);
  1980. } else if (childConfig[prop] != null) {
  1981. res[prop] = childConfig[prop];
  1982. } else {
  1983. delete res[prop];
  1984. }
  1985. }
  1986. }
  1987. for (prop in parentConfig) {
  1988. if (
  1989. hasOwnProp(parentConfig, prop) &&
  1990. !hasOwnProp(childConfig, prop) &&
  1991. isObject(parentConfig[prop])
  1992. ) {
  1993. // make sure changes to properties don't modify parent config
  1994. res[prop] = extend({}, res[prop]);
  1995. }
  1996. }
  1997. return res;
  1998. }
  1999. function Locale(config) {
  2000. if (config != null) {
  2001. this.set(config);
  2002. }
  2003. }
  2004. var keys;
  2005. if (Object.keys) {
  2006. keys = Object.keys;
  2007. } else {
  2008. keys = function (obj) {
  2009. var i,
  2010. res = [];
  2011. for (i in obj) {
  2012. if (hasOwnProp(obj, i)) {
  2013. res.push(i);
  2014. }
  2015. }
  2016. return res;
  2017. };
  2018. }
  2019. var defaultCalendar = {
  2020. sameDay: '[Today at] LT',
  2021. nextDay: '[Tomorrow at] LT',
  2022. nextWeek: 'dddd [at] LT',
  2023. lastDay: '[Yesterday at] LT',
  2024. lastWeek: '[Last] dddd [at] LT',
  2025. sameElse: 'L',
  2026. };
  2027. function calendar(key, mom, now) {
  2028. var output = this._calendar[key] || this._calendar['sameElse'];
  2029. return isFunction(output) ? output.call(mom, now) : output;
  2030. }
  2031. function zeroFill(number, targetLength, forceSign) {
  2032. var absNumber = '' + Math.abs(number),
  2033. zerosToFill = targetLength - absNumber.length,
  2034. sign = number >= 0;
  2035. return (
  2036. (sign ? (forceSign ? '+' : '') : '-') +
  2037. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  2038. absNumber
  2039. );
  2040. }
  2041. var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
  2042. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  2043. formatFunctions = {},
  2044. formatTokenFunctions = {};
  2045. // token: 'M'
  2046. // padded: ['MM', 2]
  2047. // ordinal: 'Mo'
  2048. // callback: function () { this.month() + 1 }
  2049. function addFormatToken(token, padded, ordinal, callback) {
  2050. var func = callback;
  2051. if (typeof callback === 'string') {
  2052. func = function () {
  2053. return this[callback]();
  2054. };
  2055. }
  2056. if (token) {
  2057. formatTokenFunctions[token] = func;
  2058. }
  2059. if (padded) {
  2060. formatTokenFunctions[padded[0]] = function () {
  2061. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  2062. };
  2063. }
  2064. if (ordinal) {
  2065. formatTokenFunctions[ordinal] = function () {
  2066. return this.localeData().ordinal(
  2067. func.apply(this, arguments),
  2068. token
  2069. );
  2070. };
  2071. }
  2072. }
  2073. function removeFormattingTokens(input) {
  2074. if (input.match(/\[[\s\S]/)) {
  2075. return input.replace(/^\[|\]$/g, '');
  2076. }
  2077. return input.replace(/\\/g, '');
  2078. }
  2079. function makeFormatFunction(format) {
  2080. var array = format.match(formattingTokens),
  2081. i,
  2082. length;
  2083. for (i = 0, length = array.length; i < length; i++) {
  2084. if (formatTokenFunctions[array[i]]) {
  2085. array[i] = formatTokenFunctions[array[i]];
  2086. } else {
  2087. array[i] = removeFormattingTokens(array[i]);
  2088. }
  2089. }
  2090. return function (mom) {
  2091. var output = '',
  2092. i;
  2093. for (i = 0; i < length; i++) {
  2094. output += isFunction(array[i])
  2095. ? array[i].call(mom, format)
  2096. : array[i];
  2097. }
  2098. return output;
  2099. };
  2100. }
  2101. // format date using native date object
  2102. function formatMoment(m, format) {
  2103. if (!m.isValid()) {
  2104. return m.localeData().invalidDate();
  2105. }
  2106. format = expandFormat(format, m.localeData());
  2107. formatFunctions[format] =
  2108. formatFunctions[format] || makeFormatFunction(format);
  2109. return formatFunctions[format](m);
  2110. }
  2111. function expandFormat(format, locale) {
  2112. var i = 5;
  2113. function replaceLongDateFormatTokens(input) {
  2114. return locale.longDateFormat(input) || input;
  2115. }
  2116. localFormattingTokens.lastIndex = 0;
  2117. while (i >= 0 && localFormattingTokens.test(format)) {
  2118. format = format.replace(
  2119. localFormattingTokens,
  2120. replaceLongDateFormatTokens
  2121. );
  2122. localFormattingTokens.lastIndex = 0;
  2123. i -= 1;
  2124. }
  2125. return format;
  2126. }
  2127. var defaultLongDateFormat = {
  2128. LTS: 'h:mm:ss A',
  2129. LT: 'h:mm A',
  2130. L: 'MM/DD/YYYY',
  2131. LL: 'MMMM D, YYYY',
  2132. LLL: 'MMMM D, YYYY h:mm A',
  2133. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  2134. };
  2135. function longDateFormat(key) {
  2136. var format = this._longDateFormat[key],
  2137. formatUpper = this._longDateFormat[key.toUpperCase()];
  2138. if (format || !formatUpper) {
  2139. return format;
  2140. }
  2141. this._longDateFormat[key] = formatUpper
  2142. .match(formattingTokens)
  2143. .map(function (tok) {
  2144. if (
  2145. tok === 'MMMM' ||
  2146. tok === 'MM' ||
  2147. tok === 'DD' ||
  2148. tok === 'dddd'
  2149. ) {
  2150. return tok.slice(1);
  2151. }
  2152. return tok;
  2153. })
  2154. .join('');
  2155. return this._longDateFormat[key];
  2156. }
  2157. var defaultInvalidDate = 'Invalid date';
  2158. function invalidDate() {
  2159. return this._invalidDate;
  2160. }
  2161. var defaultOrdinal = '%d',
  2162. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  2163. function ordinal(number) {
  2164. return this._ordinal.replace('%d', number);
  2165. }
  2166. var defaultRelativeTime = {
  2167. future: 'in %s',
  2168. past: '%s ago',
  2169. s: 'a few seconds',
  2170. ss: '%d seconds',
  2171. m: 'a minute',
  2172. mm: '%d minutes',
  2173. h: 'an hour',
  2174. hh: '%d hours',
  2175. d: 'a day',
  2176. dd: '%d days',
  2177. w: 'a week',
  2178. ww: '%d weeks',
  2179. M: 'a month',
  2180. MM: '%d months',
  2181. y: 'a year',
  2182. yy: '%d years',
  2183. };
  2184. function relativeTime(number, withoutSuffix, string, isFuture) {
  2185. var output = this._relativeTime[string];
  2186. return isFunction(output)
  2187. ? output(number, withoutSuffix, string, isFuture)
  2188. : output.replace(/%d/i, number);
  2189. }
  2190. function pastFuture(diff, output) {
  2191. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  2192. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  2193. }
  2194. var aliases = {};
  2195. function addUnitAlias(unit, shorthand) {
  2196. var lowerCase = unit.toLowerCase();
  2197. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  2198. }
  2199. function normalizeUnits(units) {
  2200. return typeof units === 'string'
  2201. ? aliases[units] || aliases[units.toLowerCase()]
  2202. : undefined;
  2203. }
  2204. function normalizeObjectUnits(inputObject) {
  2205. var normalizedInput = {},
  2206. normalizedProp,
  2207. prop;
  2208. for (prop in inputObject) {
  2209. if (hasOwnProp(inputObject, prop)) {
  2210. normalizedProp = normalizeUnits(prop);
  2211. if (normalizedProp) {
  2212. normalizedInput[normalizedProp] = inputObject[prop];
  2213. }
  2214. }
  2215. }
  2216. return normalizedInput;
  2217. }
  2218. var priorities = {};
  2219. function addUnitPriority(unit, priority) {
  2220. priorities[unit] = priority;
  2221. }
  2222. function getPrioritizedUnits(unitsObj) {
  2223. var units = [],
  2224. u;
  2225. for (u in unitsObj) {
  2226. if (hasOwnProp(unitsObj, u)) {
  2227. units.push({ unit: u, priority: priorities[u] });
  2228. }
  2229. }
  2230. units.sort(function (a, b) {
  2231. return a.priority - b.priority;
  2232. });
  2233. return units;
  2234. }
  2235. function isLeapYear(year) {
  2236. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  2237. }
  2238. function absFloor(number) {
  2239. if (number < 0) {
  2240. // -0 -> 0
  2241. return Math.ceil(number) || 0;
  2242. } else {
  2243. return Math.floor(number);
  2244. }
  2245. }
  2246. function toInt(argumentForCoercion) {
  2247. var coercedNumber = +argumentForCoercion,
  2248. value = 0;
  2249. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  2250. value = absFloor(coercedNumber);
  2251. }
  2252. return value;
  2253. }
  2254. function makeGetSet(unit, keepTime) {
  2255. return function (value) {
  2256. if (value != null) {
  2257. set$1(this, unit, value);
  2258. hooks.updateOffset(this, keepTime);
  2259. return this;
  2260. } else {
  2261. return get(this, unit);
  2262. }
  2263. };
  2264. }
  2265. function get(mom, unit) {
  2266. return mom.isValid()
  2267. ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
  2268. : NaN;
  2269. }
  2270. function set$1(mom, unit, value) {
  2271. if (mom.isValid() && !isNaN(value)) {
  2272. if (
  2273. unit === 'FullYear' &&
  2274. isLeapYear(mom.year()) &&
  2275. mom.month() === 1 &&
  2276. mom.date() === 29
  2277. ) {
  2278. value = toInt(value);
  2279. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
  2280. value,
  2281. mom.month(),
  2282. daysInMonth(value, mom.month())
  2283. );
  2284. } else {
  2285. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  2286. }
  2287. }
  2288. }
  2289. // MOMENTS
  2290. function stringGet(units) {
  2291. units = normalizeUnits(units);
  2292. if (isFunction(this[units])) {
  2293. return this[units]();
  2294. }
  2295. return this;
  2296. }
  2297. function stringSet(units, value) {
  2298. if (typeof units === 'object') {
  2299. units = normalizeObjectUnits(units);
  2300. var prioritized = getPrioritizedUnits(units),
  2301. i;
  2302. for (i = 0; i < prioritized.length; i++) {
  2303. this[prioritized[i].unit](units[prioritized[i].unit]);
  2304. }
  2305. } else {
  2306. units = normalizeUnits(units);
  2307. if (isFunction(this[units])) {
  2308. return this[units](value);
  2309. }
  2310. }
  2311. return this;
  2312. }
  2313. var match1 = /\d/, // 0 - 9
  2314. match2 = /\d\d/, // 00 - 99
  2315. match3 = /\d{3}/, // 000 - 999
  2316. match4 = /\d{4}/, // 0000 - 9999
  2317. match6 = /[+-]?\d{6}/, // -999999 - 999999
  2318. match1to2 = /\d\d?/, // 0 - 99
  2319. match3to4 = /\d\d\d\d?/, // 999 - 9999
  2320. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  2321. match1to3 = /\d{1,3}/, // 0 - 999
  2322. match1to4 = /\d{1,4}/, // 0 - 9999
  2323. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  2324. matchUnsigned = /\d+/, // 0 - inf
  2325. matchSigned = /[+-]?\d+/, // -inf - inf
  2326. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  2327. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  2328. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  2329. // any word (or two) characters or numbers including two/three word month in arabic.
  2330. // includes scottish gaelic two word and hyphenated months
  2331. matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
  2332. regexes;
  2333. regexes = {};
  2334. function addRegexToken(token, regex, strictRegex) {
  2335. regexes[token] = isFunction(regex)
  2336. ? regex
  2337. : function (isStrict, localeData) {
  2338. return isStrict && strictRegex ? strictRegex : regex;
  2339. };
  2340. }
  2341. function getParseRegexForToken(token, config) {
  2342. if (!hasOwnProp(regexes, token)) {
  2343. return new RegExp(unescapeFormat(token));
  2344. }
  2345. return regexes[token](config._strict, config._locale);
  2346. }
  2347. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  2348. function unescapeFormat(s) {
  2349. return regexEscape(
  2350. s
  2351. .replace('\\', '')
  2352. .replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (
  2353. matched,
  2354. p1,
  2355. p2,
  2356. p3,
  2357. p4
  2358. ) {
  2359. return p1 || p2 || p3 || p4;
  2360. })
  2361. );
  2362. }
  2363. function regexEscape(s) {
  2364. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  2365. }
  2366. var tokens = {};
  2367. function addParseToken(token, callback) {
  2368. var i,
  2369. func = callback;
  2370. if (typeof token === 'string') {
  2371. token = [token];
  2372. }
  2373. if (isNumber(callback)) {
  2374. func = function (input, array) {
  2375. array[callback] = toInt(input);
  2376. };
  2377. }
  2378. for (i = 0; i < token.length; i++) {
  2379. tokens[token[i]] = func;
  2380. }
  2381. }
  2382. function addWeekParseToken(token, callback) {
  2383. addParseToken(token, function (input, array, config, token) {
  2384. config._w = config._w || {};
  2385. callback(input, config._w, config, token);
  2386. });
  2387. }
  2388. function addTimeToArrayFromToken(token, input, config) {
  2389. if (input != null && hasOwnProp(tokens, token)) {
  2390. tokens[token](input, config._a, config, token);
  2391. }
  2392. }
  2393. var YEAR = 0,
  2394. MONTH = 1,
  2395. DATE = 2,
  2396. HOUR = 3,
  2397. MINUTE = 4,
  2398. SECOND = 5,
  2399. MILLISECOND = 6,
  2400. WEEK = 7,
  2401. WEEKDAY = 8;
  2402. function mod(n, x) {
  2403. return ((n % x) + x) % x;
  2404. }
  2405. var indexOf;
  2406. if (Array.prototype.indexOf) {
  2407. indexOf = Array.prototype.indexOf;
  2408. } else {
  2409. indexOf = function (o) {
  2410. // I know
  2411. var i;
  2412. for (i = 0; i < this.length; ++i) {
  2413. if (this[i] === o) {
  2414. return i;
  2415. }
  2416. }
  2417. return -1;
  2418. };
  2419. }
  2420. function daysInMonth(year, month) {
  2421. if (isNaN(year) || isNaN(month)) {
  2422. return NaN;
  2423. }
  2424. var modMonth = mod(month, 12);
  2425. year += (month - modMonth) / 12;
  2426. return modMonth === 1
  2427. ? isLeapYear(year)
  2428. ? 29
  2429. : 28
  2430. : 31 - ((modMonth % 7) % 2);
  2431. }
  2432. // FORMATTING
  2433. addFormatToken('M', ['MM', 2], 'Mo', function () {
  2434. return this.month() + 1;
  2435. });
  2436. addFormatToken('MMM', 0, 0, function (format) {
  2437. return this.localeData().monthsShort(this, format);
  2438. });
  2439. addFormatToken('MMMM', 0, 0, function (format) {
  2440. return this.localeData().months(this, format);
  2441. });
  2442. // ALIASES
  2443. addUnitAlias('month', 'M');
  2444. // PRIORITY
  2445. addUnitPriority('month', 8);
  2446. // PARSING
  2447. addRegexToken('M', match1to2);
  2448. addRegexToken('MM', match1to2, match2);
  2449. addRegexToken('MMM', function (isStrict, locale) {
  2450. return locale.monthsShortRegex(isStrict);
  2451. });
  2452. addRegexToken('MMMM', function (isStrict, locale) {
  2453. return locale.monthsRegex(isStrict);
  2454. });
  2455. addParseToken(['M', 'MM'], function (input, array) {
  2456. array[MONTH] = toInt(input) - 1;
  2457. });
  2458. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  2459. var month = config._locale.monthsParse(input, token, config._strict);
  2460. // if we didn't find a month name, mark the date as invalid.
  2461. if (month != null) {
  2462. array[MONTH] = month;
  2463. } else {
  2464. getParsingFlags(config).invalidMonth = input;
  2465. }
  2466. });
  2467. // LOCALES
  2468. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  2469. '_'
  2470. ),
  2471. defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(
  2472. '_'
  2473. ),
  2474. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  2475. defaultMonthsShortRegex = matchWord,
  2476. defaultMonthsRegex = matchWord;
  2477. function localeMonths(m, format) {
  2478. if (!m) {
  2479. return isArray(this._months)
  2480. ? this._months
  2481. : this._months['standalone'];
  2482. }
  2483. return isArray(this._months)
  2484. ? this._months[m.month()]
  2485. : this._months[
  2486. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  2487. ? 'format'
  2488. : 'standalone'
  2489. ][m.month()];
  2490. }
  2491. function localeMonthsShort(m, format) {
  2492. if (!m) {
  2493. return isArray(this._monthsShort)
  2494. ? this._monthsShort
  2495. : this._monthsShort['standalone'];
  2496. }
  2497. return isArray(this._monthsShort)
  2498. ? this._monthsShort[m.month()]
  2499. : this._monthsShort[
  2500. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  2501. ][m.month()];
  2502. }
  2503. function handleStrictParse(monthName, format, strict) {
  2504. var i,
  2505. ii,
  2506. mom,
  2507. llc = monthName.toLocaleLowerCase();
  2508. if (!this._monthsParse) {
  2509. // this is not used
  2510. this._monthsParse = [];
  2511. this._longMonthsParse = [];
  2512. this._shortMonthsParse = [];
  2513. for (i = 0; i < 12; ++i) {
  2514. mom = createUTC([2000, i]);
  2515. this._shortMonthsParse[i] = this.monthsShort(
  2516. mom,
  2517. ''
  2518. ).toLocaleLowerCase();
  2519. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  2520. }
  2521. }
  2522. if (strict) {
  2523. if (format === 'MMM') {
  2524. ii = indexOf.call(this._shortMonthsParse, llc);
  2525. return ii !== -1 ? ii : null;
  2526. } else {
  2527. ii = indexOf.call(this._longMonthsParse, llc);
  2528. return ii !== -1 ? ii : null;
  2529. }
  2530. } else {
  2531. if (format === 'MMM') {
  2532. ii = indexOf.call(this._shortMonthsParse, llc);
  2533. if (ii !== -1) {
  2534. return ii;
  2535. }
  2536. ii = indexOf.call(this._longMonthsParse, llc);
  2537. return ii !== -1 ? ii : null;
  2538. } else {
  2539. ii = indexOf.call(this._longMonthsParse, llc);
  2540. if (ii !== -1) {
  2541. return ii;
  2542. }
  2543. ii = indexOf.call(this._shortMonthsParse, llc);
  2544. return ii !== -1 ? ii : null;
  2545. }
  2546. }
  2547. }
  2548. function localeMonthsParse(monthName, format, strict) {
  2549. var i, mom, regex;
  2550. if (this._monthsParseExact) {
  2551. return handleStrictParse.call(this, monthName, format, strict);
  2552. }
  2553. if (!this._monthsParse) {
  2554. this._monthsParse = [];
  2555. this._longMonthsParse = [];
  2556. this._shortMonthsParse = [];
  2557. }
  2558. // TODO: add sorting
  2559. // Sorting makes sure if one month (or abbr) is a prefix of another
  2560. // see sorting in computeMonthsParse
  2561. for (i = 0; i < 12; i++) {
  2562. // make the regex if we don't have it already
  2563. mom = createUTC([2000, i]);
  2564. if (strict && !this._longMonthsParse[i]) {
  2565. this._longMonthsParse[i] = new RegExp(
  2566. '^' + this.months(mom, '').replace('.', '') + '$',
  2567. 'i'
  2568. );
  2569. this._shortMonthsParse[i] = new RegExp(
  2570. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  2571. 'i'
  2572. );
  2573. }
  2574. if (!strict && !this._monthsParse[i]) {
  2575. regex =
  2576. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  2577. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2578. }
  2579. // test the regex
  2580. if (
  2581. strict &&
  2582. format === 'MMMM' &&
  2583. this._longMonthsParse[i].test(monthName)
  2584. ) {
  2585. return i;
  2586. } else if (
  2587. strict &&
  2588. format === 'MMM' &&
  2589. this._shortMonthsParse[i].test(monthName)
  2590. ) {
  2591. return i;
  2592. } else if (!strict && this._monthsParse[i].test(monthName)) {
  2593. return i;
  2594. }
  2595. }
  2596. }
  2597. // MOMENTS
  2598. function setMonth(mom, value) {
  2599. var dayOfMonth;
  2600. if (!mom.isValid()) {
  2601. // No op
  2602. return mom;
  2603. }
  2604. if (typeof value === 'string') {
  2605. if (/^\d+$/.test(value)) {
  2606. value = toInt(value);
  2607. } else {
  2608. value = mom.localeData().monthsParse(value);
  2609. // TODO: Another silent failure?
  2610. if (!isNumber(value)) {
  2611. return mom;
  2612. }
  2613. }
  2614. }
  2615. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  2616. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  2617. return mom;
  2618. }
  2619. function getSetMonth(value) {
  2620. if (value != null) {
  2621. setMonth(this, value);
  2622. hooks.updateOffset(this, true);
  2623. return this;
  2624. } else {
  2625. return get(this, 'Month');
  2626. }
  2627. }
  2628. function getDaysInMonth() {
  2629. return daysInMonth(this.year(), this.month());
  2630. }
  2631. function monthsShortRegex(isStrict) {
  2632. if (this._monthsParseExact) {
  2633. if (!hasOwnProp(this, '_monthsRegex')) {
  2634. computeMonthsParse.call(this);
  2635. }
  2636. if (isStrict) {
  2637. return this._monthsShortStrictRegex;
  2638. } else {
  2639. return this._monthsShortRegex;
  2640. }
  2641. } else {
  2642. if (!hasOwnProp(this, '_monthsShortRegex')) {
  2643. this._monthsShortRegex = defaultMonthsShortRegex;
  2644. }
  2645. return this._monthsShortStrictRegex && isStrict
  2646. ? this._monthsShortStrictRegex
  2647. : this._monthsShortRegex;
  2648. }
  2649. }
  2650. function monthsRegex(isStrict) {
  2651. if (this._monthsParseExact) {
  2652. if (!hasOwnProp(this, '_monthsRegex')) {
  2653. computeMonthsParse.call(this);
  2654. }
  2655. if (isStrict) {
  2656. return this._monthsStrictRegex;
  2657. } else {
  2658. return this._monthsRegex;
  2659. }
  2660. } else {
  2661. if (!hasOwnProp(this, '_monthsRegex')) {
  2662. this._monthsRegex = defaultMonthsRegex;
  2663. }
  2664. return this._monthsStrictRegex && isStrict
  2665. ? this._monthsStrictRegex
  2666. : this._monthsRegex;
  2667. }
  2668. }
  2669. function computeMonthsParse() {
  2670. function cmpLenRev(a, b) {
  2671. return b.length - a.length;
  2672. }
  2673. var shortPieces = [],
  2674. longPieces = [],
  2675. mixedPieces = [],
  2676. i,
  2677. mom;
  2678. for (i = 0; i < 12; i++) {
  2679. // make the regex if we don't have it already
  2680. mom = createUTC([2000, i]);
  2681. shortPieces.push(this.monthsShort(mom, ''));
  2682. longPieces.push(this.months(mom, ''));
  2683. mixedPieces.push(this.months(mom, ''));
  2684. mixedPieces.push(this.monthsShort(mom, ''));
  2685. }
  2686. // Sorting makes sure if one month (or abbr) is a prefix of another it
  2687. // will match the longer piece.
  2688. shortPieces.sort(cmpLenRev);
  2689. longPieces.sort(cmpLenRev);
  2690. mixedPieces.sort(cmpLenRev);
  2691. for (i = 0; i < 12; i++) {
  2692. shortPieces[i] = regexEscape(shortPieces[i]);
  2693. longPieces[i] = regexEscape(longPieces[i]);
  2694. }
  2695. for (i = 0; i < 24; i++) {
  2696. mixedPieces[i] = regexEscape(mixedPieces[i]);
  2697. }
  2698. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2699. this._monthsShortRegex = this._monthsRegex;
  2700. this._monthsStrictRegex = new RegExp(
  2701. '^(' + longPieces.join('|') + ')',
  2702. 'i'
  2703. );
  2704. this._monthsShortStrictRegex = new RegExp(
  2705. '^(' + shortPieces.join('|') + ')',
  2706. 'i'
  2707. );
  2708. }
  2709. // FORMATTING
  2710. addFormatToken('Y', 0, 0, function () {
  2711. var y = this.year();
  2712. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  2713. });
  2714. addFormatToken(0, ['YY', 2], 0, function () {
  2715. return this.year() % 100;
  2716. });
  2717. addFormatToken(0, ['YYYY', 4], 0, 'year');
  2718. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  2719. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  2720. // ALIASES
  2721. addUnitAlias('year', 'y');
  2722. // PRIORITIES
  2723. addUnitPriority('year', 1);
  2724. // PARSING
  2725. addRegexToken('Y', matchSigned);
  2726. addRegexToken('YY', match1to2, match2);
  2727. addRegexToken('YYYY', match1to4, match4);
  2728. addRegexToken('YYYYY', match1to6, match6);
  2729. addRegexToken('YYYYYY', match1to6, match6);
  2730. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  2731. addParseToken('YYYY', function (input, array) {
  2732. array[YEAR] =
  2733. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  2734. });
  2735. addParseToken('YY', function (input, array) {
  2736. array[YEAR] = hooks.parseTwoDigitYear(input);
  2737. });
  2738. addParseToken('Y', function (input, array) {
  2739. array[YEAR] = parseInt(input, 10);
  2740. });
  2741. // HELPERS
  2742. function daysInYear(year) {
  2743. return isLeapYear(year) ? 366 : 365;
  2744. }
  2745. // HOOKS
  2746. hooks.parseTwoDigitYear = function (input) {
  2747. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  2748. };
  2749. // MOMENTS
  2750. var getSetYear = makeGetSet('FullYear', true);
  2751. function getIsLeapYear() {
  2752. return isLeapYear(this.year());
  2753. }
  2754. function createDate(y, m, d, h, M, s, ms) {
  2755. // can't just apply() to create a date:
  2756. // https://stackoverflow.com/q/181348
  2757. var date;
  2758. // the date constructor remaps years 0-99 to 1900-1999
  2759. if (y < 100 && y >= 0) {
  2760. // preserve leap years using a full 400 year cycle, then reset
  2761. date = new Date(y + 400, m, d, h, M, s, ms);
  2762. if (isFinite(date.getFullYear())) {
  2763. date.setFullYear(y);
  2764. }
  2765. } else {
  2766. date = new Date(y, m, d, h, M, s, ms);
  2767. }
  2768. return date;
  2769. }
  2770. function createUTCDate(y) {
  2771. var date, args;
  2772. // the Date.UTC function remaps years 0-99 to 1900-1999
  2773. if (y < 100 && y >= 0) {
  2774. args = Array.prototype.slice.call(arguments);
  2775. // preserve leap years using a full 400 year cycle, then reset
  2776. args[0] = y + 400;
  2777. date = new Date(Date.UTC.apply(null, args));
  2778. if (isFinite(date.getUTCFullYear())) {
  2779. date.setUTCFullYear(y);
  2780. }
  2781. } else {
  2782. date = new Date(Date.UTC.apply(null, arguments));
  2783. }
  2784. return date;
  2785. }
  2786. // start-of-first-week - start-of-year
  2787. function firstWeekOffset(year, dow, doy) {
  2788. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  2789. fwd = 7 + dow - doy,
  2790. // first-week day local weekday -- which local weekday is fwd
  2791. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  2792. return -fwdlw + fwd - 1;
  2793. }
  2794. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  2795. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  2796. var localWeekday = (7 + weekday - dow) % 7,
  2797. weekOffset = firstWeekOffset(year, dow, doy),
  2798. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  2799. resYear,
  2800. resDayOfYear;
  2801. if (dayOfYear <= 0) {
  2802. resYear = year - 1;
  2803. resDayOfYear = daysInYear(resYear) + dayOfYear;
  2804. } else if (dayOfYear > daysInYear(year)) {
  2805. resYear = year + 1;
  2806. resDayOfYear = dayOfYear - daysInYear(year);
  2807. } else {
  2808. resYear = year;
  2809. resDayOfYear = dayOfYear;
  2810. }
  2811. return {
  2812. year: resYear,
  2813. dayOfYear: resDayOfYear,
  2814. };
  2815. }
  2816. function weekOfYear(mom, dow, doy) {
  2817. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  2818. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  2819. resWeek,
  2820. resYear;
  2821. if (week < 1) {
  2822. resYear = mom.year() - 1;
  2823. resWeek = week + weeksInYear(resYear, dow, doy);
  2824. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  2825. resWeek = week - weeksInYear(mom.year(), dow, doy);
  2826. resYear = mom.year() + 1;
  2827. } else {
  2828. resYear = mom.year();
  2829. resWeek = week;
  2830. }
  2831. return {
  2832. week: resWeek,
  2833. year: resYear,
  2834. };
  2835. }
  2836. function weeksInYear(year, dow, doy) {
  2837. var weekOffset = firstWeekOffset(year, dow, doy),
  2838. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  2839. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  2840. }
  2841. // FORMATTING
  2842. addFormatToken('w', ['ww', 2], 'wo', 'week');
  2843. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  2844. // ALIASES
  2845. addUnitAlias('week', 'w');
  2846. addUnitAlias('isoWeek', 'W');
  2847. // PRIORITIES
  2848. addUnitPriority('week', 5);
  2849. addUnitPriority('isoWeek', 5);
  2850. // PARSING
  2851. addRegexToken('w', match1to2);
  2852. addRegexToken('ww', match1to2, match2);
  2853. addRegexToken('W', match1to2);
  2854. addRegexToken('WW', match1to2, match2);
  2855. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (
  2856. input,
  2857. week,
  2858. config,
  2859. token
  2860. ) {
  2861. week[token.substr(0, 1)] = toInt(input);
  2862. });
  2863. // HELPERS
  2864. // LOCALES
  2865. function localeWeek(mom) {
  2866. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  2867. }
  2868. var defaultLocaleWeek = {
  2869. dow: 0, // Sunday is the first day of the week.
  2870. doy: 6, // The week that contains Jan 6th is the first week of the year.
  2871. };
  2872. function localeFirstDayOfWeek() {
  2873. return this._week.dow;
  2874. }
  2875. function localeFirstDayOfYear() {
  2876. return this._week.doy;
  2877. }
  2878. // MOMENTS
  2879. function getSetWeek(input) {
  2880. var week = this.localeData().week(this);
  2881. return input == null ? week : this.add((input - week) * 7, 'd');
  2882. }
  2883. function getSetISOWeek(input) {
  2884. var week = weekOfYear(this, 1, 4).week;
  2885. return input == null ? week : this.add((input - week) * 7, 'd');
  2886. }
  2887. // FORMATTING
  2888. addFormatToken('d', 0, 'do', 'day');
  2889. addFormatToken('dd', 0, 0, function (format) {
  2890. return this.localeData().weekdaysMin(this, format);
  2891. });
  2892. addFormatToken('ddd', 0, 0, function (format) {
  2893. return this.localeData().weekdaysShort(this, format);
  2894. });
  2895. addFormatToken('dddd', 0, 0, function (format) {
  2896. return this.localeData().weekdays(this, format);
  2897. });
  2898. addFormatToken('e', 0, 0, 'weekday');
  2899. addFormatToken('E', 0, 0, 'isoWeekday');
  2900. // ALIASES
  2901. addUnitAlias('day', 'd');
  2902. addUnitAlias('weekday', 'e');
  2903. addUnitAlias('isoWeekday', 'E');
  2904. // PRIORITY
  2905. addUnitPriority('day', 11);
  2906. addUnitPriority('weekday', 11);
  2907. addUnitPriority('isoWeekday', 11);
  2908. // PARSING
  2909. addRegexToken('d', match1to2);
  2910. addRegexToken('e', match1to2);
  2911. addRegexToken('E', match1to2);
  2912. addRegexToken('dd', function (isStrict, locale) {
  2913. return locale.weekdaysMinRegex(isStrict);
  2914. });
  2915. addRegexToken('ddd', function (isStrict, locale) {
  2916. return locale.weekdaysShortRegex(isStrict);
  2917. });
  2918. addRegexToken('dddd', function (isStrict, locale) {
  2919. return locale.weekdaysRegex(isStrict);
  2920. });
  2921. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  2922. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  2923. // if we didn't get a weekday name, mark the date as invalid
  2924. if (weekday != null) {
  2925. week.d = weekday;
  2926. } else {
  2927. getParsingFlags(config).invalidWeekday = input;
  2928. }
  2929. });
  2930. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  2931. week[token] = toInt(input);
  2932. });
  2933. // HELPERS
  2934. function parseWeekday(input, locale) {
  2935. if (typeof input !== 'string') {
  2936. return input;
  2937. }
  2938. if (!isNaN(input)) {
  2939. return parseInt(input, 10);
  2940. }
  2941. input = locale.weekdaysParse(input);
  2942. if (typeof input === 'number') {
  2943. return input;
  2944. }
  2945. return null;
  2946. }
  2947. function parseIsoWeekday(input, locale) {
  2948. if (typeof input === 'string') {
  2949. return locale.weekdaysParse(input) % 7 || 7;
  2950. }
  2951. return isNaN(input) ? null : input;
  2952. }
  2953. // LOCALES
  2954. function shiftWeekdays(ws, n) {
  2955. return ws.slice(n, 7).concat(ws.slice(0, n));
  2956. }
  2957. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(
  2958. '_'
  2959. ),
  2960. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  2961. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  2962. defaultWeekdaysRegex = matchWord,
  2963. defaultWeekdaysShortRegex = matchWord,
  2964. defaultWeekdaysMinRegex = matchWord;
  2965. function localeWeekdays(m, format) {
  2966. var weekdays = isArray(this._weekdays)
  2967. ? this._weekdays
  2968. : this._weekdays[
  2969. m && m !== true && this._weekdays.isFormat.test(format)
  2970. ? 'format'
  2971. : 'standalone'
  2972. ];
  2973. return m === true
  2974. ? shiftWeekdays(weekdays, this._week.dow)
  2975. : m
  2976. ? weekdays[m.day()]
  2977. : weekdays;
  2978. }
  2979. function localeWeekdaysShort(m) {
  2980. return m === true
  2981. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  2982. : m
  2983. ? this._weekdaysShort[m.day()]
  2984. : this._weekdaysShort;
  2985. }
  2986. function localeWeekdaysMin(m) {
  2987. return m === true
  2988. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  2989. : m
  2990. ? this._weekdaysMin[m.day()]
  2991. : this._weekdaysMin;
  2992. }
  2993. function handleStrictParse$1(weekdayName, format, strict) {
  2994. var i,
  2995. ii,
  2996. mom,
  2997. llc = weekdayName.toLocaleLowerCase();
  2998. if (!this._weekdaysParse) {
  2999. this._weekdaysParse = [];
  3000. this._shortWeekdaysParse = [];
  3001. this._minWeekdaysParse = [];
  3002. for (i = 0; i < 7; ++i) {
  3003. mom = createUTC([2000, 1]).day(i);
  3004. this._minWeekdaysParse[i] = this.weekdaysMin(
  3005. mom,
  3006. ''
  3007. ).toLocaleLowerCase();
  3008. this._shortWeekdaysParse[i] = this.weekdaysShort(
  3009. mom,
  3010. ''
  3011. ).toLocaleLowerCase();
  3012. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  3013. }
  3014. }
  3015. if (strict) {
  3016. if (format === 'dddd') {
  3017. ii = indexOf.call(this._weekdaysParse, llc);
  3018. return ii !== -1 ? ii : null;
  3019. } else if (format === 'ddd') {
  3020. ii = indexOf.call(this._shortWeekdaysParse, llc);
  3021. return ii !== -1 ? ii : null;
  3022. } else {
  3023. ii = indexOf.call(this._minWeekdaysParse, llc);
  3024. return ii !== -1 ? ii : null;
  3025. }
  3026. } else {
  3027. if (format === 'dddd') {
  3028. ii = indexOf.call(this._weekdaysParse, llc);
  3029. if (ii !== -1) {
  3030. return ii;
  3031. }
  3032. ii = indexOf.call(this._shortWeekdaysParse, llc);
  3033. if (ii !== -1) {
  3034. return ii;
  3035. }
  3036. ii = indexOf.call(this._minWeekdaysParse, llc);
  3037. return ii !== -1 ? ii : null;
  3038. } else if (format === 'ddd') {
  3039. ii = indexOf.call(this._shortWeekdaysParse, llc);
  3040. if (ii !== -1) {
  3041. return ii;
  3042. }
  3043. ii = indexOf.call(this._weekdaysParse, llc);
  3044. if (ii !== -1) {
  3045. return ii;
  3046. }
  3047. ii = indexOf.call(this._minWeekdaysParse, llc);
  3048. return ii !== -1 ? ii : null;
  3049. } else {
  3050. ii = indexOf.call(this._minWeekdaysParse, llc);
  3051. if (ii !== -1) {
  3052. return ii;
  3053. }
  3054. ii = indexOf.call(this._weekdaysParse, llc);
  3055. if (ii !== -1) {
  3056. return ii;
  3057. }
  3058. ii = indexOf.call(this._shortWeekdaysParse, llc);
  3059. return ii !== -1 ? ii : null;
  3060. }
  3061. }
  3062. }
  3063. function localeWeekdaysParse(weekdayName, format, strict) {
  3064. var i, mom, regex;
  3065. if (this._weekdaysParseExact) {
  3066. return handleStrictParse$1.call(this, weekdayName, format, strict);
  3067. }
  3068. if (!this._weekdaysParse) {
  3069. this._weekdaysParse = [];
  3070. this._minWeekdaysParse = [];
  3071. this._shortWeekdaysParse = [];
  3072. this._fullWeekdaysParse = [];
  3073. }
  3074. for (i = 0; i < 7; i++) {
  3075. // make the regex if we don't have it already
  3076. mom = createUTC([2000, 1]).day(i);
  3077. if (strict && !this._fullWeekdaysParse[i]) {
  3078. this._fullWeekdaysParse[i] = new RegExp(
  3079. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  3080. 'i'
  3081. );
  3082. this._shortWeekdaysParse[i] = new RegExp(
  3083. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  3084. 'i'
  3085. );
  3086. this._minWeekdaysParse[i] = new RegExp(
  3087. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  3088. 'i'
  3089. );
  3090. }
  3091. if (!this._weekdaysParse[i]) {
  3092. regex =
  3093. '^' +
  3094. this.weekdays(mom, '') +
  3095. '|^' +
  3096. this.weekdaysShort(mom, '') +
  3097. '|^' +
  3098. this.weekdaysMin(mom, '');
  3099. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  3100. }
  3101. // test the regex
  3102. if (
  3103. strict &&
  3104. format === 'dddd' &&
  3105. this._fullWeekdaysParse[i].test(weekdayName)
  3106. ) {
  3107. return i;
  3108. } else if (
  3109. strict &&
  3110. format === 'ddd' &&
  3111. this._shortWeekdaysParse[i].test(weekdayName)
  3112. ) {
  3113. return i;
  3114. } else if (
  3115. strict &&
  3116. format === 'dd' &&
  3117. this._minWeekdaysParse[i].test(weekdayName)
  3118. ) {
  3119. return i;
  3120. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  3121. return i;
  3122. }
  3123. }
  3124. }
  3125. // MOMENTS
  3126. function getSetDayOfWeek(input) {
  3127. if (!this.isValid()) {
  3128. return input != null ? this : NaN;
  3129. }
  3130. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  3131. if (input != null) {
  3132. input = parseWeekday(input, this.localeData());
  3133. return this.add(input - day, 'd');
  3134. } else {
  3135. return day;
  3136. }
  3137. }
  3138. function getSetLocaleDayOfWeek(input) {
  3139. if (!this.isValid()) {
  3140. return input != null ? this : NaN;
  3141. }
  3142. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  3143. return input == null ? weekday : this.add(input - weekday, 'd');
  3144. }
  3145. function getSetISODayOfWeek(input) {
  3146. if (!this.isValid()) {
  3147. return input != null ? this : NaN;
  3148. }
  3149. // behaves the same as moment#day except
  3150. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  3151. // as a setter, sunday should belong to the previous week.
  3152. if (input != null) {
  3153. var weekday = parseIsoWeekday(input, this.localeData());
  3154. return this.day(this.day() % 7 ? weekday : weekday - 7);
  3155. } else {
  3156. return this.day() || 7;
  3157. }
  3158. }
  3159. function weekdaysRegex(isStrict) {
  3160. if (this._weekdaysParseExact) {
  3161. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3162. computeWeekdaysParse.call(this);
  3163. }
  3164. if (isStrict) {
  3165. return this._weekdaysStrictRegex;
  3166. } else {
  3167. return this._weekdaysRegex;
  3168. }
  3169. } else {
  3170. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3171. this._weekdaysRegex = defaultWeekdaysRegex;
  3172. }
  3173. return this._weekdaysStrictRegex && isStrict
  3174. ? this._weekdaysStrictRegex
  3175. : this._weekdaysRegex;
  3176. }
  3177. }
  3178. function weekdaysShortRegex(isStrict) {
  3179. if (this._weekdaysParseExact) {
  3180. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3181. computeWeekdaysParse.call(this);
  3182. }
  3183. if (isStrict) {
  3184. return this._weekdaysShortStrictRegex;
  3185. } else {
  3186. return this._weekdaysShortRegex;
  3187. }
  3188. } else {
  3189. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  3190. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  3191. }
  3192. return this._weekdaysShortStrictRegex && isStrict
  3193. ? this._weekdaysShortStrictRegex
  3194. : this._weekdaysShortRegex;
  3195. }
  3196. }
  3197. function weekdaysMinRegex(isStrict) {
  3198. if (this._weekdaysParseExact) {
  3199. if (!hasOwnProp(this, '_weekdaysRegex')) {
  3200. computeWeekdaysParse.call(this);
  3201. }
  3202. if (isStrict) {
  3203. return this._weekdaysMinStrictRegex;
  3204. } else {
  3205. return this._weekdaysMinRegex;
  3206. }
  3207. } else {
  3208. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  3209. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  3210. }
  3211. return this._weekdaysMinStrictRegex && isStrict
  3212. ? this._weekdaysMinStrictRegex
  3213. : this._weekdaysMinRegex;
  3214. }
  3215. }
  3216. function computeWeekdaysParse() {
  3217. function cmpLenRev(a, b) {
  3218. return b.length - a.length;
  3219. }
  3220. var minPieces = [],
  3221. shortPieces = [],
  3222. longPieces = [],
  3223. mixedPieces = [],
  3224. i,
  3225. mom,
  3226. minp,
  3227. shortp,
  3228. longp;
  3229. for (i = 0; i < 7; i++) {
  3230. // make the regex if we don't have it already
  3231. mom = createUTC([2000, 1]).day(i);
  3232. minp = regexEscape(this.weekdaysMin(mom, ''));
  3233. shortp = regexEscape(this.weekdaysShort(mom, ''));
  3234. longp = regexEscape(this.weekdays(mom, ''));
  3235. minPieces.push(minp);
  3236. shortPieces.push(shortp);
  3237. longPieces.push(longp);
  3238. mixedPieces.push(minp);
  3239. mixedPieces.push(shortp);
  3240. mixedPieces.push(longp);
  3241. }
  3242. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  3243. // will match the longer piece.
  3244. minPieces.sort(cmpLenRev);
  3245. shortPieces.sort(cmpLenRev);
  3246. longPieces.sort(cmpLenRev);
  3247. mixedPieces.sort(cmpLenRev);
  3248. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  3249. this._weekdaysShortRegex = this._weekdaysRegex;
  3250. this._weekdaysMinRegex = this._weekdaysRegex;
  3251. this._weekdaysStrictRegex = new RegExp(
  3252. '^(' + longPieces.join('|') + ')',
  3253. 'i'
  3254. );
  3255. this._weekdaysShortStrictRegex = new RegExp(
  3256. '^(' + shortPieces.join('|') + ')',
  3257. 'i'
  3258. );
  3259. this._weekdaysMinStrictRegex = new RegExp(
  3260. '^(' + minPieces.join('|') + ')',
  3261. 'i'
  3262. );
  3263. }
  3264. // FORMATTING
  3265. function hFormat() {
  3266. return this.hours() % 12 || 12;
  3267. }
  3268. function kFormat() {
  3269. return this.hours() || 24;
  3270. }
  3271. addFormatToken('H', ['HH', 2], 0, 'hour');
  3272. addFormatToken('h', ['hh', 2], 0, hFormat);
  3273. addFormatToken('k', ['kk', 2], 0, kFormat);
  3274. addFormatToken('hmm', 0, 0, function () {
  3275. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  3276. });
  3277. addFormatToken('hmmss', 0, 0, function () {
  3278. return (
  3279. '' +
  3280. hFormat.apply(this) +
  3281. zeroFill(this.minutes(), 2) +
  3282. zeroFill(this.seconds(), 2)
  3283. );
  3284. });
  3285. addFormatToken('Hmm', 0, 0, function () {
  3286. return '' + this.hours() + zeroFill(this.minutes(), 2);
  3287. });
  3288. addFormatToken('Hmmss', 0, 0, function () {
  3289. return (
  3290. '' +
  3291. this.hours() +
  3292. zeroFill(this.minutes(), 2) +
  3293. zeroFill(this.seconds(), 2)
  3294. );
  3295. });
  3296. function meridiem(token, lowercase) {
  3297. addFormatToken(token, 0, 0, function () {
  3298. return this.localeData().meridiem(
  3299. this.hours(),
  3300. this.minutes(),
  3301. lowercase
  3302. );
  3303. });
  3304. }
  3305. meridiem('a', true);
  3306. meridiem('A', false);
  3307. // ALIASES
  3308. addUnitAlias('hour', 'h');
  3309. // PRIORITY
  3310. addUnitPriority('hour', 13);
  3311. // PARSING
  3312. function matchMeridiem(isStrict, locale) {
  3313. return locale._meridiemParse;
  3314. }
  3315. addRegexToken('a', matchMeridiem);
  3316. addRegexToken('A', matchMeridiem);
  3317. addRegexToken('H', match1to2);
  3318. addRegexToken('h', match1to2);
  3319. addRegexToken('k', match1to2);
  3320. addRegexToken('HH', match1to2, match2);
  3321. addRegexToken('hh', match1to2, match2);
  3322. addRegexToken('kk', match1to2, match2);
  3323. addRegexToken('hmm', match3to4);
  3324. addRegexToken('hmmss', match5to6);
  3325. addRegexToken('Hmm', match3to4);
  3326. addRegexToken('Hmmss', match5to6);
  3327. addParseToken(['H', 'HH'], HOUR);
  3328. addParseToken(['k', 'kk'], function (input, array, config) {
  3329. var kInput = toInt(input);
  3330. array[HOUR] = kInput === 24 ? 0 : kInput;
  3331. });
  3332. addParseToken(['a', 'A'], function (input, array, config) {
  3333. config._isPm = config._locale.isPM(input);
  3334. config._meridiem = input;
  3335. });
  3336. addParseToken(['h', 'hh'], function (input, array, config) {
  3337. array[HOUR] = toInt(input);
  3338. getParsingFlags(config).bigHour = true;
  3339. });
  3340. addParseToken('hmm', function (input, array, config) {
  3341. var pos = input.length - 2;
  3342. array[HOUR] = toInt(input.substr(0, pos));
  3343. array[MINUTE] = toInt(input.substr(pos));
  3344. getParsingFlags(config).bigHour = true;
  3345. });
  3346. addParseToken('hmmss', function (input, array, config) {
  3347. var pos1 = input.length - 4,
  3348. pos2 = input.length - 2;
  3349. array[HOUR] = toInt(input.substr(0, pos1));
  3350. array[MINUTE] = toInt(input.substr(pos1, 2));
  3351. array[SECOND] = toInt(input.substr(pos2));
  3352. getParsingFlags(config).bigHour = true;
  3353. });
  3354. addParseToken('Hmm', function (input, array, config) {
  3355. var pos = input.length - 2;
  3356. array[HOUR] = toInt(input.substr(0, pos));
  3357. array[MINUTE] = toInt(input.substr(pos));
  3358. });
  3359. addParseToken('Hmmss', function (input, array, config) {
  3360. var pos1 = input.length - 4,
  3361. pos2 = input.length - 2;
  3362. array[HOUR] = toInt(input.substr(0, pos1));
  3363. array[MINUTE] = toInt(input.substr(pos1, 2));
  3364. array[SECOND] = toInt(input.substr(pos2));
  3365. });
  3366. // LOCALES
  3367. function localeIsPM(input) {
  3368. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  3369. // Using charAt should be more compatible.
  3370. return (input + '').toLowerCase().charAt(0) === 'p';
  3371. }
  3372. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  3373. // Setting the hour should keep the time, because the user explicitly
  3374. // specified which hour they want. So trying to maintain the same hour (in
  3375. // a new timezone) makes sense. Adding/subtracting hours does not follow
  3376. // this rule.
  3377. getSetHour = makeGetSet('Hours', true);
  3378. function localeMeridiem(hours, minutes, isLower) {
  3379. if (hours > 11) {
  3380. return isLower ? 'pm' : 'PM';
  3381. } else {
  3382. return isLower ? 'am' : 'AM';
  3383. }
  3384. }
  3385. var baseConfig = {
  3386. calendar: defaultCalendar,
  3387. longDateFormat: defaultLongDateFormat,
  3388. invalidDate: defaultInvalidDate,
  3389. ordinal: defaultOrdinal,
  3390. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  3391. relativeTime: defaultRelativeTime,
  3392. months: defaultLocaleMonths,
  3393. monthsShort: defaultLocaleMonthsShort,
  3394. week: defaultLocaleWeek,
  3395. weekdays: defaultLocaleWeekdays,
  3396. weekdaysMin: defaultLocaleWeekdaysMin,
  3397. weekdaysShort: defaultLocaleWeekdaysShort,
  3398. meridiemParse: defaultLocaleMeridiemParse,
  3399. };
  3400. // internal storage for locale config files
  3401. var locales = {},
  3402. localeFamilies = {},
  3403. globalLocale;
  3404. function commonPrefix(arr1, arr2) {
  3405. var i,
  3406. minl = Math.min(arr1.length, arr2.length);
  3407. for (i = 0; i < minl; i += 1) {
  3408. if (arr1[i] !== arr2[i]) {
  3409. return i;
  3410. }
  3411. }
  3412. return minl;
  3413. }
  3414. function normalizeLocale(key) {
  3415. return key ? key.toLowerCase().replace('_', '-') : key;
  3416. }
  3417. // pick the locale from the array
  3418. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  3419. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  3420. function chooseLocale(names) {
  3421. var i = 0,
  3422. j,
  3423. next,
  3424. locale,
  3425. split;
  3426. while (i < names.length) {
  3427. split = normalizeLocale(names[i]).split('-');
  3428. j = split.length;
  3429. next = normalizeLocale(names[i + 1]);
  3430. next = next ? next.split('-') : null;
  3431. while (j > 0) {
  3432. locale = loadLocale(split.slice(0, j).join('-'));
  3433. if (locale) {
  3434. return locale;
  3435. }
  3436. if (
  3437. next &&
  3438. next.length >= j &&
  3439. commonPrefix(split, next) >= j - 1
  3440. ) {
  3441. //the next array item is better than a shallower substring of this one
  3442. break;
  3443. }
  3444. j--;
  3445. }
  3446. i++;
  3447. }
  3448. return globalLocale;
  3449. }
  3450. function loadLocale(name) {
  3451. var oldLocale = null,
  3452. aliasedRequire;
  3453. // TODO: Find a better way to register and load all the locales in Node
  3454. if (
  3455. locales[name] === undefined &&
  3456. 'object' !== 'undefined' &&
  3457. module &&
  3458. module.exports
  3459. ) {
  3460. try {
  3461. oldLocale = globalLocale._abbr;
  3462. aliasedRequire = commonjsRequire;
  3463. aliasedRequire('./locale/' + name);
  3464. getSetGlobalLocale(oldLocale);
  3465. } catch (e) {
  3466. // mark as not found to avoid repeating expensive file require call causing high CPU
  3467. // when trying to find en-US, en_US, en-us for every format call
  3468. locales[name] = null; // null means not found
  3469. }
  3470. }
  3471. return locales[name];
  3472. }
  3473. // This function will load locale and then set the global locale. If
  3474. // no arguments are passed in, it will simply return the current global
  3475. // locale key.
  3476. function getSetGlobalLocale(key, values) {
  3477. var data;
  3478. if (key) {
  3479. if (isUndefined(values)) {
  3480. data = getLocale(key);
  3481. } else {
  3482. data = defineLocale(key, values);
  3483. }
  3484. if (data) {
  3485. // moment.duration._locale = moment._locale = data;
  3486. globalLocale = data;
  3487. } else {
  3488. if (typeof console !== 'undefined' && console.warn) {
  3489. //warn user if arguments are passed but the locale could not be set
  3490. console.warn(
  3491. 'Locale ' + key + ' not found. Did you forget to load it?'
  3492. );
  3493. }
  3494. }
  3495. }
  3496. return globalLocale._abbr;
  3497. }
  3498. function defineLocale(name, config) {
  3499. if (config !== null) {
  3500. var locale,
  3501. parentConfig = baseConfig;
  3502. config.abbr = name;
  3503. if (locales[name] != null) {
  3504. deprecateSimple(
  3505. 'defineLocaleOverride',
  3506. 'use moment.updateLocale(localeName, config) to change ' +
  3507. 'an existing locale. moment.defineLocale(localeName, ' +
  3508. 'config) should only be used for creating a new locale ' +
  3509. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  3510. );
  3511. parentConfig = locales[name]._config;
  3512. } else if (config.parentLocale != null) {
  3513. if (locales[config.parentLocale] != null) {
  3514. parentConfig = locales[config.parentLocale]._config;
  3515. } else {
  3516. locale = loadLocale(config.parentLocale);
  3517. if (locale != null) {
  3518. parentConfig = locale._config;
  3519. } else {
  3520. if (!localeFamilies[config.parentLocale]) {
  3521. localeFamilies[config.parentLocale] = [];
  3522. }
  3523. localeFamilies[config.parentLocale].push({
  3524. name: name,
  3525. config: config,
  3526. });
  3527. return null;
  3528. }
  3529. }
  3530. }
  3531. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  3532. if (localeFamilies[name]) {
  3533. localeFamilies[name].forEach(function (x) {
  3534. defineLocale(x.name, x.config);
  3535. });
  3536. }
  3537. // backwards compat for now: also set the locale
  3538. // make sure we set the locale AFTER all child locales have been
  3539. // created, so we won't end up with the child locale set.
  3540. getSetGlobalLocale(name);
  3541. return locales[name];
  3542. } else {
  3543. // useful for testing
  3544. delete locales[name];
  3545. return null;
  3546. }
  3547. }
  3548. function updateLocale(name, config) {
  3549. if (config != null) {
  3550. var locale,
  3551. tmpLocale,
  3552. parentConfig = baseConfig;
  3553. if (locales[name] != null && locales[name].parentLocale != null) {
  3554. // Update existing child locale in-place to avoid memory-leaks
  3555. locales[name].set(mergeConfigs(locales[name]._config, config));
  3556. } else {
  3557. // MERGE
  3558. tmpLocale = loadLocale(name);
  3559. if (tmpLocale != null) {
  3560. parentConfig = tmpLocale._config;
  3561. }
  3562. config = mergeConfigs(parentConfig, config);
  3563. if (tmpLocale == null) {
  3564. // updateLocale is called for creating a new locale
  3565. // Set abbr so it will have a name (getters return
  3566. // undefined otherwise).
  3567. config.abbr = name;
  3568. }
  3569. locale = new Locale(config);
  3570. locale.parentLocale = locales[name];
  3571. locales[name] = locale;
  3572. }
  3573. // backwards compat for now: also set the locale
  3574. getSetGlobalLocale(name);
  3575. } else {
  3576. // pass null for config to unupdate, useful for tests
  3577. if (locales[name] != null) {
  3578. if (locales[name].parentLocale != null) {
  3579. locales[name] = locales[name].parentLocale;
  3580. if (name === getSetGlobalLocale()) {
  3581. getSetGlobalLocale(name);
  3582. }
  3583. } else if (locales[name] != null) {
  3584. delete locales[name];
  3585. }
  3586. }
  3587. }
  3588. return locales[name];
  3589. }
  3590. // returns locale data
  3591. function getLocale(key) {
  3592. var locale;
  3593. if (key && key._locale && key._locale._abbr) {
  3594. key = key._locale._abbr;
  3595. }
  3596. if (!key) {
  3597. return globalLocale;
  3598. }
  3599. if (!isArray(key)) {
  3600. //short-circuit everything else
  3601. locale = loadLocale(key);
  3602. if (locale) {
  3603. return locale;
  3604. }
  3605. key = [key];
  3606. }
  3607. return chooseLocale(key);
  3608. }
  3609. function listLocales() {
  3610. return keys(locales);
  3611. }
  3612. function checkOverflow(m) {
  3613. var overflow,
  3614. a = m._a;
  3615. if (a && getParsingFlags(m).overflow === -2) {
  3616. overflow =
  3617. a[MONTH] < 0 || a[MONTH] > 11
  3618. ? MONTH
  3619. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  3620. ? DATE
  3621. : a[HOUR] < 0 ||
  3622. a[HOUR] > 24 ||
  3623. (a[HOUR] === 24 &&
  3624. (a[MINUTE] !== 0 ||
  3625. a[SECOND] !== 0 ||
  3626. a[MILLISECOND] !== 0))
  3627. ? HOUR
  3628. : a[MINUTE] < 0 || a[MINUTE] > 59
  3629. ? MINUTE
  3630. : a[SECOND] < 0 || a[SECOND] > 59
  3631. ? SECOND
  3632. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  3633. ? MILLISECOND
  3634. : -1;
  3635. if (
  3636. getParsingFlags(m)._overflowDayOfYear &&
  3637. (overflow < YEAR || overflow > DATE)
  3638. ) {
  3639. overflow = DATE;
  3640. }
  3641. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  3642. overflow = WEEK;
  3643. }
  3644. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  3645. overflow = WEEKDAY;
  3646. }
  3647. getParsingFlags(m).overflow = overflow;
  3648. }
  3649. return m;
  3650. }
  3651. // iso 8601 regex
  3652. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  3653. var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  3654. basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  3655. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  3656. isoDates = [
  3657. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  3658. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  3659. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  3660. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  3661. ['YYYY-DDD', /\d{4}-\d{3}/],
  3662. ['YYYY-MM', /\d{4}-\d\d/, false],
  3663. ['YYYYYYMMDD', /[+-]\d{10}/],
  3664. ['YYYYMMDD', /\d{8}/],
  3665. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  3666. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  3667. ['YYYYDDD', /\d{7}/],
  3668. ['YYYYMM', /\d{6}/, false],
  3669. ['YYYY', /\d{4}/, false],
  3670. ],
  3671. // iso time formats and regexes
  3672. isoTimes = [
  3673. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  3674. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  3675. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  3676. ['HH:mm', /\d\d:\d\d/],
  3677. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  3678. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  3679. ['HHmmss', /\d\d\d\d\d\d/],
  3680. ['HHmm', /\d\d\d\d/],
  3681. ['HH', /\d\d/],
  3682. ],
  3683. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  3684. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  3685. rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,
  3686. obsOffsets = {
  3687. UT: 0,
  3688. GMT: 0,
  3689. EDT: -4 * 60,
  3690. EST: -5 * 60,
  3691. CDT: -5 * 60,
  3692. CST: -6 * 60,
  3693. MDT: -6 * 60,
  3694. MST: -7 * 60,
  3695. PDT: -7 * 60,
  3696. PST: -8 * 60,
  3697. };
  3698. // date from iso format
  3699. function configFromISO(config) {
  3700. var i,
  3701. l,
  3702. string = config._i,
  3703. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  3704. allowTime,
  3705. dateFormat,
  3706. timeFormat,
  3707. tzFormat;
  3708. if (match) {
  3709. getParsingFlags(config).iso = true;
  3710. for (i = 0, l = isoDates.length; i < l; i++) {
  3711. if (isoDates[i][1].exec(match[1])) {
  3712. dateFormat = isoDates[i][0];
  3713. allowTime = isoDates[i][2] !== false;
  3714. break;
  3715. }
  3716. }
  3717. if (dateFormat == null) {
  3718. config._isValid = false;
  3719. return;
  3720. }
  3721. if (match[3]) {
  3722. for (i = 0, l = isoTimes.length; i < l; i++) {
  3723. if (isoTimes[i][1].exec(match[3])) {
  3724. // match[2] should be 'T' or space
  3725. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  3726. break;
  3727. }
  3728. }
  3729. if (timeFormat == null) {
  3730. config._isValid = false;
  3731. return;
  3732. }
  3733. }
  3734. if (!allowTime && timeFormat != null) {
  3735. config._isValid = false;
  3736. return;
  3737. }
  3738. if (match[4]) {
  3739. if (tzRegex.exec(match[4])) {
  3740. tzFormat = 'Z';
  3741. } else {
  3742. config._isValid = false;
  3743. return;
  3744. }
  3745. }
  3746. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  3747. configFromStringAndFormat(config);
  3748. } else {
  3749. config._isValid = false;
  3750. }
  3751. }
  3752. function extractFromRFC2822Strings(
  3753. yearStr,
  3754. monthStr,
  3755. dayStr,
  3756. hourStr,
  3757. minuteStr,
  3758. secondStr
  3759. ) {
  3760. var result = [
  3761. untruncateYear(yearStr),
  3762. defaultLocaleMonthsShort.indexOf(monthStr),
  3763. parseInt(dayStr, 10),
  3764. parseInt(hourStr, 10),
  3765. parseInt(minuteStr, 10),
  3766. ];
  3767. if (secondStr) {
  3768. result.push(parseInt(secondStr, 10));
  3769. }
  3770. return result;
  3771. }
  3772. function untruncateYear(yearStr) {
  3773. var year = parseInt(yearStr, 10);
  3774. if (year <= 49) {
  3775. return 2000 + year;
  3776. } else if (year <= 999) {
  3777. return 1900 + year;
  3778. }
  3779. return year;
  3780. }
  3781. function preprocessRFC2822(s) {
  3782. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  3783. return s
  3784. .replace(/\([^)]*\)|[\n\t]/g, ' ')
  3785. .replace(/(\s\s+)/g, ' ')
  3786. .replace(/^\s\s*/, '')
  3787. .replace(/\s\s*$/, '');
  3788. }
  3789. function checkWeekday(weekdayStr, parsedInput, config) {
  3790. if (weekdayStr) {
  3791. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  3792. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  3793. weekdayActual = new Date(
  3794. parsedInput[0],
  3795. parsedInput[1],
  3796. parsedInput[2]
  3797. ).getDay();
  3798. if (weekdayProvided !== weekdayActual) {
  3799. getParsingFlags(config).weekdayMismatch = true;
  3800. config._isValid = false;
  3801. return false;
  3802. }
  3803. }
  3804. return true;
  3805. }
  3806. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  3807. if (obsOffset) {
  3808. return obsOffsets[obsOffset];
  3809. } else if (militaryOffset) {
  3810. // the only allowed military tz is Z
  3811. return 0;
  3812. } else {
  3813. var hm = parseInt(numOffset, 10),
  3814. m = hm % 100,
  3815. h = (hm - m) / 100;
  3816. return h * 60 + m;
  3817. }
  3818. }
  3819. // date and time from ref 2822 format
  3820. function configFromRFC2822(config) {
  3821. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  3822. parsedArray;
  3823. if (match) {
  3824. parsedArray = extractFromRFC2822Strings(
  3825. match[4],
  3826. match[3],
  3827. match[2],
  3828. match[5],
  3829. match[6],
  3830. match[7]
  3831. );
  3832. if (!checkWeekday(match[1], parsedArray, config)) {
  3833. return;
  3834. }
  3835. config._a = parsedArray;
  3836. config._tzm = calculateOffset(match[8], match[9], match[10]);
  3837. config._d = createUTCDate.apply(null, config._a);
  3838. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3839. getParsingFlags(config).rfc2822 = true;
  3840. } else {
  3841. config._isValid = false;
  3842. }
  3843. }
  3844. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  3845. function configFromString(config) {
  3846. var matched = aspNetJsonRegex.exec(config._i);
  3847. if (matched !== null) {
  3848. config._d = new Date(+matched[1]);
  3849. return;
  3850. }
  3851. configFromISO(config);
  3852. if (config._isValid === false) {
  3853. delete config._isValid;
  3854. } else {
  3855. return;
  3856. }
  3857. configFromRFC2822(config);
  3858. if (config._isValid === false) {
  3859. delete config._isValid;
  3860. } else {
  3861. return;
  3862. }
  3863. if (config._strict) {
  3864. config._isValid = false;
  3865. } else {
  3866. // Final attempt, use Input Fallback
  3867. hooks.createFromInputFallback(config);
  3868. }
  3869. }
  3870. hooks.createFromInputFallback = deprecate(
  3871. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  3872. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  3873. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  3874. function (config) {
  3875. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  3876. }
  3877. );
  3878. // Pick the first defined of two or three arguments.
  3879. function defaults(a, b, c) {
  3880. if (a != null) {
  3881. return a;
  3882. }
  3883. if (b != null) {
  3884. return b;
  3885. }
  3886. return c;
  3887. }
  3888. function currentDateArray(config) {
  3889. // hooks is actually the exported moment object
  3890. var nowValue = new Date(hooks.now());
  3891. if (config._useUTC) {
  3892. return [
  3893. nowValue.getUTCFullYear(),
  3894. nowValue.getUTCMonth(),
  3895. nowValue.getUTCDate(),
  3896. ];
  3897. }
  3898. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  3899. }
  3900. // convert an array to a date.
  3901. // the array should mirror the parameters below
  3902. // note: all values past the year are optional and will default to the lowest possible value.
  3903. // [year, month, day , hour, minute, second, millisecond]
  3904. function configFromArray(config) {
  3905. var i,
  3906. date,
  3907. input = [],
  3908. currentDate,
  3909. expectedWeekday,
  3910. yearToUse;
  3911. if (config._d) {
  3912. return;
  3913. }
  3914. currentDate = currentDateArray(config);
  3915. //compute day of the year from weeks and weekdays
  3916. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  3917. dayOfYearFromWeekInfo(config);
  3918. }
  3919. //if the day of the year is set, figure out what it is
  3920. if (config._dayOfYear != null) {
  3921. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  3922. if (
  3923. config._dayOfYear > daysInYear(yearToUse) ||
  3924. config._dayOfYear === 0
  3925. ) {
  3926. getParsingFlags(config)._overflowDayOfYear = true;
  3927. }
  3928. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  3929. config._a[MONTH] = date.getUTCMonth();
  3930. config._a[DATE] = date.getUTCDate();
  3931. }
  3932. // Default to current date.
  3933. // * if no year, month, day of month are given, default to today
  3934. // * if day of month is given, default month and year
  3935. // * if month is given, default only year
  3936. // * if year is given, don't default anything
  3937. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  3938. config._a[i] = input[i] = currentDate[i];
  3939. }
  3940. // Zero out whatever was not defaulted, including time
  3941. for (; i < 7; i++) {
  3942. config._a[i] = input[i] =
  3943. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  3944. }
  3945. // Check for 24:00:00.000
  3946. if (
  3947. config._a[HOUR] === 24 &&
  3948. config._a[MINUTE] === 0 &&
  3949. config._a[SECOND] === 0 &&
  3950. config._a[MILLISECOND] === 0
  3951. ) {
  3952. config._nextDay = true;
  3953. config._a[HOUR] = 0;
  3954. }
  3955. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  3956. null,
  3957. input
  3958. );
  3959. expectedWeekday = config._useUTC
  3960. ? config._d.getUTCDay()
  3961. : config._d.getDay();
  3962. // Apply timezone offset from input. The actual utcOffset can be changed
  3963. // with parseZone.
  3964. if (config._tzm != null) {
  3965. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3966. }
  3967. if (config._nextDay) {
  3968. config._a[HOUR] = 24;
  3969. }
  3970. // check for mismatching day of week
  3971. if (
  3972. config._w &&
  3973. typeof config._w.d !== 'undefined' &&
  3974. config._w.d !== expectedWeekday
  3975. ) {
  3976. getParsingFlags(config).weekdayMismatch = true;
  3977. }
  3978. }
  3979. function dayOfYearFromWeekInfo(config) {
  3980. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  3981. w = config._w;
  3982. if (w.GG != null || w.W != null || w.E != null) {
  3983. dow = 1;
  3984. doy = 4;
  3985. // TODO: We need to take the current isoWeekYear, but that depends on
  3986. // how we interpret now (local, utc, fixed offset). So create
  3987. // a now version of current config (take local/utc/offset flags, and
  3988. // create now).
  3989. weekYear = defaults(
  3990. w.GG,
  3991. config._a[YEAR],
  3992. weekOfYear(createLocal(), 1, 4).year
  3993. );
  3994. week = defaults(w.W, 1);
  3995. weekday = defaults(w.E, 1);
  3996. if (weekday < 1 || weekday > 7) {
  3997. weekdayOverflow = true;
  3998. }
  3999. } else {
  4000. dow = config._locale._week.dow;
  4001. doy = config._locale._week.doy;
  4002. curWeek = weekOfYear(createLocal(), dow, doy);
  4003. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  4004. // Default to current week.
  4005. week = defaults(w.w, curWeek.week);
  4006. if (w.d != null) {
  4007. // weekday -- low day numbers are considered next week
  4008. weekday = w.d;
  4009. if (weekday < 0 || weekday > 6) {
  4010. weekdayOverflow = true;
  4011. }
  4012. } else if (w.e != null) {
  4013. // local weekday -- counting starts from beginning of week
  4014. weekday = w.e + dow;
  4015. if (w.e < 0 || w.e > 6) {
  4016. weekdayOverflow = true;
  4017. }
  4018. } else {
  4019. // default to beginning of week
  4020. weekday = dow;
  4021. }
  4022. }
  4023. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  4024. getParsingFlags(config)._overflowWeeks = true;
  4025. } else if (weekdayOverflow != null) {
  4026. getParsingFlags(config)._overflowWeekday = true;
  4027. } else {
  4028. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  4029. config._a[YEAR] = temp.year;
  4030. config._dayOfYear = temp.dayOfYear;
  4031. }
  4032. }
  4033. // constant that refers to the ISO standard
  4034. hooks.ISO_8601 = function () {};
  4035. // constant that refers to the RFC 2822 form
  4036. hooks.RFC_2822 = function () {};
  4037. // date from string and format string
  4038. function configFromStringAndFormat(config) {
  4039. // TODO: Move this to another part of the creation flow to prevent circular deps
  4040. if (config._f === hooks.ISO_8601) {
  4041. configFromISO(config);
  4042. return;
  4043. }
  4044. if (config._f === hooks.RFC_2822) {
  4045. configFromRFC2822(config);
  4046. return;
  4047. }
  4048. config._a = [];
  4049. getParsingFlags(config).empty = true;
  4050. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  4051. var string = '' + config._i,
  4052. i,
  4053. parsedInput,
  4054. tokens,
  4055. token,
  4056. skipped,
  4057. stringLength = string.length,
  4058. totalParsedInputLength = 0,
  4059. era;
  4060. tokens =
  4061. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  4062. for (i = 0; i < tokens.length; i++) {
  4063. token = tokens[i];
  4064. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  4065. [])[0];
  4066. if (parsedInput) {
  4067. skipped = string.substr(0, string.indexOf(parsedInput));
  4068. if (skipped.length > 0) {
  4069. getParsingFlags(config).unusedInput.push(skipped);
  4070. }
  4071. string = string.slice(
  4072. string.indexOf(parsedInput) + parsedInput.length
  4073. );
  4074. totalParsedInputLength += parsedInput.length;
  4075. }
  4076. // don't parse if it's not a known token
  4077. if (formatTokenFunctions[token]) {
  4078. if (parsedInput) {
  4079. getParsingFlags(config).empty = false;
  4080. } else {
  4081. getParsingFlags(config).unusedTokens.push(token);
  4082. }
  4083. addTimeToArrayFromToken(token, parsedInput, config);
  4084. } else if (config._strict && !parsedInput) {
  4085. getParsingFlags(config).unusedTokens.push(token);
  4086. }
  4087. }
  4088. // add remaining unparsed input length to the string
  4089. getParsingFlags(config).charsLeftOver =
  4090. stringLength - totalParsedInputLength;
  4091. if (string.length > 0) {
  4092. getParsingFlags(config).unusedInput.push(string);
  4093. }
  4094. // clear _12h flag if hour is <= 12
  4095. if (
  4096. config._a[HOUR] <= 12 &&
  4097. getParsingFlags(config).bigHour === true &&
  4098. config._a[HOUR] > 0
  4099. ) {
  4100. getParsingFlags(config).bigHour = undefined;
  4101. }
  4102. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  4103. getParsingFlags(config).meridiem = config._meridiem;
  4104. // handle meridiem
  4105. config._a[HOUR] = meridiemFixWrap(
  4106. config._locale,
  4107. config._a[HOUR],
  4108. config._meridiem
  4109. );
  4110. // handle era
  4111. era = getParsingFlags(config).era;
  4112. if (era !== null) {
  4113. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  4114. }
  4115. configFromArray(config);
  4116. checkOverflow(config);
  4117. }
  4118. function meridiemFixWrap(locale, hour, meridiem) {
  4119. var isPm;
  4120. if (meridiem == null) {
  4121. // nothing to do
  4122. return hour;
  4123. }
  4124. if (locale.meridiemHour != null) {
  4125. return locale.meridiemHour(hour, meridiem);
  4126. } else if (locale.isPM != null) {
  4127. // Fallback
  4128. isPm = locale.isPM(meridiem);
  4129. if (isPm && hour < 12) {
  4130. hour += 12;
  4131. }
  4132. if (!isPm && hour === 12) {
  4133. hour = 0;
  4134. }
  4135. return hour;
  4136. } else {
  4137. // this is not supposed to happen
  4138. return hour;
  4139. }
  4140. }
  4141. // date from string and array of format strings
  4142. function configFromStringAndArray(config) {
  4143. var tempConfig,
  4144. bestMoment,
  4145. scoreToBeat,
  4146. i,
  4147. currentScore,
  4148. validFormatFound,
  4149. bestFormatIsValid = false;
  4150. if (config._f.length === 0) {
  4151. getParsingFlags(config).invalidFormat = true;
  4152. config._d = new Date(NaN);
  4153. return;
  4154. }
  4155. for (i = 0; i < config._f.length; i++) {
  4156. currentScore = 0;
  4157. validFormatFound = false;
  4158. tempConfig = copyConfig({}, config);
  4159. if (config._useUTC != null) {
  4160. tempConfig._useUTC = config._useUTC;
  4161. }
  4162. tempConfig._f = config._f[i];
  4163. configFromStringAndFormat(tempConfig);
  4164. if (isValid(tempConfig)) {
  4165. validFormatFound = true;
  4166. }
  4167. // if there is any input that was not parsed add a penalty for that format
  4168. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  4169. //or tokens
  4170. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  4171. getParsingFlags(tempConfig).score = currentScore;
  4172. if (!bestFormatIsValid) {
  4173. if (
  4174. scoreToBeat == null ||
  4175. currentScore < scoreToBeat ||
  4176. validFormatFound
  4177. ) {
  4178. scoreToBeat = currentScore;
  4179. bestMoment = tempConfig;
  4180. if (validFormatFound) {
  4181. bestFormatIsValid = true;
  4182. }
  4183. }
  4184. } else {
  4185. if (currentScore < scoreToBeat) {
  4186. scoreToBeat = currentScore;
  4187. bestMoment = tempConfig;
  4188. }
  4189. }
  4190. }
  4191. extend(config, bestMoment || tempConfig);
  4192. }
  4193. function configFromObject(config) {
  4194. if (config._d) {
  4195. return;
  4196. }
  4197. var i = normalizeObjectUnits(config._i),
  4198. dayOrDate = i.day === undefined ? i.date : i.day;
  4199. config._a = map(
  4200. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  4201. function (obj) {
  4202. return obj && parseInt(obj, 10);
  4203. }
  4204. );
  4205. configFromArray(config);
  4206. }
  4207. function createFromConfig(config) {
  4208. var res = new Moment(checkOverflow(prepareConfig(config)));
  4209. if (res._nextDay) {
  4210. // Adding is smart enough around DST
  4211. res.add(1, 'd');
  4212. res._nextDay = undefined;
  4213. }
  4214. return res;
  4215. }
  4216. function prepareConfig(config) {
  4217. var input = config._i,
  4218. format = config._f;
  4219. config._locale = config._locale || getLocale(config._l);
  4220. if (input === null || (format === undefined && input === '')) {
  4221. return createInvalid({ nullInput: true });
  4222. }
  4223. if (typeof input === 'string') {
  4224. config._i = input = config._locale.preparse(input);
  4225. }
  4226. if (isMoment(input)) {
  4227. return new Moment(checkOverflow(input));
  4228. } else if (isDate(input)) {
  4229. config._d = input;
  4230. } else if (isArray(format)) {
  4231. configFromStringAndArray(config);
  4232. } else if (format) {
  4233. configFromStringAndFormat(config);
  4234. } else {
  4235. configFromInput(config);
  4236. }
  4237. if (!isValid(config)) {
  4238. config._d = null;
  4239. }
  4240. return config;
  4241. }
  4242. function configFromInput(config) {
  4243. var input = config._i;
  4244. if (isUndefined(input)) {
  4245. config._d = new Date(hooks.now());
  4246. } else if (isDate(input)) {
  4247. config._d = new Date(input.valueOf());
  4248. } else if (typeof input === 'string') {
  4249. configFromString(config);
  4250. } else if (isArray(input)) {
  4251. config._a = map(input.slice(0), function (obj) {
  4252. return parseInt(obj, 10);
  4253. });
  4254. configFromArray(config);
  4255. } else if (isObject(input)) {
  4256. configFromObject(config);
  4257. } else if (isNumber(input)) {
  4258. // from milliseconds
  4259. config._d = new Date(input);
  4260. } else {
  4261. hooks.createFromInputFallback(config);
  4262. }
  4263. }
  4264. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  4265. var c = {};
  4266. if (format === true || format === false) {
  4267. strict = format;
  4268. format = undefined;
  4269. }
  4270. if (locale === true || locale === false) {
  4271. strict = locale;
  4272. locale = undefined;
  4273. }
  4274. if (
  4275. (isObject(input) && isObjectEmpty(input)) ||
  4276. (isArray(input) && input.length === 0)
  4277. ) {
  4278. input = undefined;
  4279. }
  4280. // object construction must be done this way.
  4281. // https://github.com/moment/moment/issues/1423
  4282. c._isAMomentObject = true;
  4283. c._useUTC = c._isUTC = isUTC;
  4284. c._l = locale;
  4285. c._i = input;
  4286. c._f = format;
  4287. c._strict = strict;
  4288. return createFromConfig(c);
  4289. }
  4290. function createLocal(input, format, locale, strict) {
  4291. return createLocalOrUTC(input, format, locale, strict, false);
  4292. }
  4293. var prototypeMin = deprecate(
  4294. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  4295. function () {
  4296. var other = createLocal.apply(null, arguments);
  4297. if (this.isValid() && other.isValid()) {
  4298. return other < this ? this : other;
  4299. } else {
  4300. return createInvalid();
  4301. }
  4302. }
  4303. ),
  4304. prototypeMax = deprecate(
  4305. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  4306. function () {
  4307. var other = createLocal.apply(null, arguments);
  4308. if (this.isValid() && other.isValid()) {
  4309. return other > this ? this : other;
  4310. } else {
  4311. return createInvalid();
  4312. }
  4313. }
  4314. );
  4315. // Pick a moment m from moments so that m[fn](other) is true for all
  4316. // other. This relies on the function fn to be transitive.
  4317. //
  4318. // moments should either be an array of moment objects or an array, whose
  4319. // first element is an array of moment objects.
  4320. function pickBy(fn, moments) {
  4321. var res, i;
  4322. if (moments.length === 1 && isArray(moments[0])) {
  4323. moments = moments[0];
  4324. }
  4325. if (!moments.length) {
  4326. return createLocal();
  4327. }
  4328. res = moments[0];
  4329. for (i = 1; i < moments.length; ++i) {
  4330. if (!moments[i].isValid() || moments[i][fn](res)) {
  4331. res = moments[i];
  4332. }
  4333. }
  4334. return res;
  4335. }
  4336. // TODO: Use [].sort instead?
  4337. function min() {
  4338. var args = [].slice.call(arguments, 0);
  4339. return pickBy('isBefore', args);
  4340. }
  4341. function max() {
  4342. var args = [].slice.call(arguments, 0);
  4343. return pickBy('isAfter', args);
  4344. }
  4345. var now = function () {
  4346. return Date.now ? Date.now() : +new Date();
  4347. };
  4348. var ordering = [
  4349. 'year',
  4350. 'quarter',
  4351. 'month',
  4352. 'week',
  4353. 'day',
  4354. 'hour',
  4355. 'minute',
  4356. 'second',
  4357. 'millisecond',
  4358. ];
  4359. function isDurationValid(m) {
  4360. var key,
  4361. unitHasDecimal = false,
  4362. i;
  4363. for (key in m) {
  4364. if (
  4365. hasOwnProp(m, key) &&
  4366. !(
  4367. indexOf.call(ordering, key) !== -1 &&
  4368. (m[key] == null || !isNaN(m[key]))
  4369. )
  4370. ) {
  4371. return false;
  4372. }
  4373. }
  4374. for (i = 0; i < ordering.length; ++i) {
  4375. if (m[ordering[i]]) {
  4376. if (unitHasDecimal) {
  4377. return false; // only allow non-integers for smallest unit
  4378. }
  4379. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  4380. unitHasDecimal = true;
  4381. }
  4382. }
  4383. }
  4384. return true;
  4385. }
  4386. function isValid$1() {
  4387. return this._isValid;
  4388. }
  4389. function createInvalid$1() {
  4390. return createDuration(NaN);
  4391. }
  4392. function Duration(duration) {
  4393. var normalizedInput = normalizeObjectUnits(duration),
  4394. years = normalizedInput.year || 0,
  4395. quarters = normalizedInput.quarter || 0,
  4396. months = normalizedInput.month || 0,
  4397. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  4398. days = normalizedInput.day || 0,
  4399. hours = normalizedInput.hour || 0,
  4400. minutes = normalizedInput.minute || 0,
  4401. seconds = normalizedInput.second || 0,
  4402. milliseconds = normalizedInput.millisecond || 0;
  4403. this._isValid = isDurationValid(normalizedInput);
  4404. // representation for dateAddRemove
  4405. this._milliseconds =
  4406. +milliseconds +
  4407. seconds * 1e3 + // 1000
  4408. minutes * 6e4 + // 1000 * 60
  4409. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  4410. // Because of dateAddRemove treats 24 hours as different from a
  4411. // day when working around DST, we need to store them separately
  4412. this._days = +days + weeks * 7;
  4413. // It is impossible to translate months into days without knowing
  4414. // which months you are are talking about, so we have to store
  4415. // it separately.
  4416. this._months = +months + quarters * 3 + years * 12;
  4417. this._data = {};
  4418. this._locale = getLocale();
  4419. this._bubble();
  4420. }
  4421. function isDuration(obj) {
  4422. return obj instanceof Duration;
  4423. }
  4424. function absRound(number) {
  4425. if (number < 0) {
  4426. return Math.round(-1 * number) * -1;
  4427. } else {
  4428. return Math.round(number);
  4429. }
  4430. }
  4431. // compare two arrays, return the number of differences
  4432. function compareArrays(array1, array2, dontConvert) {
  4433. var len = Math.min(array1.length, array2.length),
  4434. lengthDiff = Math.abs(array1.length - array2.length),
  4435. diffs = 0,
  4436. i;
  4437. for (i = 0; i < len; i++) {
  4438. if (
  4439. (dontConvert && array1[i] !== array2[i]) ||
  4440. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  4441. ) {
  4442. diffs++;
  4443. }
  4444. }
  4445. return diffs + lengthDiff;
  4446. }
  4447. // FORMATTING
  4448. function offset(token, separator) {
  4449. addFormatToken(token, 0, 0, function () {
  4450. var offset = this.utcOffset(),
  4451. sign = '+';
  4452. if (offset < 0) {
  4453. offset = -offset;
  4454. sign = '-';
  4455. }
  4456. return (
  4457. sign +
  4458. zeroFill(~~(offset / 60), 2) +
  4459. separator +
  4460. zeroFill(~~offset % 60, 2)
  4461. );
  4462. });
  4463. }
  4464. offset('Z', ':');
  4465. offset('ZZ', '');
  4466. // PARSING
  4467. addRegexToken('Z', matchShortOffset);
  4468. addRegexToken('ZZ', matchShortOffset);
  4469. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  4470. config._useUTC = true;
  4471. config._tzm = offsetFromString(matchShortOffset, input);
  4472. });
  4473. // HELPERS
  4474. // timezone chunker
  4475. // '+10:00' > ['10', '00']
  4476. // '-1530' > ['-15', '30']
  4477. var chunkOffset = /([\+\-]|\d\d)/gi;
  4478. function offsetFromString(matcher, string) {
  4479. var matches = (string || '').match(matcher),
  4480. chunk,
  4481. parts,
  4482. minutes;
  4483. if (matches === null) {
  4484. return null;
  4485. }
  4486. chunk = matches[matches.length - 1] || [];
  4487. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  4488. minutes = +(parts[1] * 60) + toInt(parts[2]);
  4489. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  4490. }
  4491. // Return a moment from input, that is local/utc/zone equivalent to model.
  4492. function cloneWithOffset(input, model) {
  4493. var res, diff;
  4494. if (model._isUTC) {
  4495. res = model.clone();
  4496. diff =
  4497. (isMoment(input) || isDate(input)
  4498. ? input.valueOf()
  4499. : createLocal(input).valueOf()) - res.valueOf();
  4500. // Use low-level api, because this fn is low-level api.
  4501. res._d.setTime(res._d.valueOf() + diff);
  4502. hooks.updateOffset(res, false);
  4503. return res;
  4504. } else {
  4505. return createLocal(input).local();
  4506. }
  4507. }
  4508. function getDateOffset(m) {
  4509. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  4510. // https://github.com/moment/moment/pull/1871
  4511. return -Math.round(m._d.getTimezoneOffset());
  4512. }
  4513. // HOOKS
  4514. // This function will be called whenever a moment is mutated.
  4515. // It is intended to keep the offset in sync with the timezone.
  4516. hooks.updateOffset = function () {};
  4517. // MOMENTS
  4518. // keepLocalTime = true means only change the timezone, without
  4519. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  4520. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  4521. // +0200, so we adjust the time as needed, to be valid.
  4522. //
  4523. // Keeping the time actually adds/subtracts (one hour)
  4524. // from the actual represented time. That is why we call updateOffset
  4525. // a second time. In case it wants us to change the offset again
  4526. // _changeInProgress == true case, then we have to adjust, because
  4527. // there is no such time in the given timezone.
  4528. function getSetOffset(input, keepLocalTime, keepMinutes) {
  4529. var offset = this._offset || 0,
  4530. localAdjust;
  4531. if (!this.isValid()) {
  4532. return input != null ? this : NaN;
  4533. }
  4534. if (input != null) {
  4535. if (typeof input === 'string') {
  4536. input = offsetFromString(matchShortOffset, input);
  4537. if (input === null) {
  4538. return this;
  4539. }
  4540. } else if (Math.abs(input) < 16 && !keepMinutes) {
  4541. input = input * 60;
  4542. }
  4543. if (!this._isUTC && keepLocalTime) {
  4544. localAdjust = getDateOffset(this);
  4545. }
  4546. this._offset = input;
  4547. this._isUTC = true;
  4548. if (localAdjust != null) {
  4549. this.add(localAdjust, 'm');
  4550. }
  4551. if (offset !== input) {
  4552. if (!keepLocalTime || this._changeInProgress) {
  4553. addSubtract(
  4554. this,
  4555. createDuration(input - offset, 'm'),
  4556. 1,
  4557. false
  4558. );
  4559. } else if (!this._changeInProgress) {
  4560. this._changeInProgress = true;
  4561. hooks.updateOffset(this, true);
  4562. this._changeInProgress = null;
  4563. }
  4564. }
  4565. return this;
  4566. } else {
  4567. return this._isUTC ? offset : getDateOffset(this);
  4568. }
  4569. }
  4570. function getSetZone(input, keepLocalTime) {
  4571. if (input != null) {
  4572. if (typeof input !== 'string') {
  4573. input = -input;
  4574. }
  4575. this.utcOffset(input, keepLocalTime);
  4576. return this;
  4577. } else {
  4578. return -this.utcOffset();
  4579. }
  4580. }
  4581. function setOffsetToUTC(keepLocalTime) {
  4582. return this.utcOffset(0, keepLocalTime);
  4583. }
  4584. function setOffsetToLocal(keepLocalTime) {
  4585. if (this._isUTC) {
  4586. this.utcOffset(0, keepLocalTime);
  4587. this._isUTC = false;
  4588. if (keepLocalTime) {
  4589. this.subtract(getDateOffset(this), 'm');
  4590. }
  4591. }
  4592. return this;
  4593. }
  4594. function setOffsetToParsedOffset() {
  4595. if (this._tzm != null) {
  4596. this.utcOffset(this._tzm, false, true);
  4597. } else if (typeof this._i === 'string') {
  4598. var tZone = offsetFromString(matchOffset, this._i);
  4599. if (tZone != null) {
  4600. this.utcOffset(tZone);
  4601. } else {
  4602. this.utcOffset(0, true);
  4603. }
  4604. }
  4605. return this;
  4606. }
  4607. function hasAlignedHourOffset(input) {
  4608. if (!this.isValid()) {
  4609. return false;
  4610. }
  4611. input = input ? createLocal(input).utcOffset() : 0;
  4612. return (this.utcOffset() - input) % 60 === 0;
  4613. }
  4614. function isDaylightSavingTime() {
  4615. return (
  4616. this.utcOffset() > this.clone().month(0).utcOffset() ||
  4617. this.utcOffset() > this.clone().month(5).utcOffset()
  4618. );
  4619. }
  4620. function isDaylightSavingTimeShifted() {
  4621. if (!isUndefined(this._isDSTShifted)) {
  4622. return this._isDSTShifted;
  4623. }
  4624. var c = {},
  4625. other;
  4626. copyConfig(c, this);
  4627. c = prepareConfig(c);
  4628. if (c._a) {
  4629. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  4630. this._isDSTShifted =
  4631. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  4632. } else {
  4633. this._isDSTShifted = false;
  4634. }
  4635. return this._isDSTShifted;
  4636. }
  4637. function isLocal() {
  4638. return this.isValid() ? !this._isUTC : false;
  4639. }
  4640. function isUtcOffset() {
  4641. return this.isValid() ? this._isUTC : false;
  4642. }
  4643. function isUtc() {
  4644. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  4645. }
  4646. // ASP.NET json date format regex
  4647. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  4648. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  4649. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  4650. // and further modified to allow for strings containing both week and day
  4651. isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  4652. function createDuration(input, key) {
  4653. var duration = input,
  4654. // matching against regexp is expensive, do it on demand
  4655. match = null,
  4656. sign,
  4657. ret,
  4658. diffRes;
  4659. if (isDuration(input)) {
  4660. duration = {
  4661. ms: input._milliseconds,
  4662. d: input._days,
  4663. M: input._months,
  4664. };
  4665. } else if (isNumber(input) || !isNaN(+input)) {
  4666. duration = {};
  4667. if (key) {
  4668. duration[key] = +input;
  4669. } else {
  4670. duration.milliseconds = +input;
  4671. }
  4672. } else if ((match = aspNetRegex.exec(input))) {
  4673. sign = match[1] === '-' ? -1 : 1;
  4674. duration = {
  4675. y: 0,
  4676. d: toInt(match[DATE]) * sign,
  4677. h: toInt(match[HOUR]) * sign,
  4678. m: toInt(match[MINUTE]) * sign,
  4679. s: toInt(match[SECOND]) * sign,
  4680. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  4681. };
  4682. } else if ((match = isoRegex.exec(input))) {
  4683. sign = match[1] === '-' ? -1 : 1;
  4684. duration = {
  4685. y: parseIso(match[2], sign),
  4686. M: parseIso(match[3], sign),
  4687. w: parseIso(match[4], sign),
  4688. d: parseIso(match[5], sign),
  4689. h: parseIso(match[6], sign),
  4690. m: parseIso(match[7], sign),
  4691. s: parseIso(match[8], sign),
  4692. };
  4693. } else if (duration == null) {
  4694. // checks for null or undefined
  4695. duration = {};
  4696. } else if (
  4697. typeof duration === 'object' &&
  4698. ('from' in duration || 'to' in duration)
  4699. ) {
  4700. diffRes = momentsDifference(
  4701. createLocal(duration.from),
  4702. createLocal(duration.to)
  4703. );
  4704. duration = {};
  4705. duration.ms = diffRes.milliseconds;
  4706. duration.M = diffRes.months;
  4707. }
  4708. ret = new Duration(duration);
  4709. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  4710. ret._locale = input._locale;
  4711. }
  4712. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  4713. ret._isValid = input._isValid;
  4714. }
  4715. return ret;
  4716. }
  4717. createDuration.fn = Duration.prototype;
  4718. createDuration.invalid = createInvalid$1;
  4719. function parseIso(inp, sign) {
  4720. // We'd normally use ~~inp for this, but unfortunately it also
  4721. // converts floats to ints.
  4722. // inp may be undefined, so careful calling replace on it.
  4723. var res = inp && parseFloat(inp.replace(',', '.'));
  4724. // apply sign while we're at it
  4725. return (isNaN(res) ? 0 : res) * sign;
  4726. }
  4727. function positiveMomentsDifference(base, other) {
  4728. var res = {};
  4729. res.months =
  4730. other.month() - base.month() + (other.year() - base.year()) * 12;
  4731. if (base.clone().add(res.months, 'M').isAfter(other)) {
  4732. --res.months;
  4733. }
  4734. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  4735. return res;
  4736. }
  4737. function momentsDifference(base, other) {
  4738. var res;
  4739. if (!(base.isValid() && other.isValid())) {
  4740. return { milliseconds: 0, months: 0 };
  4741. }
  4742. other = cloneWithOffset(other, base);
  4743. if (base.isBefore(other)) {
  4744. res = positiveMomentsDifference(base, other);
  4745. } else {
  4746. res = positiveMomentsDifference(other, base);
  4747. res.milliseconds = -res.milliseconds;
  4748. res.months = -res.months;
  4749. }
  4750. return res;
  4751. }
  4752. // TODO: remove 'name' arg after deprecation is removed
  4753. function createAdder(direction, name) {
  4754. return function (val, period) {
  4755. var dur, tmp;
  4756. //invert the arguments, but complain about it
  4757. if (period !== null && !isNaN(+period)) {
  4758. deprecateSimple(
  4759. name,
  4760. 'moment().' +
  4761. name +
  4762. '(period, number) is deprecated. Please use moment().' +
  4763. name +
  4764. '(number, period). ' +
  4765. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  4766. );
  4767. tmp = val;
  4768. val = period;
  4769. period = tmp;
  4770. }
  4771. dur = createDuration(val, period);
  4772. addSubtract(this, dur, direction);
  4773. return this;
  4774. };
  4775. }
  4776. function addSubtract(mom, duration, isAdding, updateOffset) {
  4777. var milliseconds = duration._milliseconds,
  4778. days = absRound(duration._days),
  4779. months = absRound(duration._months);
  4780. if (!mom.isValid()) {
  4781. // No op
  4782. return;
  4783. }
  4784. updateOffset = updateOffset == null ? true : updateOffset;
  4785. if (months) {
  4786. setMonth(mom, get(mom, 'Month') + months * isAdding);
  4787. }
  4788. if (days) {
  4789. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  4790. }
  4791. if (milliseconds) {
  4792. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  4793. }
  4794. if (updateOffset) {
  4795. hooks.updateOffset(mom, days || months);
  4796. }
  4797. }
  4798. var add = createAdder(1, 'add'),
  4799. subtract = createAdder(-1, 'subtract');
  4800. function isString(input) {
  4801. return typeof input === 'string' || input instanceof String;
  4802. }
  4803. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  4804. function isMomentInput(input) {
  4805. return (
  4806. isMoment(input) ||
  4807. isDate(input) ||
  4808. isString(input) ||
  4809. isNumber(input) ||
  4810. isNumberOrStringArray(input) ||
  4811. isMomentInputObject(input) ||
  4812. input === null ||
  4813. input === undefined
  4814. );
  4815. }
  4816. function isMomentInputObject(input) {
  4817. var objectTest = isObject(input) && !isObjectEmpty(input),
  4818. propertyTest = false,
  4819. properties = [
  4820. 'years',
  4821. 'year',
  4822. 'y',
  4823. 'months',
  4824. 'month',
  4825. 'M',
  4826. 'days',
  4827. 'day',
  4828. 'd',
  4829. 'dates',
  4830. 'date',
  4831. 'D',
  4832. 'hours',
  4833. 'hour',
  4834. 'h',
  4835. 'minutes',
  4836. 'minute',
  4837. 'm',
  4838. 'seconds',
  4839. 'second',
  4840. 's',
  4841. 'milliseconds',
  4842. 'millisecond',
  4843. 'ms',
  4844. ],
  4845. i,
  4846. property;
  4847. for (i = 0; i < properties.length; i += 1) {
  4848. property = properties[i];
  4849. propertyTest = propertyTest || hasOwnProp(input, property);
  4850. }
  4851. return objectTest && propertyTest;
  4852. }
  4853. function isNumberOrStringArray(input) {
  4854. var arrayTest = isArray(input),
  4855. dataTypeTest = false;
  4856. if (arrayTest) {
  4857. dataTypeTest =
  4858. input.filter(function (item) {
  4859. return !isNumber(item) && isString(input);
  4860. }).length === 0;
  4861. }
  4862. return arrayTest && dataTypeTest;
  4863. }
  4864. function isCalendarSpec(input) {
  4865. var objectTest = isObject(input) && !isObjectEmpty(input),
  4866. propertyTest = false,
  4867. properties = [
  4868. 'sameDay',
  4869. 'nextDay',
  4870. 'lastDay',
  4871. 'nextWeek',
  4872. 'lastWeek',
  4873. 'sameElse',
  4874. ],
  4875. i,
  4876. property;
  4877. for (i = 0; i < properties.length; i += 1) {
  4878. property = properties[i];
  4879. propertyTest = propertyTest || hasOwnProp(input, property);
  4880. }
  4881. return objectTest && propertyTest;
  4882. }
  4883. function getCalendarFormat(myMoment, now) {
  4884. var diff = myMoment.diff(now, 'days', true);
  4885. return diff < -6
  4886. ? 'sameElse'
  4887. : diff < -1
  4888. ? 'lastWeek'
  4889. : diff < 0
  4890. ? 'lastDay'
  4891. : diff < 1
  4892. ? 'sameDay'
  4893. : diff < 2
  4894. ? 'nextDay'
  4895. : diff < 7
  4896. ? 'nextWeek'
  4897. : 'sameElse';
  4898. }
  4899. function calendar$1(time, formats) {
  4900. // Support for single parameter, formats only overload to the calendar function
  4901. if (arguments.length === 1) {
  4902. if (!arguments[0]) {
  4903. time = undefined;
  4904. formats = undefined;
  4905. } else if (isMomentInput(arguments[0])) {
  4906. time = arguments[0];
  4907. formats = undefined;
  4908. } else if (isCalendarSpec(arguments[0])) {
  4909. formats = arguments[0];
  4910. time = undefined;
  4911. }
  4912. }
  4913. // We want to compare the start of today, vs this.
  4914. // Getting start-of-today depends on whether we're local/utc/offset or not.
  4915. var now = time || createLocal(),
  4916. sod = cloneWithOffset(now, this).startOf('day'),
  4917. format = hooks.calendarFormat(this, sod) || 'sameElse',
  4918. output =
  4919. formats &&
  4920. (isFunction(formats[format])
  4921. ? formats[format].call(this, now)
  4922. : formats[format]);
  4923. return this.format(
  4924. output || this.localeData().calendar(format, this, createLocal(now))
  4925. );
  4926. }
  4927. function clone() {
  4928. return new Moment(this);
  4929. }
  4930. function isAfter(input, units) {
  4931. var localInput = isMoment(input) ? input : createLocal(input);
  4932. if (!(this.isValid() && localInput.isValid())) {
  4933. return false;
  4934. }
  4935. units = normalizeUnits(units) || 'millisecond';
  4936. if (units === 'millisecond') {
  4937. return this.valueOf() > localInput.valueOf();
  4938. } else {
  4939. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  4940. }
  4941. }
  4942. function isBefore(input, units) {
  4943. var localInput = isMoment(input) ? input : createLocal(input);
  4944. if (!(this.isValid() && localInput.isValid())) {
  4945. return false;
  4946. }
  4947. units = normalizeUnits(units) || 'millisecond';
  4948. if (units === 'millisecond') {
  4949. return this.valueOf() < localInput.valueOf();
  4950. } else {
  4951. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  4952. }
  4953. }
  4954. function isBetween(from, to, units, inclusivity) {
  4955. var localFrom = isMoment(from) ? from : createLocal(from),
  4956. localTo = isMoment(to) ? to : createLocal(to);
  4957. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  4958. return false;
  4959. }
  4960. inclusivity = inclusivity || '()';
  4961. return (
  4962. (inclusivity[0] === '('
  4963. ? this.isAfter(localFrom, units)
  4964. : !this.isBefore(localFrom, units)) &&
  4965. (inclusivity[1] === ')'
  4966. ? this.isBefore(localTo, units)
  4967. : !this.isAfter(localTo, units))
  4968. );
  4969. }
  4970. function isSame(input, units) {
  4971. var localInput = isMoment(input) ? input : createLocal(input),
  4972. inputMs;
  4973. if (!(this.isValid() && localInput.isValid())) {
  4974. return false;
  4975. }
  4976. units = normalizeUnits(units) || 'millisecond';
  4977. if (units === 'millisecond') {
  4978. return this.valueOf() === localInput.valueOf();
  4979. } else {
  4980. inputMs = localInput.valueOf();
  4981. return (
  4982. this.clone().startOf(units).valueOf() <= inputMs &&
  4983. inputMs <= this.clone().endOf(units).valueOf()
  4984. );
  4985. }
  4986. }
  4987. function isSameOrAfter(input, units) {
  4988. return this.isSame(input, units) || this.isAfter(input, units);
  4989. }
  4990. function isSameOrBefore(input, units) {
  4991. return this.isSame(input, units) || this.isBefore(input, units);
  4992. }
  4993. function diff(input, units, asFloat) {
  4994. var that, zoneDelta, output;
  4995. if (!this.isValid()) {
  4996. return NaN;
  4997. }
  4998. that = cloneWithOffset(input, this);
  4999. if (!that.isValid()) {
  5000. return NaN;
  5001. }
  5002. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  5003. units = normalizeUnits(units);
  5004. switch (units) {
  5005. case 'year':
  5006. output = monthDiff(this, that) / 12;
  5007. break;
  5008. case 'month':
  5009. output = monthDiff(this, that);
  5010. break;
  5011. case 'quarter':
  5012. output = monthDiff(this, that) / 3;
  5013. break;
  5014. case 'second':
  5015. output = (this - that) / 1e3;
  5016. break; // 1000
  5017. case 'minute':
  5018. output = (this - that) / 6e4;
  5019. break; // 1000 * 60
  5020. case 'hour':
  5021. output = (this - that) / 36e5;
  5022. break; // 1000 * 60 * 60
  5023. case 'day':
  5024. output = (this - that - zoneDelta) / 864e5;
  5025. break; // 1000 * 60 * 60 * 24, negate dst
  5026. case 'week':
  5027. output = (this - that - zoneDelta) / 6048e5;
  5028. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  5029. default:
  5030. output = this - that;
  5031. }
  5032. return asFloat ? output : absFloor(output);
  5033. }
  5034. function monthDiff(a, b) {
  5035. if (a.date() < b.date()) {
  5036. // end-of-month calculations work correct when the start month has more
  5037. // days than the end month.
  5038. return -monthDiff(b, a);
  5039. }
  5040. // difference in months
  5041. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  5042. // b is in (anchor - 1 month, anchor + 1 month)
  5043. anchor = a.clone().add(wholeMonthDiff, 'months'),
  5044. anchor2,
  5045. adjust;
  5046. if (b - anchor < 0) {
  5047. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  5048. // linear across the month
  5049. adjust = (b - anchor) / (anchor - anchor2);
  5050. } else {
  5051. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  5052. // linear across the month
  5053. adjust = (b - anchor) / (anchor2 - anchor);
  5054. }
  5055. //check for negative zero, return zero if negative zero
  5056. return -(wholeMonthDiff + adjust) || 0;
  5057. }
  5058. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  5059. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  5060. function toString() {
  5061. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  5062. }
  5063. function toISOString(keepOffset) {
  5064. if (!this.isValid()) {
  5065. return null;
  5066. }
  5067. var utc = keepOffset !== true,
  5068. m = utc ? this.clone().utc() : this;
  5069. if (m.year() < 0 || m.year() > 9999) {
  5070. return formatMoment(
  5071. m,
  5072. utc
  5073. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  5074. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  5075. );
  5076. }
  5077. if (isFunction(Date.prototype.toISOString)) {
  5078. // native implementation is ~50x faster, use it when we can
  5079. if (utc) {
  5080. return this.toDate().toISOString();
  5081. } else {
  5082. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  5083. .toISOString()
  5084. .replace('Z', formatMoment(m, 'Z'));
  5085. }
  5086. }
  5087. return formatMoment(
  5088. m,
  5089. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  5090. );
  5091. }
  5092. /**
  5093. * Return a human readable representation of a moment that can
  5094. * also be evaluated to get a new moment which is the same
  5095. *
  5096. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  5097. */
  5098. function inspect() {
  5099. if (!this.isValid()) {
  5100. return 'moment.invalid(/* ' + this._i + ' */)';
  5101. }
  5102. var func = 'moment',
  5103. zone = '',
  5104. prefix,
  5105. year,
  5106. datetime,
  5107. suffix;
  5108. if (!this.isLocal()) {
  5109. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  5110. zone = 'Z';
  5111. }
  5112. prefix = '[' + func + '("]';
  5113. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  5114. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  5115. suffix = zone + '[")]';
  5116. return this.format(prefix + year + datetime + suffix);
  5117. }
  5118. function format(inputString) {
  5119. if (!inputString) {
  5120. inputString = this.isUtc()
  5121. ? hooks.defaultFormatUtc
  5122. : hooks.defaultFormat;
  5123. }
  5124. var output = formatMoment(this, inputString);
  5125. return this.localeData().postformat(output);
  5126. }
  5127. function from(time, withoutSuffix) {
  5128. if (
  5129. this.isValid() &&
  5130. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  5131. ) {
  5132. return createDuration({ to: this, from: time })
  5133. .locale(this.locale())
  5134. .humanize(!withoutSuffix);
  5135. } else {
  5136. return this.localeData().invalidDate();
  5137. }
  5138. }
  5139. function fromNow(withoutSuffix) {
  5140. return this.from(createLocal(), withoutSuffix);
  5141. }
  5142. function to(time, withoutSuffix) {
  5143. if (
  5144. this.isValid() &&
  5145. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  5146. ) {
  5147. return createDuration({ from: this, to: time })
  5148. .locale(this.locale())
  5149. .humanize(!withoutSuffix);
  5150. } else {
  5151. return this.localeData().invalidDate();
  5152. }
  5153. }
  5154. function toNow(withoutSuffix) {
  5155. return this.to(createLocal(), withoutSuffix);
  5156. }
  5157. // If passed a locale key, it will set the locale for this
  5158. // instance. Otherwise, it will return the locale configuration
  5159. // variables for this instance.
  5160. function locale(key) {
  5161. var newLocaleData;
  5162. if (key === undefined) {
  5163. return this._locale._abbr;
  5164. } else {
  5165. newLocaleData = getLocale(key);
  5166. if (newLocaleData != null) {
  5167. this._locale = newLocaleData;
  5168. }
  5169. return this;
  5170. }
  5171. }
  5172. var lang = deprecate(
  5173. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  5174. function (key) {
  5175. if (key === undefined) {
  5176. return this.localeData();
  5177. } else {
  5178. return this.locale(key);
  5179. }
  5180. }
  5181. );
  5182. function localeData() {
  5183. return this._locale;
  5184. }
  5185. var MS_PER_SECOND = 1000,
  5186. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  5187. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  5188. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  5189. // actual modulo - handles negative numbers (for dates before 1970):
  5190. function mod$1(dividend, divisor) {
  5191. return ((dividend % divisor) + divisor) % divisor;
  5192. }
  5193. function localStartOfDate(y, m, d) {
  5194. // the date constructor remaps years 0-99 to 1900-1999
  5195. if (y < 100 && y >= 0) {
  5196. // preserve leap years using a full 400 year cycle, then reset
  5197. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  5198. } else {
  5199. return new Date(y, m, d).valueOf();
  5200. }
  5201. }
  5202. function utcStartOfDate(y, m, d) {
  5203. // Date.UTC remaps years 0-99 to 1900-1999
  5204. if (y < 100 && y >= 0) {
  5205. // preserve leap years using a full 400 year cycle, then reset
  5206. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  5207. } else {
  5208. return Date.UTC(y, m, d);
  5209. }
  5210. }
  5211. function startOf(units) {
  5212. var time, startOfDate;
  5213. units = normalizeUnits(units);
  5214. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  5215. return this;
  5216. }
  5217. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  5218. switch (units) {
  5219. case 'year':
  5220. time = startOfDate(this.year(), 0, 1);
  5221. break;
  5222. case 'quarter':
  5223. time = startOfDate(
  5224. this.year(),
  5225. this.month() - (this.month() % 3),
  5226. 1
  5227. );
  5228. break;
  5229. case 'month':
  5230. time = startOfDate(this.year(), this.month(), 1);
  5231. break;
  5232. case 'week':
  5233. time = startOfDate(
  5234. this.year(),
  5235. this.month(),
  5236. this.date() - this.weekday()
  5237. );
  5238. break;
  5239. case 'isoWeek':
  5240. time = startOfDate(
  5241. this.year(),
  5242. this.month(),
  5243. this.date() - (this.isoWeekday() - 1)
  5244. );
  5245. break;
  5246. case 'day':
  5247. case 'date':
  5248. time = startOfDate(this.year(), this.month(), this.date());
  5249. break;
  5250. case 'hour':
  5251. time = this._d.valueOf();
  5252. time -= mod$1(
  5253. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  5254. MS_PER_HOUR
  5255. );
  5256. break;
  5257. case 'minute':
  5258. time = this._d.valueOf();
  5259. time -= mod$1(time, MS_PER_MINUTE);
  5260. break;
  5261. case 'second':
  5262. time = this._d.valueOf();
  5263. time -= mod$1(time, MS_PER_SECOND);
  5264. break;
  5265. }
  5266. this._d.setTime(time);
  5267. hooks.updateOffset(this, true);
  5268. return this;
  5269. }
  5270. function endOf(units) {
  5271. var time, startOfDate;
  5272. units = normalizeUnits(units);
  5273. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  5274. return this;
  5275. }
  5276. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  5277. switch (units) {
  5278. case 'year':
  5279. time = startOfDate(this.year() + 1, 0, 1) - 1;
  5280. break;
  5281. case 'quarter':
  5282. time =
  5283. startOfDate(
  5284. this.year(),
  5285. this.month() - (this.month() % 3) + 3,
  5286. 1
  5287. ) - 1;
  5288. break;
  5289. case 'month':
  5290. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  5291. break;
  5292. case 'week':
  5293. time =
  5294. startOfDate(
  5295. this.year(),
  5296. this.month(),
  5297. this.date() - this.weekday() + 7
  5298. ) - 1;
  5299. break;
  5300. case 'isoWeek':
  5301. time =
  5302. startOfDate(
  5303. this.year(),
  5304. this.month(),
  5305. this.date() - (this.isoWeekday() - 1) + 7
  5306. ) - 1;
  5307. break;
  5308. case 'day':
  5309. case 'date':
  5310. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  5311. break;
  5312. case 'hour':
  5313. time = this._d.valueOf();
  5314. time +=
  5315. MS_PER_HOUR -
  5316. mod$1(
  5317. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  5318. MS_PER_HOUR
  5319. ) -
  5320. 1;
  5321. break;
  5322. case 'minute':
  5323. time = this._d.valueOf();
  5324. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  5325. break;
  5326. case 'second':
  5327. time = this._d.valueOf();
  5328. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  5329. break;
  5330. }
  5331. this._d.setTime(time);
  5332. hooks.updateOffset(this, true);
  5333. return this;
  5334. }
  5335. function valueOf() {
  5336. return this._d.valueOf() - (this._offset || 0) * 60000;
  5337. }
  5338. function unix() {
  5339. return Math.floor(this.valueOf() / 1000);
  5340. }
  5341. function toDate() {
  5342. return new Date(this.valueOf());
  5343. }
  5344. function toArray() {
  5345. var m = this;
  5346. return [
  5347. m.year(),
  5348. m.month(),
  5349. m.date(),
  5350. m.hour(),
  5351. m.minute(),
  5352. m.second(),
  5353. m.millisecond(),
  5354. ];
  5355. }
  5356. function toObject() {
  5357. var m = this;
  5358. return {
  5359. years: m.year(),
  5360. months: m.month(),
  5361. date: m.date(),
  5362. hours: m.hours(),
  5363. minutes: m.minutes(),
  5364. seconds: m.seconds(),
  5365. milliseconds: m.milliseconds(),
  5366. };
  5367. }
  5368. function toJSON() {
  5369. // new Date(NaN).toJSON() === null
  5370. return this.isValid() ? this.toISOString() : null;
  5371. }
  5372. function isValid$2() {
  5373. return isValid(this);
  5374. }
  5375. function parsingFlags() {
  5376. return extend({}, getParsingFlags(this));
  5377. }
  5378. function invalidAt() {
  5379. return getParsingFlags(this).overflow;
  5380. }
  5381. function creationData() {
  5382. return {
  5383. input: this._i,
  5384. format: this._f,
  5385. locale: this._locale,
  5386. isUTC: this._isUTC,
  5387. strict: this._strict,
  5388. };
  5389. }
  5390. addFormatToken('N', 0, 0, 'eraAbbr');
  5391. addFormatToken('NN', 0, 0, 'eraAbbr');
  5392. addFormatToken('NNN', 0, 0, 'eraAbbr');
  5393. addFormatToken('NNNN', 0, 0, 'eraName');
  5394. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  5395. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  5396. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  5397. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  5398. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  5399. addRegexToken('N', matchEraAbbr);
  5400. addRegexToken('NN', matchEraAbbr);
  5401. addRegexToken('NNN', matchEraAbbr);
  5402. addRegexToken('NNNN', matchEraName);
  5403. addRegexToken('NNNNN', matchEraNarrow);
  5404. addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function (
  5405. input,
  5406. array,
  5407. config,
  5408. token
  5409. ) {
  5410. var era = config._locale.erasParse(input, token, config._strict);
  5411. if (era) {
  5412. getParsingFlags(config).era = era;
  5413. } else {
  5414. getParsingFlags(config).invalidEra = input;
  5415. }
  5416. });
  5417. addRegexToken('y', matchUnsigned);
  5418. addRegexToken('yy', matchUnsigned);
  5419. addRegexToken('yyy', matchUnsigned);
  5420. addRegexToken('yyyy', matchUnsigned);
  5421. addRegexToken('yo', matchEraYearOrdinal);
  5422. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  5423. addParseToken(['yo'], function (input, array, config, token) {
  5424. var match;
  5425. if (config._locale._eraYearOrdinalRegex) {
  5426. match = input.match(config._locale._eraYearOrdinalRegex);
  5427. }
  5428. if (config._locale.eraYearOrdinalParse) {
  5429. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  5430. } else {
  5431. array[YEAR] = parseInt(input, 10);
  5432. }
  5433. });
  5434. function localeEras(m, format) {
  5435. var i,
  5436. l,
  5437. date,
  5438. eras = this._eras || getLocale('en')._eras;
  5439. for (i = 0, l = eras.length; i < l; ++i) {
  5440. switch (typeof eras[i].since) {
  5441. case 'string':
  5442. // truncate time
  5443. date = hooks(eras[i].since).startOf('day');
  5444. eras[i].since = date.valueOf();
  5445. break;
  5446. }
  5447. switch (typeof eras[i].until) {
  5448. case 'undefined':
  5449. eras[i].until = +Infinity;
  5450. break;
  5451. case 'string':
  5452. // truncate time
  5453. date = hooks(eras[i].until).startOf('day').valueOf();
  5454. eras[i].until = date.valueOf();
  5455. break;
  5456. }
  5457. }
  5458. return eras;
  5459. }
  5460. function localeErasParse(eraName, format, strict) {
  5461. var i,
  5462. l,
  5463. eras = this.eras(),
  5464. name,
  5465. abbr,
  5466. narrow;
  5467. eraName = eraName.toUpperCase();
  5468. for (i = 0, l = eras.length; i < l; ++i) {
  5469. name = eras[i].name.toUpperCase();
  5470. abbr = eras[i].abbr.toUpperCase();
  5471. narrow = eras[i].narrow.toUpperCase();
  5472. if (strict) {
  5473. switch (format) {
  5474. case 'N':
  5475. case 'NN':
  5476. case 'NNN':
  5477. if (abbr === eraName) {
  5478. return eras[i];
  5479. }
  5480. break;
  5481. case 'NNNN':
  5482. if (name === eraName) {
  5483. return eras[i];
  5484. }
  5485. break;
  5486. case 'NNNNN':
  5487. if (narrow === eraName) {
  5488. return eras[i];
  5489. }
  5490. break;
  5491. }
  5492. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  5493. return eras[i];
  5494. }
  5495. }
  5496. }
  5497. function localeErasConvertYear(era, year) {
  5498. var dir = era.since <= era.until ? +1 : -1;
  5499. if (year === undefined) {
  5500. return hooks(era.since).year();
  5501. } else {
  5502. return hooks(era.since).year() + (year - era.offset) * dir;
  5503. }
  5504. }
  5505. function getEraName() {
  5506. var i,
  5507. l,
  5508. val,
  5509. eras = this.localeData().eras();
  5510. for (i = 0, l = eras.length; i < l; ++i) {
  5511. // truncate time
  5512. val = this.clone().startOf('day').valueOf();
  5513. if (eras[i].since <= val && val <= eras[i].until) {
  5514. return eras[i].name;
  5515. }
  5516. if (eras[i].until <= val && val <= eras[i].since) {
  5517. return eras[i].name;
  5518. }
  5519. }
  5520. return '';
  5521. }
  5522. function getEraNarrow() {
  5523. var i,
  5524. l,
  5525. val,
  5526. eras = this.localeData().eras();
  5527. for (i = 0, l = eras.length; i < l; ++i) {
  5528. // truncate time
  5529. val = this.clone().startOf('day').valueOf();
  5530. if (eras[i].since <= val && val <= eras[i].until) {
  5531. return eras[i].narrow;
  5532. }
  5533. if (eras[i].until <= val && val <= eras[i].since) {
  5534. return eras[i].narrow;
  5535. }
  5536. }
  5537. return '';
  5538. }
  5539. function getEraAbbr() {
  5540. var i,
  5541. l,
  5542. val,
  5543. eras = this.localeData().eras();
  5544. for (i = 0, l = eras.length; i < l; ++i) {
  5545. // truncate time
  5546. val = this.clone().startOf('day').valueOf();
  5547. if (eras[i].since <= val && val <= eras[i].until) {
  5548. return eras[i].abbr;
  5549. }
  5550. if (eras[i].until <= val && val <= eras[i].since) {
  5551. return eras[i].abbr;
  5552. }
  5553. }
  5554. return '';
  5555. }
  5556. function getEraYear() {
  5557. var i,
  5558. l,
  5559. dir,
  5560. val,
  5561. eras = this.localeData().eras();
  5562. for (i = 0, l = eras.length; i < l; ++i) {
  5563. dir = eras[i].since <= eras[i].until ? +1 : -1;
  5564. // truncate time
  5565. val = this.clone().startOf('day').valueOf();
  5566. if (
  5567. (eras[i].since <= val && val <= eras[i].until) ||
  5568. (eras[i].until <= val && val <= eras[i].since)
  5569. ) {
  5570. return (
  5571. (this.year() - hooks(eras[i].since).year()) * dir +
  5572. eras[i].offset
  5573. );
  5574. }
  5575. }
  5576. return this.year();
  5577. }
  5578. function erasNameRegex(isStrict) {
  5579. if (!hasOwnProp(this, '_erasNameRegex')) {
  5580. computeErasParse.call(this);
  5581. }
  5582. return isStrict ? this._erasNameRegex : this._erasRegex;
  5583. }
  5584. function erasAbbrRegex(isStrict) {
  5585. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  5586. computeErasParse.call(this);
  5587. }
  5588. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  5589. }
  5590. function erasNarrowRegex(isStrict) {
  5591. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  5592. computeErasParse.call(this);
  5593. }
  5594. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  5595. }
  5596. function matchEraAbbr(isStrict, locale) {
  5597. return locale.erasAbbrRegex(isStrict);
  5598. }
  5599. function matchEraName(isStrict, locale) {
  5600. return locale.erasNameRegex(isStrict);
  5601. }
  5602. function matchEraNarrow(isStrict, locale) {
  5603. return locale.erasNarrowRegex(isStrict);
  5604. }
  5605. function matchEraYearOrdinal(isStrict, locale) {
  5606. return locale._eraYearOrdinalRegex || matchUnsigned;
  5607. }
  5608. function computeErasParse() {
  5609. var abbrPieces = [],
  5610. namePieces = [],
  5611. narrowPieces = [],
  5612. mixedPieces = [],
  5613. i,
  5614. l,
  5615. eras = this.eras();
  5616. for (i = 0, l = eras.length; i < l; ++i) {
  5617. namePieces.push(regexEscape(eras[i].name));
  5618. abbrPieces.push(regexEscape(eras[i].abbr));
  5619. narrowPieces.push(regexEscape(eras[i].narrow));
  5620. mixedPieces.push(regexEscape(eras[i].name));
  5621. mixedPieces.push(regexEscape(eras[i].abbr));
  5622. mixedPieces.push(regexEscape(eras[i].narrow));
  5623. }
  5624. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  5625. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  5626. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  5627. this._erasNarrowRegex = new RegExp(
  5628. '^(' + narrowPieces.join('|') + ')',
  5629. 'i'
  5630. );
  5631. }
  5632. // FORMATTING
  5633. addFormatToken(0, ['gg', 2], 0, function () {
  5634. return this.weekYear() % 100;
  5635. });
  5636. addFormatToken(0, ['GG', 2], 0, function () {
  5637. return this.isoWeekYear() % 100;
  5638. });
  5639. function addWeekYearFormatToken(token, getter) {
  5640. addFormatToken(0, [token, token.length], 0, getter);
  5641. }
  5642. addWeekYearFormatToken('gggg', 'weekYear');
  5643. addWeekYearFormatToken('ggggg', 'weekYear');
  5644. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  5645. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  5646. // ALIASES
  5647. addUnitAlias('weekYear', 'gg');
  5648. addUnitAlias('isoWeekYear', 'GG');
  5649. // PRIORITY
  5650. addUnitPriority('weekYear', 1);
  5651. addUnitPriority('isoWeekYear', 1);
  5652. // PARSING
  5653. addRegexToken('G', matchSigned);
  5654. addRegexToken('g', matchSigned);
  5655. addRegexToken('GG', match1to2, match2);
  5656. addRegexToken('gg', match1to2, match2);
  5657. addRegexToken('GGGG', match1to4, match4);
  5658. addRegexToken('gggg', match1to4, match4);
  5659. addRegexToken('GGGGG', match1to6, match6);
  5660. addRegexToken('ggggg', match1to6, match6);
  5661. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (
  5662. input,
  5663. week,
  5664. config,
  5665. token
  5666. ) {
  5667. week[token.substr(0, 2)] = toInt(input);
  5668. });
  5669. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  5670. week[token] = hooks.parseTwoDigitYear(input);
  5671. });
  5672. // MOMENTS
  5673. function getSetWeekYear(input) {
  5674. return getSetWeekYearHelper.call(
  5675. this,
  5676. input,
  5677. this.week(),
  5678. this.weekday(),
  5679. this.localeData()._week.dow,
  5680. this.localeData()._week.doy
  5681. );
  5682. }
  5683. function getSetISOWeekYear(input) {
  5684. return getSetWeekYearHelper.call(
  5685. this,
  5686. input,
  5687. this.isoWeek(),
  5688. this.isoWeekday(),
  5689. 1,
  5690. 4
  5691. );
  5692. }
  5693. function getISOWeeksInYear() {
  5694. return weeksInYear(this.year(), 1, 4);
  5695. }
  5696. function getISOWeeksInISOWeekYear() {
  5697. return weeksInYear(this.isoWeekYear(), 1, 4);
  5698. }
  5699. function getWeeksInYear() {
  5700. var weekInfo = this.localeData()._week;
  5701. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  5702. }
  5703. function getWeeksInWeekYear() {
  5704. var weekInfo = this.localeData()._week;
  5705. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  5706. }
  5707. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  5708. var weeksTarget;
  5709. if (input == null) {
  5710. return weekOfYear(this, dow, doy).year;
  5711. } else {
  5712. weeksTarget = weeksInYear(input, dow, doy);
  5713. if (week > weeksTarget) {
  5714. week = weeksTarget;
  5715. }
  5716. return setWeekAll.call(this, input, week, weekday, dow, doy);
  5717. }
  5718. }
  5719. function setWeekAll(weekYear, week, weekday, dow, doy) {
  5720. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  5721. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  5722. this.year(date.getUTCFullYear());
  5723. this.month(date.getUTCMonth());
  5724. this.date(date.getUTCDate());
  5725. return this;
  5726. }
  5727. // FORMATTING
  5728. addFormatToken('Q', 0, 'Qo', 'quarter');
  5729. // ALIASES
  5730. addUnitAlias('quarter', 'Q');
  5731. // PRIORITY
  5732. addUnitPriority('quarter', 7);
  5733. // PARSING
  5734. addRegexToken('Q', match1);
  5735. addParseToken('Q', function (input, array) {
  5736. array[MONTH] = (toInt(input) - 1) * 3;
  5737. });
  5738. // MOMENTS
  5739. function getSetQuarter(input) {
  5740. return input == null
  5741. ? Math.ceil((this.month() + 1) / 3)
  5742. : this.month((input - 1) * 3 + (this.month() % 3));
  5743. }
  5744. // FORMATTING
  5745. addFormatToken('D', ['DD', 2], 'Do', 'date');
  5746. // ALIASES
  5747. addUnitAlias('date', 'D');
  5748. // PRIORITY
  5749. addUnitPriority('date', 9);
  5750. // PARSING
  5751. addRegexToken('D', match1to2);
  5752. addRegexToken('DD', match1to2, match2);
  5753. addRegexToken('Do', function (isStrict, locale) {
  5754. // TODO: Remove "ordinalParse" fallback in next major release.
  5755. return isStrict
  5756. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  5757. : locale._dayOfMonthOrdinalParseLenient;
  5758. });
  5759. addParseToken(['D', 'DD'], DATE);
  5760. addParseToken('Do', function (input, array) {
  5761. array[DATE] = toInt(input.match(match1to2)[0]);
  5762. });
  5763. // MOMENTS
  5764. var getSetDayOfMonth = makeGetSet('Date', true);
  5765. // FORMATTING
  5766. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  5767. // ALIASES
  5768. addUnitAlias('dayOfYear', 'DDD');
  5769. // PRIORITY
  5770. addUnitPriority('dayOfYear', 4);
  5771. // PARSING
  5772. addRegexToken('DDD', match1to3);
  5773. addRegexToken('DDDD', match3);
  5774. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  5775. config._dayOfYear = toInt(input);
  5776. });
  5777. // HELPERS
  5778. // MOMENTS
  5779. function getSetDayOfYear(input) {
  5780. var dayOfYear =
  5781. Math.round(
  5782. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  5783. ) + 1;
  5784. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  5785. }
  5786. // FORMATTING
  5787. addFormatToken('m', ['mm', 2], 0, 'minute');
  5788. // ALIASES
  5789. addUnitAlias('minute', 'm');
  5790. // PRIORITY
  5791. addUnitPriority('minute', 14);
  5792. // PARSING
  5793. addRegexToken('m', match1to2);
  5794. addRegexToken('mm', match1to2, match2);
  5795. addParseToken(['m', 'mm'], MINUTE);
  5796. // MOMENTS
  5797. var getSetMinute = makeGetSet('Minutes', false);
  5798. // FORMATTING
  5799. addFormatToken('s', ['ss', 2], 0, 'second');
  5800. // ALIASES
  5801. addUnitAlias('second', 's');
  5802. // PRIORITY
  5803. addUnitPriority('second', 15);
  5804. // PARSING
  5805. addRegexToken('s', match1to2);
  5806. addRegexToken('ss', match1to2, match2);
  5807. addParseToken(['s', 'ss'], SECOND);
  5808. // MOMENTS
  5809. var getSetSecond = makeGetSet('Seconds', false);
  5810. // FORMATTING
  5811. addFormatToken('S', 0, 0, function () {
  5812. return ~~(this.millisecond() / 100);
  5813. });
  5814. addFormatToken(0, ['SS', 2], 0, function () {
  5815. return ~~(this.millisecond() / 10);
  5816. });
  5817. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  5818. addFormatToken(0, ['SSSS', 4], 0, function () {
  5819. return this.millisecond() * 10;
  5820. });
  5821. addFormatToken(0, ['SSSSS', 5], 0, function () {
  5822. return this.millisecond() * 100;
  5823. });
  5824. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  5825. return this.millisecond() * 1000;
  5826. });
  5827. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  5828. return this.millisecond() * 10000;
  5829. });
  5830. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  5831. return this.millisecond() * 100000;
  5832. });
  5833. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  5834. return this.millisecond() * 1000000;
  5835. });
  5836. // ALIASES
  5837. addUnitAlias('millisecond', 'ms');
  5838. // PRIORITY
  5839. addUnitPriority('millisecond', 16);
  5840. // PARSING
  5841. addRegexToken('S', match1to3, match1);
  5842. addRegexToken('SS', match1to3, match2);
  5843. addRegexToken('SSS', match1to3, match3);
  5844. var token, getSetMillisecond;
  5845. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  5846. addRegexToken(token, matchUnsigned);
  5847. }
  5848. function parseMs(input, array) {
  5849. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  5850. }
  5851. for (token = 'S'; token.length <= 9; token += 'S') {
  5852. addParseToken(token, parseMs);
  5853. }
  5854. getSetMillisecond = makeGetSet('Milliseconds', false);
  5855. // FORMATTING
  5856. addFormatToken('z', 0, 0, 'zoneAbbr');
  5857. addFormatToken('zz', 0, 0, 'zoneName');
  5858. // MOMENTS
  5859. function getZoneAbbr() {
  5860. return this._isUTC ? 'UTC' : '';
  5861. }
  5862. function getZoneName() {
  5863. return this._isUTC ? 'Coordinated Universal Time' : '';
  5864. }
  5865. var proto = Moment.prototype;
  5866. proto.add = add;
  5867. proto.calendar = calendar$1;
  5868. proto.clone = clone;
  5869. proto.diff = diff;
  5870. proto.endOf = endOf;
  5871. proto.format = format;
  5872. proto.from = from;
  5873. proto.fromNow = fromNow;
  5874. proto.to = to;
  5875. proto.toNow = toNow;
  5876. proto.get = stringGet;
  5877. proto.invalidAt = invalidAt;
  5878. proto.isAfter = isAfter;
  5879. proto.isBefore = isBefore;
  5880. proto.isBetween = isBetween;
  5881. proto.isSame = isSame;
  5882. proto.isSameOrAfter = isSameOrAfter;
  5883. proto.isSameOrBefore = isSameOrBefore;
  5884. proto.isValid = isValid$2;
  5885. proto.lang = lang;
  5886. proto.locale = locale;
  5887. proto.localeData = localeData;
  5888. proto.max = prototypeMax;
  5889. proto.min = prototypeMin;
  5890. proto.parsingFlags = parsingFlags;
  5891. proto.set = stringSet;
  5892. proto.startOf = startOf;
  5893. proto.subtract = subtract;
  5894. proto.toArray = toArray;
  5895. proto.toObject = toObject;
  5896. proto.toDate = toDate;
  5897. proto.toISOString = toISOString;
  5898. proto.inspect = inspect;
  5899. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  5900. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  5901. return 'Moment<' + this.format() + '>';
  5902. };
  5903. }
  5904. proto.toJSON = toJSON;
  5905. proto.toString = toString;
  5906. proto.unix = unix;
  5907. proto.valueOf = valueOf;
  5908. proto.creationData = creationData;
  5909. proto.eraName = getEraName;
  5910. proto.eraNarrow = getEraNarrow;
  5911. proto.eraAbbr = getEraAbbr;
  5912. proto.eraYear = getEraYear;
  5913. proto.year = getSetYear;
  5914. proto.isLeapYear = getIsLeapYear;
  5915. proto.weekYear = getSetWeekYear;
  5916. proto.isoWeekYear = getSetISOWeekYear;
  5917. proto.quarter = proto.quarters = getSetQuarter;
  5918. proto.month = getSetMonth;
  5919. proto.daysInMonth = getDaysInMonth;
  5920. proto.week = proto.weeks = getSetWeek;
  5921. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  5922. proto.weeksInYear = getWeeksInYear;
  5923. proto.weeksInWeekYear = getWeeksInWeekYear;
  5924. proto.isoWeeksInYear = getISOWeeksInYear;
  5925. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  5926. proto.date = getSetDayOfMonth;
  5927. proto.day = proto.days = getSetDayOfWeek;
  5928. proto.weekday = getSetLocaleDayOfWeek;
  5929. proto.isoWeekday = getSetISODayOfWeek;
  5930. proto.dayOfYear = getSetDayOfYear;
  5931. proto.hour = proto.hours = getSetHour;
  5932. proto.minute = proto.minutes = getSetMinute;
  5933. proto.second = proto.seconds = getSetSecond;
  5934. proto.millisecond = proto.milliseconds = getSetMillisecond;
  5935. proto.utcOffset = getSetOffset;
  5936. proto.utc = setOffsetToUTC;
  5937. proto.local = setOffsetToLocal;
  5938. proto.parseZone = setOffsetToParsedOffset;
  5939. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  5940. proto.isDST = isDaylightSavingTime;
  5941. proto.isLocal = isLocal;
  5942. proto.isUtcOffset = isUtcOffset;
  5943. proto.isUtc = isUtc;
  5944. proto.isUTC = isUtc;
  5945. proto.zoneAbbr = getZoneAbbr;
  5946. proto.zoneName = getZoneName;
  5947. proto.dates = deprecate(
  5948. 'dates accessor is deprecated. Use date instead.',
  5949. getSetDayOfMonth
  5950. );
  5951. proto.months = deprecate(
  5952. 'months accessor is deprecated. Use month instead',
  5953. getSetMonth
  5954. );
  5955. proto.years = deprecate(
  5956. 'years accessor is deprecated. Use year instead',
  5957. getSetYear
  5958. );
  5959. proto.zone = deprecate(
  5960. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  5961. getSetZone
  5962. );
  5963. proto.isDSTShifted = deprecate(
  5964. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  5965. isDaylightSavingTimeShifted
  5966. );
  5967. function createUnix(input) {
  5968. return createLocal(input * 1000);
  5969. }
  5970. function createInZone() {
  5971. return createLocal.apply(null, arguments).parseZone();
  5972. }
  5973. function preParsePostFormat(string) {
  5974. return string;
  5975. }
  5976. var proto$1 = Locale.prototype;
  5977. proto$1.calendar = calendar;
  5978. proto$1.longDateFormat = longDateFormat;
  5979. proto$1.invalidDate = invalidDate;
  5980. proto$1.ordinal = ordinal;
  5981. proto$1.preparse = preParsePostFormat;
  5982. proto$1.postformat = preParsePostFormat;
  5983. proto$1.relativeTime = relativeTime;
  5984. proto$1.pastFuture = pastFuture;
  5985. proto$1.set = set;
  5986. proto$1.eras = localeEras;
  5987. proto$1.erasParse = localeErasParse;
  5988. proto$1.erasConvertYear = localeErasConvertYear;
  5989. proto$1.erasAbbrRegex = erasAbbrRegex;
  5990. proto$1.erasNameRegex = erasNameRegex;
  5991. proto$1.erasNarrowRegex = erasNarrowRegex;
  5992. proto$1.months = localeMonths;
  5993. proto$1.monthsShort = localeMonthsShort;
  5994. proto$1.monthsParse = localeMonthsParse;
  5995. proto$1.monthsRegex = monthsRegex;
  5996. proto$1.monthsShortRegex = monthsShortRegex;
  5997. proto$1.week = localeWeek;
  5998. proto$1.firstDayOfYear = localeFirstDayOfYear;
  5999. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  6000. proto$1.weekdays = localeWeekdays;
  6001. proto$1.weekdaysMin = localeWeekdaysMin;
  6002. proto$1.weekdaysShort = localeWeekdaysShort;
  6003. proto$1.weekdaysParse = localeWeekdaysParse;
  6004. proto$1.weekdaysRegex = weekdaysRegex;
  6005. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  6006. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  6007. proto$1.isPM = localeIsPM;
  6008. proto$1.meridiem = localeMeridiem;
  6009. function get$1(format, index, field, setter) {
  6010. var locale = getLocale(),
  6011. utc = createUTC().set(setter, index);
  6012. return locale[field](utc, format);
  6013. }
  6014. function listMonthsImpl(format, index, field) {
  6015. if (isNumber(format)) {
  6016. index = format;
  6017. format = undefined;
  6018. }
  6019. format = format || '';
  6020. if (index != null) {
  6021. return get$1(format, index, field, 'month');
  6022. }
  6023. var i,
  6024. out = [];
  6025. for (i = 0; i < 12; i++) {
  6026. out[i] = get$1(format, i, field, 'month');
  6027. }
  6028. return out;
  6029. }
  6030. // ()
  6031. // (5)
  6032. // (fmt, 5)
  6033. // (fmt)
  6034. // (true)
  6035. // (true, 5)
  6036. // (true, fmt, 5)
  6037. // (true, fmt)
  6038. function listWeekdaysImpl(localeSorted, format, index, field) {
  6039. if (typeof localeSorted === 'boolean') {
  6040. if (isNumber(format)) {
  6041. index = format;
  6042. format = undefined;
  6043. }
  6044. format = format || '';
  6045. } else {
  6046. format = localeSorted;
  6047. index = format;
  6048. localeSorted = false;
  6049. if (isNumber(format)) {
  6050. index = format;
  6051. format = undefined;
  6052. }
  6053. format = format || '';
  6054. }
  6055. var locale = getLocale(),
  6056. shift = localeSorted ? locale._week.dow : 0,
  6057. i,
  6058. out = [];
  6059. if (index != null) {
  6060. return get$1(format, (index + shift) % 7, field, 'day');
  6061. }
  6062. for (i = 0; i < 7; i++) {
  6063. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  6064. }
  6065. return out;
  6066. }
  6067. function listMonths(format, index) {
  6068. return listMonthsImpl(format, index, 'months');
  6069. }
  6070. function listMonthsShort(format, index) {
  6071. return listMonthsImpl(format, index, 'monthsShort');
  6072. }
  6073. function listWeekdays(localeSorted, format, index) {
  6074. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  6075. }
  6076. function listWeekdaysShort(localeSorted, format, index) {
  6077. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  6078. }
  6079. function listWeekdaysMin(localeSorted, format, index) {
  6080. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  6081. }
  6082. getSetGlobalLocale('en', {
  6083. eras: [
  6084. {
  6085. since: '0001-01-01',
  6086. until: +Infinity,
  6087. offset: 1,
  6088. name: 'Anno Domini',
  6089. narrow: 'AD',
  6090. abbr: 'AD',
  6091. },
  6092. {
  6093. since: '0000-12-31',
  6094. until: -Infinity,
  6095. offset: 1,
  6096. name: 'Before Christ',
  6097. narrow: 'BC',
  6098. abbr: 'BC',
  6099. },
  6100. ],
  6101. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  6102. ordinal: function (number) {
  6103. var b = number % 10,
  6104. output =
  6105. toInt((number % 100) / 10) === 1
  6106. ? 'th'
  6107. : b === 1
  6108. ? 'st'
  6109. : b === 2
  6110. ? 'nd'
  6111. : b === 3
  6112. ? 'rd'
  6113. : 'th';
  6114. return number + output;
  6115. },
  6116. });
  6117. // Side effect imports
  6118. hooks.lang = deprecate(
  6119. 'moment.lang is deprecated. Use moment.locale instead.',
  6120. getSetGlobalLocale
  6121. );
  6122. hooks.langData = deprecate(
  6123. 'moment.langData is deprecated. Use moment.localeData instead.',
  6124. getLocale
  6125. );
  6126. var mathAbs = Math.abs;
  6127. function abs() {
  6128. var data = this._data;
  6129. this._milliseconds = mathAbs(this._milliseconds);
  6130. this._days = mathAbs(this._days);
  6131. this._months = mathAbs(this._months);
  6132. data.milliseconds = mathAbs(data.milliseconds);
  6133. data.seconds = mathAbs(data.seconds);
  6134. data.minutes = mathAbs(data.minutes);
  6135. data.hours = mathAbs(data.hours);
  6136. data.months = mathAbs(data.months);
  6137. data.years = mathAbs(data.years);
  6138. return this;
  6139. }
  6140. function addSubtract$1(duration, input, value, direction) {
  6141. var other = createDuration(input, value);
  6142. duration._milliseconds += direction * other._milliseconds;
  6143. duration._days += direction * other._days;
  6144. duration._months += direction * other._months;
  6145. return duration._bubble();
  6146. }
  6147. // supports only 2.0-style add(1, 's') or add(duration)
  6148. function add$1(input, value) {
  6149. return addSubtract$1(this, input, value, 1);
  6150. }
  6151. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  6152. function subtract$1(input, value) {
  6153. return addSubtract$1(this, input, value, -1);
  6154. }
  6155. function absCeil(number) {
  6156. if (number < 0) {
  6157. return Math.floor(number);
  6158. } else {
  6159. return Math.ceil(number);
  6160. }
  6161. }
  6162. function bubble() {
  6163. var milliseconds = this._milliseconds,
  6164. days = this._days,
  6165. months = this._months,
  6166. data = this._data,
  6167. seconds,
  6168. minutes,
  6169. hours,
  6170. years,
  6171. monthsFromDays;
  6172. // if we have a mix of positive and negative values, bubble down first
  6173. // check: https://github.com/moment/moment/issues/2166
  6174. if (
  6175. !(
  6176. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  6177. (milliseconds <= 0 && days <= 0 && months <= 0)
  6178. )
  6179. ) {
  6180. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  6181. days = 0;
  6182. months = 0;
  6183. }
  6184. // The following code bubbles up values, see the tests for
  6185. // examples of what that means.
  6186. data.milliseconds = milliseconds % 1000;
  6187. seconds = absFloor(milliseconds / 1000);
  6188. data.seconds = seconds % 60;
  6189. minutes = absFloor(seconds / 60);
  6190. data.minutes = minutes % 60;
  6191. hours = absFloor(minutes / 60);
  6192. data.hours = hours % 24;
  6193. days += absFloor(hours / 24);
  6194. // convert days to months
  6195. monthsFromDays = absFloor(daysToMonths(days));
  6196. months += monthsFromDays;
  6197. days -= absCeil(monthsToDays(monthsFromDays));
  6198. // 12 months -> 1 year
  6199. years = absFloor(months / 12);
  6200. months %= 12;
  6201. data.days = days;
  6202. data.months = months;
  6203. data.years = years;
  6204. return this;
  6205. }
  6206. function daysToMonths(days) {
  6207. // 400 years have 146097 days (taking into account leap year rules)
  6208. // 400 years have 12 months === 4800
  6209. return (days * 4800) / 146097;
  6210. }
  6211. function monthsToDays(months) {
  6212. // the reverse of daysToMonths
  6213. return (months * 146097) / 4800;
  6214. }
  6215. function as(units) {
  6216. if (!this.isValid()) {
  6217. return NaN;
  6218. }
  6219. var days,
  6220. months,
  6221. milliseconds = this._milliseconds;
  6222. units = normalizeUnits(units);
  6223. if (units === 'month' || units === 'quarter' || units === 'year') {
  6224. days = this._days + milliseconds / 864e5;
  6225. months = this._months + daysToMonths(days);
  6226. switch (units) {
  6227. case 'month':
  6228. return months;
  6229. case 'quarter':
  6230. return months / 3;
  6231. case 'year':
  6232. return months / 12;
  6233. }
  6234. } else {
  6235. // handle milliseconds separately because of floating point math errors (issue #1867)
  6236. days = this._days + Math.round(monthsToDays(this._months));
  6237. switch (units) {
  6238. case 'week':
  6239. return days / 7 + milliseconds / 6048e5;
  6240. case 'day':
  6241. return days + milliseconds / 864e5;
  6242. case 'hour':
  6243. return days * 24 + milliseconds / 36e5;
  6244. case 'minute':
  6245. return days * 1440 + milliseconds / 6e4;
  6246. case 'second':
  6247. return days * 86400 + milliseconds / 1000;
  6248. // Math.floor prevents floating point math errors here
  6249. case 'millisecond':
  6250. return Math.floor(days * 864e5) + milliseconds;
  6251. default:
  6252. throw new Error('Unknown unit ' + units);
  6253. }
  6254. }
  6255. }
  6256. // TODO: Use this.as('ms')?
  6257. function valueOf$1() {
  6258. if (!this.isValid()) {
  6259. return NaN;
  6260. }
  6261. return (
  6262. this._milliseconds +
  6263. this._days * 864e5 +
  6264. (this._months % 12) * 2592e6 +
  6265. toInt(this._months / 12) * 31536e6
  6266. );
  6267. }
  6268. function makeAs(alias) {
  6269. return function () {
  6270. return this.as(alias);
  6271. };
  6272. }
  6273. var asMilliseconds = makeAs('ms'),
  6274. asSeconds = makeAs('s'),
  6275. asMinutes = makeAs('m'),
  6276. asHours = makeAs('h'),
  6277. asDays = makeAs('d'),
  6278. asWeeks = makeAs('w'),
  6279. asMonths = makeAs('M'),
  6280. asQuarters = makeAs('Q'),
  6281. asYears = makeAs('y');
  6282. function clone$1() {
  6283. return createDuration(this);
  6284. }
  6285. function get$2(units) {
  6286. units = normalizeUnits(units);
  6287. return this.isValid() ? this[units + 's']() : NaN;
  6288. }
  6289. function makeGetter(name) {
  6290. return function () {
  6291. return this.isValid() ? this._data[name] : NaN;
  6292. };
  6293. }
  6294. var milliseconds = makeGetter('milliseconds'),
  6295. seconds = makeGetter('seconds'),
  6296. minutes = makeGetter('minutes'),
  6297. hours = makeGetter('hours'),
  6298. days = makeGetter('days'),
  6299. months = makeGetter('months'),
  6300. years = makeGetter('years');
  6301. function weeks() {
  6302. return absFloor(this.days() / 7);
  6303. }
  6304. var round = Math.round,
  6305. thresholds = {
  6306. ss: 44, // a few seconds to seconds
  6307. s: 45, // seconds to minute
  6308. m: 45, // minutes to hour
  6309. h: 22, // hours to day
  6310. d: 26, // days to month/week
  6311. w: null, // weeks to month
  6312. M: 11, // months to year
  6313. };
  6314. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  6315. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  6316. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  6317. }
  6318. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  6319. var duration = createDuration(posNegDuration).abs(),
  6320. seconds = round(duration.as('s')),
  6321. minutes = round(duration.as('m')),
  6322. hours = round(duration.as('h')),
  6323. days = round(duration.as('d')),
  6324. months = round(duration.as('M')),
  6325. weeks = round(duration.as('w')),
  6326. years = round(duration.as('y')),
  6327. a =
  6328. (seconds <= thresholds.ss && ['s', seconds]) ||
  6329. (seconds < thresholds.s && ['ss', seconds]) ||
  6330. (minutes <= 1 && ['m']) ||
  6331. (minutes < thresholds.m && ['mm', minutes]) ||
  6332. (hours <= 1 && ['h']) ||
  6333. (hours < thresholds.h && ['hh', hours]) ||
  6334. (days <= 1 && ['d']) ||
  6335. (days < thresholds.d && ['dd', days]);
  6336. if (thresholds.w != null) {
  6337. a =
  6338. a ||
  6339. (weeks <= 1 && ['w']) ||
  6340. (weeks < thresholds.w && ['ww', weeks]);
  6341. }
  6342. a = a ||
  6343. (months <= 1 && ['M']) ||
  6344. (months < thresholds.M && ['MM', months]) ||
  6345. (years <= 1 && ['y']) || ['yy', years];
  6346. a[2] = withoutSuffix;
  6347. a[3] = +posNegDuration > 0;
  6348. a[4] = locale;
  6349. return substituteTimeAgo.apply(null, a);
  6350. }
  6351. // This function allows you to set the rounding function for relative time strings
  6352. function getSetRelativeTimeRounding(roundingFunction) {
  6353. if (roundingFunction === undefined) {
  6354. return round;
  6355. }
  6356. if (typeof roundingFunction === 'function') {
  6357. round = roundingFunction;
  6358. return true;
  6359. }
  6360. return false;
  6361. }
  6362. // This function allows you to set a threshold for relative time strings
  6363. function getSetRelativeTimeThreshold(threshold, limit) {
  6364. if (thresholds[threshold] === undefined) {
  6365. return false;
  6366. }
  6367. if (limit === undefined) {
  6368. return thresholds[threshold];
  6369. }
  6370. thresholds[threshold] = limit;
  6371. if (threshold === 's') {
  6372. thresholds.ss = limit - 1;
  6373. }
  6374. return true;
  6375. }
  6376. function humanize(argWithSuffix, argThresholds) {
  6377. if (!this.isValid()) {
  6378. return this.localeData().invalidDate();
  6379. }
  6380. var withSuffix = false,
  6381. th = thresholds,
  6382. locale,
  6383. output;
  6384. if (typeof argWithSuffix === 'object') {
  6385. argThresholds = argWithSuffix;
  6386. argWithSuffix = false;
  6387. }
  6388. if (typeof argWithSuffix === 'boolean') {
  6389. withSuffix = argWithSuffix;
  6390. }
  6391. if (typeof argThresholds === 'object') {
  6392. th = Object.assign({}, thresholds, argThresholds);
  6393. if (argThresholds.s != null && argThresholds.ss == null) {
  6394. th.ss = argThresholds.s - 1;
  6395. }
  6396. }
  6397. locale = this.localeData();
  6398. output = relativeTime$1(this, !withSuffix, th, locale);
  6399. if (withSuffix) {
  6400. output = locale.pastFuture(+this, output);
  6401. }
  6402. return locale.postformat(output);
  6403. }
  6404. var abs$1 = Math.abs;
  6405. function sign(x) {
  6406. return (x > 0) - (x < 0) || +x;
  6407. }
  6408. function toISOString$1() {
  6409. // for ISO strings we do not use the normal bubbling rules:
  6410. // * milliseconds bubble up until they become hours
  6411. // * days do not bubble at all
  6412. // * months bubble up until they become years
  6413. // This is because there is no context-free conversion between hours and days
  6414. // (think of clock changes)
  6415. // and also not between days and months (28-31 days per month)
  6416. if (!this.isValid()) {
  6417. return this.localeData().invalidDate();
  6418. }
  6419. var seconds = abs$1(this._milliseconds) / 1000,
  6420. days = abs$1(this._days),
  6421. months = abs$1(this._months),
  6422. minutes,
  6423. hours,
  6424. years,
  6425. s,
  6426. total = this.asSeconds(),
  6427. totalSign,
  6428. ymSign,
  6429. daysSign,
  6430. hmsSign;
  6431. if (!total) {
  6432. // this is the same as C#'s (Noda) and python (isodate)...
  6433. // but not other JS (goog.date)
  6434. return 'P0D';
  6435. }
  6436. // 3600 seconds -> 60 minutes -> 1 hour
  6437. minutes = absFloor(seconds / 60);
  6438. hours = absFloor(minutes / 60);
  6439. seconds %= 60;
  6440. minutes %= 60;
  6441. // 12 months -> 1 year
  6442. years = absFloor(months / 12);
  6443. months %= 12;
  6444. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  6445. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  6446. totalSign = total < 0 ? '-' : '';
  6447. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  6448. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  6449. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  6450. return (
  6451. totalSign +
  6452. 'P' +
  6453. (years ? ymSign + years + 'Y' : '') +
  6454. (months ? ymSign + months + 'M' : '') +
  6455. (days ? daysSign + days + 'D' : '') +
  6456. (hours || minutes || seconds ? 'T' : '') +
  6457. (hours ? hmsSign + hours + 'H' : '') +
  6458. (minutes ? hmsSign + minutes + 'M' : '') +
  6459. (seconds ? hmsSign + s + 'S' : '')
  6460. );
  6461. }
  6462. var proto$2 = Duration.prototype;
  6463. proto$2.isValid = isValid$1;
  6464. proto$2.abs = abs;
  6465. proto$2.add = add$1;
  6466. proto$2.subtract = subtract$1;
  6467. proto$2.as = as;
  6468. proto$2.asMilliseconds = asMilliseconds;
  6469. proto$2.asSeconds = asSeconds;
  6470. proto$2.asMinutes = asMinutes;
  6471. proto$2.asHours = asHours;
  6472. proto$2.asDays = asDays;
  6473. proto$2.asWeeks = asWeeks;
  6474. proto$2.asMonths = asMonths;
  6475. proto$2.asQuarters = asQuarters;
  6476. proto$2.asYears = asYears;
  6477. proto$2.valueOf = valueOf$1;
  6478. proto$2._bubble = bubble;
  6479. proto$2.clone = clone$1;
  6480. proto$2.get = get$2;
  6481. proto$2.milliseconds = milliseconds;
  6482. proto$2.seconds = seconds;
  6483. proto$2.minutes = minutes;
  6484. proto$2.hours = hours;
  6485. proto$2.days = days;
  6486. proto$2.weeks = weeks;
  6487. proto$2.months = months;
  6488. proto$2.years = years;
  6489. proto$2.humanize = humanize;
  6490. proto$2.toISOString = toISOString$1;
  6491. proto$2.toString = toISOString$1;
  6492. proto$2.toJSON = toISOString$1;
  6493. proto$2.locale = locale;
  6494. proto$2.localeData = localeData;
  6495. proto$2.toIsoString = deprecate(
  6496. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  6497. toISOString$1
  6498. );
  6499. proto$2.lang = lang;
  6500. // FORMATTING
  6501. addFormatToken('X', 0, 0, 'unix');
  6502. addFormatToken('x', 0, 0, 'valueOf');
  6503. // PARSING
  6504. addRegexToken('x', matchSigned);
  6505. addRegexToken('X', matchTimestamp);
  6506. addParseToken('X', function (input, array, config) {
  6507. config._d = new Date(parseFloat(input) * 1000);
  6508. });
  6509. addParseToken('x', function (input, array, config) {
  6510. config._d = new Date(toInt(input));
  6511. });
  6512. //! moment.js
  6513. hooks.version = '2.29.1';
  6514. setHookCallback(createLocal);
  6515. hooks.fn = proto;
  6516. hooks.min = min;
  6517. hooks.max = max;
  6518. hooks.now = now;
  6519. hooks.utc = createUTC;
  6520. hooks.unix = createUnix;
  6521. hooks.months = listMonths;
  6522. hooks.isDate = isDate;
  6523. hooks.locale = getSetGlobalLocale;
  6524. hooks.invalid = createInvalid;
  6525. hooks.duration = createDuration;
  6526. hooks.isMoment = isMoment;
  6527. hooks.weekdays = listWeekdays;
  6528. hooks.parseZone = createInZone;
  6529. hooks.localeData = getLocale;
  6530. hooks.isDuration = isDuration;
  6531. hooks.monthsShort = listMonthsShort;
  6532. hooks.weekdaysMin = listWeekdaysMin;
  6533. hooks.defineLocale = defineLocale;
  6534. hooks.updateLocale = updateLocale;
  6535. hooks.locales = listLocales;
  6536. hooks.weekdaysShort = listWeekdaysShort;
  6537. hooks.normalizeUnits = normalizeUnits;
  6538. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  6539. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  6540. hooks.calendarFormat = getCalendarFormat;
  6541. hooks.prototype = proto;
  6542. // currently HTML5 input type only supports 24-hour formats
  6543. hooks.HTML5_FMT = {
  6544. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  6545. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  6546. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  6547. DATE: 'YYYY-MM-DD', // <input type="date" />
  6548. TIME: 'HH:mm', // <input type="time" />
  6549. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  6550. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  6551. WEEK: 'GGGG-[W]WW', // <input type="week" />
  6552. MONTH: 'YYYY-MM', // <input type="month" />
  6553. };
  6554. return hooks;
  6555. })));
  6556. });
  6557. /*! *****************************************************************************
  6558. Copyright (c) Microsoft Corporation.
  6559. Permission to use, copy, modify, and/or distribute this software for any
  6560. purpose with or without fee is hereby granted.
  6561. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  6562. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  6563. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  6564. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  6565. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  6566. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  6567. PERFORMANCE OF THIS SOFTWARE.
  6568. ***************************************************************************** */
  6569. /* global Reflect, Promise */
  6570. var extendStatics = function(d, b) {
  6571. extendStatics = Object.setPrototypeOf ||
  6572. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6573. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6574. return extendStatics(d, b);
  6575. };
  6576. function __extends(d, b) {
  6577. extendStatics(d, b);
  6578. function __() { this.constructor = d; }
  6579. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6580. }
  6581. var __assign = function() {
  6582. __assign = Object.assign || function __assign(t) {
  6583. for (var s, i = 1, n = arguments.length; i < n; i++) {
  6584. s = arguments[i];
  6585. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  6586. }
  6587. return t;
  6588. };
  6589. return __assign.apply(this, arguments);
  6590. };
  6591. function __decorate(decorators, target, key, desc) {
  6592. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  6593. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  6594. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6595. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6596. }
  6597. function __param(paramIndex, decorator) {
  6598. return function (target, key) { decorator(target, key, paramIndex); }
  6599. }
  6600. function __metadata(metadataKey, metadataValue) {
  6601. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  6602. }
  6603. function __values(o) {
  6604. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  6605. if (m) return m.call(o);
  6606. if (o && typeof o.length === "number") return {
  6607. next: function () {
  6608. if (o && i >= o.length) o = void 0;
  6609. return { value: o && o[i++], done: !o };
  6610. }
  6611. };
  6612. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  6613. }
  6614. function __read(o, n) {
  6615. var m = typeof Symbol === "function" && o[Symbol.iterator];
  6616. if (!m) return o;
  6617. var i = m.call(o), r, ar = [], e;
  6618. try {
  6619. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  6620. }
  6621. catch (error) { e = { error: error }; }
  6622. finally {
  6623. try {
  6624. if (r && !r.done && (m = i["return"])) m.call(i);
  6625. }
  6626. finally { if (e) throw e.error; }
  6627. }
  6628. return ar;
  6629. }
  6630. function __spread() {
  6631. for (var ar = [], i = 0; i < arguments.length; i++)
  6632. ar = ar.concat(__read(arguments[i]));
  6633. return ar;
  6634. }
  6635. var PropertyDescription = /** @class */ (function () {
  6636. function PropertyDescription() {
  6637. var _this = this;
  6638. var args = [];
  6639. for (var _i = 0; _i < arguments.length; _i++) {
  6640. args[_i] = arguments[_i];
  6641. }
  6642. this.propertyes = {
  6643. props: [],
  6644. events: []
  6645. };
  6646. _.each(args, function (arg) {
  6647. _this.merge(arg);
  6648. });
  6649. }
  6650. PropertyDescription.prototype.merge = function (pd) {
  6651. this.propertyes.props = (_.uniqBy(__spread(this.propertyes.props, pd.props), 'name'));
  6652. if (pd.events) {
  6653. if (this.propertyes.events) {
  6654. this.propertyes.events = (_.uniqBy(__spread(this.propertyes.events, pd.events), 'name'));
  6655. }
  6656. else {
  6657. this.propertyes.events = _.uniqBy(__spread(pd.events), 'name');
  6658. }
  6659. }
  6660. };
  6661. /**
  6662. * 根据分组名 获取属性定义
  6663. */
  6664. PropertyDescription.prototype.getPropsByGroup = function (name) {
  6665. return _.filter(this.propertyes.props, function (i) { return i.group === name; });
  6666. };
  6667. /**
  6668. * 获取全部事件
  6669. */
  6670. PropertyDescription.prototype.getEvents = function () {
  6671. return this.propertyes.events;
  6672. };
  6673. return PropertyDescription;
  6674. }());
  6675. var PropertyDescriptionTable = new Map();
  6676. var width = {
  6677. name: 'width',
  6678. default: '',
  6679. group: 'common',
  6680. desc: '宽',
  6681. type: 'string'
  6682. };
  6683. var height = {
  6684. name: 'height',
  6685. default: '',
  6686. group: 'common',
  6687. desc: '高',
  6688. type: 'string'
  6689. };
  6690. var fieldLabel = {
  6691. name: 'fieldLabel',
  6692. default: '',
  6693. group: 'common',
  6694. desc: '文本描述',
  6695. type: 'string',
  6696. expr: true,
  6697. };
  6698. var text$1 = {
  6699. name: 'text',
  6700. default: '',
  6701. group: 'common',
  6702. desc: '文本描述',
  6703. type: 'string',
  6704. expr: true,
  6705. };
  6706. var iconCls = {
  6707. name: 'iconCls',
  6708. default: '',
  6709. group: 'common',
  6710. desc: '图标',
  6711. type: 'string',
  6712. expr: true,
  6713. };
  6714. var disabled = {
  6715. name: 'disabled',
  6716. default: false,
  6717. group: 'common',
  6718. desc: '禁用',
  6719. type: 'boolean',
  6720. expr: true,
  6721. };
  6722. var value = {
  6723. name: 'value',
  6724. default: '',
  6725. group: 'common',
  6726. desc: '字段值',
  6727. type: 'string',
  6728. expr: true,
  6729. };
  6730. var template = {
  6731. name: 'template',
  6732. default: '',
  6733. group: 'common',
  6734. desc: 'HTML内容',
  6735. type: 'string',
  6736. expr: true,
  6737. };
  6738. var reference = {
  6739. name: 'reference',
  6740. default: '',
  6741. group: 'common',
  6742. desc: '组件句柄',
  6743. type: 'string',
  6744. expr: true,
  6745. };
  6746. var tooltip = {
  6747. name: 'tooltip',
  6748. default: '',
  6749. group: 'common',
  6750. desc: '悬停提示',
  6751. type: 'string'
  6752. };
  6753. // =============事件 ==============
  6754. var click = {
  6755. name: 'click',
  6756. default: '',
  6757. group: 'listeners',
  6758. desc: '点击事件',
  6759. eventParamter: [
  6760. 'sender',
  6761. 'e: any'
  6762. ],
  6763. type: 'listeners'
  6764. };
  6765. var change = {
  6766. name: 'change',
  6767. default: '',
  6768. group: 'listeners',
  6769. desc: 'value change事件',
  6770. eventParamter: [
  6771. 'sender',
  6772. 'e: any'
  6773. ],
  6774. type: 'listeners'
  6775. };
  6776. var keyup = {
  6777. name: 'keyup',
  6778. default: '',
  6779. group: 'listeners',
  6780. desc: '键盘按键抬起事件',
  6781. eventParamter: [
  6782. 'sender',
  6783. 'e'
  6784. ],
  6785. type: 'listeners'
  6786. };
  6787. var afterrender = {
  6788. name: 'afterrender',
  6789. default: '',
  6790. group: 'listeners',
  6791. desc: '控件渲染后触发',
  6792. eventParamter: [
  6793. 'sender',
  6794. 'e'
  6795. ],
  6796. type: 'listeners'
  6797. };
  6798. // =============特性 ==============
  6799. var fix = {
  6800. name: 'fix',
  6801. default: '',
  6802. group: 'fix',
  6803. desc: '特性',
  6804. type: 'fix',
  6805. expr: true,
  6806. };
  6807. PropertyDescriptionTable.set('cols', new PropertyDescription({
  6808. props: [
  6809. height
  6810. ]
  6811. }));
  6812. PropertyDescriptionTable.set('layout', new PropertyDescription({
  6813. props: [
  6814. {
  6815. name: 'borderless',
  6816. default: true,
  6817. group: 'css',
  6818. desc: '有无边框',
  6819. type: 'boolean'
  6820. },
  6821. {
  6822. name: 'type',
  6823. default: '',
  6824. group: 'css',
  6825. desc: '布局类型',
  6826. type: ['line', 'clean', 'wide', 'space', 'form']
  6827. },
  6828. {
  6829. name: '_designMode',
  6830. default: 'module',
  6831. group: 'common',
  6832. desc: '设计类型',
  6833. type: ['none', 'module', 'scroll-module']
  6834. }
  6835. ]
  6836. }));
  6837. var YvBase = {
  6838. props: [
  6839. width, height, reference, afterrender, fix
  6840. ],
  6841. events: [
  6842. // {name: 'onRender', desc: '第一次控件被渲染时触发'}
  6843. ]
  6844. };
  6845. PropertyDescriptionTable.set('template', new PropertyDescription(YvBase, {
  6846. props: [
  6847. template
  6848. ]
  6849. }));
  6850. PropertyDescriptionTable.set('fieldset', new PropertyDescription(YvBase, {
  6851. props: [
  6852. {
  6853. name: 'label',
  6854. default: '',
  6855. group: 'common',
  6856. desc: '字段组标题',
  6857. type: 'string'
  6858. }
  6859. ]
  6860. }));
  6861. PropertyDescriptionTable.set('iframe', new PropertyDescription(YvBase, {
  6862. props: [
  6863. {
  6864. name: 'src',
  6865. default: '',
  6866. group: 'common',
  6867. desc: '地址路径',
  6868. type: 'string'
  6869. }
  6870. ]
  6871. }));
  6872. PropertyDescriptionTable.set('uploader', new PropertyDescription(YvBase, {
  6873. props: [
  6874. width, height,
  6875. {
  6876. name: 'value',
  6877. default: '上传',
  6878. group: 'common',
  6879. desc: '文本描述',
  6880. type: 'string'
  6881. },
  6882. {
  6883. name: 'upload',
  6884. default: '/upload',
  6885. group: 'common',
  6886. desc: '上传地址',
  6887. type: 'string'
  6888. },
  6889. ],
  6890. events: [
  6891. { name: 'onFileUpload', desc: '文件上传成功结束时触发' },
  6892. { name: 'onFileUploadError', desc: '在上传过程中发生服务器端错误时触发' },
  6893. ]
  6894. }));
  6895. PropertyDescriptionTable.set('viewer', new PropertyDescription(YvBase, {
  6896. props: [
  6897. value,
  6898. {
  6899. name: 'imgWidth',
  6900. default: '',
  6901. group: 'common',
  6902. desc: '图片宽',
  6903. type: 'string'
  6904. },
  6905. {
  6906. name: 'imgHeight',
  6907. default: '',
  6908. group: 'common',
  6909. desc: '图片高',
  6910. type: 'string'
  6911. }
  6912. ]
  6913. }));
  6914. PropertyDescriptionTable.set('image', new PropertyDescription(YvBase, {
  6915. props: [
  6916. value,
  6917. {
  6918. name: 'imgWidth',
  6919. default: '',
  6920. group: 'common',
  6921. desc: '图片宽',
  6922. type: 'string'
  6923. },
  6924. {
  6925. name: 'imgHeight',
  6926. default: '',
  6927. group: 'common',
  6928. desc: '图片高',
  6929. type: 'string'
  6930. }
  6931. ]
  6932. }));
  6933. PropertyDescriptionTable.set('button', new PropertyDescription(YvBase, {
  6934. props: [text$1, disabled, height, width, iconCls, click, afterrender],
  6935. }));
  6936. PropertyDescriptionTable.set('fieldSet', new PropertyDescription(YvBase, {
  6937. props: [
  6938. fieldLabel, value, disabled,
  6939. tooltip, width, height
  6940. ],
  6941. }));
  6942. PropertyDescriptionTable.set('textfield', new PropertyDescription(YvBase, {
  6943. props: [
  6944. fieldLabel, value, disabled,
  6945. tooltip, width, height, keyup, afterrender, change
  6946. ],
  6947. }));
  6948. PropertyDescriptionTable.set('searchfield', new PropertyDescription(YvBase, {
  6949. props: [
  6950. fieldLabel, value, disabled,
  6951. tooltip, width, height, keyup, afterrender, change
  6952. ],
  6953. }));
  6954. PropertyDescriptionTable.set('radiogroup', new PropertyDescription(YvBase, {
  6955. props: [
  6956. fieldLabel, value, disabled,
  6957. tooltip, width, height, keyup, afterrender, change
  6958. ],
  6959. }));
  6960. PropertyDescriptionTable.set('radio', new PropertyDescription(YvBase, {
  6961. props: [
  6962. fieldLabel, value, disabled,
  6963. tooltip, width, height, keyup, afterrender, change
  6964. ],
  6965. }));
  6966. PropertyDescriptionTable.set('numberfield', new PropertyDescription(YvBase, {
  6967. props: [
  6968. fieldLabel, value, disabled,
  6969. tooltip, width, height, keyup, afterrender, change
  6970. ],
  6971. }));
  6972. PropertyDescriptionTable.set('datetimepicker', new PropertyDescription(YvBase, {
  6973. props: [
  6974. fieldLabel, value, disabled,
  6975. tooltip, width, height, keyup, afterrender, change
  6976. ],
  6977. }));
  6978. PropertyDescriptionTable.set('datetimefield', new PropertyDescription(YvBase, {
  6979. props: [
  6980. fieldLabel, value, disabled,
  6981. tooltip, width, height, keyup, afterrender, change
  6982. ],
  6983. }));
  6984. PropertyDescriptionTable.set('datefield', new PropertyDescription(YvBase, {
  6985. props: [
  6986. fieldLabel, value, disabled,
  6987. tooltip, width, height, keyup, afterrender, change
  6988. ],
  6989. }));
  6990. PropertyDescriptionTable.set('combogrid', new PropertyDescription(YvBase, {
  6991. props: [
  6992. fieldLabel, value, disabled,
  6993. tooltip, width, height
  6994. ],
  6995. }));
  6996. PropertyDescriptionTable.set('combo', new PropertyDescription(YvBase, {
  6997. props: [
  6998. fieldLabel, value, disabled,
  6999. tooltip, width, height, keyup, afterrender, change
  7000. ],
  7001. }));
  7002. PropertyDescriptionTable.set('checkboxgroup', new PropertyDescription(YvBase, {
  7003. props: [
  7004. fieldLabel, value, disabled,
  7005. tooltip, width, height, keyup, afterrender, change
  7006. ],
  7007. }));
  7008. PropertyDescriptionTable.set('checkbox', new PropertyDescription(YvBase, {
  7009. props: [
  7010. fieldLabel, value, disabled,
  7011. tooltip, width, height, keyup, afterrender, change
  7012. ],
  7013. }));
  7014. PropertyDescriptionTable.set('yvgrid', new PropertyDescription(YvBase, {
  7015. props: [
  7016. fieldLabel, value, disabled,
  7017. tooltip, width, height, afterrender, change
  7018. ],
  7019. }));
  7020. /**
  7021. * 弹出输入框,输入文字
  7022. * @param message 提示文字
  7023. * @param defaultValue 默认值
  7024. * @param multiLine 是否多行输入
  7025. */
  7026. function prompt(message, defaultValue, multiLine) {
  7027. if (defaultValue === void 0) { defaultValue = ""; }
  7028. if (multiLine === void 0) { multiLine = false; }
  7029. return new Promise(function (resolve) {
  7030. Ext.MessageBox.prompt('请输入', message, function (button, value) {
  7031. if (button === 'ok') {
  7032. resolve(value);
  7033. }
  7034. }, null, multiLine, defaultValue);
  7035. });
  7036. }
  7037. /**
  7038. * 显示错误异常信息
  7039. * @param msg 错误内容
  7040. * @param sender 发送者按钮(可以为空)
  7041. */
  7042. function showErrorDialog(msg, sender) {
  7043. console.error(msg);
  7044. Ext.MessageBox.show({
  7045. title: '错误',
  7046. msg: msg,
  7047. buttons: Ext.MessageBox.OK,
  7048. animateTarget: sender,
  7049. icon: 'error',
  7050. cls: 'show-icon-messagebox',
  7051. });
  7052. }
  7053. /**
  7054. * 显示错误异常信息
  7055. * @param msg 错误内容
  7056. * @param sender 发送者按钮(可以为空)
  7057. */
  7058. function showInfoDialogSimple(msg, sender) {
  7059. console.info(msg);
  7060. Ext.MessageBox.show({
  7061. title: '提示',
  7062. msg: msg,
  7063. buttons: Ext.MessageBox.OK,
  7064. animateTarget: sender,
  7065. icon: 'info',
  7066. cls: 'show-icon-messagebox',
  7067. });
  7068. }
  7069. function msgError(msg, sender) {
  7070. showErrorDialog(msg, sender);
  7071. }
  7072. /**
  7073. * 中间灰底白字提示
  7074. */
  7075. function msg(message) {
  7076. console.log(message);
  7077. var $body = $$1('body');
  7078. $body.find('[xtype=tooltip]').remove();
  7079. var $w = $$1('<div xtype="tooltip" class="yvan-msg yvan-anim yvan-anim-00">' +
  7080. ' <div class="yvan-msg-content">' +
  7081. _.escape(message) +
  7082. '</div></div>');
  7083. $body.append($w);
  7084. var iframeWidth = $w.parent().width();
  7085. var iframeHeight = $w.parent().height();
  7086. var windowWidth = $w.width();
  7087. var windowHeight = $w.height();
  7088. var setWidth = (iframeWidth - windowWidth) / 2;
  7089. var setHeight = (iframeHeight - windowHeight) / 2;
  7090. if (iframeHeight < windowHeight || setHeight < 0) {
  7091. setHeight = 0;
  7092. }
  7093. if (iframeWidth < windowWidth || setWidth < 0) {
  7094. setWidth = 0;
  7095. }
  7096. $w.css({ left: setWidth, top: setHeight });
  7097. setTimeout(function () {
  7098. $w.remove();
  7099. }, 3000);
  7100. }
  7101. /**
  7102. * 调用方法
  7103. */
  7104. function invokeMethod(fn, sender, args) {
  7105. if (typeof fn === 'function') {
  7106. fn.apply.apply(fn, __spread([sender], args));
  7107. }
  7108. }
  7109. /**
  7110. * 判断事件是否为有效的输入字符
  7111. * @param e
  7112. */
  7113. function isChartEvent(e) {
  7114. if (e.key === 'Shift' ||
  7115. e.key === 'Control' ||
  7116. e.key === 'Alt' ||
  7117. e.key === 'Escape' ||
  7118. e.key === 'ArrowRight' ||
  7119. e.key === 'Tab' ||
  7120. e.key === 'ArrowLeft') {
  7121. return false;
  7122. }
  7123. if (e.keyCode >= 48 && e.keyCode <= 57) {
  7124. // 0-9
  7125. return true;
  7126. }
  7127. if (e.keyCode >= 65 && e.keyCode <= 90) {
  7128. // a-z
  7129. return true;
  7130. }
  7131. if (e.keyCode >= 96 && e.keyCode <= 111 && e.keyCode !== 108) {
  7132. // 小键盘 0-9
  7133. return true;
  7134. }
  7135. return false;
  7136. }
  7137. if (!window["time_offset"]) {
  7138. window["time_offset"] = 0;
  7139. }
  7140. function syncDate(date) {
  7141. if (date && date.setTime && date.getTime) {
  7142. date.setTime(date.getTime() + window["time_offset"]);
  7143. }
  7144. return date;
  7145. }
  7146. function toString(value) {
  7147. if (typeof value === 'undefined' || value === null) {
  7148. return "";
  7149. }
  7150. if (typeof value === 'number' && isNaN(value)) {
  7151. return "";
  7152. }
  7153. if (value == 'N/A') {
  7154. return "";
  7155. }
  7156. return ("" + value);
  7157. }
  7158. function isEmpty(value) {
  7159. if (typeof value === 'undefined' || value === null) {
  7160. return true;
  7161. }
  7162. if (typeof value === 'number' && isNaN(value)) {
  7163. return true;
  7164. }
  7165. if (value == 'N/A') {
  7166. return true;
  7167. }
  7168. return ("" + value).trim().length <= 0;
  7169. }
  7170. function createUUID() {
  7171. //@ts-ignore
  7172. return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
  7173. return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
  7174. });
  7175. }
  7176. function getRegList() {
  7177. var regList = _.get(window, 'yvanLib.regList');
  7178. if (!regList) {
  7179. regList = [];
  7180. _.set(window, 'yvanLib.regList', regList);
  7181. }
  7182. return regList;
  7183. }
  7184. function getRegParamList(methodName) {
  7185. var regParamList = _.get(window, 'yvanLib.regParamList');
  7186. if (!regParamList) {
  7187. regParamList = {};
  7188. _.set(window, 'yvanLib.regParamList', regParamList);
  7189. }
  7190. if (!_.has(regParamList, methodName)) {
  7191. regParamList[methodName] = [];
  7192. }
  7193. return regParamList[methodName];
  7194. }
  7195. /**
  7196. * 模拟点击按钮
  7197. */
  7198. function raiseClick(buttonHandle) {
  7199. if (!buttonHandle) {
  7200. return false;
  7201. }
  7202. if (buttonHandle.disabled) {
  7203. // 按钮是禁止状态
  7204. return false;
  7205. }
  7206. if (buttonHandle.hidden) {
  7207. // 按钮是隐藏状态
  7208. return false;
  7209. }
  7210. // 按钮点击
  7211. buttonHandle.click();
  7212. return true;
  7213. }
  7214. /**
  7215. * 标注系统全局函数的参数
  7216. * @param title 函数名称
  7217. * @param type 函数类型
  7218. * @param allowEmpty 可否为空
  7219. */
  7220. function LibParam(title, type, allowEmpty) {
  7221. if (allowEmpty === void 0) { allowEmpty = false; }
  7222. return function (target, methodName, paramsIndex) {
  7223. var systemFnArgs = getRegParamList(methodName);
  7224. systemFnArgs[paramsIndex] = {
  7225. type: type,
  7226. title: title,
  7227. name: methodName,
  7228. allowEmpty: allowEmpty,
  7229. };
  7230. };
  7231. }
  7232. /**
  7233. * 标注函数变成"系统全局函数"
  7234. */
  7235. function Lib(registe) {
  7236. return function (target, propertyKey, descriptor) {
  7237. var libList = getRegList();
  7238. libList.push(__assign(__assign({}, registe), { name: propertyKey, target: target[propertyKey] }));
  7239. if (registe.type === 'system') {
  7240. _.set(window, 'yvanLib.system.' + propertyKey, target[propertyKey]);
  7241. }
  7242. else if (registe.type === 'format') {
  7243. _.set(window, 'yvanLib.format.' + propertyKey, target[propertyKey]);
  7244. }
  7245. return target;
  7246. };
  7247. }
  7248. /**
  7249. * 解析事件
  7250. * 'scope.私有方法名'
  7251. * 'system.系统函数名'
  7252. * 'format.格式化名'
  7253. */
  7254. function lookupFn(scope, event, errorWho) {
  7255. if (window["IS_DESIGN_MODE"]) {
  7256. return Ext.emptyFn;
  7257. }
  7258. if (!_.startsWith(event, 'scope.') &&
  7259. !_.startsWith(event, 'system.') &&
  7260. !_.startsWith(event, 'format.')) {
  7261. console.error('无法识别的事件响应类型', event);
  7262. throw new TypeError('无法识别的事件响应类型');
  7263. }
  7264. // 为 eval 准备环境
  7265. var _a = window['yvanLib'], system = _a.system, format = _a.format;
  7266. var data = scope.viewModel.data;
  7267. var keys = [];
  7268. var values = [];
  7269. _.forOwn(data, function (value, key) {
  7270. var idxKey = key.indexOf('//');
  7271. if (idxKey >= 0) {
  7272. keys.push(key.substr(0, idxKey));
  7273. }
  7274. else {
  7275. keys.push(key);
  7276. }
  7277. values.push(value);
  7278. });
  7279. var func = Function.apply(void 0, __spread(['scope', 'system', 'format'], keys, ['return ' + event]));
  7280. var funcResult = func.apply(void 0, __spread([scope, system, format], values));
  7281. if (typeof funcResult !== 'function') {
  7282. console.error('无法识别的事件响应类型', event, func, errorWho);
  7283. throw new TypeError('无法识别的事件响应类型');
  7284. }
  7285. return funcResult;
  7286. }
  7287. /**
  7288. * 从 ext.element 获取 scope 对象
  7289. */
  7290. function lookupScope(extHandle) {
  7291. if (!extHandle) {
  7292. // @ts-ignore
  7293. return;
  7294. }
  7295. if (extHandle.isScope) {
  7296. return extHandle;
  7297. }
  7298. if (extHandle.column) {
  7299. // 列上的组件
  7300. return extHandle.column.lookupReferenceHolder().yvanScope;
  7301. }
  7302. if (_.get(extHandle, 'alias[0]') === 'widget.button') ;
  7303. var vm = extHandle.lookupViewModel();
  7304. return vm.yvanScope;
  7305. }
  7306. /**
  7307. * 全局 ajax 方法
  7308. */
  7309. var ajax = {};
  7310. /**
  7311. * 计算拼音的函数
  7312. */
  7313. var pinyinFunc = function (str) { return (str); };
  7314. exports.scopeOnLoad = null;
  7315. exports.apiConvert = undefined;
  7316. var baseConfigProcessList = [];
  7317. /**
  7318. * 在基类添加 Config 的处理方法
  7319. */
  7320. function baseConfigProcess(option) {
  7321. return function (target, propertyKey) {
  7322. baseConfigProcessList.push(target[propertyKey]);
  7323. };
  7324. }
  7325. var designMode = false;
  7326. function isDesignMode() {
  7327. return designMode;
  7328. }
  7329. function setDesignMode(v) {
  7330. designMode = v;
  7331. }
  7332. /**
  7333. * 将业务定义的 url 转换为调用服务端 groovy 的 url
  7334. */
  7335. function serverInvokeUrlTransform(url, option) {
  7336. return _.get(window, '_YvanUI_serverInvokePrefix')(url, option);
  7337. }
  7338. /**
  7339. * 将业务定义的 url 转换为调用服务端 sql 的 Url
  7340. */
  7341. function sqlUrlTransform(url) {
  7342. return _.get(window, '_YvanUI_sqlPrefix')(url);
  7343. }
  7344. /**
  7345. * YvanUI 全局扩展配置
  7346. */
  7347. function extend(option) {
  7348. if (option.ajax) {
  7349. ajax.func = option.ajax;
  7350. }
  7351. if (option.serverInvokeUrlTransform) {
  7352. _.extend(window, { _YvanUI_serverInvokePrefix: option.serverInvokeUrlTransform });
  7353. }
  7354. if (option.sqlUrlTransform) {
  7355. _.extend(window, { _YvanUI_sqlPrefix: option.sqlUrlTransform });
  7356. }
  7357. if (option.pinyinFunction) {
  7358. pinyinFunc = option.pinyinFunction;
  7359. }
  7360. if (option.scopeOnLoad) {
  7361. exports.scopeOnLoad = option.scopeOnLoad;
  7362. }
  7363. if (option.apiConvert) {
  7364. exports.apiConvert = option.apiConvert;
  7365. }
  7366. if (typeof option.designMode !== 'undefined') {
  7367. setDesignMode(option.designMode);
  7368. }
  7369. }
  7370. function getApiConvert() {
  7371. return exports.apiConvert;
  7372. }
  7373. function getPinyin(v) {
  7374. return pinyinFunc(v);
  7375. }
  7376. /**
  7377. * 适用于 Select / Tree 等,作筛选的通用方法.
  7378. * 1.首字母模糊匹配(不区分大小写)
  7379. * 2.标识的模糊匹配(不区分大小写)
  7380. * 3.名称的模糊匹配,且支持以逗号(全角或半角)隔开的字词匹配,并自动去空格,如“南京, 物流 ”可以匹配出“南京九州通物流技术开发有限公司”
  7381. */
  7382. function keywordFilter(keyword, label, value) {
  7383. if (!keyword) {
  7384. return true;
  7385. }
  7386. var ws = _.trim(keyword).split(/\s+|\.|,|\)|\(|,|。|-|—/g);
  7387. // const labelPy = _.toLower(getPinyin(label))
  7388. //@ts-ignore
  7389. var labelPy = _.toLower(getFirstPinyin2(label));
  7390. value = _.toLower(_.trim(value));
  7391. var found = 0;
  7392. _.some(ws, function (word) {
  7393. if (labelPy.indexOf(word.toLowerCase()) >= 0 || label.indexOf(word) >= 0) {
  7394. found++;
  7395. return;
  7396. }
  7397. if (value && value.indexOf(word.toLowerCase()) >= 0) {
  7398. found++;
  7399. return;
  7400. }
  7401. });
  7402. return found >= ws.length;
  7403. }
  7404. var Scope = /** @class */ (function () {
  7405. function Scope(_a) {
  7406. var model = _a.model, vjson = _a.vjson;
  7407. /**
  7408. * 业务模块的唯一编号
  7409. */
  7410. this.id = _.uniqueId('scope_');
  7411. /**
  7412. * onload 运行完成之后才会设置本标记为 true
  7413. */
  7414. this.isLoadFinish = false;
  7415. this._isLoading = false;
  7416. this.model = model;
  7417. this.originalVjson = _.cloneDeep(vjson);
  7418. this.vjson = this.originalVjson; // this.buildVjson()
  7419. }
  7420. Scope.prototype._addWatch = function (tplExpress, fn) {
  7421. if (!this._watchList) {
  7422. this._watchList = [];
  7423. }
  7424. this._watchList.push({ watch: tplExpress, fn: fn });
  7425. };
  7426. Scope.prototype._applyWatchList = function () {
  7427. var _this = this;
  7428. _.forEach(this._watchList, function (item) {
  7429. _this.viewModel.bind(item.watch, item.fn.bind(_this));
  7430. });
  7431. };
  7432. Object.defineProperty(Scope.prototype, "isScope", {
  7433. get: function () {
  7434. return true;
  7435. },
  7436. enumerable: true,
  7437. configurable: true
  7438. });
  7439. /**
  7440. * 产生一个当前模块有效的唯一id
  7441. * @param key 唯一编号
  7442. */
  7443. Scope.prototype.uid = function (key) {
  7444. return this.id + key;
  7445. };
  7446. /**
  7447. * 对话框"保存"成功.
  7448. * 关闭对话框,并响应 success 方法
  7449. * @param data 要傳回的數據(可以為空)
  7450. */
  7451. Scope.prototype.dialogSuccess = function (data) {
  7452. this._handle.fireEvent('success', this, data);
  7453. var sender = this._handle.config.animateTarget;
  7454. var scope = lookupScope(sender);
  7455. if (typeof this['success'] === 'function') {
  7456. this['success'].call(scope, sender, data);
  7457. }
  7458. this.close();
  7459. };
  7460. /**
  7461. * 设置等待状态
  7462. * @param value
  7463. * @param msg
  7464. */
  7465. Scope.prototype.setLoading = function (value) {
  7466. var _a;
  7467. var scope = this;
  7468. this._isLoading = value;
  7469. (_a = scope._handle) === null || _a === void 0 ? void 0 : _a.setLoading(value);
  7470. };
  7471. Scope.prototype.getLoading = function () {
  7472. return this._isLoading;
  7473. };
  7474. /**
  7475. * 以对话框模式打开当前模块
  7476. * @param sender 发送者(按钮或Scope对象)
  7477. * @param vjsonOption 界面覆盖选项(可以为空)
  7478. * @param dataOption 数据覆盖选项(可以为空)
  7479. */
  7480. Scope.prototype.showDialog = function (sender, vjsonOption, dataOption) {
  7481. var _a;
  7482. var that = this;
  7483. var vmodel = _.defaultsDeep({
  7484. //
  7485. }, dataOption, that.model);
  7486. this.viewModel = new Ext.app.ViewModel(vmodel);
  7487. this.viewModel.yvanScope = this;
  7488. this._applyWatchList();
  7489. this["scopeKey"] = "dialog-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  7490. var config = _.defaultsDeep({
  7491. animateTarget: sender,
  7492. viewModel: this.viewModel,
  7493. yvanScope: this,
  7494. referenceHolder: true,
  7495. }, vjsonOption, that.vjson, windows);
  7496. if (config.height === 'unset') {
  7497. delete config.height;
  7498. }
  7499. if (config.width === 'unset') {
  7500. delete config.width;
  7501. }
  7502. // const holder = sender?.lookupReferenceHolder()
  7503. // delete config.constrain
  7504. var topScope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  7505. if (topScope) {
  7506. config.constrain = true;
  7507. this.topScope = topScope;
  7508. }
  7509. var win = new Ext.Window(config);
  7510. // if (holder) {
  7511. // holder.add(win)
  7512. // }
  7513. if (topScope) {
  7514. topScope._handle.add(win);
  7515. }
  7516. win.addListener('beforerender', function (sender) {
  7517. // 记录句柄
  7518. if (sender && !that._handle) {
  7519. that._handle = sender;
  7520. }
  7521. });
  7522. win.addListener('afterrender', function (sender) {
  7523. // 调用onLoad回调
  7524. try {
  7525. that._onLoad();
  7526. }
  7527. catch (e) {
  7528. console.error('errorAt onLoad', e);
  7529. }
  7530. window['cw'] = that;
  7531. });
  7532. win.addListener('destroy', this._destroy.bind(this));
  7533. win.show();
  7534. };
  7535. /**
  7536. * 以标签模式打开当前模块
  7537. * @param vjsonOption 界面覆盖选项(可以为空)
  7538. * @param dataOption 数据覆盖选项(可以为空)
  7539. */
  7540. Scope.prototype.showPage = function (vjsonOption, dataOption) {
  7541. var _this = this;
  7542. var that = this;
  7543. this._vjsonOption = vjsonOption;
  7544. this._dataOption = dataOption;
  7545. var vmodel = _.defaultsDeep({
  7546. data: {}
  7547. }, dataOption, that.model);
  7548. this.viewModel = new Ext.app.ViewModel(vmodel);
  7549. this.viewModel.yvanScope = this;
  7550. this._applyWatchList();
  7551. this["scopeKey"] = "page-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  7552. // 根级不能设置id
  7553. delete that.vjson.id;
  7554. var config = _.defaultsDeep({
  7555. viewModel: this.viewModel,
  7556. yvanScope: this,
  7557. referenceHolder: true,
  7558. }, vjsonOption, that.vjson);
  7559. var tt = Ext.getCmp('TT');
  7560. var handle = tt.addScope(this, config, function (handle) {
  7561. handle.addListener('added', function (sender) {
  7562. // 记录句柄
  7563. if (sender && !that._handle) {
  7564. that._handle = sender;
  7565. }
  7566. });
  7567. handle.addListener('afterrender', function (sender) {
  7568. // 调用onLoad回调
  7569. try {
  7570. that._onLoad();
  7571. }
  7572. catch (e) {
  7573. console.error('errorAt onLoad', e);
  7574. }
  7575. });
  7576. handle.addListener('destroy', _this._destroy.bind(_this));
  7577. });
  7578. return handle;
  7579. };
  7580. /**
  7581. * 直接渲染到元素
  7582. * @param element 渲染目标
  7583. * @param vjsonOption 界面覆盖选项(可以为空)
  7584. * @param dataOption 数据覆盖选项(可以为空)
  7585. */
  7586. Scope.prototype.renderTo = function (element, vjsonOption, dataOption) {
  7587. var that = this;
  7588. this._vjsonOption = vjsonOption;
  7589. this._dataOption = dataOption;
  7590. var vmodel = _.defaultsDeep({
  7591. data: {}
  7592. }, that.model, dataOption);
  7593. this["scopeKey"] = "render-" + getVjsonHash(JSON.stringify(this.vjson) + JSON.stringify(vjsonOption));
  7594. this.viewModel = new Ext.app.ViewModel(vmodel);
  7595. this.viewModel.yvanScope = this;
  7596. this._applyWatchList();
  7597. var config = _.defaultsDeep({
  7598. viewModel: this.viewModel,
  7599. yvanScope: this,
  7600. referenceHolder: true,
  7601. renderTo: element,
  7602. listeners: {
  7603. afterrender: function (sender) {
  7604. var _a;
  7605. // 记录句柄
  7606. if (sender && !that._handle) {
  7607. that._handle = sender;
  7608. }
  7609. // 调用onLoad回调
  7610. that._onLoad();
  7611. // 如果vjson中配置了 afterrender ,需要恢复状态
  7612. invokeMethod((_a = that.vjson.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, that, arguments);
  7613. },
  7614. },
  7615. }, vjsonOption, that.vjson);
  7616. new Ext.container.Viewport(config);
  7617. };
  7618. /**
  7619. * 关闭对话框(或标签页)
  7620. */
  7621. Scope.prototype.close = function () {
  7622. this._handle.close();
  7623. };
  7624. Object.defineProperty(Scope.prototype, "data", {
  7625. /**
  7626. * 获取 viewModel 里包含的数据(只读)
  7627. */
  7628. get: function () {
  7629. return this.viewModel.getData();
  7630. },
  7631. enumerable: true,
  7632. configurable: true
  7633. });
  7634. /**
  7635. * 设置 viewModel 中的数据
  7636. * 可以是 key, value 模式
  7637. * 也可以是 {key:value} 模式
  7638. */
  7639. Scope.prototype.set = function (path, value) {
  7640. return this.viewModel.set(path, value);
  7641. };
  7642. /**
  7643. * 寻找模块内所有的 xtype 对应的对象
  7644. * @param xtypeKey
  7645. */
  7646. Scope.prototype.down = function (xtypeKey) {
  7647. return this._handle.down(xtypeKey);
  7648. };
  7649. Object.defineProperty(Scope.prototype, "refs", {
  7650. /**
  7651. * 获取所有设置过 Reference 名称的组件
  7652. */
  7653. get: function () {
  7654. var _a, _b;
  7655. return (_b = (_a = this._handle) === null || _a === void 0 ? void 0 : _a.getReferences()) !== null && _b !== void 0 ? _b : {};
  7656. },
  7657. enumerable: true,
  7658. configurable: true
  7659. });
  7660. Scope.prototype._destroy = function () {
  7661. var that = this;
  7662. that.onDestroy();
  7663. delete that._watchList;
  7664. delete that._handle;
  7665. this.isLoadFinish = false;
  7666. };
  7667. /**
  7668. * 私有渲染完成后的回调
  7669. */
  7670. Scope.prototype._onLoad = function () {
  7671. var _this = this;
  7672. if (exports.scopeOnLoad && typeof exports.scopeOnLoad === 'function') {
  7673. exports.scopeOnLoad(this);
  7674. }
  7675. this.onLoad();
  7676. _.defer(function () {
  7677. _this.isLoadFinish = true;
  7678. });
  7679. };
  7680. /**
  7681. * 默认 渲染完成之后调用的函数
  7682. */
  7683. Scope.prototype.onLoad = function () {
  7684. };
  7685. /**
  7686. * 组件卸载之后的回调
  7687. */
  7688. Scope.prototype.onDestroy = function () {
  7689. };
  7690. return Scope;
  7691. }());
  7692. /**
  7693. * 观察装饰器,viewModel 属性更改时触发成员方法
  7694. * @param tplExpress tpl表达式,例如 "{form.f1}"
  7695. */
  7696. function watch(tplExpress, deep) {
  7697. if (deep === void 0) { deep = false; }
  7698. return function (target, propertyKey, pd) {
  7699. target._addWatch({ bindTo: tplExpress, deep: deep }, target[propertyKey]);
  7700. return target[propertyKey];
  7701. };
  7702. }
  7703. // 获取vjson的hash值
  7704. function getVjsonHash(str) {
  7705. var hash = 3465217896, i, ch;
  7706. for (i = str.length - 1; i >= 0; i--) {
  7707. ch = str.charCodeAt(i);
  7708. hash ^= ((hash << 5) + ch + (hash >> 2));
  7709. }
  7710. return (hash & 0x7FFFFFFF) + "";
  7711. }
  7712. var ScopeEngine = /** @class */ (function () {
  7713. function ScopeEngine() {
  7714. }
  7715. ScopeEngine.getVjsonAndModel = function (table, bill, layout) {
  7716. // 生成controller
  7717. var controller = {};
  7718. var title = table.name;
  7719. var vjsonItem = { xtype: "form", items: [] };
  7720. for (var i = 0; i < table.fields.length; i++) {
  7721. var item = table.fields[i];
  7722. if (item.hasOwnProperty("fieldset")) {
  7723. vjsonItem.items.push({
  7724. xtype: 'fieldset',
  7725. title: item.fieldset,
  7726. items: [
  7727. item
  7728. ]
  7729. });
  7730. }
  7731. if (item.hasOwnProperty("listeners")) {
  7732. controller[item.listeners.change.split(".")[1]] = function () {
  7733. console.log("fuck");
  7734. };
  7735. }
  7736. }
  7737. // 生成vjson
  7738. var vjson = {
  7739. title: title,
  7740. layout: 'fit',
  7741. items: [
  7742. vjsonItem
  7743. ],
  7744. referenceHolder: true,
  7745. };
  7746. var scope = new Scope({ model: {}, vjson: vjson });
  7747. _.merge(scope, controller);
  7748. return scope;
  7749. };
  7750. return ScopeEngine;
  7751. }());
  7752. function initComponent () {
  7753. var ct = Ext.Component.prototype.constructor;
  7754. Ext.Component.override({
  7755. constructor: function (config) {
  7756. if (!window["IS_DESIGN_MODE"] && config) {
  7757. var me_1 = this;
  7758. // 任意组件 Ext.Component 构造时调用的方法, 可以用来在渲染之前加工处理 VJSON
  7759. _.each(baseConfigProcessList, function (process) {
  7760. process.call(me_1, me_1, config);
  7761. });
  7762. }
  7763. ct.call(this, config);
  7764. }
  7765. });
  7766. var _initComponent = Ext.picker.Date.prototype.initComponent;
  7767. Ext.picker.Date.override({
  7768. initComponent: function () {
  7769. var me = this;
  7770. me.defaultValue = Ext.isDate(me.defaultValue) ? me.defaultValue : syncDate(new Date());
  7771. _initComponent.call(me);
  7772. },
  7773. selectToday: function () {
  7774. var me = this, btn = me.todayBtn, handler = me.handler;
  7775. if (btn && !btn.disabled) {
  7776. me.setValue(Ext.Date.clearTime(syncDate(new Date())));
  7777. me.fireEvent('select', me, me.value);
  7778. if (handler) {
  7779. Ext.callback(handler, me.scope, [me, me.value], null, me, me);
  7780. }
  7781. me.onSelect();
  7782. }
  7783. return me;
  7784. },
  7785. });
  7786. }
  7787. function initMainTab () {
  7788. Ext.define('Yvan.MainTab', {
  7789. extend: 'Ext.tab.Panel',
  7790. xtype: 'maintab',
  7791. plugins: Ext.create('Ext.ux.TabCloseMenu', {
  7792. closeTabText: '关闭',
  7793. closeOthersTabsText: '关闭其他',
  7794. closeAllTabsText: '关闭所有'
  7795. }),
  7796. constructor: function (config) {
  7797. var me = this;
  7798. var newConfig = _.defaultsDeep({
  7799. // 强制属性
  7800. }, config);
  7801. this.superclass.constructor.call(me, newConfig);
  7802. },
  7803. initComponent: function () {
  7804. var me = this;
  7805. this.on({
  7806. tabchange: function (tabPanel, newCard, oldCard, eOpts) {
  7807. _.defer(function () {
  7808. me.changeHash(newCard.id);
  7809. window['cp'] = newCard.yvanScope;
  7810. });
  7811. $$1(window).trigger('tabChange', {
  7812. tabPanel: tabPanel, newCard: newCard, oldCard: oldCard, eOpts: eOpts
  7813. });
  7814. },
  7815. afterrender: function () {
  7816. _.defer(function () {
  7817. me.tryRestoryPage();
  7818. });
  7819. }
  7820. });
  7821. this.superclass.initComponent.call(me);
  7822. },
  7823. tryRestoryPage: function () {
  7824. var me = this;
  7825. var hash = '' + window.location.hash;
  7826. if (hash && hash.indexOf('page=') > 0) {
  7827. if (hash.startsWith('#')) {
  7828. hash = hash.substr(1);
  7829. }
  7830. if (hash) {
  7831. var page = Qs.parse(hash).page;
  7832. if (page) {
  7833. // this.openScope(page)
  7834. me.fireEvent('restorypage', page);
  7835. }
  7836. }
  7837. }
  7838. },
  7839. changeHash: function (id) {
  7840. window.location.hash = Qs.stringify({ page: id });
  7841. },
  7842. /**
  7843. * 添加一个业务模块实例到选项卡
  7844. * @param scopeInstance 业务对象实例
  7845. * @param config ExtJS配置对象
  7846. * @param panelInitCallback panel初始化之后会调用函数进行构造前的加工
  7847. */
  7848. addScope: function (scopeInstance, config, panelInitCallback) {
  7849. scopeInstance.topScope = scopeInstance;
  7850. var me = this;
  7851. if (config.path) {
  7852. for (var i = 0; i < this.items.items.length; i++) {
  7853. // 找到当前 tabs 里有没有已经打开过
  7854. var tab = this.items.items[i];
  7855. if (_.isEqual(tab.path, config.path)) {
  7856. // 激活
  7857. this.setActiveTab(tab);
  7858. return tab;
  7859. }
  7860. }
  7861. }
  7862. var newPanel = new Ext.panel.Panel(__assign({ closable: true }, config));
  7863. if (typeof panelInitCallback === 'function') {
  7864. panelInitCallback(newPanel);
  7865. }
  7866. // 添加业务模块
  7867. var newTab = this.add(newPanel);
  7868. this.setActiveTab(newTab);
  7869. newTab.on({
  7870. destroy: function (sender) {
  7871. me.changeHash('');
  7872. delete window['cp'];
  7873. }
  7874. });
  7875. return newTab;
  7876. }
  7877. });
  7878. }
  7879. /**
  7880. * 构建所有组件的公共属性
  7881. * @param config 原始config
  7882. * @param dragType 组件模式
  7883. * 不填,代表不能在设计时被拖拽
  7884. * row-container 是一个rows容器
  7885. * col-container 是一个cols容器
  7886. * col-item cols中的一个格子(非容器),比如 textfield / combofield 等等
  7887. * row-item rows中的一行,比如 tree / grid / panel 等等
  7888. */
  7889. function baseConfig(config, dragType) {
  7890. if (config && window["IS_DESIGN_MODE"] && dragType) {
  7891. var cc = '';
  7892. switch (dragType) {
  7893. case "cols-container":
  7894. cc = 'design_cols_container';
  7895. break;
  7896. case "col-item":
  7897. cc = 'design_col_item';
  7898. break;
  7899. case "rows-container":
  7900. cc = 'design_rows_container';
  7901. break;
  7902. case "row-item":
  7903. cc = 'design_row_item';
  7904. break;
  7905. }
  7906. if (typeof config.cls === 'string') {
  7907. _.extend(config, {
  7908. cls: [config.cls, 'yvan_design', cc]
  7909. });
  7910. }
  7911. else if (_.isArray(config.cls)) {
  7912. _.extend(config, {
  7913. cls: __spread(config.cls, ['yvan_design', cc])
  7914. });
  7915. }
  7916. else {
  7917. _.extend(config, {
  7918. cls: ['yvan_design', cc]
  7919. });
  7920. }
  7921. }
  7922. return config;
  7923. }
  7924. function initPanel () {
  7925. /**
  7926. *
  7927. */
  7928. var ct = Ext.panel.Panel.prototype.constructor;
  7929. Ext.panel.Panel.override({
  7930. constructor: function (config) {
  7931. var newConfig = _.defaultsDeep({}, config, baseConfig(config, "rows-container"), panel);
  7932. ct.call(this, newConfig);
  7933. }
  7934. });
  7935. var ss = Ext.form.FieldContainer.prototype;
  7936. Ext.form.FieldContainer.override({
  7937. config: __assign({}, fieldContainer)
  7938. });
  7939. }
  7940. function initGridColumn () {
  7941. var ct = Ext.grid.column.Column.prototype.constructor;
  7942. Ext.grid.column.Column.override({
  7943. constructor: function (config) {
  7944. var scope = lookupScope(config.$initParent.$initParent);
  7945. var newConfig = _.defaults({}, config, column);
  7946. if (typeof newConfig.summaryRenderer === 'string') {
  7947. newConfig.summaryRenderer = lookupFn(scope, config.summaryRenderer);
  7948. if (typeof newConfig.summaryRenderer === 'function') {
  7949. newConfig.summaryRenderer = newConfig.summaryRenderer.bind(scope);
  7950. }
  7951. }
  7952. // 在 grid.constructor 已经转换过了
  7953. // if (typeof newConfig.renderer === 'string') {
  7954. // newConfig.renderer = lookupFn(scope, config.renderer)
  7955. // if (typeof newConfig.renderer === 'function') {
  7956. // newConfig.renderer = newConfig.renderer.bind(scope)
  7957. // }
  7958. // }
  7959. ct.call(this, newConfig);
  7960. }
  7961. });
  7962. var ctAction = Ext.grid.column.Action.prototype.constructor;
  7963. Ext.grid.column.Action.override({
  7964. constructor: function (config) {
  7965. var scope = lookupScope(config.$initParent.$initParent);
  7966. _.forEach(config.items, function (item) {
  7967. if (typeof item.handler === 'string') {
  7968. item.handler = lookupFn(scope, item.handler);
  7969. if (typeof item.handler === 'function') {
  7970. item.handler = item.handler.bind(scope);
  7971. }
  7972. }
  7973. });
  7974. ctAction.call(this, config);
  7975. }
  7976. });
  7977. var ck = Ext.grid.column.Check.prototype.constructor;
  7978. Ext.grid.column.Check.override({
  7979. constructor: function (config) {
  7980. _.set(config, 'listeners.checkchange', function (sender, rowIndex, checked, record, e, eOpts) {
  7981. var grid = sender.view.grid.ownerGrid;
  7982. var column = grid.getColumns()[sender.fullColumnIndex];
  7983. var context = {
  7984. event: e,
  7985. column: column,
  7986. field: sender.dataIndex,
  7987. value: checked,
  7988. record: record,
  7989. rowIdx: rowIndex
  7990. };
  7991. grid.fireEvent('editfinish', grid, sender, context, eOpts);
  7992. });
  7993. ck.call(this, config);
  7994. }
  7995. });
  7996. // 227573
  7997. // const {onTitleElClick} = Ext.grid.column.Column.prototype
  7998. // Ext.define('Yvan.ColumnOverride', {
  7999. // override: 'Ext.grid.column.Column',
  8000. //
  8001. // config: {
  8002. // enableSortOnClick: false,
  8003. // },
  8004. //
  8005. // // /**@Overrides*/
  8006. // onTitleElClick: function (e, t, sortOnClick) {
  8007. // // return this.callParent([e, t, this.enableSortOnClick && sortOnClick]);
  8008. // if (!$(e.target).is('.x-column-header-trigger')) {
  8009. // // 不是点击菜单的情况下,让列自适应宽度
  8010. // this.autoSize()
  8011. // }
  8012. // return onTitleElClick.call(this, e, t, false)
  8013. // }
  8014. // });
  8015. }
  8016. var SIMPLE_RE = /^(?:\{(?:(\d+)|([a-z_][\w\.]*))\})$/i;
  8017. /**
  8018. * 判断目标字符串与关键字是否重叠
  8019. * @param target 目标字符串
  8020. * @param keyword 搜索关键字
  8021. */
  8022. function pinyinMatch(target, keyword) {
  8023. if (typeof target != 'string' || typeof keyword != 'string') {
  8024. return false;
  8025. }
  8026. if (!keyword || !target) {
  8027. return false;
  8028. }
  8029. var pyzh = _.toLower(window['getFirstPinyin2'](target));
  8030. keyword = _.toLower(keyword);
  8031. var pos1 = _.toLower(target).indexOf(keyword);
  8032. if (pos1 >= 0) {
  8033. return true;
  8034. }
  8035. if (_.intersection(pyzh.split(''), keyword.split('')).length === keyword.length) {
  8036. return true;
  8037. }
  8038. return false;
  8039. }
  8040. /**
  8041. * 对某个表达式进行求值
  8042. * a:{query.a},b:{query.b} -> a:aValue,b:bValue
  8043. *
  8044. * @example
  8045. * calcExpress(cc.viewModel.data, "WH_ID:{query.WH_ID},C:{theGrid.selection.data.WH_ID}")
  8046. * 计算出来的值是: "WH_ID:queryWhId,C:JH000000001"
  8047. *
  8048. * @param data 数据环境对象
  8049. * @param express 表达式对象
  8050. */
  8051. function calcExpress(data, express) {
  8052. var result = express;
  8053. if (SIMPLE_RE.test(express)) {
  8054. // '{foo}' 简单表达式
  8055. var path = express.substring(1, express.length - 1);
  8056. var ret = _.get(data, path);
  8057. return (ret === null || ret === void 0 ? void 0 : ret.isModel) ? ret.data : ret;
  8058. }
  8059. while (true) {
  8060. var mlist = result.match(/{(.*?)}/);
  8061. if (!mlist) {
  8062. break;
  8063. }
  8064. var pathC = mlist[0]; // {query.a}
  8065. var path = mlist[1]; // query.a
  8066. var value = _.get(data, path);
  8067. result = result.replaceAll(pathC, value || '');
  8068. }
  8069. return result;
  8070. }
  8071. /**
  8072. * 对个对象进行表达式求值,不用回调
  8073. * @example
  8074. * calcObjectFlat({query:{a:'aValue',b1:'b1Value',b2:'b2Value',d1:1,d2:2}}, { a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}'] })
  8075. *
  8076. * {
  8077. * a: '{query.a}',
  8078. * b: {
  8079. * b1: '{query.b1}',
  8080. * b2: '{query.b2}',
  8081. * },
  8082. * c: 'aa',
  8083. * d: [
  8084. * '{query.d1}',
  8085. * '{query.d2}'
  8086. * ]
  8087. * }
  8088. *
  8089. * 计算结果为
  8090. * {
  8091. * a: 'aValue',
  8092. * b: {
  8093. * b1: 'b1Value',
  8094. * b2: 'b2Value'
  8095. * },
  8096. * c: 'aa'
  8097. * d: [
  8098. * '1',
  8099. * '2'
  8100. * ]
  8101. * }
  8102. *
  8103. * @param data
  8104. * @param paramObject
  8105. */
  8106. function calcObjectFlat(data, paramObject) {
  8107. var result = _.cloneDeep(paramObject);
  8108. if (typeof paramObject === 'string') {
  8109. return calcExpress(data, paramObject);
  8110. }
  8111. var trav = function (param) {
  8112. _.forOwn(param, function (value, key) {
  8113. if (_.isPlainObject(value)) {
  8114. // 深度递归,对子对象进行求解
  8115. trav(value);
  8116. }
  8117. else if (_.isString(value)) {
  8118. // 字符串直接用 calcExpress 表达式求解
  8119. param[key] = calcExpress(data, param[key]);
  8120. }
  8121. else if (_.isArray(value)) {
  8122. // 数组求解
  8123. _.each(value, function (v, idx) {
  8124. value[idx] = calcExpress(data, v);
  8125. });
  8126. }
  8127. });
  8128. };
  8129. trav(result);
  8130. return result;
  8131. }
  8132. /**
  8133. * 合併 data 到當前的 ViewModel 對象
  8134. */
  8135. function mergeViewModel(viewModel, propertyName, data, isFlat) {
  8136. var newRow = {};
  8137. if (isFlat == false) {
  8138. newRow = data;
  8139. }
  8140. else {
  8141. flatObject(newRow, '', data);
  8142. }
  8143. _.forOwn(newRow, function (value, key) {
  8144. viewModel.set(propertyName + "." + key, value);
  8145. });
  8146. }
  8147. /**
  8148. * 转换内联结构的行,到平面结构
  8149. * company: { name:'公司1', id:'编号1' } => { company_id:'编号1', company_name:'公司1' }
  8150. *
  8151. * @param array
  8152. * @param flatOption
  8153. * @return {[]}
  8154. */
  8155. function flatRow(array) {
  8156. var ret = [];
  8157. _.forEach(array, function (row) {
  8158. var newRow = {};
  8159. flatObject(newRow, '', row);
  8160. ret.push(newRow);
  8161. });
  8162. return ret;
  8163. }
  8164. function flatObject(parentObj, parentProp, obj) {
  8165. _.forOwn(obj, function (value, key) {
  8166. var fullKey = parentProp ? parentProp + '_' + key : key;
  8167. if (_.isArray(value)) {
  8168. parentObj[fullKey] = _.map(value, function (row) {
  8169. var newRow = {};
  8170. flatObject(newRow, '', row);
  8171. return newRow;
  8172. });
  8173. }
  8174. else {
  8175. if (typeof value === 'object') {
  8176. flatObject(parentObj, fullKey, value);
  8177. }
  8178. else {
  8179. parentObj[fullKey] = value;
  8180. }
  8181. }
  8182. });
  8183. }
  8184. /**
  8185. * 替换内部结构中,所有 N/A
  8186. */
  8187. function replaceNA(obj) {
  8188. if (obj === 'N/A') {
  8189. return '';
  8190. }
  8191. if (_.isArray(obj)) {
  8192. _.forEach(obj, function (value, idx) {
  8193. if (value === 'N/A') {
  8194. obj[idx] = '';
  8195. }
  8196. else {
  8197. replaceNA(value);
  8198. }
  8199. });
  8200. }
  8201. else if (_.isPlainObject(obj)) {
  8202. _.forOwn(obj, function (value, key) {
  8203. if (value === 'N/A') {
  8204. obj[key] = '';
  8205. }
  8206. else {
  8207. replaceNA(value);
  8208. }
  8209. });
  8210. }
  8211. }
  8212. /**
  8213. * 根据表达式进入写值
  8214. * express="{query.a}" 写值就是 viewModel.set('query.a', value)
  8215. * express="test-{query.a}" 写值就会失败
  8216. *
  8217. * @example
  8218. * tryWriteByExpress(cc.viewModel, "{query.WH_ID}", "111")
  8219. * 写值成功
  8220. *
  8221. * tryWriteByExpress(cc.viewModel, "test-{query.WH_ID}", "111")
  8222. * 写值失败
  8223. *
  8224. * @param viewModel VM对象
  8225. * @param express 表达式对象
  8226. * @param value 目标值
  8227. */
  8228. function tryWriteByExpress(viewModel, express, value) {
  8229. if (SIMPLE_RE.test(express)) {
  8230. // '{foo}' 简单表达式
  8231. express = express.substring(1, express.length - 1);
  8232. viewModel.set(express, value);
  8233. }
  8234. }
  8235. /**
  8236. * 尝试根据含表达式的对象回写, calcObjectFlat 的逆向方法
  8237. * @example
  8238. * tryWriteObject({ a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}']}, {a:'aValue', b:{b1:'b1Value', b2:'b2Value'}, c:'aa', d:[1,2]})
  8239. *
  8240. * expressObject:
  8241. * {
  8242. * a: '{query.a}',
  8243. * b: {
  8244. * b1: '{query.b1}',
  8245. * b2: '{query.b2}',
  8246. * },
  8247. * c: 'aa',
  8248. * d: [
  8249. * '{query.a}',
  8250. * '{query.b2}'
  8251. * ]
  8252. * }
  8253. *
  8254. * valueObject:
  8255. * {
  8256. * a: 'aValue',
  8257. * b: {
  8258. * b1: 'b1Value',
  8259. * b2: 'b2Value'
  8260. * },
  8261. * c: 'aa'
  8262. * c: [
  8263. * 'aValue',
  8264. * 'b2Value'
  8265. * ]
  8266. * }
  8267. *
  8268. * 系统会尝试回写
  8269. * viewModel.set('query.a', 'aValue')
  8270. * viewModel.set('query.b1', 'b1Value')
  8271. * viewModel.set('query.b2', 'b2Value')
  8272. *
  8273. * @param expressObject 含表达式的对象
  8274. * @param valueObject 表达式计算完成之后的结果对象
  8275. * @param writeFn 写入的方法 (path, value)=>void
  8276. */
  8277. function tryWriteObject(expressObject, valueObject, writeFn) {
  8278. var trav = function (pathPrefix) {
  8279. var parent = expressObject;
  8280. if (_.size(pathPrefix) > 1) {
  8281. parent = _.get(parent, pathPrefix.substring(1));
  8282. }
  8283. _.forOwn(parent, function (value, key) {
  8284. if (_.isPlainObject(value)) {
  8285. // 深度递归,对子对象进行求解
  8286. trav(pathPrefix + "." + key);
  8287. }
  8288. else if (_.isString(value)) {
  8289. // 字符串直接用 calcExpress 表达式求解
  8290. if (SIMPLE_RE.test(value)) {
  8291. // If we have '{foo}' alone it is a literal 简单表达式
  8292. var targetPath = value.substring(1, value.length - 1);
  8293. var targetValue = _.get(valueObject, (pathPrefix + "." + key).substr(1));
  8294. if (!writeFn) {
  8295. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  8296. }
  8297. else {
  8298. writeFn(targetPath, targetValue);
  8299. }
  8300. }
  8301. }
  8302. else if (_.isArray(value)) {
  8303. _.each(value, function (v, idx) {
  8304. if (SIMPLE_RE.test(v)) {
  8305. var targetPath = (pathPrefix + "." + key).substr(1) + "[" + idx + "]";
  8306. var targetValue = _.get(valueObject, (pathPrefix + "." + key).substr(1) + "[" + idx + "]");
  8307. if (!writeFn) {
  8308. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  8309. }
  8310. else {
  8311. writeFn(targetPath, targetValue);
  8312. }
  8313. }
  8314. });
  8315. }
  8316. });
  8317. };
  8318. trav("");
  8319. }
  8320. /**
  8321. * 尝试去掉变量两边括号
  8322. * {a} => a
  8323. * a => a
  8324. */
  8325. function tryVarSimple(value) {
  8326. if (SIMPLE_RE.test(value)) {
  8327. // If we have '{foo}' alone it is a literal 简单表达式
  8328. return value.substring(1, value.length - 1);
  8329. }
  8330. return value;
  8331. }
  8332. /**
  8333. * 对多个表达式进行求值. 异步回调的方式返回
  8334. * {
  8335. * a: 1,
  8336. * b: '{someBind}',
  8337. * c: ['a', 'b', 'c'],
  8338. * d: ['a', 'b', '{someBind}'],
  8339. * e: {
  8340. * y: 1,
  8341. * z: 2
  8342. * },
  8343. * f: {
  8344. * y: 1,
  8345. * z: '{someBind}'
  8346. * }
  8347. * }
  8348. *
  8349. * // Will produce
  8350. * {
  8351. * b: value,
  8352. * d: ['a', 'b', value],
  8353. * f: {
  8354. * y: 1,
  8355. * z: value
  8356. * }
  8357. * }
  8358. * @param viewModel scope.viewModel对象
  8359. * @param paramObject 求值对象
  8360. */
  8361. function calcObject(viewModel, paramObject) {
  8362. // new Ext.app.bind.Multi({a:'1',b:'ddd{query.WH_ID}'},currentScope.viewModel,function(v){console.log(v)},currentScope, {single: true})
  8363. return new Promise(function (resolve) {
  8364. var schedule = new Ext.app.bind.Multi(paramObject, viewModel, function (ret) {
  8365. schedule.destroy();
  8366. // 从 Ext.data.Model 对象转换为 js-object 对象
  8367. ret = toPlainObject(ret);
  8368. resolve(ret);
  8369. }, viewModel, { single: true });
  8370. });
  8371. }
  8372. /**
  8373. * 用于任意组件 Ext.Component 构造时,获取当前组件对应的表格(如果不是 grid.columns 对象就会返回 undefined)
  8374. * @param config 组件构造函数传入的 config 配置文件
  8375. */
  8376. function getParentGrid(config) {
  8377. var _a;
  8378. return (_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.grid;
  8379. }
  8380. /**
  8381. * 解析
  8382. * {
  8383. * condition: "{skuId}",
  8384. * errorMsg: "无法编辑",
  8385. * notice: 'msg'
  8386. * }
  8387. */
  8388. function tryEnable(data, enableSetting) {
  8389. if (!enableSetting) {
  8390. // 没有这一段配置,可以编辑
  8391. return true;
  8392. }
  8393. var condition = enableSetting.condition, errorMsg = enableSetting.errorMsg, notice = enableSetting.notice;
  8394. if (!evalFunction(data, condition)) {
  8395. // 没有达成 condition 条件
  8396. // 计算 msg 消息内容
  8397. var msgContent = calcExpress(data, errorMsg);
  8398. if (msgContent) {
  8399. if (!notice || notice === 'msg') {
  8400. // 进行提示
  8401. msg$1(msgContent);
  8402. }
  8403. }
  8404. return false;
  8405. }
  8406. return true;
  8407. }
  8408. /**
  8409. * 动态的为 combo 或 columns.combo 设置下拉框的值
  8410. * @param sender 目标对象
  8411. * @param config 目标对象的配置(在构造函数之前也可以)
  8412. * @param getDictFn 获取字典的方法
  8413. * @param bizKey 传入字典的参数
  8414. * @param multiValueSeparator 多个字典值的分割符号
  8415. */
  8416. function setComboStore(sender, config, getDictFn, bizKey, multiValueSeparator) {
  8417. if (multiValueSeparator === void 0) { multiValueSeparator = ""; }
  8418. // sender 和 config为空的时候获取值、
  8419. if (_.isArray(getDictFn)) {
  8420. // 如果 getDictFn 是直接给定的值,就造一个异步回调的方法
  8421. var realArray_1 = getDictFn;
  8422. getDictFn = function () {
  8423. return realArray_1;
  8424. };
  8425. }
  8426. if (!sender) {
  8427. return new Promise(function (resolve, reject) {
  8428. getDictFn(bizKey, function (r) {
  8429. resolve({ config: config, r: r });
  8430. });
  8431. });
  8432. }
  8433. if (sender.xtype === 'combotree') {
  8434. getDictFn(bizKey, function (r) {
  8435. if (sender.store) {
  8436. // 异步回传
  8437. sender.setStore(new Ext.data.TreeStore({ root: r }));
  8438. }
  8439. else {
  8440. // 同步回传
  8441. config.store = new Ext.data.TreeStore({ root: r });
  8442. }
  8443. });
  8444. return;
  8445. }
  8446. else if (sender.$className === 'Ext.form.field.ComboBox') {
  8447. getDictFn(bizKey, function (r) {
  8448. var _a, _b;
  8449. if (sender.store) {
  8450. // 异步回传
  8451. sender.setStore(new Ext.data.Store(r));
  8452. // 这里有个bug, 异步回传完毕之后, 需要强制刷新一下
  8453. // 否则在 forceSelection 的模式下。displayField 不会强制做变更
  8454. var realValue = (_b = (_a = sender.bind) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.getValue();
  8455. if (typeof realValue !== 'undefined') {
  8456. sender.setValue(realValue);
  8457. }
  8458. }
  8459. else {
  8460. // 同步回传
  8461. config.store = new Ext.data.Store(r);
  8462. }
  8463. });
  8464. return;
  8465. }
  8466. else if (sender.xtype === 'gridcolumn') {
  8467. var grid = getParentGrid(config);
  8468. var editor_1 = config.editor, renderer = config.renderer;
  8469. getDictFn(bizKey, function (r) {
  8470. if (sender.store) {
  8471. // 已经渲染出来了, 用方法进行修改
  8472. var editor_2 = sender.getEditor();
  8473. if (editor_2 && editor_2.xtype === 'combo') {
  8474. var valueField_1 = r.field[0];
  8475. var displayField_1 = r.field[1];
  8476. editor_2.valueField = valueField_1;
  8477. editor_2.setDisplayField(displayField_1);
  8478. editor_2.setStore(new Ext.data.Store(r));
  8479. }
  8480. }
  8481. else {
  8482. // 没有渲染之前,修改 config 即可
  8483. if (editor_1 && editor_1.xtype === 'combo') {
  8484. // 带编辑模式
  8485. editor_1.store = new Ext.data.Store(r);
  8486. }
  8487. }
  8488. var renderer = function (value, metaData) {
  8489. if (!value && value != 0) {
  8490. return '';
  8491. }
  8492. var valueField = r.field[0];
  8493. var displayField = r.field[1];
  8494. var separator = multiValueSeparator;
  8495. if (separator) {
  8496. var arr = value.split(separator);
  8497. var displayValue_1 = "";
  8498. var _loop_1 = function (i) {
  8499. var itv = arr[i];
  8500. if (i > 0) {
  8501. displayValue_1 += separator;
  8502. }
  8503. _.each(r.data, function (row) {
  8504. // 从 valueField 找到要显示的 displayField
  8505. if (row[valueField] == itv) {
  8506. displayValue_1 += row[displayField];
  8507. return false;
  8508. }
  8509. else {
  8510. if (i >= r.data.length - 1) {
  8511. displayValue_1 += itv;
  8512. }
  8513. }
  8514. });
  8515. };
  8516. for (var i = 0; i < arr.length; i++) {
  8517. _loop_1(i);
  8518. }
  8519. return displayValue_1;
  8520. }
  8521. _.each(r.data, function (row) {
  8522. // 从 valueField 找到要显示的 displayField
  8523. if (row[valueField] == value) {
  8524. value = row[displayField];
  8525. return false;
  8526. }
  8527. });
  8528. return value;
  8529. };
  8530. var dictForExcel = {};
  8531. var valueField = r.field[0];
  8532. var displayField = r.field[1];
  8533. _.each(r.data, function (row) {
  8534. // 从 valueField 找到要显示的 displayField
  8535. var key = row[valueField];
  8536. if (key != '' && typeof key != "undefined" && key != null) {
  8537. dictForExcel[key] = row[displayField];
  8538. }
  8539. });
  8540. if (sender.rendered) {
  8541. // 已经渲染出来了, 对列进行渲染
  8542. sender.renderer = renderer;
  8543. sender.dictForExcel = dictForExcel;
  8544. sender.getView().refresh();
  8545. }
  8546. else {
  8547. sender.renderer = renderer;
  8548. sender.dictForExcel = dictForExcel;
  8549. config.renderer = renderer;
  8550. config.dictForExcel = dictForExcel;
  8551. }
  8552. });
  8553. return;
  8554. }
  8555. throw new TypeError("无法识别的组件类型");
  8556. }
  8557. /**
  8558. * 调用服务器 Ajax
  8559. */
  8560. function invokeServer(url) {
  8561. var args = [];
  8562. for (var _i = 1; _i < arguments.length; _i++) {
  8563. args[_i - 1] = arguments[_i];
  8564. }
  8565. // @ts-ignore
  8566. return ajax.func({
  8567. url: url,
  8568. method: 'invoke',
  8569. args: args
  8570. });
  8571. }
  8572. function clearViewModelValues(viewModel, propertyName) {
  8573. if (!propertyName) {
  8574. var dd_1 = viewModel.getData();
  8575. _.forOwn(dd_1, function (value, key) {
  8576. viewModel.set(key, '');
  8577. });
  8578. return;
  8579. }
  8580. var dd = _.get(viewModel.getData(), propertyName);
  8581. _.forOwn(dd, function (value, key) {
  8582. viewModel.set(propertyName + '.' + key, '');
  8583. });
  8584. }
  8585. function reloadGrid(scope, gridRefName) {
  8586. var _a;
  8587. (_a = scope.refs[gridRefName]) === null || _a === void 0 ? void 0 : _a.reload();
  8588. }
  8589. /**
  8590. * 将 Ext.data.Model 对象 (及子属性) 转换为 js.object 对象
  8591. */
  8592. function toPlainObject(obj) {
  8593. if (obj.isModel) {
  8594. obj = obj.data;
  8595. }
  8596. _.forOwn(obj, function (v, k) {
  8597. // Ext.data.Model.constructor
  8598. if (!v) {
  8599. return;
  8600. }
  8601. if (v.isModel) {
  8602. v = v.data;
  8603. }
  8604. if (typeof v === 'object') {
  8605. obj[k] = toPlainObject(v);
  8606. }
  8607. else {
  8608. obj[k] = v;
  8609. }
  8610. });
  8611. return obj;
  8612. }
  8613. function confirm(msg, sender) {
  8614. return new Promise(function (resolve) {
  8615. var _a, _b;
  8616. var scope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  8617. var config = {
  8618. title: '请确认',
  8619. modal: true,
  8620. animateTarget: sender,
  8621. // resizable: false,
  8622. // constrainHeader: true,
  8623. // constrain: true,
  8624. // constrainTo: scope._handle?.el?.dom || Ext.getBody(),
  8625. layout: {
  8626. type: 'hbox',
  8627. pack: 'start',
  8628. align: 'stretch'
  8629. },
  8630. items: [
  8631. {
  8632. html: '<i class="x-fa fa-question-circle" style="font:normal normal normal 40px/1 FontAwesome;color: #31708f;"></i>',
  8633. border: false,
  8634. },
  8635. {
  8636. flex: 1,
  8637. border: false,
  8638. html: "<div style=\"min-width: 170px;min-height: 25px;max-width: 400px;\">" + _.escape(msg) + "</div>"
  8639. }
  8640. ],
  8641. buttons: [
  8642. {
  8643. xtype: 'button', text: '确定', iconCls: 'x-fa fa-check-circle',
  8644. handler: function () {
  8645. resolve();
  8646. win.close();
  8647. }
  8648. },
  8649. {
  8650. xtype: 'button', text: '取消', iconCls: 'x-fa fa-power-off',
  8651. handler: function () {
  8652. win.close();
  8653. }
  8654. }
  8655. ],
  8656. keyMapEnabled: true,
  8657. keyMap: {
  8658. ENTER: function () {
  8659. resolve();
  8660. win.close();
  8661. }
  8662. }
  8663. };
  8664. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  8665. config.constrain = true;
  8666. }
  8667. var win = new Ext.Window(config);
  8668. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  8669. (_b = scope === null || scope === void 0 ? void 0 : scope._handle) === null || _b === void 0 ? void 0 : _b.add(win);
  8670. }
  8671. win.show();
  8672. });
  8673. }
  8674. /**
  8675. * 任何符号字符串都替换成下换线
  8676. */
  8677. function normId(value) {
  8678. return _.replace(value, /[^\w]/g, '_');
  8679. }
  8680. /**
  8681. *
  8682. * @param sender
  8683. * @param propertyName
  8684. * @param gridRefName
  8685. */
  8686. function clearViewModelReloadGrid(sender, propertyName, gridRefName) {
  8687. var _a, _b;
  8688. var scope = lookupScope(sender);
  8689. clearViewModelValues(scope.viewModel, propertyName);
  8690. if (!gridRefName) {
  8691. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  8692. }
  8693. else {
  8694. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  8695. }
  8696. }
  8697. var keydown_fun_item = _.debounce(function (sender, event, eOpts) {
  8698. if ([10, 13, 20, 40].includes(event.keyCode)) {
  8699. // 获取读码器读取的内容,最好不要从 viewModel 中取值,而是从 sender.rawValue 中取值
  8700. var value = _.trim(sender.rawValue);
  8701. raiseClick(eOpts.handle);
  8702. }
  8703. }, 150);
  8704. var SystemEventFu = /** @class */ (function () {
  8705. function SystemEventFu() {
  8706. }
  8707. SystemEventFu.prototype.enterToClick = function (btnReferenceName) {
  8708. return function (sender, config) {
  8709. if (!config.listeners) {
  8710. config.listeners = {};
  8711. }
  8712. config.listeners.afterrender = function (sender) {
  8713. var scope = lookupScope(sender);
  8714. // $(sender.el.dom).on('keydown', (e) => {
  8715. // const xtype = Ext.fly(e.target).component.xtype
  8716. // if (xtype === 'textfield' && e.keyCode === 13) {
  8717. // Ext.defer(() => {
  8718. // raiseClick(scope.refs[btnReferenceName])
  8719. // })
  8720. // e.preventDefault()
  8721. // e.stopPropagation()
  8722. // return false
  8723. // }
  8724. // })
  8725. $(sender.el.dom).on('keyup', function (e) {
  8726. var tt = Ext.fly(e.target).component;
  8727. var xtype = tt === null || tt === void 0 ? void 0 : tt.xtype;
  8728. if ((xtype !== 'textfield' && xtype !== 'numberfield') ||
  8729. ![10, 13, 20, 40].includes(e.keyCode)) {
  8730. return;
  8731. }
  8732. e.preventDefault();
  8733. e.stopPropagation();
  8734. keydown_fun_item(tt, e, { handle: scope.refs[btnReferenceName] });
  8735. return;
  8736. });
  8737. };
  8738. };
  8739. };
  8740. SystemEventFu.prototype.confirm = function (text, fn) {
  8741. return function (sender) {
  8742. var scope = lookupScope(sender);
  8743. var msg = calcExpress(scope.viewModel.data, text);
  8744. confirm(msg, sender).then(function () {
  8745. fn.call(scope, sender);
  8746. });
  8747. };
  8748. };
  8749. SystemEventFu.prototype.gridRemoveCurrentRow = function (gridRefName) {
  8750. return function (sender) {
  8751. var scope = lookupScope(sender);
  8752. var grid = scope.refs[gridRefName];
  8753. if (grid) {
  8754. var records = grid.getSelectionModel().getLastSelected();
  8755. grid.store.remove(records);
  8756. }
  8757. };
  8758. };
  8759. SystemEventFu.prototype.loadForm = function (invokeUrl, invokeParam,
  8760. //可以是 scope.XX / system.XX / string / lookup表达式
  8761. writeTarget) {
  8762. return function (sender) {
  8763. if (!invokeUrl) {
  8764. return;
  8765. }
  8766. var scope = lookupScope(sender);
  8767. scope.setLoading(true);
  8768. var data = scope.viewModel.data;
  8769. if (invokeParam) {
  8770. data = calcObjectFlat(data, invokeParam);
  8771. }
  8772. invokeServer(invokeUrl, data).then(function (res) {
  8773. if (res.success) {
  8774. if (typeof writeTarget === "string") {
  8775. _.forOwn(res.data, function (v, k) {
  8776. scope.viewModel.set(writeTarget + "." + k, v);
  8777. });
  8778. }
  8779. else if (typeof writeTarget === 'function') {
  8780. writeTarget.call(scope, res.data);
  8781. }
  8782. else if (typeof writeTarget === 'object') {
  8783. var ret = calcObjectFlat(res.data, writeTarget);
  8784. _.forOwn(ret, function (v, k) {
  8785. scope.viewModel.set(k, v);
  8786. });
  8787. }
  8788. }
  8789. else {
  8790. showErrorDialog$1(res.msg || '未知错误', sender);
  8791. }
  8792. }).catch(function (e) {
  8793. var _a, _b;
  8794. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  8795. showErrorDialog$1(msg || e.toString(), sender);
  8796. }).finally(function () {
  8797. scope.setLoading(false);
  8798. });
  8799. };
  8800. };
  8801. SystemEventFu.prototype.commit = function (groovyUrl, arg0, successCallback) {
  8802. return function (sender) {
  8803. var scope = lookupScope(sender);
  8804. scope.setLoading(true);
  8805. var data = scope.viewModel.data;
  8806. if (arg0) {
  8807. data = calcObjectFlat(data, arg0);
  8808. }
  8809. invokeServer(groovyUrl, data).then(function (res) {
  8810. if (res.success) {
  8811. if (res.msg) {
  8812. msg(res.msg);
  8813. }
  8814. if (typeof successCallback === 'function') {
  8815. successCallback.call(scope, sender, res.data);
  8816. }
  8817. }
  8818. else {
  8819. showErrorDialog$1(res.msg || '未知错误', sender);
  8820. }
  8821. }).catch(function (e) {
  8822. var _a, _b;
  8823. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  8824. showErrorDialog$1(msg || e.toString(), sender);
  8825. }).finally(function () {
  8826. scope.setLoading(false);
  8827. });
  8828. };
  8829. };
  8830. SystemEventFu.prototype.formCommit = function (groovyUrl, arg0) {
  8831. return function (sender) {
  8832. var scope = lookupScope(sender);
  8833. var form = scope.down('form');
  8834. if (form) {
  8835. // 如果下级有表单,就做表单校验
  8836. var valid = form.isValid();
  8837. if (!valid) {
  8838. return;
  8839. }
  8840. }
  8841. scope.setLoading(true);
  8842. var data = scope.viewModel.data;
  8843. if (arg0) {
  8844. data = calcObjectFlat(data, arg0);
  8845. }
  8846. invokeServer(groovyUrl, data).then(function (res) {
  8847. if (res.success) {
  8848. if (res.msg) {
  8849. msg(res.msg);
  8850. }
  8851. scope.dialogSuccess(res);
  8852. }
  8853. else {
  8854. showErrorDialog$1(res.msg || '未知错误', sender);
  8855. }
  8856. }).catch(function (e) {
  8857. var _a, _b;
  8858. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  8859. showErrorDialog$1(msg || e.toString(), sender);
  8860. }).finally(function () {
  8861. scope.setLoading(false);
  8862. });
  8863. };
  8864. };
  8865. SystemEventFu.prototype.dialogSuccess = function (lookupObject) {
  8866. return function (sender) {
  8867. var scope = lookupScope(sender);
  8868. if (lookupObject) {
  8869. scope.dialogSuccess(calcObjectFlat(scope.viewModel.data, lookupObject));
  8870. }
  8871. else {
  8872. scope.dialogSuccess();
  8873. }
  8874. };
  8875. };
  8876. SystemEventFu.prototype.clearViewModelValues = function (propertyName) {
  8877. return function (sender) {
  8878. var scope = lookupScope(sender);
  8879. clearViewModelValues(scope.viewModel, propertyName);
  8880. };
  8881. };
  8882. SystemEventFu.prototype.getGrid = function (url) {
  8883. return function (sender, config) {
  8884. if (config.xtype == "combogridmulti") {
  8885. // @ts-ignore
  8886. require([url], function (grid) {
  8887. _.forOwn(grid.default, function (v, k) {
  8888. sender[k] = v;
  8889. sender.config[k] = v;
  8890. if (sender.rendered) {
  8891. // 已经渲染出来了,重新调用 reload 强制刷新
  8892. sender.reload();
  8893. }
  8894. });
  8895. });
  8896. }
  8897. else {
  8898. // @ts-ignore
  8899. require([url], function (grid) {
  8900. sender.grid = grid.default;
  8901. config.grid = grid.default;
  8902. });
  8903. }
  8904. };
  8905. };
  8906. SystemEventFu.prototype.clearViewModelReloadGrid = function (propertyName, gridRefName) {
  8907. return function (sender) {
  8908. clearViewModelReloadGrid(sender, propertyName, gridRefName);
  8909. };
  8910. };
  8911. SystemEventFu.prototype.reloadGrid = function (gridRefName) {
  8912. return function (sender) {
  8913. var _a, _b;
  8914. var scope = lookupScope(sender);
  8915. if (!gridRefName) {
  8916. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  8917. }
  8918. else {
  8919. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  8920. }
  8921. };
  8922. };
  8923. SystemEventFu.prototype.showDialog = function (url, lookupForData, successCallback) {
  8924. return function (sender) {
  8925. var scope = lookupScope(sender);
  8926. var data = scope.viewModel.data;
  8927. var param = calcObjectFlat(data, lookupForData);
  8928. // @ts-ignore
  8929. require([url], function (module) {
  8930. var ScopeClass = module.default;
  8931. var scope = new ScopeClass();
  8932. scope.success = successCallback;
  8933. scope.showDialog(sender, {}, { data: param });
  8934. });
  8935. };
  8936. };
  8937. SystemEventFu.prototype.showWidget = function (widgetUrl, lookup) {
  8938. return function (sender, queryValue) {
  8939. showWidget(widgetUrl, lookup, sender, queryValue);
  8940. };
  8941. };
  8942. SystemEventFu.prototype.clearViewModelByLookup = function (lookup) {
  8943. return function (sender) {
  8944. clearViewModelByLookup(sender, lookup);
  8945. };
  8946. };
  8947. SystemEventFu.prototype.closeMe = function (callBack) {
  8948. return function (sender) {
  8949. var scope = lookupScope(sender);
  8950. scope.close();
  8951. if (callBack) {
  8952. callBack.call(sender);
  8953. }
  8954. };
  8955. };
  8956. __decorate([
  8957. Lib({
  8958. title: '按下回车键之后默认是否按下某个按钮',
  8959. author: '罗一帆',
  8960. createAt: '2021-07-02',
  8961. updateAt: '2021-07-02',
  8962. type: 'system',
  8963. category: '字典',
  8964. }),
  8965. __metadata("design:type", Function),
  8966. __metadata("design:paramtypes", [Object]),
  8967. __metadata("design:returntype", void 0)
  8968. ], SystemEventFu.prototype, "enterToClick", null);
  8969. __decorate([
  8970. Lib({
  8971. title: '弹出确认对话框,回答 YES 之后调用某方法',
  8972. author: '罗一帆',
  8973. createAt: '2021-07-06',
  8974. updateAt: '2021-07-06',
  8975. type: 'system',
  8976. category: '对话框',
  8977. }),
  8978. __param(0, LibParam('对话框的确认文字', 'string')),
  8979. __param(1, LibParam('确认之后的调用的方法', 'event')),
  8980. __metadata("design:type", Function),
  8981. __metadata("design:paramtypes", [Object, Object]),
  8982. __metadata("design:returntype", void 0)
  8983. ], SystemEventFu.prototype, "confirm", null);
  8984. __decorate([
  8985. Lib({
  8986. title: '删除表格当前的选中行(前端删除)',
  8987. author: '罗一帆',
  8988. createAt: '2021-07-08',
  8989. updateAt: '2021-07-08',
  8990. type: 'system',
  8991. category: '表格',
  8992. }),
  8993. __param(0, LibParam('表格引用名', 'refs')),
  8994. __metadata("design:type", Function),
  8995. __metadata("design:paramtypes", [Object]),
  8996. __metadata("design:returntype", void 0)
  8997. ], SystemEventFu.prototype, "gridRemoveCurrentRow", null);
  8998. __decorate([
  8999. Lib({
  9000. title: '查询表单,如果 url 为空值,就取消查询',
  9001. author: '罗一帆',
  9002. createAt: '2021-07-06',
  9003. updateAt: '2021-07-06',
  9004. type: 'system',
  9005. category: '表单',
  9006. }),
  9007. __param(0, LibParam('后端服务路径', 'string')),
  9008. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  9009. __param(2, LibParam('提交成功后的回调', 'viewModel', true)),
  9010. __metadata("design:type", Function),
  9011. __metadata("design:paramtypes", [String, Object, Object]),
  9012. __metadata("design:returntype", void 0)
  9013. ], SystemEventFu.prototype, "loadForm", null);
  9014. __decorate([
  9015. Lib({
  9016. title: '提交(不做校验、不关闭窗体)',
  9017. author: '罗一帆',
  9018. createAt: '2021-07-02',
  9019. updateAt: '2021-07-02',
  9020. type: 'system',
  9021. category: '表单',
  9022. }),
  9023. __param(0, LibParam('后端服务路径', 'string')),
  9024. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  9025. __param(2, LibParam('提交成功后的回调', 'event', true)),
  9026. __metadata("design:type", Function),
  9027. __metadata("design:paramtypes", [String, Object, Object]),
  9028. __metadata("design:returntype", void 0)
  9029. ], SystemEventFu.prototype, "commit", null);
  9030. __decorate([
  9031. Lib({
  9032. title: '提交表单',
  9033. author: '罗一帆',
  9034. createAt: '2021-07-02',
  9035. updateAt: '2021-07-02',
  9036. type: 'system',
  9037. category: '表单',
  9038. }),
  9039. __param(0, LibParam('后端服务路径', 'string')),
  9040. __param(1, LibParam('后端需要的参数,默认情况提交所有', 'lookup', true)),
  9041. __metadata("design:type", Function),
  9042. __metadata("design:paramtypes", [String, Object]),
  9043. __metadata("design:returntype", void 0)
  9044. ], SystemEventFu.prototype, "formCommit", null);
  9045. __decorate([
  9046. Lib({
  9047. title: '对话框成功回调',
  9048. author: '罗一帆',
  9049. createAt: '2021-07-02',
  9050. updateAt: '2021-07-02',
  9051. type: 'system',
  9052. category: '对话框',
  9053. }),
  9054. __param(0, LibParam('传回给父窗口的成功参数对象', 'lookup', true)),
  9055. __metadata("design:type", Function),
  9056. __metadata("design:paramtypes", [Object]),
  9057. __metadata("design:returntype", void 0)
  9058. ], SystemEventFu.prototype, "dialogSuccess", null);
  9059. __decorate([
  9060. Lib({
  9061. title: '清空 viewModel 某个属性',
  9062. author: '罗一帆',
  9063. createAt: '2021-07-02',
  9064. updateAt: '2021-07-02',
  9065. type: 'system',
  9066. category: '表单',
  9067. }),
  9068. __param(0, LibParam('属性路径', 'viewModel', true)),
  9069. __metadata("design:type", Function),
  9070. __metadata("design:paramtypes", [String]),
  9071. __metadata("design:returntype", void 0)
  9072. ], SystemEventFu.prototype, "clearViewModelValues", null);
  9073. __decorate([
  9074. Lib({
  9075. title: '从其他资源获取表格设置',
  9076. author: '罗一帆',
  9077. createAt: '2021-07-02',
  9078. updateAt: '2021-07-02',
  9079. type: 'system',
  9080. category: '表单',
  9081. }),
  9082. __param(0, LibParam('定义文件', 'module')),
  9083. __metadata("design:type", Function),
  9084. __metadata("design:paramtypes", [Object]),
  9085. __metadata("design:returntype", void 0)
  9086. ], SystemEventFu.prototype, "getGrid", null);
  9087. __decorate([
  9088. Lib({
  9089. title: '清空 viewModel 某个属性,并刷新表格',
  9090. author: '罗一帆',
  9091. createAt: '2021-07-02',
  9092. updateAt: '2021-07-02',
  9093. type: 'system',
  9094. category: '表单',
  9095. }),
  9096. __param(0, LibParam('清空的属性', 'viewModel')),
  9097. __param(1, LibParam('要刷新的表格', 'refs', true)),
  9098. __metadata("design:type", Function),
  9099. __metadata("design:paramtypes", [String, String]),
  9100. __metadata("design:returntype", void 0)
  9101. ], SystemEventFu.prototype, "clearViewModelReloadGrid", null);
  9102. __decorate([
  9103. Lib({
  9104. title: '刷新表格',
  9105. author: '罗一帆',
  9106. createAt: '2021-07-02',
  9107. updateAt: '2021-07-02',
  9108. type: 'system',
  9109. category: '表单',
  9110. }),
  9111. __param(0, LibParam('表格对象,不填的情况下就是第一个表格', 'refs', true)),
  9112. __metadata("design:type", Function),
  9113. __metadata("design:paramtypes", [String]),
  9114. __metadata("design:returntype", void 0)
  9115. ], SystemEventFu.prototype, "reloadGrid", null);
  9116. __decorate([
  9117. Lib({
  9118. title: '显示对话框',
  9119. author: '罗一帆',
  9120. createAt: '2021-07-02',
  9121. updateAt: '2021-07-02',
  9122. type: 'system',
  9123. category: '对话框',
  9124. }),
  9125. __param(0, LibParam('业务模块名', 'module')),
  9126. __param(1, LibParam('参数数据 lookup 表达式', 'lookup', true)),
  9127. __param(2, LibParam('成功回调(对话框成功结束后的回调方法)', 'event', true)),
  9128. __metadata("design:type", Function),
  9129. __metadata("design:paramtypes", [String, Object, Object]),
  9130. __metadata("design:returntype", void 0)
  9131. ], SystemEventFu.prototype, "showDialog", null);
  9132. __decorate([
  9133. Lib({
  9134. title: '弹出查找框(不借助 search)',
  9135. author: '罗一帆',
  9136. createAt: '2021-07-02',
  9137. updateAt: '2021-07-02',
  9138. type: 'system',
  9139. category: '对话框',
  9140. }),
  9141. __param(0, LibParam('模块名 (WidgetDialog)', 'module')),
  9142. __param(1, LibParam('lookup 映射关系', 'lookup', true)),
  9143. __metadata("design:type", Function),
  9144. __metadata("design:paramtypes", [Object, Object]),
  9145. __metadata("design:returntype", void 0)
  9146. ], SystemEventFu.prototype, "showWidget", null);
  9147. __decorate([
  9148. Lib({
  9149. title: '根据 lookup 清空 viewModel',
  9150. author: '罗一帆',
  9151. createAt: '2021-07-05',
  9152. updateAt: '2021-07-05',
  9153. type: 'system',
  9154. category: '表单',
  9155. }),
  9156. __param(0, LibParam('设值表达式', 'lookup')),
  9157. __metadata("design:type", Function),
  9158. __metadata("design:paramtypes", [Object]),
  9159. __metadata("design:returntype", void 0)
  9160. ], SystemEventFu.prototype, "clearViewModelByLookup", null);
  9161. __decorate([
  9162. Lib({
  9163. title: '关闭对话框',
  9164. author: '罗一帆',
  9165. createAt: '2021-07-05',
  9166. updateAt: '2021-07-05',
  9167. type: 'system',
  9168. category: '对话框',
  9169. }),
  9170. __param(0, LibParam('对话框的返回值回调', 'event', true)),
  9171. __metadata("design:type", Function),
  9172. __metadata("design:paramtypes", [Object]),
  9173. __metadata("design:returntype", void 0)
  9174. ], SystemEventFu.prototype, "closeMe", null);
  9175. return SystemEventFu;
  9176. }());
  9177. /**
  9178. * 清空 viewmodel 里下属的所有属性
  9179. * @param viewModel VM对象
  9180. * @param propertyKey 要清空的属性,可以是 "a.b.c" 这种表达模式
  9181. * @param ignoreProps 要忽略清空的属性名集合, 比如 ["a.b","b"]
  9182. */
  9183. function clearViewModel(viewModel, propertyKey, ignoreProps) {
  9184. var data = viewModel.data;
  9185. if (propertyKey) {
  9186. data = _.get(data, propertyKey);
  9187. }
  9188. _.forOwn(data, function (value, key) {
  9189. var targetKey = propertyKey ? propertyKey + "." + key : key;
  9190. if (ignoreProps && _.indexOf(ignoreProps, targetKey) >= 0) {
  9191. return;
  9192. }
  9193. viewModel.set(targetKey, '');
  9194. });
  9195. }
  9196. function clearViewModelByLookup(sender, lookup) {
  9197. if (_.isPlainObject(lookup)) {
  9198. var parentScope_1 = lookupScope(sender);
  9199. _.forOwn(lookup, function (value, key) {
  9200. if (SIMPLE_RE.test(value)) {
  9201. // '{foo}' 简单表达式
  9202. var path = value.substring(1, value.length - 1);
  9203. if (path !== 'queryValue') {
  9204. parentScope_1.viewModel.set(path, '');
  9205. }
  9206. }
  9207. });
  9208. }
  9209. }
  9210. function showWidget(widgetUrl, lookup, sender, queryValue, vjson) {
  9211. if (vjson === void 0) { vjson = {}; }
  9212. var parentScope = lookupScope(sender);
  9213. var me = sender;
  9214. // @ts-ignore
  9215. require([widgetUrl], function (widgetScope) {
  9216. var WidgetScopeClass = widgetScope.default;
  9217. widgetScope = new WidgetScopeClass();
  9218. // 传递进 widget.model 的数据
  9219. var widgetDialogData = calcObjectFlat(__assign({ queryValue: queryValue }, parentScope.viewModel.data), lookup);
  9220. widgetScope.parentScope = parentScope;
  9221. widgetScope.searchWidgetSuccess = function (data) {
  9222. if (typeof lookup === 'string') {
  9223. // lookup 是字符串的情况下,就是取某个列作为 value 值
  9224. me.setValue(data[lookup]);
  9225. return;
  9226. }
  9227. /**
  9228. * lookup: {
  9229. * // 扩展到 viewModel 的值做更改
  9230. * WH_CODE: "{queryValue}",
  9231. * WH_NAME: "{query.WH_NAME}",
  9232. * }
  9233. */
  9234. if (_.isPlainObject(lookup)) {
  9235. var parentScope_2 = lookupScope(sender);
  9236. tryWriteObject(lookup, data, function (path, value) {
  9237. if (path === 'queryValue') {
  9238. me.setValue(value);
  9239. }
  9240. else {
  9241. parentScope_2.viewModel.set(path, value);
  9242. }
  9243. });
  9244. }
  9245. return true;
  9246. };
  9247. widgetScope.showDialog(sender, vjson, { data: widgetDialogData });
  9248. });
  9249. }
  9250. /**
  9251. * 停止事件的默认行为
  9252. * @param e
  9253. */
  9254. function stopEvent(e) {
  9255. e.preventDefault();
  9256. e.stopPropagation();
  9257. // @ts-ignore
  9258. window.event.cancelBubble = true;
  9259. e.returnValue = false;
  9260. e.cancelBubble = true;
  9261. }
  9262. /**
  9263. * 屏幕中央显示一个黑框提示
  9264. */
  9265. function msg$1(content) {
  9266. msg(content);
  9267. }
  9268. /**
  9269. * 错误对话框的强提醒
  9270. */
  9271. function showErrorDialog$1(msg, sender) {
  9272. showErrorDialog(msg, sender);
  9273. }
  9274. /**
  9275. * 错误对话框的强提醒
  9276. */
  9277. function showInfoDialog(msg, sender) {
  9278. showInfoDialogSimple(msg, sender);
  9279. }
  9280. /**
  9281. * 错误对话框的强提醒
  9282. */
  9283. function prompt$1(message, defaultValue, multiLine) {
  9284. if (defaultValue === void 0) { defaultValue = ""; }
  9285. if (multiLine === void 0) { multiLine = false; }
  9286. return prompt(message, defaultValue, multiLine);
  9287. }
  9288. /**
  9289. * 用于计算 express 表达式
  9290. */
  9291. function evalFunction(data, express) {
  9292. var keys = [];
  9293. var values = [];
  9294. _.forOwn(data, function (value, key) {
  9295. var match = key.match(/\-|\*|\\|\/|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)/i);
  9296. if (match) {
  9297. key = key.substring(0, match.index);
  9298. }
  9299. keys.push(key);
  9300. values.push(value);
  9301. });
  9302. var func = Function.apply(void 0, __spread(keys, ['return ' + express]));
  9303. try {
  9304. return func.apply(void 0, __spread(values));
  9305. }
  9306. catch (e) {
  9307. return;
  9308. }
  9309. }
  9310. /**
  9311. * 获取表格编辑的行数据
  9312. */
  9313. function getGridEditRows(grid) {
  9314. return grid.getGridEditRows();
  9315. }
  9316. var SystemLib = /*#__PURE__*/Object.freeze({
  9317. __proto__: null,
  9318. SIMPLE_RE: SIMPLE_RE,
  9319. pinyinMatch: pinyinMatch,
  9320. calcExpress: calcExpress,
  9321. calcObjectFlat: calcObjectFlat,
  9322. mergeViewModel: mergeViewModel,
  9323. flatRow: flatRow,
  9324. replaceNA: replaceNA,
  9325. tryWriteByExpress: tryWriteByExpress,
  9326. tryWriteObject: tryWriteObject,
  9327. tryVarSimple: tryVarSimple,
  9328. calcObject: calcObject,
  9329. getParentGrid: getParentGrid,
  9330. tryEnable: tryEnable,
  9331. setComboStore: setComboStore,
  9332. invokeServer: invokeServer,
  9333. clearViewModelValues: clearViewModelValues,
  9334. reloadGrid: reloadGrid,
  9335. toPlainObject: toPlainObject,
  9336. confirm: confirm,
  9337. normId: normId,
  9338. clearViewModelReloadGrid: clearViewModelReloadGrid,
  9339. SystemEventFu: SystemEventFu,
  9340. clearViewModel: clearViewModel,
  9341. clearViewModelByLookup: clearViewModelByLookup,
  9342. showWidget: showWidget,
  9343. stopEvent: stopEvent,
  9344. msg: msg$1,
  9345. showErrorDialog: showErrorDialog$1,
  9346. showInfoDialog: showInfoDialog,
  9347. prompt: prompt$1,
  9348. evalFunction: evalFunction,
  9349. getGridEditRows: getGridEditRows
  9350. });
  9351. function initTree () {
  9352. Ext.define('Yvan.Tree', {
  9353. extend: 'Ext.tree.Panel',
  9354. alias: 'widget.yvtree',
  9355. xtype: 'yvtree',
  9356. constructor: function (config) {
  9357. var newConfig = _.defaultsDeep({
  9358. // 强制性属性
  9359. }, baseConfig(config, 'row-item'), config, tree);
  9360. _.assign(newConfig, {
  9361. root: [],
  9362. rootVisible: false,
  9363. tbar: [
  9364. {
  9365. xtype: 'trigger',
  9366. triggerCls: 'x-form-clear-trigger',
  9367. flex: 1,
  9368. emptyText: '搜索过滤',
  9369. enableKeyEvents: true,
  9370. listeners: {
  9371. change: {
  9372. fn: function (sender, e) {
  9373. var _this = this;
  9374. _.defer(function () {
  9375. var scope = sender.up("yvtree");
  9376. scope.filterByText(_this.getRawValue());
  9377. });
  9378. },
  9379. buffer: 500
  9380. },
  9381. }
  9382. },
  9383. ],
  9384. });
  9385. if (!newConfig.hideRefresh) {
  9386. newConfig.tbar.push({
  9387. xtype: 'button', iconCls: 'x-fa fa-refresh', tooltip: '刷新',
  9388. listeners: {
  9389. click: function (sender) {
  9390. var scope = sender.up("yvtree");
  9391. scope.reload();
  9392. }
  9393. }
  9394. });
  9395. }
  9396. if (!newConfig.hideExpand) {
  9397. newConfig.tbar.push({
  9398. xtype: 'button', iconCls: 'x-fa fa-plus-square-o', tooltip: '全部展开',
  9399. listeners: {
  9400. click: function (sender) {
  9401. var scope = sender.up("yvtree");
  9402. scope.expandAll();
  9403. }
  9404. }
  9405. });
  9406. }
  9407. if (!newConfig.hideCollapse) {
  9408. newConfig.tbar.push({
  9409. xtype: 'button', iconCls: 'x-fa fa-minus-square-o', tooltip: '全部收起',
  9410. listeners: {
  9411. click: function (sender) {
  9412. var scope = sender.up("yvtree");
  9413. scope.collapseAll();
  9414. }
  9415. }
  9416. });
  9417. }
  9418. this.superclass.constructor.call(this, newConfig);
  9419. },
  9420. /**
  9421. * 在根节点上增加一个节点,会触发 addNode 事件
  9422. * @param props
  9423. */
  9424. addRoot: function (props) {
  9425. var me = this;
  9426. var tableNode = me.getRootNode();
  9427. var fieldNode = tableNode.createNode(new Ext.data.NodeInterface({}));
  9428. if (_.isFunction(props)) {
  9429. props = props.call(this, parent);
  9430. }
  9431. _.forOwn(props, function (value, key) {
  9432. fieldNode.set(key, value);
  9433. });
  9434. var node = tableNode.appendChild(fieldNode);
  9435. me.ensureVisible(node);
  9436. me.setSelection(node);
  9437. me.fireEvent('addNode', me, {
  9438. parent: tableNode,
  9439. node: node,
  9440. });
  9441. },
  9442. addLast: function (props) {
  9443. var me = this;
  9444. var sel = me.selModel.getSelection();
  9445. if (!sel || sel.length <= 0) {
  9446. msg('请选择一个要添加的同级节点路径');
  9447. return;
  9448. }
  9449. var parent = sel[0].parentNode ? sel[0].parentNode : me.getRootNode();
  9450. var fieldNode = parent.createNode(new Ext.data.NodeInterface({}));
  9451. if (_.isFunction(props)) {
  9452. props = props.call(this, parent);
  9453. }
  9454. _.forOwn(props, function (value, key) {
  9455. fieldNode.set(key, value);
  9456. });
  9457. var node = parent.appendChild(fieldNode);
  9458. me.ensureVisible(node);
  9459. me.setSelection(node);
  9460. me.fireEvent('addNode', me, {
  9461. parent: parent,
  9462. node: node,
  9463. });
  9464. },
  9465. addChildren: function (props) {
  9466. var me = this;
  9467. var sel = me.selModel.getSelection();
  9468. if (!sel || sel.length <= 0) {
  9469. msg('请选择一个要添加子节点的路径');
  9470. return;
  9471. }
  9472. var parent = sel[0];
  9473. if (_.isFunction(props)) {
  9474. props = props.call(this, parent);
  9475. }
  9476. var fieldNode = parent.createNode(new Ext.data.NodeInterface({}));
  9477. _.forOwn(props, function (value, key) {
  9478. fieldNode.set(key, value);
  9479. });
  9480. var node = parent.appendChild(fieldNode);
  9481. parent.expand();
  9482. me.ensureVisible(node);
  9483. me.setSelection(node);
  9484. me.fireEvent('addNode', me, {
  9485. parent: parent,
  9486. node: node,
  9487. });
  9488. },
  9489. initComponent: function () {
  9490. var me = this;
  9491. var config = me.config;
  9492. var scope = lookupScope(this);
  9493. if (!window["IS_DESIGN_MODE"]) {
  9494. // 转换 dataSource 属性
  9495. convertDataSource(me, scope, config);
  9496. }
  9497. this.superclass.initComponent.call(this);
  9498. this.on({
  9499. afterrender: function (sender) {
  9500. var me = this;
  9501. var config = this.config;
  9502. var dataSource = config.dataSource;
  9503. if (config.autoLoad) {
  9504. if (config.dataSourceCallbackFn) {
  9505. me.reload();
  9506. }
  9507. else if (_.isPlainObject(dataSource) && dataSource.method === 'invoke') {
  9508. me.reload();
  9509. }
  9510. }
  9511. }
  9512. });
  9513. },
  9514. _setDataReal: function (value) {
  9515. var me = this;
  9516. // me.setStore(new Ext.data.TreeStore({
  9517. // root: {
  9518. // expanded: true,
  9519. // // children: value
  9520. // children: [
  9521. // {
  9522. // id: '1', text: 'A',
  9523. // children: [
  9524. // {id: '1', text: 'A',},
  9525. // {id: '2', text: 'B'},
  9526. // ]
  9527. // },
  9528. // {id: '2', text: 'B'},
  9529. // ]
  9530. // }
  9531. // }))
  9532. me.store.setRoot({
  9533. expanded: true,
  9534. children: value
  9535. });
  9536. // me.store = new Ext.data.TreeStore({
  9537. // root: {
  9538. // expanded: true,
  9539. // // children: value
  9540. // children: [
  9541. // {
  9542. // id: '1', text: 'A',
  9543. // children: [
  9544. // {id: '1', text: 'A',},
  9545. // {id: '2', text: 'B'},
  9546. // ]
  9547. // },
  9548. // {id: '2', text: 'B'},
  9549. // ]
  9550. // }
  9551. // })
  9552. },
  9553. /**
  9554. * 重新载入数据(重新计算参数)
  9555. */
  9556. reload: function (reloadParams) {
  9557. if (reloadParams === void 0) { reloadParams = {}; }
  9558. var me = this;
  9559. var config = me.config;
  9560. if (config.dataSourceCallbackFn) {
  9561. // 函数请求刷新
  9562. var scope = lookupScope(this);
  9563. // me.setLoading(true)
  9564. config.dataSourceCallbackFn.call(scope, me, {
  9565. successCallback: function (value) {
  9566. me._setDataReal(value);
  9567. // me.setLoading(false)
  9568. me.fireEvent('dataLoadComplete', me, true, value);
  9569. },
  9570. failCallback: function (error) {
  9571. // me.setLoading(false)
  9572. me.fireEvent('dataLoadComplete', me, false, error);
  9573. }
  9574. });
  9575. return;
  9576. }
  9577. var dataSource = config.dataSource;
  9578. if (_.isPlainObject(dataSource) && dataSource.method === 'invoke' && !window["IS_DESIGN_MODE"]) {
  9579. var scope = lookupScope(me);
  9580. var params = calcObjectFlat(scope.viewModel.data, _.defaultsDeep({}, reloadParams, dataSource.params));
  9581. me.setLoading(true);
  9582. invokeServer(dataSource.url, params)
  9583. .then(function (res) {
  9584. me._setDataReal(res.data);
  9585. me.fireEvent('dataLoadComplete', me, res);
  9586. })
  9587. .finally(function () {
  9588. me.setLoading(false);
  9589. });
  9590. }
  9591. },
  9592. filterByText: function (text) {
  9593. this.filterBy(text, 'text');
  9594. },
  9595. filterBy: function (text, by) {
  9596. this.clearFilter();
  9597. var view = this.getView(), me = this, nodesAndParents = [];
  9598. this.getRootNode().cascadeBy(function (tree, view) {
  9599. var currNode = this;
  9600. if (currNode && currNode.data[by] && currNode.data[by].toString().toLowerCase().indexOf(text.toLowerCase()) > -1) {
  9601. me.expandPath(currNode.getPath());
  9602. while (currNode.parentNode) {
  9603. nodesAndParents.push(currNode.id);
  9604. currNode = currNode.parentNode;
  9605. }
  9606. }
  9607. }, null, [me, view]);
  9608. this.getRootNode().cascadeBy(function (tree, view) {
  9609. var uiNode = view.getNodeByRecord(this);
  9610. if (uiNode && !Ext.Array.contains(nodesAndParents, this.id)) {
  9611. Ext.get(uiNode).setDisplayed('none');
  9612. }
  9613. }, null, [me, view]);
  9614. },
  9615. clearFilter: function () {
  9616. var view = this.getView();
  9617. this.getRootNode().cascadeBy(function (tree, view) {
  9618. var uiNode = view.getNodeByRecord(this);
  9619. if (uiNode) {
  9620. Ext.get(uiNode).setDisplayed('table-row');
  9621. }
  9622. }, null, [this, view]);
  9623. },
  9624. });
  9625. }
  9626. function convertDataSource(sender, scope, newConfig) {
  9627. if (typeof newConfig.store !== 'undefined') {
  9628. // 有 store 属性的情况下,不做任何事
  9629. return;
  9630. }
  9631. if (typeof newConfig.dataSource === 'undefined') {
  9632. // 没有定义 dataSource 的情况下,不做任何事
  9633. return;
  9634. }
  9635. var dataSource = newConfig.dataSource;
  9636. if (typeof dataSource === 'string') {
  9637. // dataSource 是字符串的情况下,找到成员函数
  9638. dataSource = lookupFn(scope, dataSource);
  9639. }
  9640. if (typeof dataSource === 'function') {
  9641. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  9642. newConfig.store = new Ext.data.TreeStore({
  9643. root: {
  9644. expanded: true,
  9645. children: []
  9646. }
  9647. });
  9648. newConfig.dataSourceCallbackFn = dataSource;
  9649. return;
  9650. }
  9651. // throw new TypeError('无法识别的调用方法')
  9652. }
  9653. /**
  9654. * 构建一个 grid 支持的 dataSource
  9655. */
  9656. function gridInvokeBuild(scope, grid, config, dataSource, reloadParams, isExcelExport, excelExportCallBack) {
  9657. if (reloadParams === void 0) { reloadParams = {}; }
  9658. if (isExcelExport === void 0) { isExcelExport = false; }
  9659. if (excelExportCallBack === void 0) { excelExportCallBack = null; }
  9660. var me = grid;
  9661. var params = calcObjectFlat(scope.viewModel.data, dataSource.params);
  9662. var storeOption = {};
  9663. if (dataSource.method === 'invoke') {
  9664. var fields_1 = [];
  9665. _.forEach(grid.columns, function (col) {
  9666. var c = {};
  9667. if (col.dataIndex) {
  9668. c.name = col.dataIndex;
  9669. fields_1.push(c);
  9670. }
  9671. if (col.dataType) {
  9672. c.type = col.dataType;
  9673. }
  9674. });
  9675. // 默认支持 gridInvoke
  9676. //@ts-ignore
  9677. storeOption = {
  9678. fields: fields_1,
  9679. remoteSort: config.remoteSort,
  9680. remoteFilter: config.remoteFilter,
  9681. autoLoad: true,
  9682. pageSize: me.store.pageSize || config.pageSize,
  9683. proxy: {
  9684. type: 'jsonAjax',
  9685. $owner: me,
  9686. url: serverInvokeUrlTransform(dataSource.url, { scope: scope, grid: grid, isExcelExport: isExcelExport, excelExportCallBack: excelExportCallBack }),
  9687. extraParams: _.defaultsDeep({}, reloadParams, params),
  9688. reader: {
  9689. type: 'json',
  9690. rootProperty: 'data',
  9691. totalProperty: 'pagination.total',
  9692. successProperty: 'success',
  9693. messageProperty: 'msg',
  9694. transform: function (data) {
  9695. if (typeof window['ajaxProcess'] === 'function') {
  9696. window['ajaxProcess'](data);
  9697. }
  9698. if (typeof grid._transform === 'function') {
  9699. // 系统转换函数
  9700. grid._transform(data.data);
  9701. }
  9702. if (grid.dataTransform) {
  9703. if (typeof grid.dataTransform === 'string') {
  9704. grid.dataTransform = lookupFn(lookupScope(grid), grid.dataTransform);
  9705. }
  9706. return grid.dataTransform.call(scope, grid, data);
  9707. }
  9708. return data;
  9709. }
  9710. }
  9711. },
  9712. listeners: {
  9713. load: function (store, records, successful, operation) {
  9714. var _a, _b, _c;
  9715. var rep = (_a = operation.getResponse()) === null || _a === void 0 ? void 0 : _a.responseJson;
  9716. if (rep.pagination) {
  9717. grid.dbInfo = rep.pagination.dbInfo;
  9718. grid.exportDataSql = rep.pagination.exportDataSql;
  9719. grid.exportDataSqlParams = rep.pagination.exportDataSqlParams;
  9720. }
  9721. me.exportExcelTotal = ((_b = rep === null || rep === void 0 ? void 0 : rep.pagination) === null || _b === void 0 ? void 0 : _b.total) || ((_c = rep === null || rep === void 0 ? void 0 : rep.data) === null || _c === void 0 ? void 0 : _c.length) || 0;
  9722. if (isExcelExport) {
  9723. if (typeof excelExportCallBack === 'function') {
  9724. excelExportCallBack(rep);
  9725. }
  9726. else if (excelExportCallBack) {
  9727. console.error("导出回调方法错误!");
  9728. }
  9729. me.fireEvent('excelDataLoadComplete', me, successful, records);
  9730. }
  9731. else {
  9732. me.fireEvent('dataLoadComplete', me, successful, records);
  9733. }
  9734. }
  9735. }
  9736. };
  9737. }
  9738. else if (exports.apiConvert) {
  9739. // 外部扩展的 apiConvert
  9740. //@ts-ignore
  9741. storeOption = exports.apiConvert.gridInvokeBuild(scope, grid, config, dataSource, params, reloadParams);
  9742. }
  9743. else {
  9744. throw new TypeError("不支持的 API 请求方式");
  9745. }
  9746. if (isExcelExport) {
  9747. var excelStore = new Ext.data.Store(storeOption);
  9748. excelStore.load();
  9749. }
  9750. else {
  9751. if (me.groupField) {
  9752. console.log('groupField', storeOption.groupField);
  9753. storeOption.groupField = me.groupField;
  9754. }
  9755. me.setStore(new Ext.data.Store(storeOption));
  9756. }
  9757. }
  9758. function initStores () {
  9759. Ext.define('Yvan.JsonAjaxProxy', {
  9760. extend: 'Ext.data.proxy.Ajax',
  9761. alias: 'proxy.jsonAjax',
  9762. actionMethods: {
  9763. create: "POST",
  9764. read: "POST",
  9765. update: "POST",
  9766. destroy: "POST"
  9767. },
  9768. timeout: storeAjax.timeout,
  9769. buildRequest: function (operation) {
  9770. // 参考源码 ext-all-debug.js:71468 method:buildRequest
  9771. var me = this;
  9772. var $owner = me.$owner; // 在 grid.initComponent 中赋值 $owner
  9773. var scope = lookupScope($owner);
  9774. var gridParam = me.getParams(operation);
  9775. var customParam = {};
  9776. // 提取 srot 元素
  9777. if (gridParam.sort) {
  9778. var sort = JSON.parse(gridParam.sort);
  9779. // 字符串 [{"property":"BRANCHID","direction":"ASC"}]
  9780. // 转换为对象 [{colId: "BRANCHID", sort: "asc"}]
  9781. customParam.sortModel = [];
  9782. _.forEach(sort, function (s) {
  9783. customParam.sortModel.push({
  9784. colId: s.property,
  9785. sort: _.toLower(s.direction)
  9786. });
  9787. });
  9788. delete gridParam.sort;
  9789. }
  9790. // 提取筛选元素
  9791. if (gridParam.filter) {
  9792. var filter = JSON.parse(gridParam.filter);
  9793. // "[{"operator":"like","value":"1","property":"id"}]"
  9794. // 转换为 filterModel: {BRANCHID: {filterType: "text", type: "contains", filter: "12"}}
  9795. customParam.filterModel = {};
  9796. _.forEach(filter, function (s) {
  9797. var newFilterItem = {};
  9798. if (s.operator === 'like') {
  9799. newFilterItem.filterType = 'text';
  9800. newFilterItem.type = 'contains';
  9801. newFilterItem.filter = s.value;
  9802. }
  9803. else {
  9804. // 无法识别的筛选类型
  9805. debugger;
  9806. }
  9807. customParam.filterModel[s.property] = newFilterItem;
  9808. });
  9809. delete gridParam.filter;
  9810. }
  9811. // 被 grid.constructor 作为方法存在
  9812. var extraParams = _.cloneDeep(me.getExtraParams());
  9813. var params = _.defaultsDeep(gridParam, extraParams);
  9814. // var request = this.superclass.buildRequest.apply(this, arguments);
  9815. var request = new Ext.data.Request({
  9816. params: {},
  9817. action: operation.getAction(),
  9818. records: operation.getRecords(),
  9819. url: me.buildUrl(),
  9820. jsonData: __assign({ args: [
  9821. params
  9822. ] }, customParam),
  9823. proxy: me
  9824. });
  9825. operation.setRequest(request);
  9826. return request;
  9827. },
  9828. afterRequest: function (req, res) {
  9829. // Extend.afterExtRequest(req, res)
  9830. }
  9831. });
  9832. Ext.define('Ext.ux.data.MyReader', {
  9833. extend: 'Ext.data.reader.Json',
  9834. xtype: 'yvgridreader',
  9835. useSimpleAccessors: false,
  9836. });
  9837. }
  9838. window["EXPORT_DATA_HOST"] = "http://127.0.0.1:30000/exportData";
  9839. var hexToString = function (hex) {
  9840. var arr = hex.split("");
  9841. var out = "";
  9842. for (var i = 0; i < arr.length / 2; i++) {
  9843. var tmp = "0x" + arr[i * 2] + arr[i * 2 + 1];
  9844. // @ts-ignore
  9845. var charValue = String.fromCharCode(tmp);
  9846. out += charValue;
  9847. }
  9848. return out;
  9849. };
  9850. var defaultGrid = grid;
  9851. function initGrid () {
  9852. Ext.define('Yvan.Grid', {
  9853. extend: 'Ext.grid.Panel',
  9854. xtype: 'yvgrid',
  9855. constructor: function (config) {
  9856. var _this = this;
  9857. var _a, _b, _c, _d, _e, _f;
  9858. var me = this;
  9859. var dataSource = config.dataSource;
  9860. if (!window["IS_DESIGN_MODE"]) {
  9861. this.columnConfigCacheKey = this.makeColumnConfigCacheKey(config);
  9862. if (Array.isArray(config.columns) && config.columns.length > 0) {
  9863. var cacheData = this.getColumnConfigCache();
  9864. if (Array.isArray(cacheData) && cacheData.length > 0) {
  9865. var newColumns = [];
  9866. for (var j = 0; j < cacheData.length; j++) {
  9867. var itData = cacheData[j];
  9868. for (var i = 0; i < config.columns.length; i++) {
  9869. var column = config.columns[i];
  9870. if (itData.dataIndex === column.dataIndex) {
  9871. if (itData.width) {
  9872. column.width = itData.width;
  9873. }
  9874. column.hidden = itData.hidden;
  9875. column.locked = itData.locked;
  9876. newColumns.push(column);
  9877. break;
  9878. }
  9879. }
  9880. }
  9881. config.columns = newColumns;
  9882. }
  9883. }
  9884. }
  9885. var newConfig = _.defaultsDeep({
  9886. // 强制性属性 bug.
  9887. // lock 属性会造成 Cannot read properties of undefined (reading 'els')
  9888. // enableLocking: false,
  9889. // syncRowHeight: false,
  9890. }, baseConfig(config, 'row-item'), config, grid);
  9891. // 在面板上的组件
  9892. var scope = ((_a = newConfig.$initParent) === null || _a === void 0 ? void 0 : _a.yvanScope) || ((_c = (_b = newConfig.$initParent) === null || _b === void 0 ? void 0 : _b.lookupReferenceHolder()) === null || _c === void 0 ? void 0 : _c.yvanScope) || ((_d = config.$vmParent) === null || _d === void 0 ? void 0 : _d.yvanScope) || ((_f = (_e = newConfig.$vmParent) === null || _e === void 0 ? void 0 : _e._parent) === null || _f === void 0 ? void 0 : _f.yvanScope);
  9893. var buttons = [];
  9894. var getRowClass = newConfig.getRowClass;
  9895. if (typeof getRowClass === 'string' && (_.startsWith(getRowClass, "scope.") ||
  9896. _.startsWith(getRowClass, "system."))) {
  9897. var fn = lookupFn(scope, getRowClass);
  9898. _.set(newConfig, 'viewConfig.getRowClass', fn);
  9899. }
  9900. if (!newConfig.hideExport) {
  9901. buttons.push({
  9902. xtype: 'button',
  9903. tooltip: '导出Excel',
  9904. iconCls: 'x-fa fa-download',
  9905. listeners: {
  9906. click: this.exportExcel
  9907. },
  9908. });
  9909. }
  9910. if (!newConfig.hideAutoSize) {
  9911. buttons.push({
  9912. xtype: 'button',
  9913. iconCls: 'x-fa fa-text-width',
  9914. tooltip: '自适应宽度',
  9915. listeners: {
  9916. click: this.autoSizeColumns
  9917. }
  9918. });
  9919. }
  9920. if (!newConfig.hideClearFilter) {
  9921. buttons.push({
  9922. xtype: 'button',
  9923. tooltip: '清空筛选',
  9924. iconCls: 'x-fa fa-filter',
  9925. handler: this.clearFilter
  9926. });
  9927. }
  9928. if (!newConfig.hideSaveGridUIConfig) {
  9929. buttons.push({
  9930. xtype: 'button',
  9931. tooltip: '保存布局',
  9932. iconCls: 'x-fa fa-cogs',
  9933. handler: this.saveGridUIConfig
  9934. });
  9935. }
  9936. if (!newConfig.hideClearGridUIConfig) {
  9937. buttons.push({
  9938. xtype: 'button',
  9939. tooltip: '还原布局',
  9940. iconCls: 'x-fa fa-reply-all',
  9941. handler: this.clearGridUIConfig
  9942. });
  9943. }
  9944. if (!newConfig.hideFootbar) {
  9945. if (newConfig.pagination) {
  9946. newConfig.bbar = new Ext.PagingToolbar({
  9947. // pageSize: newConfig.pageSize, 这个值是无效的
  9948. displayInfo: true,
  9949. store: this.store,
  9950. emptyMsg: '没有记录',
  9951. items: __spread([
  9952. {
  9953. xtype: 'combobox',
  9954. tooltip: '分页',
  9955. queryMode: 'local',
  9956. editable: false,
  9957. allowBlank: true,
  9958. labelAlign: 'right',
  9959. width: 90,
  9960. // labelWidth: 30,
  9961. listConfig: {
  9962. minWidth: null
  9963. },
  9964. value: 50,
  9965. valueField: undefined,
  9966. displayField: undefined,
  9967. hideClear: true,
  9968. store: newConfig.pageSizeOption,
  9969. listeners: {
  9970. change: function (sender, nv, ov) {
  9971. _this.store.pageSize = nv;
  9972. _this.store.loadPage(1);
  9973. }
  9974. }
  9975. }
  9976. ], buttons)
  9977. });
  9978. }
  9979. else {
  9980. newConfig.bbar = {
  9981. xtype: 'toolbar', overflowHandler: 'menu',
  9982. items: __spread([
  9983. {
  9984. xtype: 'button',
  9985. tooltip: '刷新',
  9986. iconCls: 'x-fa fa-refresh',
  9987. handler: function () {
  9988. _this.reload();
  9989. }
  9990. },
  9991. '-'
  9992. ], buttons)
  9993. };
  9994. if (newConfig.hideRefresh) {
  9995. newConfig.bbar.items.splice(0, 1);
  9996. }
  9997. }
  9998. }
  9999. _.each(newConfig.columns, function (c) {
  10000. var renderer = c.renderer, formatter = c.formatter;
  10001. if (typeof renderer === 'string' && (_.startsWith(renderer, "scope.") ||
  10002. _.startsWith(renderer, "system."))) {
  10003. if (newConfig.$initParent) {
  10004. if (scope) {
  10005. var rendererFn = lookupFn(scope, renderer);
  10006. c.renderer = rendererFn.bind(scope);
  10007. }
  10008. }
  10009. }
  10010. if (formatter === 'button') {
  10011. c.tdCls = 'td-btn';
  10012. if (!c.listeners) {
  10013. c.listeners = {};
  10014. }
  10015. c.listeners.click = function (sender, td, rowIdx, colIdx, event, record) {
  10016. if ($(event.target).is('input')) {
  10017. me.fireEvent('buttonclick', me, this, record);
  10018. }
  10019. };
  10020. }
  10021. else if (formatter === 'percentRenderer') {
  10022. c.tdCls = 'td-percent';
  10023. }
  10024. });
  10025. this.superclass.constructor.call(this, newConfig);
  10026. this.store.pageSize = newConfig.pageSize;
  10027. },
  10028. setData: function (value) {
  10029. var me = this;
  10030. me._setDataReal(value);
  10031. },
  10032. /**
  10033. * 添加行,并进入编辑状态
  10034. * @param record 新行的属性集
  10035. * @param editRowCol 要编辑的列序号,或 dataIndex 的名称
  10036. */
  10037. appendEditRow: function (record, editRowCol) {
  10038. var records = this.getStore().add(record);
  10039. var recNew = records[0];
  10040. this.setSelection(records);
  10041. if (typeof editRowCol === 'string' && editRowCol) {
  10042. editRowCol = this.columns.findIndex(function (c) { return c.dataIndex === editRowCol; });
  10043. }
  10044. if (typeof editRowCol === 'number') {
  10045. var ce = this.findPlugin('cellediting');
  10046. this.editingPlugin = ce;
  10047. ce.startEdit(recNew, editRowCol);
  10048. }
  10049. },
  10050. beginEdit: function (record, editRowCol) {
  10051. if (typeof record === 'number') {
  10052. record = this.store.data.getAt(record);
  10053. }
  10054. if (record.isEntity === true) {
  10055. this.setSelection([record]);
  10056. if (typeof editRowCol === 'string' && editRowCol) {
  10057. editRowCol = this.columns.findIndex(function (c) { return c.dataIndex === editRowCol; });
  10058. }
  10059. if (typeof editRowCol === 'number') {
  10060. var ce = this.findPlugin('cellediting');
  10061. this.editingPlugin = ce;
  10062. ce.startEdit(record, editRowCol);
  10063. }
  10064. }
  10065. },
  10066. /**
  10067. * 移除行
  10068. * @param record 如果记录传空,就是当前选中的行
  10069. */
  10070. removeEditRow: function (record) {
  10071. if (!record) {
  10072. record = this.selection;
  10073. }
  10074. if (!record) {
  10075. msg('请选中要删除的行');
  10076. return;
  10077. }
  10078. this.getStore().remove(record);
  10079. },
  10080. /**
  10081. * 获取全部原始数据
  10082. */
  10083. getDataRows: function () {
  10084. return this.getStore().data.items.map(function (r) { return r.data; });
  10085. },
  10086. /**
  10087. * 获取全部原始数据, 不带 id/ 不带 origin
  10088. */
  10089. getDataRowsOnlyData: function () {
  10090. return _.map(_.cloneDeep(this.getDataRows()), function (r) {
  10091. delete r.id;
  10092. delete r._origin;
  10093. return r;
  10094. });
  10095. },
  10096. rowMoveUp: function () {
  10097. var grid = this;
  10098. if (!grid.selection) {
  10099. msg('无法对多行进行移动');
  10100. return;
  10101. }
  10102. var record = grid.selection;
  10103. // const records = grid.selModel.getSelection()
  10104. // if (records.length !== 1) {
  10105. // msg('无法对多行进行移动')
  10106. // return
  10107. // }
  10108. //
  10109. // const [record] = records
  10110. var index = grid.store.indexOf(record);
  10111. if (index > 0) {
  10112. grid.store.removeAt(index);
  10113. grid.store.insert(index - 1, record);
  10114. grid.getView().refresh();
  10115. grid.selModel.select([record]);
  10116. }
  10117. },
  10118. rowMoveDown: function () {
  10119. var grid = this;
  10120. // const records = grid.selModel.getSelection()
  10121. // if (records.length !== 1) {
  10122. // msg('无法对多行进行移动')
  10123. // return
  10124. // }
  10125. if (!grid.selection) {
  10126. msg('无法对多行进行移动');
  10127. return;
  10128. }
  10129. var record = grid.selection;
  10130. var index = grid.store.indexOf(record);
  10131. if (index < grid.store.getCount() - 1) {
  10132. grid.store.removeAt(index);
  10133. grid.store.insert(index + 1, record);
  10134. grid.getView().refresh();
  10135. grid.selModel.select([record]);
  10136. }
  10137. },
  10138. getEditRecord: function () {
  10139. var _a, _b;
  10140. var me = this;
  10141. var editingPlugin = me.editingPlugin || me.ownerGrid.editingPlugin;
  10142. var rowIdx = (_b = (_a = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.rowIdx;
  10143. var record;
  10144. if (typeof rowIdx === 'undefined') {
  10145. record = me.getSelectionModel().getLastSelected();
  10146. }
  10147. else {
  10148. record = me.store.getAt(rowIdx);
  10149. }
  10150. return record;
  10151. },
  10152. getEditRow: function () {
  10153. var _a;
  10154. var me = this;
  10155. return (_a = me.getEditRecord()) === null || _a === void 0 ? void 0 : _a.data;
  10156. },
  10157. setEditRow: function (rowValues) {
  10158. var me = this;
  10159. var record = me.getEditRecord();
  10160. if (record) {
  10161. _.forOwn(rowValues, function (v, k) {
  10162. record.set(k, v);
  10163. });
  10164. }
  10165. },
  10166. _transform: function (data) {
  10167. // 无论是 grid._setDataReal 还是 stores.gridInvokeBuild 都会走这个函数,设值前都可以改变表格值
  10168. _.forEach(data, function (row) {
  10169. row._origin = _.clone(row);
  10170. });
  10171. },
  10172. _setDataReal: function (value) {
  10173. var me = this;
  10174. this._transform(value);
  10175. var storeOpt = {
  10176. fields: getFileds(this),
  10177. data: value,
  10178. };
  10179. if (this.groupField) {
  10180. storeOpt.groupField = this.groupField;
  10181. }
  10182. var store = new Ext.data.Store(storeOpt);
  10183. me.setStore(store);
  10184. },
  10185. setStore: function (store) {
  10186. var me = this;
  10187. if (_.isArray(store)) {
  10188. var value = store;
  10189. this._transform(value);
  10190. var storeOpt = {
  10191. fields: getFileds(this),
  10192. data: value,
  10193. };
  10194. if (this.groupField) {
  10195. storeOpt.groupField = this.groupField;
  10196. }
  10197. store = new Ext.data.Store(storeOpt);
  10198. }
  10199. me.superclass.setStore.call(this, store);
  10200. var reference = this.reference;
  10201. if (reference) {
  10202. lookupScope(this).viewModel.set(reference + '.ischanged', false);
  10203. }
  10204. if (store) {
  10205. store.on({
  10206. add: function (store, records, index, eOpts) {
  10207. me._raiseChange(store, 'add');
  10208. },
  10209. remove: function (store, records, index, isMove, eOpts) {
  10210. me._raiseChange(store, 'remove');
  10211. },
  10212. datachanged: function (sender, opt) {
  10213. me._raiseChange(store, 'datachanged');
  10214. }
  10215. });
  10216. }
  10217. },
  10218. _raiseChange: function (store, type) {
  10219. var _a, _b;
  10220. var reference = this.reference;
  10221. if (reference && store) {
  10222. var ischanged = false;
  10223. if (store.getModifiedRecords().length > 0 ||
  10224. store.getNewRecords().length > 0 ||
  10225. store.getRemovedRecords().length > 0) {
  10226. ischanged = true;
  10227. }
  10228. else {
  10229. ischanged = false;
  10230. }
  10231. (_b = (_a = lookupScope(this)) === null || _a === void 0 ? void 0 : _a.viewModel) === null || _b === void 0 ? void 0 : _b.set(reference + '.ischanged', ischanged);
  10232. }
  10233. },
  10234. /**
  10235. * 轻量级刷新
  10236. */
  10237. refreshData: function () {
  10238. var store = this.getStore();
  10239. if (store) {
  10240. store.reload();
  10241. }
  10242. },
  10243. /**
  10244. * 为表格强制设置焦点
  10245. * @param seq 顺序号
  10246. */
  10247. focusRow: function (seq) {
  10248. this.setSelection(this.store.getAt(seq));
  10249. this.getView().focusRow(seq);
  10250. },
  10251. /**
  10252. * 重新载入数据(重新计算参数)
  10253. */
  10254. reload: function (reloadParams) {
  10255. if (reloadParams === void 0) { reloadParams = {}; }
  10256. var me = this;
  10257. var config = me.config;
  10258. if (config.dataSourceCallbackFn) {
  10259. // 函数请求刷新
  10260. var scope = lookupScope(this);
  10261. _.defer(function () {
  10262. me.setLoading(true);
  10263. });
  10264. config.dataSourceCallbackFn.call(scope, me, {
  10265. successCallback: function (value) {
  10266. me._setDataReal(value);
  10267. _.defer(function () {
  10268. me.setLoading(false);
  10269. });
  10270. me.fireEvent('dataLoadComplete', me, true, value);
  10271. },
  10272. failCallback: function (error) {
  10273. _.defer(function () {
  10274. me.setLoading(false);
  10275. });
  10276. me.fireEvent('dataLoadComplete', me, false, error);
  10277. }
  10278. });
  10279. return;
  10280. }
  10281. // if (this.store) {
  10282. // this.store.reload({aaaa: 1, bbbb: 2})
  10283. // }
  10284. var dataSource = config.dataSource;
  10285. if (_.isPlainObject(dataSource) && !window["IS_DESIGN_MODE"]) {
  10286. var scope = lookupScope(me);
  10287. gridInvokeBuild(scope, me, config, dataSource, reloadParams);
  10288. }
  10289. },
  10290. exportCurrentExcelClick: function () {
  10291. var _a;
  10292. var me = this;
  10293. var config = me.config;
  10294. var scope = lookupScope(me);
  10295. var excelFileName = config.excelFileName || scope.vjson.title || _.uniqueId("excel-");
  10296. if (excelFileName.endsWith(".xlsx")) {
  10297. excelFileName = excelFileName.split(".xlsx")[0];
  10298. }
  10299. excelFileName += ".xlsx";
  10300. var rowsAll = (_a = this.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  10301. var excelData = me.makeExcelData(rowsAll);
  10302. LAY_EXCEL.exportExcel(excelData, excelFileName, 'xlsx');
  10303. },
  10304. exportExcelClick: function (excelExportParams) {
  10305. var me = this;
  10306. var config = me.config;
  10307. excelExportParams.isExcelExport = true;
  10308. var scope = lookupScope(me);
  10309. var dataSource = config.dataSource;
  10310. scope.setLoading(true);
  10311. var excelFileName = config.excelFileName || scope.vjson.title || _.uniqueId("excel-");
  10312. gridInvokeBuild(scope, me, config, dataSource, excelExportParams, true, function (responseData) {
  10313. var _a, _b, _c, _d;
  10314. var page = parseInt((_a = responseData.pagination) === null || _a === void 0 ? void 0 : _a.current) || 1;
  10315. var size = parseInt((_b = responseData.pagination) === null || _b === void 0 ? void 0 : _b.size) || me.exportExcelPageSize;
  10316. var total = parseInt((_c = responseData.pagination) === null || _c === void 0 ? void 0 : _c.total) || ((_d = responseData.data) === null || _d === void 0 ? void 0 : _d.length) || 0;
  10317. me.exportExcelCurrentPage = page;
  10318. me.exportExcelPageSize = size;
  10319. me.exportExcelTotal = total;
  10320. if (excelFileName.endsWith(".xlsx")) {
  10321. excelFileName = excelFileName.split(".xlsx")[0];
  10322. }
  10323. excelFileName += "(第" + me.exportExcelCurrentPage + "页,共" + Math.ceil(total / size) + "页、" + total + "条)";
  10324. excelFileName += ".xlsx";
  10325. var excelData = me.makeExcelData(responseData.data);
  10326. LAY_EXCEL.exportExcel(excelData, excelFileName, 'xlsx');
  10327. if (page < total / size) {
  10328. page++;
  10329. me.exportExcelCurrentPage = page;
  10330. }
  10331. scope.setLoading(false);
  10332. });
  10333. },
  10334. exportBigExcelClick: function () {
  10335. var _a;
  10336. var me = this;
  10337. if (!((_a = me.dbInfo) === null || _a === void 0 ? void 0 : _a.jdbcurl) || !me.exportDataSql) {
  10338. showErrorDialog('当前表格不支持大批量导出');
  10339. return;
  10340. }
  10341. var config = me.config;
  10342. var scope = lookupScope(me);
  10343. var excelFileName = config.excelFileName || scope.vjson.title || _.uniqueId("excel-");
  10344. var head = [];
  10345. var dict = {};
  10346. _.forEach(me.columns, function (column) {
  10347. if (column.isHidden())
  10348. return;
  10349. if (!column.dataIndex)
  10350. return;
  10351. if (!column.text)
  10352. return;
  10353. head.push({ field: column.dataIndex, name: column.text });
  10354. if (column.dictForExcel) {
  10355. dict[column.dataIndex] = column.dictForExcel;
  10356. }
  10357. });
  10358. // 判断是否需要解密
  10359. if (me.dbInfo.jdbcurl.indexOf("jdbc") < 0) {
  10360. me.dbInfo.jdbcurl = hexToString(me.dbInfo.jdbcurl);
  10361. me.dbInfo.password = hexToString(me.dbInfo.password);
  10362. me.dbInfo.username = hexToString(me.dbInfo.username);
  10363. }
  10364. scope.setLoading(true);
  10365. Ext.Ajax.request({
  10366. timeout: 15000,
  10367. url: window["EXPORT_DATA_HOST"],
  10368. method: "POST",
  10369. jsonData: {
  10370. file: excelFileName,
  10371. dbInfo: me.dbInfo,
  10372. exportDataSql: me.exportDataSql,
  10373. exportDataSqlParams: me.exportDataSqlParams,
  10374. head: head,
  10375. dict: dict,
  10376. },
  10377. }).then(function () {
  10378. scope.setLoading(false);
  10379. msg('请求成功');
  10380. }).catch(function () {
  10381. scope.setLoading(false);
  10382. showErrorDialog('请求失败,请确认是否已安装客户端');
  10383. });
  10384. },
  10385. makeExcelData: function (jsonData) {
  10386. var me = this;
  10387. me.fireEvent('onExcelDataLoadCompleted', me, jsonData);
  10388. if (!Array.isArray(jsonData) || jsonData.length === 0) {
  10389. return;
  10390. }
  10391. var data = [];
  10392. // 获取表格的列定义
  10393. var headerTextArr = [];
  10394. var headers = [];
  10395. for (var i = 0; i < me.headerCt.getGridColumns().length; i++) {
  10396. var header = me.headerCt.getGridColumns()[i];
  10397. if (!header.isHidden()) {
  10398. var textStr = _.trim(header.text);
  10399. var dataIndexStr = _.trim(header.dataIndex);
  10400. if (dataIndexStr) {
  10401. if (textStr === '') {
  10402. headerTextArr.push(dataIndexStr);
  10403. }
  10404. else {
  10405. headerTextArr.push(textStr);
  10406. }
  10407. headers.push(header);
  10408. }
  10409. }
  10410. }
  10411. if (headers.length === 0) {
  10412. return;
  10413. }
  10414. data.push(headerTextArr);
  10415. for (var i = 0; i < jsonData.length; i++) {
  10416. var dataRow = jsonData[i];
  10417. var row = [];
  10418. for (var j = 0; j < headers.length; j++) {
  10419. var key = headers[j].dataIndex;
  10420. var value = dataRow[key];
  10421. if (!value && value !== 0) {
  10422. value = '';
  10423. }
  10424. var oValue = value;
  10425. // todo 导出处理字典日期等数据,如果有特殊的单元格渲染也可能出现导出的数据有特殊标记需要特殊处理一下
  10426. if (typeof headers[j].renderer === 'function' && (!headers[j].config.formatter)) {
  10427. try {
  10428. value = headers[j].renderer(value);
  10429. if (!value && value !== 0) {
  10430. value = oValue;
  10431. }
  10432. }
  10433. catch (e) {
  10434. value = oValue;
  10435. }
  10436. }
  10437. row.push(value);
  10438. }
  10439. data.push(row);
  10440. }
  10441. return data;
  10442. },
  10443. initComponent: function () {
  10444. var _this = this;
  10445. var _a;
  10446. var me = this;
  10447. var config = me.config;
  10448. if (window["IS_DESIGN_MODE"]) {
  10449. this.superclass.initComponent.call(this);
  10450. return;
  10451. }
  10452. var scope = lookupScope(this);
  10453. if (!window["IS_DESIGN_MODE"]) {
  10454. // 转换 dataSource 属性
  10455. convertDataSource$1(me, scope, config);
  10456. }
  10457. this.on({
  10458. afterrender: function (sender) {
  10459. var me = this;
  10460. var config = this.config;
  10461. var dataSource = config.dataSource;
  10462. if (config.autoLoad) {
  10463. if (config.dataSourceCallbackFn) {
  10464. me.reload();
  10465. }
  10466. else if (_.isPlainObject(dataSource)) {
  10467. me.reload();
  10468. }
  10469. }
  10470. if (config.contextMenu === true && _.isArray(config.tbar)) {
  10471. var vm = this.lookupViewModel();
  10472. this.contextMenu = this.add(new Ext.menu.Menu({
  10473. viewModel: vm,
  10474. items: _.map(config.tbar, function (item) {
  10475. var menuItem = __assign({}, item);
  10476. if (menuItem.xtype === 'button') {
  10477. delete menuItem.xtype;
  10478. }
  10479. return menuItem;
  10480. })
  10481. }));
  10482. }
  10483. else if (_.isPlainObject(config.contextMenu)) {
  10484. this.contextMenu = this.add(config.contextMenu);
  10485. }
  10486. var $dom = $(sender.el.dom);
  10487. $dom.on('keydown', function (e) {
  10488. me.fireEvent('keydown', me, e);
  10489. }).on('keyup', function (e) {
  10490. me.fireEvent('keyup', me, e);
  10491. });
  10492. // 默认显示提示
  10493. if (this.cellTip) {
  10494. this.tip = Ext.create('Ext.tip.ToolTip', {
  10495. target: this.el,
  10496. delegate: '.x-grid-cell-inner',
  10497. trackMouse: true,
  10498. ancor: 'top',
  10499. style: 'background-color: #FFFFCC;',
  10500. listeners: {
  10501. beforeshow: function (tip) {
  10502. var tipText = (tip.triggerElement.innerText || tip.triggerElement.textContent);
  10503. if (Ext.isEmpty(tipText) || Ext.isEmpty(tipText.trim())) {
  10504. return false;
  10505. }
  10506. tip.update(tipText);
  10507. }
  10508. }
  10509. });
  10510. }
  10511. },
  10512. itemcontextmenu: function (view, rec, node, index, e) {
  10513. if (this.contextMenu) {
  10514. e.stopEvent();
  10515. this.contextMenu.show().setLocalXY(e.getXY());
  10516. return false;
  10517. }
  10518. },
  10519. // columnmove(sender, column, fromIndex, toIndex, eOpts) {
  10520. // this.setColumnConfigCache()
  10521. // },
  10522. // columnhide(sender, column, eOpts) {
  10523. // this.setColumnConfigCache()
  10524. // },
  10525. // columnshow(sender, column, eOpts) {
  10526. // this.setColumnConfigCache()
  10527. // },
  10528. // columnresize(sender, column, width, eOpts) {
  10529. // this.setColumnConfigCache()
  10530. // },
  10531. destory: function () {
  10532. },
  10533. selectionchange: function (sender, _a) {
  10534. var _b = __read(_a, 1), record = _b[0];
  10535. itemselectFun(this, sender, record);
  10536. },
  10537. itemclick: function (sender, record) {
  10538. itemselectFun(this, sender, record);
  10539. }
  10540. });
  10541. _.defer(function () {
  10542. var ce = _this.findPlugin('cellediting');
  10543. ce.on({
  10544. beforeedit: function (editor, context, eOpts) {
  10545. me.fireEvent('editbefore', me, editor, context, eOpts);
  10546. },
  10547. canceledit: function (editor, context, eOpts) {
  10548. me.fireEvent('editcancel', me, editor, context, eOpts);
  10549. },
  10550. edit: function (editor, context, eOpts) {
  10551. me.fireEvent('editfinish', me, editor, context, eOpts);
  10552. },
  10553. validateedit: function (editor, context, eOpts) {
  10554. me.fireEvent('editvalidate', me, editor, context, eOpts);
  10555. },
  10556. });
  10557. });
  10558. var itemselectFun = _.debounce(function (me, sender, record) {
  10559. me.fireEvent('itemselect', sender, record);
  10560. }, 100);
  10561. if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.proxy) {
  10562. // 为 stores.proxy.buildRequest 做准备
  10563. this.store.proxy.$owner = this;
  10564. }
  10565. this.superclass.initComponent.call(this);
  10566. },
  10567. // 生成列自定义的缓存key
  10568. makeColumnConfigCacheKey: function (config) {
  10569. var _a, _b, _c, _d, _e, _f;
  10570. var scope = ((_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.yvanScope) || ((_c = (_b = config.$initParent) === null || _b === void 0 ? void 0 : _b.lookupReferenceHolder()) === null || _c === void 0 ? void 0 : _c.yvanScope) || ((_d = config.$vmParent) === null || _d === void 0 ? void 0 : _d.yvanScope) || ((_f = (_e = config.$vmParent) === null || _e === void 0 ? void 0 : _e._parent) === null || _f === void 0 ? void 0 : _f.yvanScope);
  10571. var key = "gridColumnCache-" + scope.scopeKey + "-";
  10572. if (config.reference) {
  10573. key += config.reference;
  10574. }
  10575. else {
  10576. var subKey = "";
  10577. for (var i = 0; i < config.columns.length; i++) {
  10578. var column = config.columns[i];
  10579. if (column.dataIndex) {
  10580. subKey += column.dataIndex;
  10581. }
  10582. }
  10583. key += subKey;
  10584. }
  10585. return key;
  10586. },
  10587. getColumnConfigCache: function () {
  10588. var key = this.columnConfigCacheKey;
  10589. var dataStr = localStorage.getItem(key);
  10590. if (dataStr) {
  10591. return JSON.parse(dataStr);
  10592. }
  10593. return "";
  10594. },
  10595. setColumnConfigCache: function () {
  10596. var key = this.columnConfigCacheKey;
  10597. var cacheData = [];
  10598. var columns = this.headerCt.getGridColumns();
  10599. var index = 0;
  10600. for (var i = 0; i < columns.length; i++) {
  10601. var column = columns[i];
  10602. if (column.dataIndex) {
  10603. cacheData.push({
  10604. dataIndex: column.dataIndex,
  10605. width: column.width,
  10606. hidden: column.hidden,
  10607. locked: column.locked,
  10608. index: index
  10609. });
  10610. index++;
  10611. }
  10612. }
  10613. localStorage.setItem(key, JSON.stringify(cacheData));
  10614. },
  10615. autoSizeColumns: function (sender) {
  10616. var grid = sender ? sender.up('grid') : this;
  10617. // const columns = grid.columns;
  10618. // for (let i = 0; i < columns.length; i++) {
  10619. // const column = columns[i];
  10620. // grid.getView().autoSizeColumn(column);
  10621. // column.setWidth(column.getWidth() + 5);
  10622. // }
  10623. for (var i = 1; i < grid.headerCt.getColumnCount(); i++) {
  10624. grid.headerCt.getGridColumns()[i].autoSize(i);
  10625. grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
  10626. }
  10627. },
  10628. clearFilter: function (sender) {
  10629. var grid = sender.up('grid');
  10630. grid.filters.clearFilters();
  10631. grid.getStore().sorters.removeAll();
  10632. // grid.getStore().reload()
  10633. },
  10634. saveGridUIConfig: function (sender) {
  10635. var grid = sender.up('grid');
  10636. grid.setColumnConfigCache();
  10637. msg('保存设置成功!');
  10638. },
  10639. clearGridUIConfig: function (sender) {
  10640. var grid = sender.up('grid');
  10641. var key = grid.columnConfigCacheKey;
  10642. localStorage.setItem(key, "");
  10643. msg('清空设置成功,重新打开后生效!');
  10644. },
  10645. setLoading: function (value) {
  10646. if (value) {
  10647. this.mask('读取中');
  10648. }
  10649. else {
  10650. this.unmask();
  10651. }
  10652. },
  10653. exportExcel: function (sender) {
  10654. var rect = sender.btnEl.dom.getBoundingClientRect();
  10655. var scope = lookupScope(this);
  10656. var grid = sender.up('grid');
  10657. var treeMenu = new Ext.menu.Menu({
  10658. xtype: 'menu',
  10659. floated: false,
  10660. width: 300,
  10661. docked: 'left',
  10662. items: [
  10663. {
  10664. text: '大批量导出 (需要客户端支持!)',
  10665. iconCls: 'x-fa fa-download',
  10666. listeners: {
  10667. click: function (sender, value) {
  10668. // @ts-ignore
  10669. YvanUI.confirm('大批量数据导出会占用大量服务器资源和带宽资源,您真的要导出吗?')
  10670. .then(function (res) {
  10671. grid.exportBigExcelClick();
  10672. });
  10673. }
  10674. }
  10675. },
  10676. '-',
  10677. {
  10678. text: '导出当前数据',
  10679. iconCls: 'x-fa fa-download',
  10680. listeners: {
  10681. click: function (sender, value) {
  10682. grid.exportCurrentExcelClick();
  10683. }
  10684. }
  10685. },
  10686. {
  10687. xtype: "textfield",
  10688. fieldLabel: '当前导出页',
  10689. maskRe: /[0-9]/,
  10690. value: grid.exportExcelCurrentPage,
  10691. listeners: {
  10692. render: function (sender) {
  10693. grid.exportExcelCurrentPageCmp = sender;
  10694. },
  10695. change: function (sender, value) {
  10696. var v = parseInt(value);
  10697. if (isNaN(v) || v === 0) {
  10698. window['system'].msg("页码不能为0");
  10699. v = 1;
  10700. sender.setValue(v);
  10701. }
  10702. var size = parseInt(grid.exportExcelPageSize);
  10703. var total = parseInt(grid.exportExcelTotal);
  10704. if (v > total / size) {
  10705. v = parseInt(total / size + "");
  10706. }
  10707. grid.exportExcelCurrentPage = v + "";
  10708. }
  10709. }
  10710. },
  10711. {
  10712. xtype: "textfield",
  10713. fieldLabel: '导出页大小',
  10714. maskRe: /[0-9]/,
  10715. value: grid.exportExcelPageSize,
  10716. listeners: {
  10717. render: function (sender) {
  10718. grid.exportExcelPageSizeCmp = sender;
  10719. },
  10720. change: function (sender, value) {
  10721. var v = parseInt(value);
  10722. if (isNaN(v) || v === 0) {
  10723. window['system'].msg("导出页大小不能为0");
  10724. v = defaultGrid.exportExcelPageSize;
  10725. sender.setValue(v);
  10726. }
  10727. if (v > 10000) {
  10728. window['system'].msg("导出页大小不能大于10000");
  10729. v = 10000;
  10730. sender.setValue(v);
  10731. }
  10732. var page = parseInt(grid.exportExcelCurrentPage);
  10733. var total = parseInt(grid.exportExcelTotal);
  10734. if (page > total / v) {
  10735. page = parseInt(total / v + "") + 1;
  10736. grid.exportExcelCurrentPageCmp.setValue(page);
  10737. }
  10738. grid.exportExcelPageSize = v + "";
  10739. }
  10740. }
  10741. },
  10742. {
  10743. xtype: "textfield",
  10744. fieldLabel: '总条数',
  10745. value: grid.exportExcelTotal,
  10746. readOnly: true
  10747. },
  10748. {
  10749. text: '导出',
  10750. iconCls: 'x-fa fa-download',
  10751. listeners: {
  10752. click: function (sender, value) {
  10753. grid.exportExcelClick({
  10754. exportExcelPageSize: grid.exportExcelPageSize,
  10755. exportExcelCurrentPage: grid.exportExcelCurrentPage
  10756. });
  10757. }
  10758. }
  10759. },
  10760. ]
  10761. });
  10762. treeMenu.showAt(rect.left, rect.top - 120);
  10763. // for (let i = 1; i < grid.headerCt.getColumnCount(); i++) {
  10764. // grid.headerCt.getGridColumns()[i].autoSize(i);
  10765. // grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
  10766. // }
  10767. },
  10768. /**
  10769. * 获取表格编辑的行数据
  10770. */
  10771. getGridEditRows: function () {
  10772. var grid = this;
  10773. var store = grid.getStore();
  10774. var rows = [];
  10775. var modifyRows = [];
  10776. var newRows = [];
  10777. var err = "";
  10778. var records = store.getModifiedRecords();
  10779. var newRecords = store.getNewRecords();
  10780. var removeRecords = [];
  10781. _.forEach(store.getRemovedRecords(), function (row) {
  10782. removeRecords.push(row.data);
  10783. });
  10784. _.forEach(records, function (record) {
  10785. var colums = grid.columns;
  10786. var errFunc = undefined;
  10787. _.forEach(colums, function (col) {
  10788. var name = col.dataIndex;
  10789. var value = record.data[name];
  10790. var colIndex = col.getIndex(); //获得列号
  10791. var rowIndex = store.indexOfId(record.id); //获得行号
  10792. var editor = col.getEditor(); //使用的编辑器
  10793. var tmpErrFunc = function () {
  10794. var text = col.text || col.name;
  10795. msg(text + ' 校验失败, 请确保输入的数据正确');
  10796. grid.findPlugin('cellediting').startEdit(rowIndex, col); //如果不通过激活当前编辑状态
  10797. };
  10798. if (editor && !editor.allowBlank && isEmpty(value)) {
  10799. errFunc = tmpErrFunc;
  10800. return false;
  10801. }
  10802. if (editor && !isEmpty(value) && !editor.validateValue(value)) {
  10803. errFunc = tmpErrFunc;
  10804. return false;
  10805. }
  10806. });
  10807. if (typeof errFunc === 'function') {
  10808. err = "1";
  10809. _.remove(rows, function (n) {
  10810. return true;
  10811. });
  10812. //@ts-ignore
  10813. errFunc();
  10814. // Ext.Msg.alert('提示', '请确保输入的数据正确', errFunc)
  10815. return false;
  10816. }
  10817. else {
  10818. if (_.findIndex(newRecords, function (item) {
  10819. return item === record;
  10820. }) >= 0) {
  10821. newRows.push(record.data);
  10822. }
  10823. else {
  10824. modifyRows.push(record.data);
  10825. }
  10826. rows.push(record.data);
  10827. }
  10828. });
  10829. return {
  10830. rows: rows,
  10831. newRows: newRows,
  10832. modifyRows: modifyRows,
  10833. removeRecords: removeRecords,
  10834. err: err
  10835. };
  10836. }
  10837. // reload() {
  10838. // dataSourceReload(this)
  10839. // },
  10840. });
  10841. }
  10842. /**
  10843. * 获取 columns 中所有的 dataIndex
  10844. */
  10845. function getFileds(newConfig) {
  10846. var fields = [];
  10847. _.forEach(newConfig.columns, function (c) {
  10848. if (c.dataIndex) {
  10849. fields.push(c.dataIndex);
  10850. }
  10851. });
  10852. return fields;
  10853. }
  10854. function convertDataSource$1(sender, scope, newConfig) {
  10855. if (typeof newConfig.store !== 'undefined') {
  10856. // 有 store 属性的情况下,不做任何事
  10857. return;
  10858. }
  10859. if (typeof newConfig.dataSource === 'undefined') {
  10860. // 没有定义 dataSource 的情况下,不做任何事
  10861. return;
  10862. }
  10863. if (_.isArray(newConfig.data)) {
  10864. // 有 data 属性赋值的情况下
  10865. newConfig.store = {
  10866. fields: getFileds(newConfig),
  10867. data: newConfig.data
  10868. };
  10869. delete newConfig.data;
  10870. return;
  10871. }
  10872. var dataSource = newConfig.dataSource;
  10873. if (typeof dataSource === 'string') {
  10874. // dataSource 是字符串的情况下,找到成员函数
  10875. dataSource = lookupFn(scope, dataSource);
  10876. }
  10877. if (typeof dataSource === 'function') {
  10878. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  10879. newConfig.store = new Ext.data.Store({
  10880. fields: getFileds(newConfig),
  10881. // data: [],
  10882. autoLoad: true,
  10883. proxy: {
  10884. type: 'memory',
  10885. data: [],
  10886. }
  10887. });
  10888. newConfig.dataSourceCallbackFn = dataSource;
  10889. return;
  10890. }
  10891. // throw new TypeError('无法识别的调用方法')
  10892. }
  10893. /**
  10894. * 创建一个 Ajax 客户端
  10895. */
  10896. function createAjax(createOption) {
  10897. if (createOption.baseUrl) {
  10898. axios__default.defaults.baseURL = createOption.baseUrl;
  10899. axios__default.defaults.timeout = createOption.timeout;
  10900. storeAjax.timeout = createOption.timeout;
  10901. axios__default.defaults.timeoutErrorMessage = '网络超时';
  10902. }
  10903. return function (option) {
  10904. //@ts-ignore
  10905. option.method = (option.method || 'get').toLocaleLowerCase();
  10906. //@ts-ignore
  10907. var ax = __assign({}, option);
  10908. switch (option.method) {
  10909. case 'get':
  10910. ax.method = 'GET';
  10911. ax.params = option.param;
  10912. ax.headers = __assign({}, option.headers);
  10913. break;
  10914. case 'post':
  10915. ax.method = 'POST';
  10916. ax.headers = __assign({ 'Content-Type': 'application/x-www-form-urlencoded' }, option.headers);
  10917. ax.params = option.param;
  10918. ax.data = Qs.stringify(option.data);
  10919. break;
  10920. case 'put':
  10921. case 'patch':
  10922. case 'delete':
  10923. ax.method = option.method;
  10924. ax.headers = option.headers;
  10925. ax.params = option.param;
  10926. ax.data = Qs.stringify(option.data);
  10927. break;
  10928. case 'download':
  10929. downLoad(createOption.baseUrl + option.url, option.fileName || 'file', option.data, option.headers);
  10930. return new Promise(function (resolver, reject) {
  10931. });
  10932. case "invoke":
  10933. ax.url = serverInvokeUrlTransform(option.url, option);
  10934. ax.method = 'POST';
  10935. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  10936. if (typeof option.args === 'object') {
  10937. ax.data = JSON.stringify({
  10938. args: option.args,
  10939. });
  10940. }
  10941. else {
  10942. ax.data = JSON.stringify({
  10943. args: [
  10944. __assign(__assign({}, option.data), option.param)
  10945. ],
  10946. filterModel: option.filterModel,
  10947. sortModel: option.sortModel
  10948. });
  10949. }
  10950. break;
  10951. case 'post-json':
  10952. ax.method = 'POST';
  10953. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  10954. ax.data = JSON.stringify(__assign(__assign({}, option.data), { filterModel: option.filterModel, sortModel: option.sortModel }));
  10955. break;
  10956. case 'post-file':
  10957. //TODO 刘壮. 上传文件
  10958. var forms = new FormData();
  10959. ax.headers = __assign({ 'Content-Type': 'multipart/form-data' }, option.headers);
  10960. _.forOwn(option.data, function (value, key) {
  10961. if (key === 'files') {
  10962. var i_1 = 0;
  10963. _.each(value, function (f) {
  10964. // @ts-ignore
  10965. forms.append('file' + (++i_1), f);
  10966. });
  10967. }
  10968. else {
  10969. forms.append(key, value);
  10970. }
  10971. });
  10972. ax.data = forms;
  10973. ax.method = 'POST';
  10974. break;
  10975. case "sql":
  10976. ax.url = sqlUrlTransform(option.url);
  10977. ax.method = 'POST';
  10978. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  10979. ax.data = JSON.stringify({
  10980. args: [option.data],
  10981. db: option.db,
  10982. filterModel: option.filterModel,
  10983. sortModel: option.sortModel
  10984. });
  10985. break;
  10986. default:
  10987. throw new Error('not implements');
  10988. }
  10989. return new Promise(function (resolver, reject) {
  10990. axios__default(ax).then(function (resolverRaw) {
  10991. var apiResult = {
  10992. rawData: resolverRaw.data,
  10993. status: resolverRaw.status,
  10994. success: (resolverRaw.data && resolverRaw.data.success),
  10995. data: resolverRaw.data.data,
  10996. pagination: resolverRaw.data.pagination,
  10997. msg: (resolverRaw.data.msg),
  10998. errors: resolverRaw.data.errors,
  10999. headers: resolverRaw.headers
  11000. };
  11001. resolver(apiResult);
  11002. }).catch(function (reason) {
  11003. reject(reason);
  11004. });
  11005. });
  11006. };
  11007. }
  11008. function downLoad(downLoadUrl, filename, data, header, isJson) {
  11009. if (isJson === void 0) { isJson = false; }
  11010. var YvanUI = _.get(window, 'YvanUI');
  11011. YvanUI.loading();
  11012. var createObjectURL = function (object) {
  11013. return (window.URL) ? window.URL.createObjectURL(object) : _.get(window, 'webkitURL').createObjectURL(object);
  11014. };
  11015. // const formData = new FormData();
  11016. // _.forOwn(data, (v, k) => {
  11017. // formData.append(k, v);
  11018. // });
  11019. var formData = '';
  11020. var xhr = new XMLHttpRequest();
  11021. xhr.open('POST', downLoadUrl);
  11022. xhr.responseType = 'blob';
  11023. // xhr.setRequestHeader('Authorization', $.cookie('auth'))
  11024. if (isJson) {
  11025. formData = data ? JSON.stringify(data) : '';
  11026. xhr.setRequestHeader('Content-Type', 'application/json');
  11027. }
  11028. else {
  11029. formData = data ? Qs.stringify(data) : '';
  11030. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  11031. }
  11032. //
  11033. if (header) {
  11034. _.forOwn(header, function (v, k) {
  11035. xhr.setRequestHeader(k, v);
  11036. });
  11037. }
  11038. xhr.onload = function (e) {
  11039. if (this.status === 200) {
  11040. var blob = this.response;
  11041. if (_.hasIn(window, 'navigator.msSaveOrOpenBlob')) {
  11042. navigator.msSaveBlob(blob, filename);
  11043. YvanUI.clearLoading();
  11044. }
  11045. else {
  11046. var a = document.createElement('a');
  11047. var url = createObjectURL(blob);
  11048. a.href = url;
  11049. a.download = filename;
  11050. document.append(a);
  11051. a.click();
  11052. a.remove();
  11053. window.URL.revokeObjectURL(url);
  11054. YvanUI.clearLoading();
  11055. }
  11056. }
  11057. };
  11058. xhr.send(formData);
  11059. }
  11060. function readExcel(file) {
  11061. return new Promise(function (resolve, reject) {
  11062. if (!file) {
  11063. reject("文件读取失败!!!");
  11064. return;
  11065. }
  11066. var reader = new FileReader();
  11067. reader.onload = function (e) {
  11068. if (e.target) {
  11069. var data = e.target.result;
  11070. var workbook = XLSX.read(data, { type: 'binary' });
  11071. resolve(workbook);
  11072. }
  11073. else {
  11074. reject("文件读取失败!!!");
  11075. }
  11076. };
  11077. try {
  11078. reader.readAsBinaryString(file);
  11079. }
  11080. catch (e) {
  11081. reject(e);
  11082. }
  11083. });
  11084. }
  11085. function readExcelWithColumnsSet(topScope, file, columnsSet, dataStartRow, titleRowNumber, rowValidate, otherValidate, fieldValidate) {
  11086. if (dataStartRow === void 0) { dataStartRow = 2; }
  11087. if (titleRowNumber === void 0) { titleRowNumber = 1; }
  11088. if (rowValidate === void 0) { rowValidate = undefined; }
  11089. if (otherValidate === void 0) { otherValidate = undefined; }
  11090. if (fieldValidate === void 0) { fieldValidate = undefined; }
  11091. return new Promise(function (resolve, reject) {
  11092. var promiseArr = [];
  11093. for (var i = 0; i < columnsSet.length; i++) {
  11094. var fix = columnsSet[i].fix;
  11095. if (_.isArray(fix) && fix.length > 0) {
  11096. var ss = fix[0].toLowerCase();
  11097. if (ss.indexOf("date") > -1 || ss.indexOf("time") > -1) {
  11098. columnsSet[i].importFormatter = function (vdata) {
  11099. // @ts-ignore
  11100. return window.moment(vdata.ov) - 0;
  11101. };
  11102. }
  11103. else {
  11104. var fn = lookupFn(topScope, fix[0]);
  11105. promiseArr.push(fn(null, columnsSet[i]));
  11106. delete columnsSet[i].fix;
  11107. }
  11108. }
  11109. else if (_.isString(fix)) {
  11110. var ss = fix.toLowerCase();
  11111. if (ss.indexOf("date") > -1 || ss.indexOf("time") > -1) {
  11112. columnsSet[i].importFormatter = function (vdata) {
  11113. // @ts-ignore
  11114. return window.moment(vdata.ov) - 0;
  11115. };
  11116. }
  11117. else {
  11118. var fn = lookupFn(topScope, fix);
  11119. promiseArr.push(fn(null, columnsSet[i]));
  11120. delete columnsSet[i].fix;
  11121. }
  11122. }
  11123. }
  11124. var read = function () {
  11125. readExcel(file).then(function (workbook) {
  11126. var sheetNames = workbook.SheetNames; // 工作表名称集合
  11127. var worksheet = workbook.Sheets[sheetNames[0]]; // 这里我们只读取第一张sheet
  11128. var titleRowValue = [];
  11129. var titleRowKey = [];
  11130. var needLoop = false; // 是否需要迭代
  11131. var columns = [];
  11132. if (worksheet && worksheet["!ref"]) {
  11133. var t = worksheet["!ref"];
  11134. var tempArr = t.split(':');
  11135. if (tempArr.length >= 2) {
  11136. var firstRowNumber = tempArr[0].replace(/[^0-9]/ig, "");
  11137. // 选取title的行,删除之前的行
  11138. if (titleRowNumber > firstRowNumber) {
  11139. for (var i = firstRowNumber; i < titleRowNumber; i++) {
  11140. for (var key in worksheet) {
  11141. if (key.endsWith(i) && key.replace(/[^0-9]/ig, "") === i) {
  11142. delete worksheet[key];
  11143. }
  11144. }
  11145. }
  11146. var fc = tempArr[0].replace(/[^a-z]/ig, "");
  11147. firstRowNumber = titleRowNumber + '';
  11148. worksheet["!ref"] = fc + firstRowNumber + ":" + tempArr[1];
  11149. }
  11150. var lastRowNumber = tempArr[1].replace(/[^0-9]/ig, "");
  11151. // const firstColNumber = tempArr[0].split(''+firstRowNumber)[0];
  11152. // const lastColNumber = tempArr[1].split(''+lastRowNumber)[0];
  11153. for (var key in worksheet) {
  11154. if (key.endsWith(firstRowNumber) && key.replace(/[^0-9]/ig, "") === firstRowNumber) {
  11155. titleRowKey.push(key);
  11156. titleRowValue.push(worksheet[key].v);
  11157. }
  11158. }
  11159. if (columnsSet && columnsSet.length > 0) {
  11160. var length = columnsSet.length;
  11161. length = length <= titleRowKey.length ? length : titleRowKey.length;
  11162. for (var i = 0; i < length; i++) {
  11163. var vk = titleRowKey[i];
  11164. var item = columnsSet[i];
  11165. var column = {};
  11166. if (typeof item === 'string') {
  11167. column.dataIndex = item;
  11168. column.header = worksheet[vk].v;
  11169. worksheet[vk] = { t: "s", v: item, h: item, w: item };
  11170. }
  11171. else if (typeof item.dataIndex === "string") {
  11172. column.dataIndex = item.dataIndex;
  11173. column.header = worksheet[vk].v;
  11174. worksheet[vk] = { t: "s", v: item.dataIndex, h: item.dataIndex, w: item.dataIndex };
  11175. if (typeof item.validate === "function") {
  11176. column.validate = item.validate;
  11177. needLoop = true;
  11178. }
  11179. if (typeof item.importFormatter === "function") {
  11180. column.importFormatter = item.importFormatter;
  11181. needLoop = true;
  11182. }
  11183. if ((item.data instanceof Array && item.data.length > 0)
  11184. || _.isPlainObject(item.data) && Object.keys(item.data).length > 0) {
  11185. column.data = item.data;
  11186. needLoop = true;
  11187. }
  11188. }
  11189. columns.push(column);
  11190. }
  11191. }
  11192. }
  11193. }
  11194. if (fieldValidate && typeof fieldValidate === "function") {
  11195. if (fieldValidate(columns, titleRowValue) !== true) {
  11196. reject("fields validate error");
  11197. return;
  11198. }
  11199. }
  11200. var allData = XLSX.utils.sheet_to_json(worksheet);
  11201. var okData = [], errorData = [], errorMsgData = [];
  11202. var needItemLoop = needLoop;
  11203. if (rowValidate && typeof rowValidate === "function") {
  11204. needLoop = true;
  11205. }
  11206. if (needLoop === true) {
  11207. for (var index = 0; index < allData.length; index++) {
  11208. var row = allData[index];
  11209. var rowNumber = dataStartRow + index;
  11210. row.__importID__ = rowNumber;
  11211. var isRowOk = true;
  11212. if (needItemLoop) {
  11213. var _loop_1 = function (num) {
  11214. var column = columns[num];
  11215. var ov = row[column.dataIndex];
  11216. var nv = ov;
  11217. var hasError = false;
  11218. var rowNumber_1 = dataStartRow + index;
  11219. var ei = {
  11220. errorId: rowNumber_1 + '_' + column.dataIndex,
  11221. importID: rowNumber_1,
  11222. dataIndex: column.dataIndex,
  11223. header: column.header,
  11224. value: ov,
  11225. errormessage: ""
  11226. };
  11227. // 格式化
  11228. if (column.data instanceof Array) {
  11229. nv = undefined;
  11230. ei.errormessage = "字典匹配失败";
  11231. _.forEach(column.data, function (v, index) {
  11232. if (v.text === ov) {
  11233. nv = v.id;
  11234. return;
  11235. }
  11236. });
  11237. }
  11238. else if (_.isPlainObject(column.data)) {
  11239. nv = undefined;
  11240. ei.errormessage = "字典匹配失败";
  11241. _.forEach(column.data, function (value, key) {
  11242. if (value === ov) {
  11243. nv = key;
  11244. return;
  11245. }
  11246. });
  11247. }
  11248. if (typeof column.importFormatter === 'function') {
  11249. var vdata = {
  11250. column: column,
  11251. ov: ov,
  11252. nv: nv,
  11253. rowIndex: index,
  11254. data: row,
  11255. rowDatas: allData
  11256. };
  11257. nv = undefined;
  11258. ei.errormessage = "格式化失败";
  11259. nv = column.importFormatter(vdata);
  11260. }
  11261. if (!nv && nv != 0) {
  11262. hasError = true;
  11263. }
  11264. else {
  11265. row[column.dataIndex] = nv;
  11266. ei.errormessage = "";
  11267. }
  11268. // 校验
  11269. if (typeof column.validate === 'function') {
  11270. var vdata = {
  11271. column: column,
  11272. ov: ov,
  11273. nv: nv,
  11274. rowIndex: index,
  11275. data: row,
  11276. rowDatas: allData
  11277. };
  11278. var errormessage = column.validate(vdata);
  11279. if (errormessage === true) ;
  11280. else {
  11281. hasError = true;
  11282. ei.errormessage = ei.errormessage + "/" + errormessage;
  11283. }
  11284. }
  11285. if (hasError === true) {
  11286. isRowOk = false;
  11287. errorMsgData.push(ei);
  11288. }
  11289. };
  11290. for (var num = 0; num < columns.length; num++) {
  11291. _loop_1(num);
  11292. }
  11293. }
  11294. if (rowValidate && typeof rowValidate === "function") {
  11295. var errormessage = rowValidate({
  11296. columns: columns,
  11297. data: row,
  11298. rowIndex: index,
  11299. rowDatas: allData
  11300. });
  11301. if (errormessage === true) ;
  11302. else {
  11303. isRowOk = false;
  11304. var ei = {
  11305. errorId: rowNumber + '',
  11306. dataIndex: "row",
  11307. header: "数据行",
  11308. value: "当前行的数据",
  11309. importID: rowNumber,
  11310. errormessage: errormessage
  11311. };
  11312. errorMsgData.push(ei);
  11313. }
  11314. }
  11315. row.__hasError__ = !isRowOk;
  11316. if (isRowOk === true) {
  11317. okData.push(row);
  11318. }
  11319. else {
  11320. errorData.push(row);
  11321. }
  11322. }
  11323. }
  11324. else {
  11325. // 添加数据的唯一标识
  11326. for (var index = 0; index < allData.length; index++) {
  11327. var row = allData[index];
  11328. var rowNumber = dataStartRow + index;
  11329. row.__importID__ = rowNumber;
  11330. row.__hasError__ = false;
  11331. }
  11332. okData = allData;
  11333. }
  11334. if (otherValidate && typeof otherValidate === "function") {
  11335. otherValidate({ allData: allData, okData: okData, errorData: errorData, errorMsgData: errorMsgData }, resolve);
  11336. }
  11337. else {
  11338. resolve({ allData: allData, okData: okData, errorData: errorData, errorMsgData: errorMsgData });
  11339. }
  11340. // clearLoading()
  11341. }).catch(function (e) {
  11342. reject(e);
  11343. });
  11344. };
  11345. if (promiseArr.length > 0) {
  11346. Promise.all(promiseArr).then(function (resArr) {
  11347. for (var i = 0; i < resArr.length; i++) {
  11348. var tmp = resArr[i];
  11349. tmp.config.data = [];
  11350. if (tmp && tmp.r && Array.isArray(tmp.r.field) && Array.isArray(tmp.r.data)) {
  11351. if (tmp.r.field.length > 1) {
  11352. var keyKey = tmp.r.field[0];
  11353. var valueKey = tmp.r.field[1];
  11354. for (var j = 0; j < tmp.r.data.length; j++) {
  11355. var it = tmp.r.data[j];
  11356. var newIt = {};
  11357. newIt.id = it[keyKey];
  11358. newIt.text = it[valueKey];
  11359. tmp.config.data.push(newIt);
  11360. }
  11361. }
  11362. }
  11363. }
  11364. read();
  11365. });
  11366. }
  11367. else {
  11368. setTimeout(read, 50);
  11369. }
  11370. });
  11371. }
  11372. var ExcelImportDialog = /** @class */ (function (_super) {
  11373. __extends(ExcelImportDialog, _super);
  11374. function ExcelImportDialog(option) {
  11375. var _this = this;
  11376. var vjson = vjsonFunc(option);
  11377. _this = _super.call(this, { model: model, vjson: vjson }) || this;
  11378. _this.importExcelOption = option;
  11379. return _this;
  11380. }
  11381. ExcelImportDialog.prototype.onLoad = function () {
  11382. _super.prototype.onLoad.call(this);
  11383. };
  11384. ExcelImportDialog.prototype.fileChange = function (sender) {
  11385. var _this = this;
  11386. var file = sender.fileInputEl.dom.files[0];
  11387. // const senderScope = lookupScope(sender)
  11388. var topScope = this.topScope;
  11389. var rowValidate = this.importExcelOption.rowValidate;
  11390. if (this.importExcelOption.rowValidate && typeof this.importExcelOption.rowValidate === 'string') {
  11391. rowValidate = lookupFn(topScope, this.importExcelOption.rowValidate).bind(topScope);
  11392. }
  11393. var afterClientValidate = this.importExcelOption.afterClientValidate;
  11394. if (this.importExcelOption.afterClientValidate && typeof this.importExcelOption.afterClientValidate === 'string') {
  11395. afterClientValidate = lookupFn(topScope, this.importExcelOption.afterClientValidate).bind(topScope);
  11396. }
  11397. var fieldValidate = this.importExcelOption.fieldValidate;
  11398. if (this.importExcelOption.fieldValidate && typeof this.importExcelOption.fieldValidate === 'string') {
  11399. fieldValidate = lookupFn(topScope, this.importExcelOption.fieldValidate).bind(topScope);
  11400. }
  11401. this.setLoading(true);
  11402. readExcelWithColumnsSet(topScope, file, this.importExcelOption.columns, this.importExcelOption.dataStartRow, this.importExcelOption.titleRowNumber, rowValidate, afterClientValidate, fieldValidate).then(function (res) {
  11403. _this.importData = res;
  11404. _this.refs.dataGrid.setData(res.allData);
  11405. _this.viewModel.set("dataCount", res.allData.length);
  11406. _this.refs.errGrid.setData(res.errorMsgData);
  11407. _this.viewModel.set("errMsgCount", res.errorMsgData.length);
  11408. }).catch(function (e) {
  11409. _this.importData = null;
  11410. _this.refs.dataGrid.setData();
  11411. _this.refs.errGrid.setData();
  11412. msg(e.toString());
  11413. }).finally(function () {
  11414. _this.setLoading(false);
  11415. });
  11416. };
  11417. ExcelImportDialog.prototype.getDataGridRowRecord = function (record, rowIndex, rowParams, store) {
  11418. if (record.get('__hasError__')) {
  11419. return "x-grid-record-bg-red";
  11420. }
  11421. };
  11422. ExcelImportDialog.prototype.getErrGridRowRecord = function (record, rowIndex, rowParams, store) {
  11423. return "x-grid-record-bg-red";
  11424. };
  11425. ExcelImportDialog.prototype.dataGridClick = function (sender, td, cellIndex, record, item, index, e, eOpts) {
  11426. var _a;
  11427. var id = record.data.__importID__;
  11428. var subId = this.refs.dataGrid.headerCt.getGridColumns()[cellIndex].dataIndex;
  11429. var selectRecord = null;
  11430. var dataIndex = -1;
  11431. var rows = (_a = this.refs.errGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  11432. for (var i = 0; i < rows.length; i++) {
  11433. if (rows[i].importID === id) {
  11434. selectRecord = this.refs.errGrid.getStore().getAt(i);
  11435. dataIndex = i;
  11436. }
  11437. if (rows[i].errorId === id + "_" + subId) {
  11438. selectRecord = this.refs.errGrid.getStore().getAt(i);
  11439. dataIndex = i;
  11440. break;
  11441. }
  11442. }
  11443. if (selectRecord) {
  11444. this.refs.errGrid.ensureVisible(selectRecord);
  11445. this.refs.errGrid.selModel.select(dataIndex);
  11446. // this.refs.errGrid.reload()
  11447. }
  11448. };
  11449. ExcelImportDialog.prototype.errGridClick = function (sender, record, item, index, e, eOpts) {
  11450. var _a;
  11451. var id = record.data.importID;
  11452. var rows = (_a = this.refs.dataGrid.getStore().getData().items) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.data; });
  11453. var selectRecord = null;
  11454. var dataIndex = -1;
  11455. for (var i = 0; i < rows.length; i++) {
  11456. if (rows[i].__importID__ === id) {
  11457. selectRecord = this.refs.dataGrid.getStore().getAt(i);
  11458. dataIndex = i;
  11459. break;
  11460. }
  11461. }
  11462. if (selectRecord) {
  11463. this.refs.dataGrid.ensureVisible(selectRecord);
  11464. this.refs.dataGrid.selModel.select(dataIndex);
  11465. // this.refs.dataGrid.reload()
  11466. }
  11467. };
  11468. ExcelImportDialog.prototype.filterData = function (sender, newValue, oldValue, eOpts) {
  11469. this.viewModel.set("dataType", newValue);
  11470. if (this.importData) {
  11471. this.refs.dataGrid.setData(this.importData[newValue]);
  11472. this.viewModel.set("dataCount", this.importData[newValue].length);
  11473. }
  11474. };
  11475. ExcelImportDialog.prototype.downloadTemplate = function (sender) {
  11476. if (this.importExcelOption.dowLoadUrl && this.importExcelOption.dowLoadUrl.length > 0) {
  11477. window.location.href = this.importExcelOption.dowLoadUrl;
  11478. return;
  11479. }
  11480. var xt = [];
  11481. _.forEach(this.importExcelOption.columns, function (v) {
  11482. xt.push(v.header);
  11483. });
  11484. var filename = this.importExcelOption.templateName ? this.importExcelOption.templateName : "模版"; //文件名称
  11485. if (filename.endsWith(".xlsx")) {
  11486. filename = filename.split(".xlsx")[0];
  11487. }
  11488. filename = filename + ".xlsx";
  11489. var ws_name = "Sheet1"; //Excel第一个sheet的名称
  11490. var wb = XLSX.utils.book_new(), ws = XLSX.utils.aoa_to_sheet([xt]);
  11491. XLSX.utils.book_append_sheet(wb, ws, ws_name); //将数据添加到工作薄
  11492. XLSX.writeFile(wb, filename); //导出Excel
  11493. };
  11494. ExcelImportDialog.prototype.getData = function (sender) {
  11495. _.each(this.importData.okData, function (item) {
  11496. delete item.id;
  11497. delete item.__hasError__;
  11498. delete item.__importID__;
  11499. delete item._origin;
  11500. });
  11501. _.each(this.importData.allData, function (item) {
  11502. delete item.id;
  11503. delete item.__hasError__;
  11504. delete item.__importID__;
  11505. delete item._origin;
  11506. });
  11507. _.each(this.importData.errorData, function (item) {
  11508. delete item.id;
  11509. delete item.__hasError__;
  11510. delete item.__importID__;
  11511. delete item._origin;
  11512. });
  11513. this.dialogSuccess(this.importData);
  11514. };
  11515. return ExcelImportDialog;
  11516. }(Scope));
  11517. var model = {
  11518. data: {
  11519. dataType: "all",
  11520. errMsgCount: 0,
  11521. dataCount: 0
  11522. }
  11523. };
  11524. var vjsonFunc = function (option) {
  11525. return {
  11526. title: option.title || 'excel导入',
  11527. layout: 'fit',
  11528. items: [
  11529. {
  11530. layout: 'border',
  11531. tbar: {
  11532. xtype: "form",
  11533. items: [
  11534. {
  11535. xtype: "cols",
  11536. items: [
  11537. {
  11538. xtype: "filefield",
  11539. fieldLabel: 'excel文件',
  11540. buttonText: '请选择excel文件',
  11541. accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel",
  11542. flex: 3,
  11543. listeners: {
  11544. change: "scope.fileChange"
  11545. }
  11546. }, {
  11547. xtype: "button",
  11548. iconCls: "x-fa fa-download",
  11549. text: "下载模版",
  11550. listeners: {
  11551. click: "scope.downloadTemplate"
  11552. }
  11553. }, {
  11554. xtype: 'container',
  11555. border: false,
  11556. layout: 'hbox',
  11557. }, {
  11558. xtype: "button",
  11559. iconCls: "x-fa fa-upload",
  11560. text: option.tQButtonText || "提取数据",
  11561. listeners: {
  11562. click: "scope.getData"
  11563. }
  11564. }
  11565. ]
  11566. },
  11567. ]
  11568. },
  11569. items: [
  11570. {
  11571. tbar: {
  11572. xtype: "toolbar",
  11573. title: "导入的数据",
  11574. items: [{
  11575. xtype: 'label',
  11576. html: '<span style="font-size: 14px; font-weight: bold">导入的数据</span>',
  11577. }, {
  11578. xtype: 'radiogroup',
  11579. items: [
  11580. {
  11581. boxLabel: '所有数据',
  11582. checked: true,
  11583. inputValue: 'allData',
  11584. }, {
  11585. boxLabel: '正确数据',
  11586. inputValue: 'okData',
  11587. }, {
  11588. boxLabel: '错误数据',
  11589. inputValue: 'errorData',
  11590. }
  11591. ],
  11592. listeners: {
  11593. change: 'scope.filterData',
  11594. },
  11595. }, {
  11596. xtype: "textfield",
  11597. readOnly: true,
  11598. fieldLabel: "条目数",
  11599. bind: "{dataCount}"
  11600. }]
  11601. },
  11602. xtype: 'yvgrid',
  11603. reference: 'dataGrid',
  11604. layout: 'fit',
  11605. pagination: false,
  11606. // pageSize: 50,
  11607. getRowClass: 'scope.getDataGridRowRecord',
  11608. columns: option.columns,
  11609. region: 'center',
  11610. split: true,
  11611. listeners: {
  11612. cellclick: "scope.dataGridClick",
  11613. },
  11614. selModel: {
  11615. // type: 'rowmodel',
  11616. mode: 'SINGLE',
  11617. },
  11618. }, {
  11619. tbar: {
  11620. xtype: "toolbar", items: [
  11621. {
  11622. xtype: 'label',
  11623. html: '<span style="font-size: 14px; font-weight: bold; color: red">错误信息</span>',
  11624. }, {
  11625. xtype: "textfield",
  11626. readOnly: true,
  11627. fieldLabel: "条目数",
  11628. bind: "{errMsgCount}"
  11629. }
  11630. ]
  11631. },
  11632. xtype: 'yvgrid',
  11633. reference: 'errGrid',
  11634. layout: 'fit',
  11635. pagination: false,
  11636. getRowClass: 'scope.getErrGridRowRecord',
  11637. height: "40%",
  11638. columns: [
  11639. { dataIndex: "errorId", header: "ID", hidden: true },
  11640. { dataIndex: "importID", header: "行号", width: 80 },
  11641. { dataIndex: "errormessage", header: "错误信息", width: 200 },
  11642. { dataIndex: "value", header: "值", width: 120 },
  11643. { dataIndex: "header", header: "字段名", width: 120 },
  11644. { dataIndex: "dataIndex", header: "字段", width: 120 }
  11645. ],
  11646. region: 'south',
  11647. split: true,
  11648. listeners: {
  11649. itemclick: "scope.errGridClick"
  11650. },
  11651. selModel: {
  11652. // type: 'rowmodel',
  11653. mode: 'SINGLE',
  11654. },
  11655. },
  11656. ],
  11657. },
  11658. ],
  11659. referenceHolder: true,
  11660. };
  11661. };
  11662. function buildReportScope(config, reportId, invokeServerFn, getDictFnName) {
  11663. var _a = buildVjson(config, invokeServerFn, getDictFnName), model = _a.model, vjson = _a.vjson, report = _a.report;
  11664. var ret = new ReportScope({ model: model, vjson: vjson }, invokeServerFn);
  11665. ret.report_id = reportId;
  11666. ret.report = report;
  11667. return ret;
  11668. }
  11669. function buildVjson(config, invokeServerFn, getDictFnName) {
  11670. var e_1, _a, e_2, _b;
  11671. var model = {
  11672. data: {
  11673. report_name: config.report_name,
  11674. query: {},
  11675. sum: {},
  11676. }
  11677. };
  11678. var json5 = window['YvanUI'].json5;
  11679. var report = config.report ? json5.parse(config.report) : {};
  11680. var conditionRows = [];
  11681. var sumRows = [];
  11682. model.data.has_sum = _.size(report.summary) > 0;
  11683. // query 查询条件
  11684. var newRow = false;
  11685. var currentRow = { xtype: 'cols', items: [], };
  11686. conditionRows.push(currentRow);
  11687. _.forEach(report.query, function (item) {
  11688. if (newRow) {
  11689. currentRow = { xtype: 'cols', items: [], };
  11690. conditionRows.push(currentRow);
  11691. }
  11692. var vj = json5.parse(item.conditionFieldExtend);
  11693. if (item.conditionFieldXtype) {
  11694. vj.xtype = item.conditionFieldXtype;
  11695. if (item.conditionFieldXtype === 'combo') {
  11696. vj.fix = ['system.' + getDictFnName + '("' + item.conditionFieldDict + '")'];
  11697. }
  11698. if (item.conditionFieldXtype === 'datetimefield') {
  11699. //@ts-ignore
  11700. _.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD HH:mm:ss'));
  11701. }
  11702. else if (item.conditionFieldXtype === 'datefield') {
  11703. //@ts-ignore
  11704. _.set(model.data.query, item.conditionFieldBind, moment(window.getServerTime()).format('YYYY-MM-DD'));
  11705. }
  11706. else {
  11707. model.data.query[item.conditionFieldBind] = '';
  11708. }
  11709. }
  11710. else {
  11711. // 没有组件类型,是个空占位符
  11712. vj.border = false;
  11713. }
  11714. if (item.conditionFieldBind) {
  11715. vj.bind = {
  11716. value: '{query.' + item.conditionFieldBind + '}'
  11717. };
  11718. }
  11719. if (item.conditionFieldFlex) {
  11720. vj.flex = item.conditionFieldFlex;
  11721. }
  11722. if (item.conditionFieldXtype) {
  11723. vj.fieldLabel = item.conditionFieldLabel;
  11724. }
  11725. if (item.fieldLabel) {
  11726. vj.fieldLabel = item.fieldLabel;
  11727. }
  11728. newRow = item.conditionFieldWrap || false;
  11729. currentRow.items.push(vj);
  11730. });
  11731. if (currentRow) {
  11732. currentRow.margin = '10 0 10 0';
  11733. }
  11734. // sum 汇总条件
  11735. newRow = true;
  11736. try {
  11737. for (var _c = __values(report.summary), _d = _c.next(); !_d.done; _d = _c.next()) {
  11738. var item = _d.value;
  11739. if (newRow) {
  11740. currentRow = {
  11741. xtype: 'cols',
  11742. defaultType: 'displayfield',
  11743. defaults: {
  11744. labelWidth: 70,
  11745. },
  11746. items: []
  11747. };
  11748. sumRows.push(currentRow);
  11749. }
  11750. var vj = __assign({}, json5.parse(item.sumFieldExtend));
  11751. if (item.sumFieldBind) {
  11752. vj.bind = '{sum.' + item.sumFieldBind + '}';
  11753. model.data.sum[item.sumFieldBind] = '';
  11754. }
  11755. else {
  11756. // 没有组件类型,是个空占位符
  11757. vj.border = false;
  11758. }
  11759. if (item.sumFieldFlex) {
  11760. vj.flex = item.sumFieldFlex;
  11761. }
  11762. if (item.sumFieldLabel) {
  11763. vj.fieldLabel = item.sumFieldLabel;
  11764. }
  11765. // sumFieldBind: "zs"
  11766. // sumFieldExtend: "{}"
  11767. // sumFieldFlex: 1
  11768. // sumFieldLabel: "总数"
  11769. // sumFieldWrap: false
  11770. newRow = item.sumFieldWrap || false;
  11771. currentRow.items.push(vj);
  11772. }
  11773. }
  11774. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  11775. finally {
  11776. try {
  11777. if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
  11778. }
  11779. finally { if (e_1) throw e_1.error; }
  11780. }
  11781. if (currentRow) {
  11782. currentRow.margin = '10 0 10 0';
  11783. }
  11784. // column 结果字段
  11785. var columns = [];
  11786. try {
  11787. for (var _e = __values(report.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
  11788. var item = _f.value;
  11789. var vj = __assign({ dataIndex: item.dataIndex, header: item.header, hidden: item.hidden, sortable: item.sortable, filterable: item.filterable }, json5.parse(item.fieldExtend));
  11790. if (item.xtype) {
  11791. if (item.xtype == 'checkbox') {
  11792. vj.xtype = 'checkcolumn';
  11793. vj.disabled = true;
  11794. }
  11795. else {
  11796. vj.xtype = item.xtype;
  11797. }
  11798. }
  11799. if (item.dataType) {
  11800. vj.dataType = item.dataType;
  11801. }
  11802. if (item.align) {
  11803. vj.align = item.align;
  11804. }
  11805. if (item.width) {
  11806. vj.width = item.width;
  11807. }
  11808. if (item.dict) {
  11809. vj.fix = ['system.' + getDictFnName + '("' + item.dict + '")'];
  11810. }
  11811. columns.push(vj);
  11812. }
  11813. }
  11814. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  11815. finally {
  11816. try {
  11817. if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
  11818. }
  11819. finally { if (e_2) throw e_2.error; }
  11820. }
  11821. var vjson = {
  11822. bind: {
  11823. title: '{report_name}',
  11824. },
  11825. layout: 'fit',
  11826. referenceHolder: true,
  11827. items: [
  11828. {
  11829. layout: 'border',
  11830. border: false,
  11831. items: [
  11832. {
  11833. region: 'north',
  11834. border: false,
  11835. tbar: {
  11836. xtype: 'toolbar',
  11837. border: false,
  11838. items: [
  11839. {
  11840. xtype: 'button',
  11841. text: '查询',
  11842. reference: 'btnSearch',
  11843. iconCls: 'x-fa fa-search',
  11844. listeners: {
  11845. click: 'scope.reload',
  11846. },
  11847. },
  11848. {
  11849. xtype: 'button',
  11850. text: '关闭',
  11851. iconCls: 'x-fa fa-times',
  11852. listeners: {
  11853. click: 'system.closeMe()',
  11854. },
  11855. },
  11856. ],
  11857. },
  11858. defaults: {
  11859. margin: '8 0 0 0'
  11860. },
  11861. items: __spread(conditionRows, sumRows),
  11862. fix: ['system.enterToClick("btnSearch")'],
  11863. },
  11864. __assign({ region: 'center', xtype: 'yvgrid', reference: 'grid1', border: false, selModel: { selType: 'rowmodel', mode: 'SINGLE', }, autoLoad: false, dataSource: {
  11865. method: 'invoke',
  11866. url: '/report/Report@execute',
  11867. params: {
  11868. dataSource: report.dataSource,
  11869. pagination: report.grid.pagination || true,
  11870. report_id: config.report_id,
  11871. query: '{query}',
  11872. },
  11873. }, columns: columns }, report.grid),
  11874. ],
  11875. },
  11876. ],
  11877. };
  11878. return { model: model, vjson: vjson, report: report };
  11879. }
  11880. var ReportScope = /** @class */ (function (_super) {
  11881. __extends(ReportScope, _super);
  11882. function ReportScope(_a, invokeServerFn) {
  11883. var model = _a.model, vjson = _a.vjson;
  11884. var _this = _super.call(this, { model: model, vjson: vjson }) || this;
  11885. _this.invokeServerFn = invokeServerFn;
  11886. return _this;
  11887. }
  11888. ReportScope.prototype.onLoad = function () {
  11889. // this.reload()
  11890. };
  11891. ReportScope.prototype.reload = function () {
  11892. var _this = this;
  11893. // http://127.0.0.1:8095/api/com/galaxis/wms/report/Report@executeSum
  11894. if (this.viewModel.get('has_sum')) {
  11895. this.invokeServerFn('/report/Report@executeSum', {
  11896. dataSource: this.report.dataSource,
  11897. report_id: this.report_id,
  11898. query: this.viewModel.get('query'),
  11899. }).then(function (res) {
  11900. if (!res.success) {
  11901. showErrorDialog$1(res.msg);
  11902. }
  11903. else {
  11904. window['system'].mergeViewModel(_this.viewModel, 'sum', res.data, false);
  11905. }
  11906. });
  11907. }
  11908. this.refs.grid1.reload();
  11909. };
  11910. return ReportScope;
  11911. }(Scope));
  11912. function initTextfield () {
  11913. var cc = Ext.form.field.Text.prototype.constructor;
  11914. var initComponent = Ext.form.field.Text.prototype.initComponent;
  11915. Ext.form.field.Text.override({
  11916. constructor: function (config) {
  11917. var newConfig = _.defaultsDeep({
  11918. // 强制属性
  11919. triggers: {
  11920. clear: {
  11921. weight: -1,
  11922. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  11923. hidden: true,
  11924. handler: 'onClearClick',
  11925. },
  11926. }
  11927. }, baseConfig(config, 'col-item'), config, text);
  11928. if (config === null || config === void 0 ? void 0 : config.nextFocus) {
  11929. newConfig.enableKeyEvents = true;
  11930. }
  11931. cc.call(this, newConfig);
  11932. },
  11933. /**
  11934. * 清空所有值
  11935. */
  11936. onClearClick: function (sender, e) {
  11937. var me = this;
  11938. me.setValue('');
  11939. },
  11940. /**
  11941. * 尝试获取下一个要获取焦点的控件
  11942. */
  11943. _raiseNextFocus: function (sender) {
  11944. var config = sender.config;
  11945. var scope = lookupScope(sender);
  11946. if (typeof config.nextFocus === 'function') {
  11947. config.nextFocus(sender);
  11948. }
  11949. else if (typeof config.nextFocus === 'string' && _.size(config.nextFocus) > 0) {
  11950. if (_.startsWith(config.nextFocus, 'scope.')) {
  11951. var fn = lookupFn(scope, config.nextFocus);
  11952. if (typeof fn === 'function') {
  11953. var nextCtlReference = fn(sender);
  11954. if (typeof nextCtlReference === 'string' && _.size(nextCtlReference) > 0) {
  11955. var ctl = scope === null || scope === void 0 ? void 0 : scope.refs[nextCtlReference];
  11956. if (ctl) {
  11957. if (typeof ctl.focus2 === 'function') {
  11958. ctl.focus2();
  11959. }
  11960. else {
  11961. ctl.focus();
  11962. }
  11963. }
  11964. }
  11965. }
  11966. }
  11967. else {
  11968. var ctl = scope === null || scope === void 0 ? void 0 : scope.refs[config.nextFocus];
  11969. if (ctl) {
  11970. if (typeof ctl.focus2 === 'function') {
  11971. ctl.focus2();
  11972. }
  11973. else {
  11974. ctl.focus();
  11975. }
  11976. }
  11977. }
  11978. }
  11979. },
  11980. initComponent: function () {
  11981. /**
  11982. * 改变必填项之前加星号
  11983. */
  11984. if (this.config.readOnly !== true && (this.allowBlank === false || this.validateBlank === true)) {
  11985. // this.beforeLabelTextTpl = [
  11986. // '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
  11987. // ];
  11988. this.afterLabelTextTpl = [
  11989. '<span style="color:red;font-weight:bold" data-qtip="必填选项">*</span>'
  11990. ];
  11991. }
  11992. var me = this;
  11993. this.on({
  11994. change: function (sender, newVal) {
  11995. var hideTrigger = sender.hideTrigger, disabled = sender.disabled, readOnly = sender.readOnly, hideClear = sender.hideClear;
  11996. if (hideTrigger || disabled || readOnly || hideClear) {
  11997. // 禁用、隐藏、只读、隐藏清空状态下,不需要显示清空按钮
  11998. return;
  11999. }
  12000. var value = newVal;
  12001. if (value) {
  12002. me.getTrigger('clear').show();
  12003. me.updateLayout();
  12004. }
  12005. else {
  12006. me.getTrigger('clear').hide();
  12007. me.updateLayout();
  12008. }
  12009. },
  12010. afterrender: function (sender) {
  12011. var _this = this;
  12012. var _a;
  12013. if ((_a = sender.inputEl) === null || _a === void 0 ? void 0 : _a.dom) {
  12014. sender.inputEl.dom.setAttribute('spellcheck', "false");
  12015. $$1(sender.inputEl.dom).on('click', function (e) {
  12016. sender.fireEvent('click', _this, e);
  12017. });
  12018. $$1(sender.inputEl.dom).on('keydown', function (e) {
  12019. var _a, _b, _c, _d;
  12020. // 表格内编辑器,按上下键时,可以切换到下一行/上一行 进入编辑
  12021. if (e.code === "ArrowDown" || e.code === 'ArrowUp') {
  12022. if (sender.isExpanded === true) {
  12023. // 弹开下拉框的基础上,不干预上下选择
  12024. return;
  12025. }
  12026. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  12027. var grid = sender.ownerCt.up('grid');
  12028. var editingPlugin = grid.editingPlugin || grid.ownerGrid.editingPlugin;
  12029. if (editingPlugin) {
  12030. var rowIdx = (_c = (_b = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.rowIdx;
  12031. var column = (_d = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _d === void 0 ? void 0 : _d.column;
  12032. if (typeof rowIdx !== 'undefined' && typeof column !== 'undefined') {
  12033. // editingPlugin
  12034. var targetRecord = void 0;
  12035. if (e.code === 'ArrowDown') {
  12036. targetRecord = grid.store.data.getAt(rowIdx + 1);
  12037. }
  12038. else {
  12039. targetRecord = grid.store.data.getAt(rowIdx - 1);
  12040. }
  12041. if (targetRecord) {
  12042. grid.setSelection([targetRecord]);
  12043. editingPlugin.startEdit(targetRecord, column);
  12044. }
  12045. e.stopPropagation();
  12046. e.preventDefault();
  12047. }
  12048. }
  12049. }
  12050. }
  12051. });
  12052. }
  12053. var config = sender.config;
  12054. if (config.ff && config.ff > 0) {
  12055. setTimeout(function () {
  12056. if (typeof sender.focus2 === 'function') {
  12057. sender.focus2();
  12058. }
  12059. else {
  12060. sender.focus();
  12061. }
  12062. }, config.ff);
  12063. }
  12064. }
  12065. });
  12066. var config = this.config;
  12067. if (config === null || config === void 0 ? void 0 : config.nextFocus) {
  12068. this.on({
  12069. keyup: function (sender, e) {
  12070. if ([10, 13, 20, 40].includes(e.keyCode)) {
  12071. sender._raiseNextFocus(sender);
  12072. }
  12073. }
  12074. });
  12075. }
  12076. var that = this;
  12077. this.on({
  12078. keyup: function (sender, e, eOpts) {
  12079. if (![10, 13, 20, 40].includes(e.keyCode)) {
  12080. return;
  12081. }
  12082. that.keydown_fun_item(sender, e, eOpts);
  12083. }
  12084. });
  12085. initComponent.call(this);
  12086. },
  12087. keydown_fun_item: _.debounce(function (sender, event, eOpts) {
  12088. var that = sender;
  12089. if ([10, 13, 20, 40].includes(event.keyCode)) {
  12090. // 获取读码器读取的内容,最好不要从 viewModel 中取值,而是从 sender.rawValue 中取值
  12091. var value = _.trim(sender.rawValue);
  12092. var r = that.fireEvent('scancode', that, value, event);
  12093. if (r === 'OK') {
  12094. // 停止事件的默认处理程序,停止事件的冒泡
  12095. // event.stopEvent();
  12096. event.preventDefault();
  12097. event.stopPropagation();
  12098. }
  12099. }
  12100. }, 100)
  12101. });
  12102. }
  12103. function initTbFill () {
  12104. /**
  12105. *
  12106. */
  12107. var ct = Ext.toolbar.Fill.prototype.constructor;
  12108. Ext.toolbar.Fill.override({
  12109. constructor: function (config) {
  12110. var newConfig = _.defaultsDeep({}, config, baseConfig(config, "col-item"), tbfill);
  12111. ct.call(this, newConfig);
  12112. }
  12113. });
  12114. }
  12115. function initTbSeparator () {
  12116. /**
  12117. *
  12118. */
  12119. var ct = Ext.toolbar.Separator.prototype.constructor;
  12120. Ext.toolbar.Separator.override({
  12121. constructor: function (config) {
  12122. var newConfig = _.defaultsDeep({}, config, baseConfig(config, "col-item"), tbseparator);
  12123. ct.call(this, newConfig);
  12124. }
  12125. });
  12126. }
  12127. function initToolbar () {
  12128. /**
  12129. *
  12130. */
  12131. var ct = Ext.toolbar.Toolbar.prototype.constructor;
  12132. Ext.toolbar.Toolbar.override({
  12133. constructor: function (config) {
  12134. var newConfig = _.defaultsDeep({
  12135. // 强制性属性
  12136. }, baseConfig(config, 'cols-container'), config, toolbar);
  12137. ct.call(this, newConfig);
  12138. }
  12139. });
  12140. initTbFill();
  12141. initTbSeparator();
  12142. }
  12143. function initSplitter () {
  12144. var ct = Ext.resizer.Splitter.prototype.constructor;
  12145. Ext.resizer.Splitter.override({
  12146. constructor: function (config) {
  12147. var newConfig = _.defaultsDeep({}, config, baseConfig(config, "row-item"), splitter);
  12148. ct.call(this, newConfig);
  12149. }
  12150. });
  12151. }
  12152. /**
  12153. * 通用 dataSource 解析,
  12154. * Tree/Combo/Grid/PageList ... 都会从这里解析
  12155. */
  12156. function dataSourceReload(ctl, extraParam, _successCb, successCallback, failCallback) {
  12157. var config = ctl.config;
  12158. return new Promise(function (resolve, reject) {
  12159. if (!config.dataSource) {
  12160. // 没有设置数据源,直接置空
  12161. return Promise.resolve();
  12162. }
  12163. var option = {
  12164. extraParam: extraParam,
  12165. _successCb: _successCb,
  12166. successCallback: function (value) {
  12167. if (typeof successCallback === "function") {
  12168. successCallback(value);
  12169. }
  12170. else {
  12171. ctl.setData(value);
  12172. }
  12173. ctl.fireEvent('dataLoadComplete', ctl, true, value);
  12174. ctl.setLoading(false);
  12175. resolve(value);
  12176. },
  12177. failCallback: function (error) {
  12178. if (typeof failCallback === "function") {
  12179. failCallback(error);
  12180. }
  12181. ctl.fireEvent('dataLoadComplete', ctl, false);
  12182. ctl.setLoading(false);
  12183. reject(error);
  12184. }
  12185. };
  12186. // 请求前要求确认一下
  12187. var isCanceled = false;
  12188. ctl.fireEvent('dataBeforeLoad', ctl, __assign({ cancel: function () {
  12189. isCanceled = true;
  12190. } }, option));
  12191. if (!isCanceled) {
  12192. // 请求没有被取消
  12193. // 调用异步接口返回 Promise
  12194. return _innerReload(ctl, option);
  12195. }
  12196. return reject();
  12197. });
  12198. }
  12199. function _innerReload(ctl, option) {
  12200. var config = ctl.config;
  12201. ctl.setLoading(true);
  12202. var scope = lookupScope(ctl);
  12203. var dataSource = config.dataSource;
  12204. if (typeof dataSource == 'string') {
  12205. dataSource = lookupFn(scope, config.dataSource);
  12206. }
  12207. if (typeof dataSource === 'function') {
  12208. // @ts-ignore
  12209. dataSource.call(scope, ctl, option);
  12210. return;
  12211. }
  12212. else if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.url) === 'string' || typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.sqlId) === 'string') {
  12213. if (!ajax.func) {
  12214. console.error("没有配置 ajax");
  12215. return;
  12216. }
  12217. var params_1 = {};
  12218. var sortModel = null;
  12219. var filterModel = null;
  12220. if (option.extraParam && option.extraParam.filterModel) {
  12221. filterModel = option.extraParam.filterModel;
  12222. }
  12223. if (option.extraParam && option.extraParam.sortModel) {
  12224. sortModel = option.extraParam.sortModel;
  12225. }
  12226. _.forOwn(option.extraParam, function (v, key) {
  12227. if (key != "filterModel" && key != "sortModel") {
  12228. if (typeof v === 'function') {
  12229. params_1[key] = v();
  12230. }
  12231. else {
  12232. params_1[key] = v;
  12233. }
  12234. }
  12235. });
  12236. var ds = dataSource;
  12237. _.forOwn(ds.params, function (v, key) {
  12238. if (typeof v === 'function') {
  12239. params_1[key] = v();
  12240. }
  12241. else {
  12242. params_1[key] = v;
  12243. }
  12244. });
  12245. if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.url) === 'string') {
  12246. // @ts-ignore
  12247. ajax.func({
  12248. method: dataSource.method,
  12249. url: ds.url,
  12250. data: params_1,
  12251. filterModel: filterModel,
  12252. sortModel: sortModel,
  12253. }).then(function (res) {
  12254. if (res.success) {
  12255. option.successCallback(res.data);
  12256. }
  12257. else {
  12258. option.failCallback(res.msg);
  12259. }
  12260. }).catch(function (e) {
  12261. option.failCallback(e);
  12262. });
  12263. }
  12264. else if (typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.sqlId) === 'string') {
  12265. var ds_1 = ctl.dataSource;
  12266. // @ts-ignore
  12267. Extend.ajax.func({
  12268. url: ds_1.sqlId,
  12269. data: params_1,
  12270. db: ds_1.db,
  12271. method: 'sql',
  12272. filterModel: filterModel,
  12273. sortModel: sortModel,
  12274. }).then(function (res) {
  12275. if (res.success) {
  12276. option.successCallback(res.data);
  12277. }
  12278. else {
  12279. option.failCallback(res.msg);
  12280. }
  12281. }).catch(function (e) {
  12282. option.failCallback(e);
  12283. }).finally(function () {
  12284. ctl.loading = false;
  12285. });
  12286. return;
  12287. }
  12288. else {
  12289. console.error("非法的 dataSource", ctl.dataSource);
  12290. debugger;
  12291. throw new Error("非法的 dataSource");
  12292. }
  12293. }
  12294. }
  12295. function initCombo () {
  12296. var cc = Ext.form.field.ComboBox.prototype.constructor;
  12297. var _a = Ext.form.field.ComboBox.prototype, initComponent = _a.initComponent, setData = _a.setData;
  12298. Ext.form.field.ComboBox.override({
  12299. constructor: function (config) {
  12300. var newConfig = _.defaultsDeep({
  12301. // 强制性属性
  12302. }, baseConfig(config, 'col-item'), config, combo);
  12303. if (typeof newConfig.store == 'undefined') {
  12304. if (_.isArray(newConfig.data)) {
  12305. // ExtJS 无法直接接受数组模式
  12306. newConfig.store = {
  12307. fields: [newConfig.valueField, newConfig.displayField],
  12308. data: newConfig.data
  12309. };
  12310. delete newConfig.data;
  12311. }
  12312. else if (typeof newConfig.data !== 'object') {
  12313. newConfig.store = {
  12314. fields: [newConfig.valueField, newConfig.displayField],
  12315. data: []
  12316. };
  12317. delete newConfig.data;
  12318. }
  12319. }
  12320. cc.call(this, newConfig);
  12321. },
  12322. setData: function (value) {
  12323. if (!value) {
  12324. return;
  12325. }
  12326. var config = value.config;
  12327. if (!this.store) {
  12328. this.store = new Ext.data.Store({
  12329. fields: [config.valueField, config.displayField],
  12330. data: value
  12331. });
  12332. }
  12333. else {
  12334. this.store.getProxy().setData(value);
  12335. this.store.load();
  12336. }
  12337. },
  12338. setLoading: function (value) {
  12339. if (value) {
  12340. if (!this.loadMask) {
  12341. this.loadMask = new Ext.LoadMask(this, { msg: "loading..." });
  12342. }
  12343. }
  12344. else {
  12345. if (this.loadMask) {
  12346. this.loadMask.destroy();
  12347. delete this.loadMask;
  12348. }
  12349. }
  12350. },
  12351. reload: function () {
  12352. dataSourceReload(this);
  12353. },
  12354. initComponent: function () {
  12355. var that = this;
  12356. var toggle = function (e) {
  12357. var readOnly = that.readOnly, disabled = that.disabled;
  12358. if (readOnly || disabled) {
  12359. return;
  12360. }
  12361. if ($(e.target).is('.x-form-trigger')) {
  12362. return;
  12363. }
  12364. // 点击后下拉
  12365. if (that.isExpanded) {
  12366. that.collapse();
  12367. }
  12368. else {
  12369. that.expand();
  12370. that.doQuery(that.allQuery, true);
  12371. }
  12372. };
  12373. this.on({
  12374. afterrender: function (sender) {
  12375. var config = this.config;
  12376. if (config.dataSource && config.autoLoad) {
  12377. dataSourceReload(this);
  12378. }
  12379. // 点击后下拉
  12380. $(this.el.dom).on('click', toggle.bind(this));
  12381. },
  12382. focusenter: function (sender, event, opt) {
  12383. var _a;
  12384. if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
  12385. // 表格内编辑框,获取焦点后自动弹开
  12386. toggle.call(this, event);
  12387. }
  12388. },
  12389. destory: function () {
  12390. $(this.el.dom).off('click', toggle.bind(this));
  12391. },
  12392. beforequery: function (context) {
  12393. var cancel = context.cancel, forceAll = context.forceAll, lastQuery = context.lastQuery, query = context.query, rawQuery = context.rawQuery, combo = context.combo;
  12394. // console.log('beforequery', query)
  12395. if (!forceAll && query) {
  12396. combo.store.clearFilter();
  12397. combo.store.filterBy(function (record, id) {
  12398. var text = record.get(combo.displayField);
  12399. // 用拼音筛选的方式
  12400. return keywordFilter(query, text, id);
  12401. });
  12402. combo.expand();
  12403. return false;
  12404. }
  12405. combo.store.clearFilter();
  12406. combo.expand();
  12407. return false;
  12408. },
  12409. });
  12410. initComponent.call(this);
  12411. },
  12412. focus2: function () {
  12413. this.focus();
  12414. var that = this;
  12415. _.defer(function () {
  12416. if (that.isExpanded) {
  12417. that.collapse();
  12418. }
  12419. else {
  12420. that.expand();
  12421. that.doQuery(that.allQuery, true);
  12422. }
  12423. });
  12424. }
  12425. });
  12426. }
  12427. function initComboGridMulti () {
  12428. Ext.define('Yvan.LocalComboGrid', {
  12429. extend: 'Ext.form.field.Picker',
  12430. // extend: 'Yvan.PickerAlignCenter',
  12431. xtype: 'combogridmulti',
  12432. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  12433. config: __assign(__assign({}, comboGridMulti), { store: null, displayField: null, columns: null, selectOnTab: true, maxPickerHeight: 300, minPickerHeight: 100, minPickerWidth: 350, rootVisible: true }),
  12434. editable: false,
  12435. initComponent: function () {
  12436. this.on({
  12437. afterrender: function () {
  12438. var config = this.config;
  12439. if (config.dataSource && config.autoLoad) {
  12440. dataSourceReload(this);
  12441. }
  12442. },
  12443. });
  12444. this.superclass.initComponent.apply(this, arguments);
  12445. },
  12446. setStore: function (store) {
  12447. this.store = store;
  12448. var me = this;
  12449. if (me.store) {
  12450. if (me.picker) {
  12451. me.picker.setStore(store);
  12452. if (me.isExpanded) {
  12453. me.collapse();
  12454. delete me.picker;
  12455. me.expand();
  12456. }
  12457. }
  12458. this.onLoad();
  12459. me.mon(me.store, {
  12460. scope: me,
  12461. load: me.onLoad,
  12462. update: me.onUpdate
  12463. });
  12464. }
  12465. },
  12466. reload: function () {
  12467. dataSourceReload(this);
  12468. },
  12469. setData: function (value) {
  12470. var me = this;
  12471. var config = me.config;
  12472. if (!value) {
  12473. return;
  12474. }
  12475. if (!this.store) {
  12476. this.store = new Ext.data.Store({
  12477. fields: [config.valueField, config.displayField],
  12478. data: value
  12479. });
  12480. }
  12481. else {
  12482. this.store.getProxy().setData(value);
  12483. this.store.load();
  12484. }
  12485. this.onLoad();
  12486. },
  12487. createPicker: function () {
  12488. var me = this;
  12489. var picker = new Ext.grid.Panel(__assign(__assign({}, comboGridMultiPicker), { border: false, baseCls: Ext.baseCSSPrefix + 'boundlist', shrinkWrapDock: 2, store: me.store, floating: true, displayField: me.displayField, columns: me.columns, minHeight: me.minPickerHeight, maxHeight: me.maxPickerHeight, minWidth: me.minPickerWidth, manageHeight: false, shadow: false, scrollable: true, listeners: {
  12490. scope: me,
  12491. selectionchange: me.onSelectionChange,
  12492. itemkeydown: me.onPickerKeyDown
  12493. } })), view = picker.getView();
  12494. if (Ext.isIE9 && Ext.isStrict) {
  12495. view.on({
  12496. scope: me,
  12497. highlightitem: me.repaintPickerView,
  12498. unhighlightitem: me.repaintPickerView,
  12499. afteritemexpand: me.repaintPickerView,
  12500. afteritemcollapse: me.repaintPickerView
  12501. });
  12502. }
  12503. return picker;
  12504. },
  12505. repaintPickerView: function () {
  12506. var style = this.picker.getView().getEl().dom.style;
  12507. style.display = style.display;
  12508. },
  12509. onSelectionChange: function (view, record, node, rowIndex, e) {
  12510. this.selectItem(view, record);
  12511. },
  12512. onPickerKeyDown: function (treeView, record, item, index, e) {
  12513. var key = e.getKey();
  12514. if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
  12515. this.selectItem(treeView, record);
  12516. }
  12517. },
  12518. selectItem: function (sender, record) {
  12519. var me = this;
  12520. var ids = [];
  12521. _.forEach(me.picker.getSelection(), function (record) {
  12522. ids.push(record.get(me.valueField));
  12523. });
  12524. me.fireEvent('select', me, record);
  12525. me.setValue(ids.join(me.splitChar));
  12526. // me.collapse();
  12527. },
  12528. onExpand: function () {
  12529. var me = this;
  12530. var picker = this.picker;
  12531. var value = this.value;
  12532. if (!me.store) {
  12533. msg('正在初始化数据,请稍后');
  12534. me.collapse();
  12535. return;
  12536. }
  12537. var vs = _.split(value, me.splitChar);
  12538. var records = me.store.queryRecordsBy(function (r) { return _.findIndex(vs, function (i) { return r.get(me.valueField) === i; }) >= 0; });
  12539. picker.setSelection(records);
  12540. },
  12541. setValue: function (value) {
  12542. var me = this;
  12543. console.log('setValue', value);
  12544. me.value = value;
  12545. if (!me.store || me.store.loading) {
  12546. // Called while the Store is loading. Ensure it is processed by the onLoad method.
  12547. return me.mixins.field.setValue.call(me, value);
  12548. // return me;
  12549. }
  12550. var vs = _.split(value, me.splitChar);
  12551. var displayValues = [];
  12552. _.forEach(vs, function (v) {
  12553. var _a;
  12554. var record = me.store.queryRecordsBy(function (r) { return r.get(me.valueField) === v; });
  12555. var dv = (_a = record[0]) === null || _a === void 0 ? void 0 : _a.get(me.displayField);
  12556. if (dv) {
  12557. displayValues.push(dv);
  12558. }
  12559. else {
  12560. displayValues.push(v);
  12561. }
  12562. });
  12563. // set the raw value to the record's display field if a record was found
  12564. me.setRawValue(displayValues.join(me.splitChar));
  12565. return me.mixins.field.setValue.call(me, value);
  12566. },
  12567. getSubmitValue: function () {
  12568. return this.value;
  12569. },
  12570. getValue: function () {
  12571. return this.value;
  12572. },
  12573. onLoad: function () {
  12574. var value = this.value;
  12575. if (value) {
  12576. this.setValue(value);
  12577. }
  12578. },
  12579. onUpdate: function (store, rec, type, modifiedFieldNames) {
  12580. var display = this.displayField;
  12581. var me = this;
  12582. if (type === 'edit' && modifiedFieldNames &&
  12583. Ext.Array.contains(modifiedFieldNames, display) &&
  12584. this.value === rec.getId()) {
  12585. me.mixins.field.setValue.call(me, this.value);
  12586. this.setRawValue(rec.get(display));
  12587. }
  12588. }
  12589. });
  12590. }
  12591. function initSearch () {
  12592. Ext.define('Yvan.Search', {
  12593. extend: 'Ext.form.field.Text',
  12594. alias: 'widget.searchfield',
  12595. xtype: 'searchfield',
  12596. constructor: function (config) {
  12597. var self = this;
  12598. var newConfig = _.defaultsDeep({
  12599. // 强制性属性
  12600. triggers: {
  12601. clear: {
  12602. weight: 0,
  12603. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  12604. hidden: true,
  12605. handler: 'onClearClick',
  12606. },
  12607. search: {
  12608. weight: 1,
  12609. cls: Ext.baseCSSPrefix + 'form-search-trigger',
  12610. handler: 'onSearchClick'
  12611. },
  12612. },
  12613. listeners: {
  12614. blur: function (sender, e) {
  12615. this.revertOnblur();
  12616. },
  12617. specialkey: function (sender, e) {
  12618. var _a;
  12619. var me = this;
  12620. if (e.getKey() === e.ENTER) {
  12621. me.onSearchClick(sender, {}, e);
  12622. return;
  12623. }
  12624. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  12625. },
  12626. afterrender: function (sender, e) {
  12627. var _a;
  12628. this.replaceRawInputEvent();
  12629. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  12630. }
  12631. },
  12632. }, baseConfig(config, 'col-item'), config, search);
  12633. this.superclass.constructor.call(self, newConfig);
  12634. },
  12635. revertOnblur: function () {
  12636. this.setRawValue(this.lastValue);
  12637. },
  12638. onSearchClick: function (sender, vv, e) {
  12639. var me = this;
  12640. var config = me.config;
  12641. var widget = config.widget, vjson = config.vjson, lookup = config.lookup;
  12642. if (e) {
  12643. e.preventDefault();
  12644. e.stopPropagation();
  12645. }
  12646. this.fireEvent('search', sender, e);
  12647. if (!widget) {
  12648. return;
  12649. }
  12650. showWidget(widget, lookup, sender, me.getRawValue(), vjson);
  12651. },
  12652. replaceRawInputEvent: function () {
  12653. var me = this;
  12654. var $dom = $(me.inputEl.dom);
  12655. $dom.on('input', function (e) {
  12656. stopEvent(e);
  12657. // console.log('has input', e)
  12658. });
  12659. $dom.on('keyup', function (e) {
  12660. if (e.key === "Enter") {
  12661. me.onSearchClick(me, {}, e);
  12662. return;
  12663. }
  12664. stopEvent(e);
  12665. });
  12666. $dom.on('change', function (e) {
  12667. stopEvent(e);
  12668. });
  12669. },
  12670. onChange: function (newVal, oldVal) {
  12671. var me = this;
  12672. var value = newVal;
  12673. if (value) {
  12674. me.getTrigger('clear').show();
  12675. me.updateLayout();
  12676. }
  12677. else {
  12678. me.getTrigger('clear').hide();
  12679. me.updateLayout();
  12680. }
  12681. },
  12682. /**
  12683. * 清空所有值
  12684. */
  12685. onClearClick: function (sender, e) {
  12686. var me = this;
  12687. var config = me.config;
  12688. var lookup = config.lookup;
  12689. me.setValue('');
  12690. clearViewModelByLookup(sender, lookup);
  12691. }
  12692. });
  12693. }
  12694. function initMultipleSearch () {
  12695. Ext.define('Yvan.MultipleSearch', {
  12696. extend: 'Ext.form.field.Text',
  12697. xtype: 'multiplesearch',
  12698. bindTargert: '',
  12699. constructor: function (config) {
  12700. var _a, _b, _c, _d;
  12701. var self = this;
  12702. var newConfig = _.defaultsDeep({
  12703. // 强制性属性
  12704. triggers: {
  12705. clear: {
  12706. weight: 0,
  12707. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  12708. hidden: true,
  12709. handler: 'onClearClick',
  12710. }
  12711. },
  12712. transformRawValue: function (o) {
  12713. return o;
  12714. },
  12715. listeners: {
  12716. specialkey: function (sender, e) {
  12717. var me = this;
  12718. if (e.getKey() === e.ENTER) {
  12719. me.fireEvent('search', me, e);
  12720. }
  12721. },
  12722. afterrender: function (sender, e) {
  12723. var _a;
  12724. this.replaceRawInputEvent();
  12725. invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
  12726. }
  12727. },
  12728. }, baseConfig(config, 'col-item'), config, search);
  12729. this.superclass.constructor.call(self, newConfig);
  12730. var vv = (_d = (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.bind) === null || _b === void 0 ? void 0 : _b.value) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.bind))) !== null && _d !== void 0 ? _d : '';
  12731. vv = _.replace(vv, "{", "");
  12732. vv = _.replace(vv, "}", "");
  12733. this.bindTargert = vv;
  12734. this.bindTargert = _.trim(this.bindTargert);
  12735. },
  12736. setBindValue: function (arrValue) {
  12737. if (this.bindTargert) {
  12738. this.lookupViewModel().yvanScope.viewModel.set(this.bindTargert, arrValue);
  12739. }
  12740. },
  12741. replaceRawInputEvent: function () {
  12742. var me = this;
  12743. var $dom = $(me.inputEl.dom);
  12744. $dom.on('input', function (e) {
  12745. var _a, _b, _c, _d, _e, _f;
  12746. if ((_b = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.endsWith(" ")) {
  12747. var a = _.trimEnd((_c = e.currentTarget) === null || _c === void 0 ? void 0 : _c.value);
  12748. if (!a.endsWith(",") && a.length > 0) {
  12749. e.currentTarget.value = a + ",";
  12750. }
  12751. else {
  12752. e.currentTarget.value = a;
  12753. }
  12754. }
  12755. e.currentTarget.value = (_d = e.currentTarget.value) === null || _d === void 0 ? void 0 : _d.replaceAll(",,", ",");
  12756. var arr = (_f = (_e = e.currentTarget) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.split(",");
  12757. _.remove(arr, function (it) {
  12758. return !it;
  12759. });
  12760. me.setBindValue(arr);
  12761. stopEvent(e);
  12762. });
  12763. $dom.on('keyup', function (e) {
  12764. me.fireEvent('keyup', me, e);
  12765. // invokeMethod(me.config.listeners?.keyup, me, e)
  12766. stopEvent(e);
  12767. });
  12768. $dom.on('keydown', function (e) {
  12769. me.fireEvent('keydown', me, e);
  12770. // invokeMethod(me.config.listeners?.keydown, me, e)
  12771. //stopEvent(e)
  12772. });
  12773. $dom.on('change', function (e) {
  12774. stopEvent(e);
  12775. });
  12776. $dom.on('paste', function (e) {
  12777. var _a;
  12778. // @ts-ignore
  12779. var clipdata = e.originalEvent.clipboardData || window.clipboardData;
  12780. var text = clipdata.getData("text/plain");
  12781. var spliter = ',';
  12782. text = text.replaceAll("\r", "");
  12783. text = text.replaceAll("\n", spliter);
  12784. text = ((_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) + "," + text;
  12785. var arr = text.split(spliter);
  12786. if (arr && Array.isArray(arr)) {
  12787. for (var i = 0; i < arr.length; i++) {
  12788. arr[i] = _.trim(arr[i]);
  12789. }
  12790. }
  12791. _.remove(arr, function (it) {
  12792. return !it;
  12793. });
  12794. me.setBindValue(arr);
  12795. stopEvent(e);
  12796. });
  12797. },
  12798. onChange: function (newVal, oldVal) {
  12799. var me = this;
  12800. var value = newVal;
  12801. if (value) {
  12802. me.getTrigger('clear').show();
  12803. me.updateLayout();
  12804. }
  12805. else {
  12806. me.getTrigger('clear').hide();
  12807. me.updateLayout();
  12808. }
  12809. },
  12810. /**
  12811. * 清空所有值
  12812. */
  12813. onClearClick: function (sender, e) {
  12814. var me = this;
  12815. var config = me.config;
  12816. var lookup = config.lookup;
  12817. me.setValue('');
  12818. clearViewModelByLookup(sender, lookup);
  12819. }
  12820. });
  12821. }
  12822. function initDate () {
  12823. var cc = Ext.form.field.Date.prototype.constructor;
  12824. var _a = Ext.form.field.Date.prototype, initComponent = _a.initComponent, getValue = _a.getValue, valueToRaw = _a.valueToRaw;
  12825. Ext.form.field.Date.override({
  12826. format: 'Y-m-d',
  12827. altFormats: 'Y-m-d',
  12828. constructor: function (config) {
  12829. var newConfig = _.defaultsDeep({
  12830. // 强制属性
  12831. }, baseConfig(config, 'col-item'), config, date);
  12832. cc.call(this, newConfig);
  12833. },
  12834. getValue: function () {
  12835. var ov = getValue.call(this);
  12836. var nv = Ext.util.Format.date(ov, 'Y-m-d');
  12837. // console.log('cc:', nv, ov)
  12838. return nv;
  12839. },
  12840. // focus2() {
  12841. // const that = this
  12842. // if (that.isExpanded) {
  12843. // that.collapse()
  12844. //
  12845. // } else {
  12846. // that.expand();
  12847. // }
  12848. // _.defer(() => {
  12849. // that.focus()
  12850. // })
  12851. // },
  12852. initComponent: function () {
  12853. this.on({
  12854. afterrender: function () {
  12855. var config = this.config;
  12856. // 日期框,不要默认弹出
  12857. // $(this.el.dom).on('click', toggle.bind(this))
  12858. },
  12859. destory: function () {
  12860. // 日期框,不要默认弹出
  12861. // $(this.el.dom).off('click', toggle.bind(this))
  12862. },
  12863. change: {
  12864. fn: function (sender) {
  12865. if (sender.format === 'Y-m-d') {
  12866. // 年月日格式
  12867. var value = sender.getRawValue();
  12868. if (/^\d{8}$/.test(value)) {
  12869. // 8位数字,自动转换为 YYYY-MM-DD
  12870. var newValue = [
  12871. value.substr(0, 4),
  12872. value.substr(4, 2),
  12873. value.substr(6, 2)
  12874. ].join('-');
  12875. sender.setValue(newValue);
  12876. }
  12877. }
  12878. },
  12879. }
  12880. // focus: {
  12881. // // 获得焦点后自动下拉
  12882. // fn(sender) {
  12883. // sender.expand();
  12884. // this.doQuery(this.allQuery, true);
  12885. // },
  12886. // },
  12887. });
  12888. initComponent.call(this);
  12889. },
  12890. createInitialDate: function (value) {
  12891. var minValue = this.minValue, maxValue = this.maxValue;
  12892. value = value || syncDate(new Date());
  12893. if (minValue && minValue > value) {
  12894. value = minValue;
  12895. }
  12896. else if (maxValue && maxValue < value) {
  12897. value = maxValue;
  12898. }
  12899. return value;
  12900. },
  12901. });
  12902. }
  12903. function initDateTimePicker () {
  12904. Ext.define('Yvan.DateTimePicker', {
  12905. extend: 'Ext.picker.Date',
  12906. alias: 'datetimepicker',
  12907. alternateClassName: 'Ext.DateTimePicker',
  12908. renderTpl: [
  12909. '<div id="{id}-innerEl" data-ref="innerEl" role="presentation">',
  12910. '<div class="{baseCls}-header">',
  12911. '<div id="{id}-prevEl" data-ref="prevEl" class="{baseCls}-prev {baseCls}-arrow" role="presentation" title="{prevText}"></div>',
  12912. '<div id="{id}-middleBtnEl" data-ref="middleBtnEl" class="{baseCls}-month" role="heading">{%this.renderMonthBtn(values, out)%}</div>',
  12913. '<div id="{id}-nextEl" data-ref="nextEl" class="{baseCls}-next {baseCls}-arrow" role="presentation" title="{nextText}"></div>',
  12914. '</div>',
  12915. '<table role="grid" id="{id}-eventEl" data-ref="eventEl" class="{baseCls}-inner" cellspacing="0" tabindex="0" aria-readonly="true">',
  12916. '<thead>',
  12917. '<tr role="row">',
  12918. '<tpl for="dayNames">',
  12919. '<th role="columnheader" class="{parent.baseCls}-column-header" aria-label="{.}">',
  12920. '<div role="presentation" class="{parent.baseCls}-column-header-inner">{.:this.firstInitial}</div>',
  12921. '</th>',
  12922. '</tpl>',
  12923. '</tr>',
  12924. '</thead>',
  12925. '<tbody>',
  12926. '<tr role="row">',
  12927. '<tpl for="days">',
  12928. '{#:this.isEndOfWeek}',
  12929. '<td role="gridcell">',
  12930. '<div hidefocus="on" class="{parent.baseCls}-date"></div>',
  12931. '</td>',
  12932. '</tpl>',
  12933. '</tr>',
  12934. '</tbody>',
  12935. '</table>',
  12936. '<tpl if="showToday">',
  12937. '<div id="{id}-footerEl" data-ref="footerEl" role="presentation" class="{baseCls}-footer">{%this.renderTodayBtn(values, out)%}</div>',
  12938. '</tpl>',
  12939. // These elements are used with Assistive Technologies such as screen readers
  12940. '<div id="{id}-todayText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{todayText}.</div>',
  12941. '<div id="{id}-ariaMinText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaMinText}.</div>',
  12942. '<div id="{id}-ariaMaxText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaMaxText}.</div>',
  12943. '<div id="{id}-ariaDisabledDaysText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaDisabledDaysText}.</div>',
  12944. '<div id="{id}-ariaDisabledDatesText" class="' + Ext.baseCSSPrefix + 'hidden-clip">{ariaDisabledDatesText}.</div>',
  12945. '</div>',
  12946. {
  12947. firstInitial: function (value) {
  12948. return Ext.picker.Date.prototype.getDayInitial(value);
  12949. },
  12950. isEndOfWeek: function (value) {
  12951. // convert from 1 based index to 0 based
  12952. // by decrementing value once.
  12953. value--;
  12954. // eslint-disable-next-line vars-on-top
  12955. var end = value % 7 === 0 && value !== 0;
  12956. return end ? '</tr><tr role="row">' : '';
  12957. },
  12958. renderTodayBtn: function (values, out) {
  12959. Ext.DomHelper.generateMarkup(values.$comp.todayBtn.getRenderTree(), out);
  12960. },
  12961. renderMonthBtn: function (values, out) {
  12962. Ext.DomHelper.generateMarkup(values.$comp.monthBtn.getRenderTree(), out);
  12963. }
  12964. }
  12965. ],
  12966. beforeRender: function () {
  12967. var me = this, today = Ext.Date.format(syncDate(new Date()), me.format);
  12968. this.superclass.beforeRender.call(this);
  12969. function handleInput(extHandle, $input) {
  12970. var $dom = $(extHandle.el.dom);
  12971. // const $up = $dom.find('.x-form-spinner-up')
  12972. // const $down = $dom.find('.x-form-spinner-down')
  12973. // debugger
  12974. // $up.on('mousedown', () => {
  12975. // debugger
  12976. // });
  12977. // $up.on('click', () => {
  12978. // debugger
  12979. // });
  12980. extHandle.on('click', function (sender) {
  12981. var hideBak = me.hide;
  12982. me.hide = Ext.emptyFn;
  12983. extHandle.focus();
  12984. me.hide = hideBak;
  12985. });
  12986. var changeValue = function (delta) {
  12987. if (_.trim(extHandle.getValue()) === '') {
  12988. extHandle.setValue(extHandle.minValue);
  12989. }
  12990. else {
  12991. var v = parseInt('' + extHandle.getValue());
  12992. if (v + delta > extHandle.maxValue) {
  12993. extHandle.setValue(extHandle.minValue);
  12994. }
  12995. else if (v + delta < extHandle.minValue) {
  12996. extHandle.setValue(extHandle.maxValue);
  12997. }
  12998. else {
  12999. extHandle.setValue(v + delta);
  13000. }
  13001. }
  13002. };
  13003. $input.on('mousewheel', function (e) {
  13004. e.stopPropagation();
  13005. var event = e.originalEvent;
  13006. var eventDelta = event.wheelDelta || -event.deltaY + 40;
  13007. // if (event.wheelDelta) {
  13008. // delta = event.wheelDelta / 120;
  13009. // } else if (event.detail) {
  13010. // delta = -event.detail / 3;
  13011. // }
  13012. var zoomSize = Math.ceil(eventDelta / 120);
  13013. changeValue(zoomSize);
  13014. // console.log('delta', delta)
  13015. // $input.focus()
  13016. });
  13017. }
  13018. me.input1 = Ext.create('Ext.form.field.Number', {
  13019. minValue: 0,
  13020. maxValue: 23,
  13021. flex: 1,
  13022. enableKeyEvents: true,
  13023. fieldLabel: '时',
  13024. labelWidth: 20,
  13025. hideLabel: true,
  13026. spinDownEnabled: false,
  13027. spinUpEnabled: false,
  13028. style: {
  13029. marginLeft: '5px',
  13030. },
  13031. listeners: {
  13032. afterrender: function (sender) {
  13033. var $input = $(sender.inputEl.dom);
  13034. handleInput(me.input1, $input);
  13035. },
  13036. change: function (sender, e) {
  13037. if (me.getValue()) {
  13038. me.value.setHours(sender.getValue());
  13039. }
  13040. },
  13041. }
  13042. });
  13043. me.input2 = Ext.create('Ext.form.field.Number', {
  13044. minValue: 0,
  13045. maxValue: 59,
  13046. flex: 1,
  13047. enableKeyEvents: true,
  13048. fieldLabel: ' ',
  13049. hideLabel: false,
  13050. labelWidth: 8,
  13051. spinDownEnabled: false,
  13052. spinUpEnabled: false,
  13053. listeners: {
  13054. afterrender: function (sender) {
  13055. var $input = $(sender.inputEl.dom);
  13056. handleInput(me.input2, $input);
  13057. },
  13058. change: function (sender, e) {
  13059. if (me.getValue()) {
  13060. me.value.setMinutes(sender.getValue());
  13061. }
  13062. },
  13063. }
  13064. });
  13065. me.input3 = Ext.create('Ext.form.field.Number', {
  13066. minValue: 0,
  13067. maxValue: 59,
  13068. flex: 1,
  13069. enableKeyEvents: true,
  13070. fieldLabel: ' ',
  13071. hideLabel: false,
  13072. labelWidth: 8,
  13073. spinDownEnabled: false,
  13074. spinUpEnabled: false,
  13075. style: {
  13076. marginRight: '5px',
  13077. },
  13078. listeners: {
  13079. afterrender: function (sender) {
  13080. var $input = $(sender.inputEl.dom);
  13081. handleInput(me.input3, $input);
  13082. },
  13083. change: function (sender, e) {
  13084. if (me.getValue()) {
  13085. me.value.setSeconds(sender.getValue());
  13086. }
  13087. },
  13088. }
  13089. });
  13090. me.confirmBtn = new Ext.button.Button({
  13091. text: '确认',
  13092. handler: me.confirmClick,
  13093. scope: me
  13094. });
  13095. me.tdBtn = new Ext.button.Button({
  13096. text: '现在',
  13097. handler: me.selectToday,
  13098. scope: me
  13099. });
  13100. me.todayBtn = Ext.create('Ext.container.Container', {
  13101. layout: 'anchor', border: false,
  13102. defaults: {
  13103. border: false, anchor: '100%',
  13104. margin: '0 0 5 0',
  13105. },
  13106. items: [
  13107. {
  13108. layout: 'hbox',
  13109. items: [
  13110. me.input1,
  13111. me.input2,
  13112. me.input3,
  13113. ]
  13114. },
  13115. {
  13116. layout: 'hbox',
  13117. items: [
  13118. me.confirmBtn,
  13119. me.tdBtn,
  13120. ]
  13121. }
  13122. ]
  13123. });
  13124. },
  13125. // finishRenderChildren() {
  13126. // var me = this;
  13127. //
  13128. // this.superclass.finishRenderChildren.call(this);
  13129. // //*
  13130. // me.input1.finishRender();
  13131. // me.input2.finishRender();
  13132. // me.input3.finishRender();
  13133. // //
  13134. // me.tdBtn.finishRender();
  13135. // me.confirmBtn.finishRender();
  13136. // },
  13137. setValue: function (value) {
  13138. //this.value = Ext.Date.clearTime(value, true);
  13139. this.value = value;
  13140. this.input1.setValue(this.value.getHours());
  13141. this.input2.setValue(this.value.getMinutes());
  13142. this.input3.setValue(this.value.getSeconds());
  13143. return this.update(this.value);
  13144. },
  13145. selectDate: function (value) {
  13146. if (this.showTime) {
  13147. value.setHours(this.input1.getValue());
  13148. value.setMinutes(this.input2.getValue());
  13149. value.setSeconds(this.input3.getValue());
  13150. }
  13151. this.value = value;
  13152. return this.update(this.value);
  13153. },
  13154. setDisabledStatus: function (disabled) {
  13155. var me = this;
  13156. debugger;
  13157. // me.callParent();
  13158. if (me.showTime) {
  13159. me.confirmBtn.setDisabled(disabled);
  13160. }
  13161. if (me.isShowFooter()) {
  13162. me.footerContainer.setDisabled(disabled);
  13163. }
  13164. },
  13165. handleDateClick: function (e, t) {
  13166. var me = this, handler = me.handler;
  13167. // e.stopEvent();
  13168. if (!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)) {
  13169. me.doCancelFocus = me.focusOnSelect === false;
  13170. me.selectDate(new Date(t.dateValue));
  13171. delete me.doCancelFocus;
  13172. /* 有时间输入时单击事件不退出选择,只移动光标 */
  13173. if (me.showTime) {
  13174. return;
  13175. }
  13176. me.fireEvent('select', me, me.value);
  13177. if (handler) {
  13178. handler.call(me.scope || me, me, me.value);
  13179. }
  13180. me.onSelect();
  13181. }
  13182. },
  13183. selectToday: function () {
  13184. var me = this, btn = me.todayBtn, handler = me.handler;
  13185. if (btn && !btn.disabled) {
  13186. me.value = syncDate(new Date());
  13187. me.update(me.value);
  13188. me.fireEvent('select', me, me.value);
  13189. if (handler) {
  13190. handler.call(me.scope || me, me, me.value);
  13191. }
  13192. me.onSelect();
  13193. me.hide();
  13194. }
  13195. return me;
  13196. },
  13197. confirmClick: function () {
  13198. var me = this, btn = me.confirmBtn, handler = me.handler;
  13199. if (btn && !btn.disabled) {
  13200. me.fireEvent('select', me, me.value);
  13201. if (handler) {
  13202. handler.call(me.scope || me, me, me.value);
  13203. }
  13204. me.onSelect();
  13205. me.hide();
  13206. }
  13207. return me;
  13208. },
  13209. selectedUpdate: function (date) {
  13210. var me = this,
  13211. //t = date.getTime(),
  13212. t = Ext.Date.clearTime(date, true).getTime(), cells = me.cells, cls = me.selectedCls, cellItems = cells.elements, c, cLen = cellItems.length, cell;
  13213. cells.removeCls(cls);
  13214. for (c = 0; c < cLen; c++) {
  13215. cell = Ext.fly(cellItems[c]);
  13216. if (cell.dom.firstChild.dateValue == t) {
  13217. me.fireEvent('highlightitem', me, cell);
  13218. cell.addCls(cls);
  13219. if (me.isVisible() && !me.doCancelFocus) {
  13220. Ext.fly(cell.dom.firstChild).focus(50);
  13221. }
  13222. break;
  13223. }
  13224. }
  13225. },
  13226. // private, inherit docs
  13227. beforeDestroy: function () {
  13228. var me = this;
  13229. if (me.rendered) {
  13230. Ext.destroy(me.input1, me.input2, me.input3, me.confirmBtn, me.tdBtn, me.todayBtn);
  13231. }
  13232. me.superclass.beforeDestroy.call(this);
  13233. }
  13234. });
  13235. }
  13236. function initDateTime () {
  13237. Ext.define('Yvan.DateTimeField', {
  13238. extend: 'Ext.form.field.Date',
  13239. xtype: 'datetimefield',
  13240. alternateClassName: ['Ext.form.DateTimeField', 'Ext.form.DateTime'],
  13241. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  13242. showTime: true,
  13243. format: "Y-m-d H:i:s",
  13244. constructor: function (config) {
  13245. var newConfig = _.defaultsDeep({
  13246. // 强制属性
  13247. }, baseConfig(config, 'col-item'), config, date);
  13248. this.superclass.constructor.call(this, newConfig);
  13249. },
  13250. initComponent: function () {
  13251. this.superclass.initComponent.call(this);
  13252. var setInitValue = function () {
  13253. var value = this.getRawValue();
  13254. if (!value) {
  13255. // 没填内容的时候,自动设置当前时间
  13256. this.setValue(Ext.util.Format.date(syncDate(new Date()), this.format));
  13257. }
  13258. };
  13259. this.on({
  13260. afterrender: function () {
  13261. var config = this.config;
  13262. // 日期框,不要默认弹出
  13263. $(this.el.dom).on('click', setInitValue.bind(this));
  13264. },
  13265. destory: function () {
  13266. // 日期框,不要默认弹出
  13267. $(this.el.dom).off('click', setInitValue.bind(this));
  13268. },
  13269. change: {
  13270. fn: function (sender) {
  13271. if (sender.format === "Y-m-d H:i:s") {
  13272. // 年月日格式
  13273. var value = sender.getRawValue();
  13274. if (/^\d{14}$/.test(value)) {
  13275. // 8位数字,自动转换为 YYYY-MM-DD
  13276. var newValue = [
  13277. value.substr(0, 4),
  13278. '-',
  13279. value.substr(4, 2),
  13280. '-',
  13281. value.substr(6, 2),
  13282. ' ',
  13283. value.substr(8, 2),
  13284. ':',
  13285. value.substr(10, 2),
  13286. ':',
  13287. value.substr(12, 2)
  13288. ].join('');
  13289. sender.setValue(newValue);
  13290. }
  13291. }
  13292. },
  13293. }
  13294. });
  13295. },
  13296. getValue: function () {
  13297. var ov = this.getRawValue(); //this.superclass.getValue.call(this)
  13298. var nv = Ext.util.Format.date(ov, 'Y-m-d H:i:s');
  13299. // console.log('cc:', nv, ov)
  13300. return nv;
  13301. },
  13302. onExpand: function () {
  13303. var strValue = this.getValue();
  13304. var value;
  13305. if (/^\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d$/.test(strValue)) {
  13306. value = new Date(parseInt(strValue.substr(0, 4)), parseInt(strValue.substr(5, 2)) - 1, parseInt(strValue.substr(8, 2)), parseInt(strValue.substr(11, 2)), parseInt(strValue.substr(14, 2)), parseInt(strValue.substr(17, 2)));
  13307. }
  13308. else if (/^\d\d\d\d-\d\d-\d\d$/.test(strValue)) {
  13309. value = new Date(parseInt(strValue.substr(0, 4)), parseInt(strValue.substr(5, 2)) - 1, parseInt(strValue.substr(8, 2)));
  13310. }
  13311. else {
  13312. value = syncDate(new Date());
  13313. }
  13314. this.picker.setValue(value);
  13315. },
  13316. createPicker: function () {
  13317. var me = this, format = Ext.String.format;
  13318. //@ts-ignore
  13319. return new Yvan.DateTimePicker({
  13320. pickerField: me,
  13321. ownerCt: me.ownerCt,
  13322. renderTo: document.body,
  13323. floating: true,
  13324. hidden: true,
  13325. focusOnShow: true,
  13326. minDate: me.minValue,
  13327. maxDate: me.maxValue,
  13328. disabledDatesRE: me.disabledDatesRE,
  13329. disabledDatesText: me.disabledDatesText,
  13330. disabledDays: me.disabledDays,
  13331. disabledDaysText: me.disabledDaysText,
  13332. format: me.format,
  13333. showToday: me.showToday,
  13334. showTime: me.showTime,
  13335. startDay: me.startDay,
  13336. minText: format(me.minText, me.formatDate(me.minValue)),
  13337. maxText: format(me.maxText, me.formatDate(me.maxValue)),
  13338. listeners: {
  13339. scope: me,
  13340. select: me.onSelect
  13341. },
  13342. keyNavConfig: {
  13343. esc: function () {
  13344. me.collapse();
  13345. }
  13346. }
  13347. });
  13348. },
  13349. });
  13350. }
  13351. function initNumber () {
  13352. var cc = Ext.form.field.Number.prototype.constructor;
  13353. var initComponent = Ext.form.field.Number.prototype.initComponent;
  13354. Ext.form.field.Number.override({
  13355. constructor: function (config) {
  13356. var newConfig = _.defaultsDeep({
  13357. // 强制属性
  13358. }, baseConfig(config, 'col-item'), config, numberfield);
  13359. cc.call(this, newConfig);
  13360. },
  13361. initComponent: function () {
  13362. this.on({
  13363. afterrender: function (sender) {
  13364. var _this = this;
  13365. var _a;
  13366. if ((_a = sender.inputEl) === null || _a === void 0 ? void 0 : _a.dom) {
  13367. sender.inputEl.dom.setAttribute('spellcheck', "false");
  13368. $$1(sender.inputEl.dom).on('click', function (e) {
  13369. sender.fireEvent('click', _this, e);
  13370. });
  13371. }
  13372. }
  13373. });
  13374. initComponent.call(this);
  13375. },
  13376. });
  13377. }
  13378. function initCheckbox () {
  13379. var cc = Ext.form.field.Checkbox.prototype.constructor;
  13380. var _a = Ext.form.field.Checkbox.prototype, initComponent = _a.initComponent, getValue = _a.getValue, setValue = _a.setValue;
  13381. Ext.form.field.Checkbox.override({
  13382. constructor: function (config) {
  13383. var newConfig = _.defaultsDeep({
  13384. // 强制属性
  13385. }, baseConfig(config, 'col-item'), config, checkbox);
  13386. cc.call(this, newConfig);
  13387. },
  13388. getValue: function () {
  13389. var _a = this, checkedValue = _a.checkedValue, uncheckedValue = _a.uncheckedValue;
  13390. var ov = getValue.call(this);
  13391. // const ov = this.getRawValue()
  13392. return (ov ? checkedValue : uncheckedValue);
  13393. },
  13394. setValue: function (nv) {
  13395. var _a = this, checkedValue = _a.checkedValue, uncheckedValue = _a.uncheckedValue;
  13396. var value;
  13397. if (nv === checkedValue) {
  13398. value = true;
  13399. }
  13400. else if (nv === uncheckedValue) {
  13401. value = false;
  13402. }
  13403. else {
  13404. value = !!nv;
  13405. }
  13406. // me.setRawValue(value)
  13407. // me.checked = value
  13408. // return me.mixins.field.setValue.call(me, value);
  13409. setValue.call(this, value);
  13410. },
  13411. updateCheckedCls: function (checked) {
  13412. var me = this;
  13413. var _a = this, uncheckedValue = _a.uncheckedValue, checkedValue = _a.checkedValue;
  13414. checked = checked != null ? checked : me.getValue();
  13415. if (checked === uncheckedValue) {
  13416. checked = false;
  13417. }
  13418. else if (checked === checkedValue) {
  13419. checked = true;
  13420. }
  13421. me[checked ? 'addCls' : 'removeCls'](me.checkedCls);
  13422. },
  13423. initComponent: function () {
  13424. initComponent.call(this);
  13425. },
  13426. });
  13427. }
  13428. function initCheckboxGroup () {
  13429. var cc = Ext.form.CheckboxGroup.prototype.constructor;
  13430. var initComponent = Ext.form.CheckboxGroup.prototype.initComponent;
  13431. Ext.form.CheckboxGroup.override({
  13432. constructor: function (config) {
  13433. var newConfig = _.defaultsDeep({
  13434. // 强制属性
  13435. }, baseConfig(config, 'col-item'), config, checkboxgroup);
  13436. cc.call(this, newConfig);
  13437. },
  13438. initComponent: function () {
  13439. initComponent.call(this);
  13440. },
  13441. });
  13442. }
  13443. function initRadio () {
  13444. var cc = Ext.form.field.Radio.prototype.constructor;
  13445. var initComponent = Ext.form.field.Radio.prototype.initComponent;
  13446. Ext.form.field.Radio.override({
  13447. constructor: function (config) {
  13448. var newConfig = _.defaultsDeep({
  13449. // 强制属性
  13450. }, baseConfig(config, 'col-item'), config, radio);
  13451. cc.call(this, newConfig);
  13452. },
  13453. initComponent: function () {
  13454. initComponent.call(this);
  13455. },
  13456. });
  13457. }
  13458. function initRadioGroup () {
  13459. var cc = Ext.form.RadioGroup.prototype.constructor;
  13460. var initComponent = Ext.form.RadioGroup.prototype.initComponent;
  13461. Ext.form.RadioGroup.override({
  13462. constructor: function (config) {
  13463. var newConfig = _.defaultsDeep({
  13464. // 强制属性
  13465. }, baseConfig(config, 'col-item'), config, radiogroup);
  13466. cc.call(this, newConfig);
  13467. },
  13468. initComponent: function () {
  13469. initComponent.call(this);
  13470. },
  13471. });
  13472. }
  13473. function initFieldset () {
  13474. /**
  13475. *
  13476. */
  13477. var ct = Ext.form.FieldSet.prototype.constructor;
  13478. Ext.form.FieldSet.override({
  13479. constructor: function (config) {
  13480. var newConfig = _.defaultsDeep({}, config, baseConfig(config, "rows-container"), fieldSet);
  13481. ct.call(this, newConfig);
  13482. }
  13483. });
  13484. }
  13485. function initCombotree () {
  13486. Ext.define('Yvan.ComboTree', {
  13487. extend: 'Ext.form.field.Picker',
  13488. xtype: 'combotree',
  13489. triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',
  13490. config: {
  13491. store: null,
  13492. displayField: null,
  13493. columns: null,
  13494. selectOnTab: true,
  13495. maxPickerHeight: 300,
  13496. minPickerHeight: 100,
  13497. minPickerWidth: 350,
  13498. rootVisible: true,
  13499. },
  13500. editable: false,
  13501. setStore: function (store) {
  13502. this.store = store;
  13503. var me = this;
  13504. if (me.store) {
  13505. if (me.picker) {
  13506. me.picker.setStore(store);
  13507. if (me.isExpanded) {
  13508. me.collapse();
  13509. delete me.picker;
  13510. me.expand();
  13511. }
  13512. }
  13513. this.onLoad();
  13514. me.mon(me.store, {
  13515. scope: me,
  13516. load: me.onLoad,
  13517. update: me.onUpdate
  13518. });
  13519. }
  13520. },
  13521. createPicker: function () {
  13522. var me = this;
  13523. var picker = new Ext.tree.Panel({
  13524. border: false,
  13525. baseCls: Ext.baseCSSPrefix + 'boundlist',
  13526. shrinkWrapDock: 2,
  13527. store: me.store,
  13528. floating: true,
  13529. rootVisible: me.rootVisible,
  13530. displayField: me.displayField,
  13531. columns: me.columns,
  13532. minHeight: me.minPickerHeight,
  13533. maxHeight: me.maxPickerHeight,
  13534. minWidth: me.minPickerWidth,
  13535. manageHeight: false,
  13536. shadow: false,
  13537. scrollable: true,
  13538. // modal: true,
  13539. // constrain: true,
  13540. // constrainTo: topScope._handle.el.dom,
  13541. // renderTo: topScope._handle.el.dom,
  13542. // alignTarget: topScope._handle,
  13543. listeners: {
  13544. scope: me,
  13545. itemclick: me.onItemClick,
  13546. itemkeydown: me.onPickerKeyDown
  13547. }
  13548. }), view = picker.getView();
  13549. if (Ext.isIE9 && Ext.isStrict) {
  13550. view.on({
  13551. scope: me,
  13552. highlightitem: me.repaintPickerView,
  13553. unhighlightitem: me.repaintPickerView,
  13554. afteritemexpand: me.repaintPickerView,
  13555. afteritemcollapse: me.repaintPickerView
  13556. });
  13557. }
  13558. return picker;
  13559. },
  13560. repaintPickerView: function () {
  13561. var style = this.picker.getView().getEl().dom.style;
  13562. style.display = style.display;
  13563. },
  13564. onItemClick: function (view, record, node, rowIndex, e) {
  13565. this.selectItem(view, record);
  13566. },
  13567. onPickerKeyDown: function (treeView, record, item, index, e) {
  13568. var key = e.getKey();
  13569. if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
  13570. this.selectItem(treeView, record);
  13571. }
  13572. },
  13573. selectItem: function (sender, record) {
  13574. var me = this;
  13575. me.setValue(record.getId());
  13576. me.fireEvent('select', me, record);
  13577. me.collapse();
  13578. },
  13579. onExpand: function () {
  13580. var picker = this.picker;
  13581. var store = picker.store;
  13582. var value = this.value;
  13583. var node;
  13584. if (value) {
  13585. node = store.getNodeById(value);
  13586. }
  13587. if (!node) {
  13588. node = store.getRoot();
  13589. }
  13590. picker.ensureVisible(node, {
  13591. select: true,
  13592. focus: true
  13593. });
  13594. },
  13595. setValue: function (value) {
  13596. var me = this;
  13597. console.log('setValue', value);
  13598. me.value = value;
  13599. if (!me.store || me.store.loading) {
  13600. // Called while the Store is loading. Ensure it is processed by the onLoad method.
  13601. return me.mixins.field.setValue.call(me, value);
  13602. // return me;
  13603. }
  13604. var record = value ? me.store.getNodeById(value) : me.store.getRoot();
  13605. if (value === undefined) {
  13606. record = me.store.getRoot();
  13607. console.log('setValue', record.getId());
  13608. me.value = record.getId();
  13609. return me.mixins.field.setValue.call(me, value);
  13610. }
  13611. else {
  13612. record = me.store.getNodeById(value);
  13613. }
  13614. // set the raw value to the record's display field if a record was found
  13615. me.setRawValue(record ? record.get(me.displayField) : '');
  13616. return me.mixins.field.setValue.call(me, value);
  13617. },
  13618. getSubmitValue: function () {
  13619. return this.value;
  13620. },
  13621. getValue: function () {
  13622. return this.value;
  13623. },
  13624. onLoad: function () {
  13625. var value = this.value;
  13626. if (value) {
  13627. this.setValue(value);
  13628. }
  13629. },
  13630. onUpdate: function (store, rec, type, modifiedFieldNames) {
  13631. var display = this.displayField;
  13632. var me = this;
  13633. if (type === 'edit' && modifiedFieldNames &&
  13634. Ext.Array.contains(modifiedFieldNames, display) &&
  13635. this.value === rec.getId()) {
  13636. me.mixins.field.setValue.call(me, this.value);
  13637. this.setRawValue(rec.get(display));
  13638. }
  13639. }
  13640. });
  13641. }
  13642. function initPickerPlus () {
  13643. Ext.define('Yvan.PickerAlignCenter', {
  13644. extend: 'Ext.form.field.Picker',
  13645. /**
  13646. * Performs the alignment on the picker using the class defaults
  13647. * @private
  13648. */
  13649. doAlign: function () {
  13650. // 不要挪动就好
  13651. },
  13652. });
  13653. }
  13654. function initCombogrid () {
  13655. Ext.define('Yvan.ComboGrid', {
  13656. extend: 'Ext.form.field.Picker',
  13657. // extend: 'Yvan.PickerAlignCenter',
  13658. xtype: 'combogrid',
  13659. triggerCls: Ext.baseCSSPrefix + 'form-search-trigger',
  13660. triggers: {
  13661. clear: {
  13662. weight: 0,
  13663. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  13664. hidden: true,
  13665. handler: 'onClearClick',
  13666. },
  13667. },
  13668. config: __assign({}, comboGrid),
  13669. editable: true,
  13670. _superBlur: false,
  13671. allowCustomInput: false,
  13672. pressEnterPopup: true,
  13673. initComponent: function () {
  13674. var that = this;
  13675. if (window["IS_DESIGN_MODE"]) {
  13676. this.superclass.initComponent.call(this, arguments);
  13677. return;
  13678. }
  13679. this.on({
  13680. blur: function (sender, e) {
  13681. if (this._superBlur) {
  13682. // 挂起时不恢复内容
  13683. return;
  13684. }
  13685. // 离开焦点时,恢复原来的值
  13686. sender.setRawValue(sender.value);
  13687. },
  13688. afterrender: function (sender) {
  13689. var $dom = $(sender.inputEl.dom);
  13690. that.scope = lookupScope(sender);
  13691. if (sender.column) {
  13692. // 列模式,拦截 keydown
  13693. $dom.on('keydown', function (e) {
  13694. if (isChartEvent(e) && !that.tryEnable()) {
  13695. // 没有达成 editEnable 条件,不用响应
  13696. stopEvent(e);
  13697. return;
  13698. }
  13699. if (that.pressEnterPopup !== false && e.key === 'Enter') {
  13700. stopEvent(e);
  13701. that.onTriggerClick(that, that.getPickerTrigger(), e);
  13702. return;
  13703. }
  13704. });
  13705. }
  13706. else {
  13707. // 常规模式,拦截 keyup
  13708. $dom.on('keyup', function (e) {
  13709. if (e.key === 'Escape' || e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
  13710. return;
  13711. }
  13712. if (isChartEvent(e) && !that.tryEnable()) {
  13713. // 没有达成 editEnable 条件,不用响应
  13714. stopEvent(e);
  13715. return;
  13716. }
  13717. if (that.pressEnterPopup !== false && e.key === 'Enter') {
  13718. stopEvent(e);
  13719. that.onTriggerClick(that, that.getPickerTrigger(), e);
  13720. return;
  13721. }
  13722. if (!that.allowCustomInput) {
  13723. // 取消 keyup 事件,让 ext 不要吧当前输入的值记录到 value 中
  13724. stopEvent(e);
  13725. }
  13726. });
  13727. $dom.on('change', function (e) {
  13728. // 这里注释掉,是因为 当鼠标点击触发弹出后,会导致取"e.target.value"值无效
  13729. // if (that.isExpanded) {
  13730. // that.filterChange(that, e.target.value)
  13731. // }
  13732. stopEvent(e);
  13733. });
  13734. }
  13735. $dom.on('input', function (e) {
  13736. stopEvent(e);
  13737. });
  13738. },
  13739. });
  13740. this.superclass.initComponent.apply(this, arguments);
  13741. },
  13742. createPicker: function () {
  13743. var me = this;
  13744. var cfg = {
  13745. layout: 'fit',
  13746. border: 5,
  13747. style: {
  13748. borderColor: 'black',
  13749. borderWidth: '5px',
  13750. borderStyle: 'solid'
  13751. },
  13752. shadow: 'side',
  13753. shadowOffset: 100,
  13754. baseCls: Ext.baseCSSPrefix + 'boundlist',
  13755. shrinkWrapDock: 2,
  13756. floating: true,
  13757. width: me.pickerWidth,
  13758. height: me.pickerHeight,
  13759. minWidth: me.pickerWidth,
  13760. minHeight: me.pickerHeight,
  13761. maxWidth: me.pickerWidth,
  13762. maxHeight: me.pickerHeight,
  13763. items: [
  13764. __assign(__assign(__assign({}, comboGridPicker), me.grid), { tbar: {
  13765. xtype: 'toolbar',
  13766. items: [
  13767. { xtype: 'textfield', fieldLabel: '筛选' },
  13768. {
  13769. xtype: 'button',
  13770. text: '查询',
  13771. iconCls: 'x-fa fa-search',
  13772. cssType: 'primary',
  13773. listeners: {
  13774. click: function () {
  13775. me.reloadGrid();
  13776. }
  13777. }
  13778. },
  13779. ]
  13780. }, autoLoad: false, listeners: {
  13781. afterrender: function (grid) {
  13782. me.grid = grid;
  13783. grid.focus();
  13784. grid.on({
  13785. rowdblclick: function (sender, row) {
  13786. me.selectItem(row);
  13787. },
  13788. dataLoadComplete: function (sender) {
  13789. _.defer(function () {
  13790. me.setFocus();
  13791. });
  13792. },
  13793. keydown: function (sender, e) {
  13794. if (me.column) {
  13795. // 列模式,拦截 keydown
  13796. me.processKey(e);
  13797. }
  13798. },
  13799. keyup: function (sender, e) {
  13800. if (!me.column) {
  13801. // 常规模式,拦截 keyup
  13802. me.processKey(e);
  13803. }
  13804. }
  13805. });
  13806. },
  13807. } })
  13808. ]
  13809. };
  13810. // @ts-ignore
  13811. var picker = new Ext.container.Container(cfg);
  13812. return picker;
  13813. },
  13814. setFocus: function () {
  13815. if (this.grid.store.getCount() > 0) {
  13816. this.grid.focusRow(0);
  13817. }
  13818. },
  13819. processKey: function (e) {
  13820. if (this.pressEnterPopup !== false && e.key === 'Enter') {
  13821. this.selectItem(this.grid.selection);
  13822. stopEvent(e);
  13823. }
  13824. else if (e.key === 'Escape') {
  13825. this.collapse();
  13826. }
  13827. },
  13828. repaintPickerView: function () {
  13829. var style = this.picker.getView().getEl().dom.style;
  13830. style.display = style.display;
  13831. },
  13832. onItemClick: function (view, record, node, rowIndex, e) {
  13833. this.selectItem(record);
  13834. },
  13835. onPickerKeyDown: function (treeView, record, item, index, e) {
  13836. var key = e.getKey();
  13837. if ((this.pressEnterPopup !== false && key === e.ENTER) || (key === e.TAB && this.selectOnTab)) {
  13838. this.selectItem(record);
  13839. }
  13840. },
  13841. filterChange: _.debounce(function (sender, value) {
  13842. sender.onExpand();
  13843. }, 1000),
  13844. selectItem: function (record) {
  13845. var me = this;
  13846. var lookup = this.lookup;
  13847. var scope = lookupScope(this);
  13848. me.fireEvent('select', me, record);
  13849. if (record.isModel) {
  13850. record = record.data;
  13851. }
  13852. tryWriteObject(lookup, record, function (path, value) {
  13853. me._lookupSet(path, value);
  13854. });
  13855. // lookup
  13856. // fromColumn: 'toTarget'
  13857. // fromColumn: 'toTarget'
  13858. // fromColumn: 'toTarget'
  13859. _.forOwn(lookup, function (toTarget, fromColumn) {
  13860. var value = _.get(record, fromColumn);
  13861. me._lookupSet(toTarget, value);
  13862. });
  13863. // 选定之后不能做清空
  13864. // const {lookupClearOnChange} = me
  13865. // if (_.isArray(lookupClearOnChange)) {
  13866. // _.each(lookupClearOnChange, item => {
  13867. // me._lookupSet(item, '')
  13868. // })
  13869. // }
  13870. me.collapse();
  13871. // 触发 _raiseNextFocus
  13872. me._raiseNextFocus(me);
  13873. },
  13874. onExpand: function () {
  13875. // 展开时,根据 lookup 带入查询参数
  13876. var expressData = this.getExpressData();
  13877. var txtField = this.grid.down('toolbar').down('textfield');
  13878. txtField.setValue(expressData.queryValue);
  13879. this.reloadGrid();
  13880. },
  13881. reloadGrid: function () {
  13882. // 展开时,根据 lookup 带入查询参数
  13883. var expressData = this.getExpressData();
  13884. var reloadParam = calcObjectFlat(expressData, this.param) || {};
  13885. var txtField = this.grid.down('toolbar').down('textfield');
  13886. // 每个 combogrid 默认带上 __queryValue 属性
  13887. reloadParam["__queryValue"] = txtField.getValue();
  13888. this.grid.reload(reloadParam);
  13889. },
  13890. onTriggerClick: function (sender) {
  13891. var _a = this, isExpanded = _a.isExpanded, readOnly = _a.readOnly, disabled = _a.disabled, grid = _a.grid;
  13892. if (!grid) {
  13893. msg('正在初始化,请稍后');
  13894. return;
  13895. }
  13896. if (!this.tryEnable()) {
  13897. // 没有达成 editEnable 条件,不用弹出
  13898. return;
  13899. }
  13900. if (isExpanded || readOnly || disabled) {
  13901. // 已弹出、只读、禁用状态下,不允许弹出
  13902. return;
  13903. }
  13904. this._superBlur = true;
  13905. this.superclass.onTriggerClick.apply(this, arguments);
  13906. this._superBlur = false;
  13907. },
  13908. onCollapse: function () {
  13909. // 每次收回时,删除下拉组件
  13910. // delete this.picker
  13911. },
  13912. /**
  13913. * 本方法只会从 API 或外部调用,键盘输入的内容不会记录在内
  13914. */
  13915. setValue: function (value) {
  13916. var me = this;
  13917. // 设值用户看到的表面内容
  13918. this.setRawValue(value);
  13919. // 设值 setValue 调用链,正常触发 change 事件等
  13920. return me.mixins.field.setValue.call(me, value);
  13921. },
  13922. _lookupSet: function (path, value) {
  13923. var me = this;
  13924. path = tryVarSimple(path);
  13925. if (me.column) {
  13926. // 判断写入目标,是否与自己绑定的属性相等
  13927. if (path === 'queryValue' || me.column.dataIndex === path) {
  13928. me.setValue(value);
  13929. }
  13930. // 列模式下,写当前编辑行
  13931. var parentRecord = me._lookupEditorRecord();
  13932. if (parentRecord) {
  13933. // Ext.data.Record / Ext.data.Model
  13934. parentRecord.set(path, value);
  13935. }
  13936. else {
  13937. debugger;
  13938. }
  13939. }
  13940. else {
  13941. // 常规模式下,写 viewModel
  13942. me.scope.viewModel.set(path, value);
  13943. }
  13944. },
  13945. _lookupGrid: function () {
  13946. return this.column.up('grid');
  13947. },
  13948. _lookupEditorRecord: function () {
  13949. var _a, _b, _c, _d;
  13950. // parentGrid.getSelectionModel().getLastSelected()
  13951. var grid = this._lookupGrid();
  13952. var editingPlugin = (_a = grid.editingPlugin) !== null && _a !== void 0 ? _a : (_b = grid.ownerGrid) === null || _b === void 0 ? void 0 : _b.editingPlugin;
  13953. if (!editingPlugin) {
  13954. return grid.getSelectionModel().getLastSelected();
  13955. }
  13956. var rowIdx = (_d = (_c = editingPlugin.activeEditor) === null || _c === void 0 ? void 0 : _c.context) === null || _d === void 0 ? void 0 : _d.rowIdx;
  13957. if (_.isNumber(rowIdx)) {
  13958. return grid.store.getAt(rowIdx);
  13959. }
  13960. else {
  13961. return grid.getSelectionModel().getLastSelected();
  13962. }
  13963. },
  13964. onChange: function (newVal, oldVal) {
  13965. var me = this;
  13966. var value = newVal;
  13967. var hideTrigger = me.hideTrigger, disabled = me.disabled, readOnly = me.readOnly, hideClear = me.hideClear;
  13968. if (hideTrigger || disabled || readOnly || hideClear) {
  13969. // 禁用、隐藏、只读、隐藏清空状态下,不需要显示清空按钮
  13970. return;
  13971. }
  13972. if (value) {
  13973. me.getTrigger('clear').show();
  13974. me.updateLayout();
  13975. }
  13976. else {
  13977. me.getTrigger('clear').hide();
  13978. me.updateLayout();
  13979. }
  13980. },
  13981. /**
  13982. * 得到能用于 express 表达式计算的上下文数据
  13983. */
  13984. getExpressData: function () {
  13985. var queryValue = this.getRawValue();
  13986. if (this.column) {
  13987. // 列模式, 准备好判断 editEnable 表达式用的数据
  13988. var parentRecord = this._lookupEditorRecord();
  13989. if (!parentRecord) {
  13990. debugger;
  13991. }
  13992. return __assign(__assign(__assign({}, this.scope.viewModel.data), parentRecord.data), { queryValue: queryValue });
  13993. }
  13994. else {
  13995. // 编辑模式,准备好判断用的数据
  13996. return __assign(__assign({}, this.scope.viewModel.data), { queryValue: queryValue });
  13997. }
  13998. },
  13999. tryEnable: function () {
  14000. return tryEnable(this.getExpressData(), this.editEnable);
  14001. },
  14002. /**
  14003. * 清空所有值
  14004. */
  14005. onClearClick: function (sender, e) {
  14006. var me = this;
  14007. var lookup = me.lookup, lookupClearOnChange = me.lookupClearOnChange;
  14008. me.fireEvent('clear', sender, e);
  14009. me.setValue('');
  14010. _.forOwn(lookup, function (toTarget, fromColumn) {
  14011. me._lookupSet(toTarget, '');
  14012. });
  14013. _.each(lookupClearOnChange, function (item) {
  14014. me._lookupSet(item, '');
  14015. });
  14016. }
  14017. });
  14018. }
  14019. function initRows () {
  14020. Ext.define('Yvan.Rows', {
  14021. extend: 'Ext.container.Container',
  14022. xtype: 'rows',
  14023. constructor: function (config) {
  14024. var self = this;
  14025. var newConfig = _.defaultsDeep({
  14026. // 强制性属性
  14027. layout: 'anchor', border: false,
  14028. defaults: {
  14029. border: false, anchor: '100%',
  14030. margin: '0 0 5 0',
  14031. },
  14032. }, baseConfig(config, 'rows-container'), config, rows);
  14033. this.superclass.constructor.call(self, newConfig);
  14034. },
  14035. });
  14036. }
  14037. function initForm () {
  14038. var ct = Ext.form.Panel.prototype.constructor;
  14039. Ext.form.Panel.override({
  14040. constructor: function (config) {
  14041. var newConfig = _.defaultsDeep({}, config, baseConfig(config, "cols-container"), form);
  14042. ct.call(this, newConfig);
  14043. }
  14044. });
  14045. }
  14046. function initCols () {
  14047. Ext.define('Yvan.Cols', {
  14048. extend: 'Ext.container.Container',
  14049. xtype: 'cols',
  14050. constructor: function (config) {
  14051. var self = this;
  14052. var newConfig = _.defaultsDeep({
  14053. // 强制性属性
  14054. layout: 'hbox',
  14055. minHeight: config.designMode ? 32 : 0
  14056. }, baseConfig(config, 'cols-container'), config, cols);
  14057. this.superclass.constructor.call(self, newConfig);
  14058. },
  14059. });
  14060. }
  14061. function initButton () {
  14062. /**
  14063. *
  14064. */
  14065. var ct = Ext.button.Button.prototype.constructor;
  14066. Ext.button.Button.override({
  14067. constructor: function (config) {
  14068. var newConfig = _.defaultsDeep({}, config, baseConfig(config, "col-item"), button);
  14069. ct.call(this, newConfig);
  14070. },
  14071. setLoading: function (value) {
  14072. if (value) {
  14073. if (this.iconCls !== 'x-fa fa-spinner fa-spin fa-fw') {
  14074. this._originIconCls = this.iconCls;
  14075. }
  14076. this.setIconCls('x-fa fa-spinner fa-spin fa-fw');
  14077. this.setDisabled(true);
  14078. }
  14079. else {
  14080. this.setIconCls(this._originIconCls);
  14081. this.setDisabled(false);
  14082. }
  14083. }
  14084. });
  14085. }
  14086. function initIframe () {
  14087. Ext.define('Ext.ux.IFrame', {
  14088. extend: 'Ext.Component',
  14089. alias: 'widget.uxiframe',
  14090. loadMask: 'Loading...',
  14091. src: 'about:blank',
  14092. renderTpl: [
  14093. '<iframe src="{src}" id="{id}-iframeEl" data-ref="iframeEl" name="{frameName}" width="100%" height="100%" frameborder="0"></iframe>'
  14094. ],
  14095. childEls: ['iframeEl'],
  14096. initComponent: function () {
  14097. this.superclass.initComponent.call(this);
  14098. this.superclass.initEvents.call(this);
  14099. this.frameName = this.frameName || this.id + '-frame';
  14100. },
  14101. initEvents: function () {
  14102. var me = this;
  14103. this.superclass.initEvents.call(this);
  14104. me.iframeEl.on('load', me.onLoad, me);
  14105. },
  14106. initRenderData: function () {
  14107. return Ext.apply(this.superclass.initRenderData.call(this), {
  14108. src: this.src,
  14109. frameName: this.frameName
  14110. });
  14111. },
  14112. getBody: function () {
  14113. var doc = this.getDoc();
  14114. return doc.body || doc.documentElement;
  14115. },
  14116. getDoc: function () {
  14117. try {
  14118. return this.getWin().document;
  14119. }
  14120. catch (ex) {
  14121. return null;
  14122. }
  14123. },
  14124. getWin: function () {
  14125. var me = this, name = me.frameName, win = Ext.isIE ? me.iframeEl.dom.contentWindow : window.frames[name];
  14126. return win;
  14127. },
  14128. getFrame: function () {
  14129. var me = this;
  14130. return me.iframeEl.dom;
  14131. },
  14132. onLoad: function () {
  14133. var me = this, doc = me.getDoc();
  14134. if (doc) {
  14135. this.el.unmask();
  14136. this.fireEvent('load', this);
  14137. }
  14138. else if (me.src) {
  14139. this.el.unmask();
  14140. this.fireEvent('error', this);
  14141. }
  14142. },
  14143. load: function (src) {
  14144. var me = this, text = me.loadMask, frame = me.getFrame();
  14145. if (me.fireEvent('beforeload', me, src) !== false) {
  14146. if (text && me.el) {
  14147. me.el.mask(text);
  14148. }
  14149. frame.src = me.src = (src || me.src);
  14150. }
  14151. }
  14152. });
  14153. }
  14154. /**
  14155. * 属性:
  14156. * - autoLoad: true
  14157. * - dataSource: ''
  14158. * 方法:
  14159. * - handleZoomBig
  14160. * - handleZoomSmall
  14161. * - handleZoomReset
  14162. * - openDiagram
  14163. * - getBpmn
  14164. * - getBpmnCanvas
  14165. * - getBpmnOverlays
  14166. * - getBpmnZoomScroll
  14167. * 事件:
  14168. * - initFinish
  14169. * - failed
  14170. * - success
  14171. * - itemHover
  14172. * - itemOut
  14173. * - itemClick
  14174. * - itemDblclick
  14175. * - itemMousedown
  14176. * - itemMouseup
  14177. */
  14178. function initBpmn () {
  14179. Ext.define('Yvan.Bpmn', {
  14180. // extend: 'Ext.container.Container',
  14181. extend: 'Ext.panel.Panel',
  14182. alias: 'widget.bpmn',
  14183. xtype: 'bpmn',
  14184. constructor: function (config) {
  14185. var self = this;
  14186. var newConfig = _.defaultsDeep({
  14187. // 强制性属性
  14188. }, baseConfig(config, 'row-item'), config, bpmn);
  14189. if (!newConfig.hideToolbar) {
  14190. newConfig.tbar = [];
  14191. newConfig.tbar.push({
  14192. xtype: 'button', iconCls: 'x-fa fa-refresh', tooltip: '刷新',
  14193. listeners: {
  14194. click: function (sender) {
  14195. self.reload();
  14196. }
  14197. }
  14198. });
  14199. newConfig.tbar.push({
  14200. xtype: 'button', tooltip: "放大", iconCls: "x-fa fa-search-plus",
  14201. listeners: {
  14202. click: function (sender) {
  14203. self.handleZoomBig();
  14204. }
  14205. },
  14206. });
  14207. newConfig.tbar.push({
  14208. xtype: 'button', tooltip: "缩小", iconCls: "x-fa fa-search-minus",
  14209. listeners: {
  14210. click: function (sender) {
  14211. self.handleZoomSmall();
  14212. }
  14213. },
  14214. });
  14215. newConfig.tbar.push({
  14216. xtype: 'button', tooltip: "还原", iconCls: "x-fa fa-reply",
  14217. listeners: {
  14218. click: function (sender) {
  14219. self.handleZoomReset();
  14220. }
  14221. },
  14222. });
  14223. }
  14224. this.superclass.constructor.call(self, newConfig);
  14225. },
  14226. initComponent: function () {
  14227. var _this = this;
  14228. var me = this;
  14229. var config = me.config;
  14230. var scope = lookupScope(this);
  14231. if (!window["IS_DESIGN_MODE"]) {
  14232. //@ts-ignore
  14233. require(['bpmn-modeler', 'bpmn-navigated', 'bpmn-viewer'], function (BpModeler, BpNavigated, BpmnViewer) {
  14234. console.log('BpNavigated', me, BpNavigated);
  14235. var dom = me.el.dom;
  14236. var $dom = $(dom);
  14237. var $container = $dom.find('.x-autocontainer-innerCt');
  14238. var bpmn = new BpNavigated(__assign({ container: $container[0] }, config.bpmnConfig));
  14239. _this._bpmn = bpmn;
  14240. if (_this.autoLoad) {
  14241. _this.reload();
  14242. }
  14243. _this.fireEvent('initFinish', _this);
  14244. var eventBus = bpmn.get('eventBus');
  14245. eventBus.on('element.hover', function (e) {
  14246. // this.fireEvent('itemHover', this, e);
  14247. });
  14248. eventBus.on('element.out', function (e) {
  14249. _this.fireEvent('itemOut', _this, e);
  14250. });
  14251. eventBus.on('element.click', function (e) {
  14252. _this.fireEvent('itemClick', _this, e);
  14253. });
  14254. eventBus.on('element.dblclick', function (e) {
  14255. _this.fireEvent('itemDblclick', _this, e);
  14256. });
  14257. eventBus.on('element.mousedown', function (e) {
  14258. _this.fireEvent('itemMousedown', _this, e);
  14259. });
  14260. eventBus.on('element.mouseup', function (e) {
  14261. _this.fireEvent('itemMouseup', _this, e);
  14262. });
  14263. });
  14264. }
  14265. this.superclass.initComponent.call(this);
  14266. this.on({
  14267. afterrender: function (sender) {
  14268. if (window["IS_DESIGN_MODE"]) {
  14269. return;
  14270. }
  14271. }
  14272. });
  14273. },
  14274. /**
  14275. * 重新载入
  14276. */
  14277. reload: function () {
  14278. var _this = this;
  14279. var _a;
  14280. if (typeof this.dataSource === 'string' && this.dataSource) {
  14281. var scope = lookupScope(this);
  14282. var fn = lookupFn(scope, this.dataSource);
  14283. (_a = fn.call(scope, this)) === null || _a === void 0 ? void 0 : _a.then(function (res) {
  14284. _this.openDiagram(res.data);
  14285. });
  14286. }
  14287. },
  14288. /**
  14289. * 获取bpmn
  14290. */
  14291. getBpmn: function () {
  14292. return this._bpmn;
  14293. },
  14294. getBpmnCanvas: function () {
  14295. var _a;
  14296. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('canvas');
  14297. },
  14298. getBpmnOverlays: function () {
  14299. var _a;
  14300. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('overlays');
  14301. },
  14302. getBpmnZoomScroll: function () {
  14303. var _a;
  14304. return (_a = this.getBpmn()) === null || _a === void 0 ? void 0 : _a.get('zoomScroll');
  14305. },
  14306. handleZoomBig: function () {
  14307. var _a;
  14308. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(1);
  14309. },
  14310. handleZoomSmall: function () {
  14311. var _a;
  14312. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.stepZoom(-1);
  14313. },
  14314. handleZoomReset: function () {
  14315. var _a;
  14316. (_a = this.getBpmnZoomScroll()) === null || _a === void 0 ? void 0 : _a.reset();
  14317. },
  14318. openDiagram: function (diagram) {
  14319. var _this = this;
  14320. if (!this.getBpmn()) {
  14321. return;
  14322. }
  14323. this.getBpmn().importXML(diagram, function (err) {
  14324. if (err) {
  14325. // YvEventDispatch(this.onFailed, this, undefined);
  14326. _this.fireEvent('failed', _this, err);
  14327. return console.error('could not import BPMN 2.0 diagram', err);
  14328. }
  14329. // zoom to fit full viewport
  14330. _this.getBpmnCanvas().zoom('fit-viewport');
  14331. _this.fireEvent('success', _this);
  14332. });
  14333. },
  14334. });
  14335. }
  14336. var FixClass = /** @class */ (function () {
  14337. function FixClass() {
  14338. }
  14339. FixClass.prototype.fix = function (me, config) {
  14340. var _this = this;
  14341. var fix = config.fix;
  14342. if (!fix) {
  14343. return;
  14344. }
  14345. delete config.fix;
  14346. // 这里有个 bug
  14347. // 但凡是调用了 this.lookupViewModel() 就会出现绑定不了的情况
  14348. // const scope = config.$initParent.lookupReferenceHolder().yvanScope //lookupScope(me)
  14349. var scope;
  14350. if (config.$initParent) {
  14351. // 在面板上的组件
  14352. scope = config.$initParent.lookupReferenceHolder().yvanScope; //lookupScope(me)
  14353. }
  14354. else if (config.column) {
  14355. // 在列上的组件
  14356. scope = config.column.lookupReferenceHolder().yvanScope; //lookupScope(me)
  14357. }
  14358. if (_.isArray(fix)) {
  14359. _.each(fix, function (f) {
  14360. var fn = lookupFn(scope, f);
  14361. fn.call(_this, me, config);
  14362. });
  14363. }
  14364. else if (_.isString(fix)) {
  14365. var fn = lookupFn(scope, fix);
  14366. fn.call(this, me, config);
  14367. }
  14368. };
  14369. __decorate([
  14370. baseConfigProcess(),
  14371. __metadata("design:type", Function),
  14372. __metadata("design:paramtypes", [Object, Object]),
  14373. __metadata("design:returntype", void 0)
  14374. ], FixClass.prototype, "fix", null);
  14375. return FixClass;
  14376. }());
  14377. function init() {
  14378. // 引入 filters 过滤插件
  14379. Ext.require([
  14380. 'Ext.grid.filters.Filters'
  14381. ]);
  14382. // 启用 tooltip 快捷提示
  14383. Ext.QuickTips.init();
  14384. // 定义日期格式化方法
  14385. if (Ext.util && Ext.util.Format) {
  14386. Ext.apply(Ext.util.Format, {
  14387. dateFormat: 'Y-m-d'
  14388. });
  14389. }
  14390. Ext.form.field.Display.override({
  14391. cls: 'yvan-display-field',
  14392. labelAlign: 'right'
  14393. });
  14394. Ext.define("Ext.locale.zh_CN.picker.Date", {
  14395. override: "Ext.picker.Date",
  14396. format: "Y-m-d",
  14397. });
  14398. Ext.define("Ext.locale.zh_CN.form.field.Date", {
  14399. override: "Ext.form.field.Date",
  14400. format: "Y-m-d",
  14401. });
  14402. Ext.define("Ext.locale.zh_CN.grid.PropertyColumnModel", {
  14403. override: "Ext.grid.PropertyColumnModel",
  14404. format: "Y-m-d",
  14405. });
  14406. Ext.define("Ext.locale.zh_CN.view.AbstractView", {
  14407. override: "Ext.view.AbstractView",
  14408. loadingText: "读取中..."
  14409. });
  14410. Ext.LoadMask.prototype.msg = '请稍后...';
  14411. Ext.define("Ext.locale.zh_CN.grid.header.Container", {
  14412. override: "Ext.grid.header.Container",
  14413. sortClearText: '不排序',
  14414. sortAscText: "正序",
  14415. sortDescText: "倒序",
  14416. lockText: "锁定列",
  14417. unlockText: "解除锁定",
  14418. columnsText: "字段隐藏"
  14419. });
  14420. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Date", {
  14421. override: "Ext.grid.filters.filter.Date",
  14422. fields: {
  14423. lt: { text: '之前' },
  14424. gt: { text: '之后' },
  14425. eq: { text: '相等' },
  14426. },
  14427. // Defaults to Ext.Date.defaultFormat
  14428. dateFormat: null
  14429. });
  14430. // Ext.grid.locking.Lockable.prototype.unlockText = '解锁'
  14431. // Ext.grid.locking.Lockable.prototype.lockText = '锁定'
  14432. // Ext.grid.filters.Filters.prototype.menuFilterText = "过滤"
  14433. Ext.define("Ext.locale.zh_CN.grid.locking.Lockable", {
  14434. override: "Ext.grid.locking.Lockable",
  14435. lockText: "锁定",
  14436. unlockText: '解锁',
  14437. });
  14438. Ext.define("Ext.locale.zh_CN.grid.filters.Filters", {
  14439. override: "Ext.grid.filters.Filters",
  14440. menuFilterText: "过滤"
  14441. });
  14442. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Boolean", {
  14443. override: "Ext.grid.filters.filter.Boolean",
  14444. yesText: "已钩选",
  14445. noText: "未勾选"
  14446. });
  14447. Ext.define("Ext.locale.zh_CN.grid.filters.filter.String", {
  14448. override: "Ext.grid.filters.filter.String",
  14449. emptyText: "输入过滤文本..."
  14450. });
  14451. Ext.define("Ext.locale.zh_CN.grid.filters.filter.Number", {
  14452. override: "Ext.grid.filters.filter.Number",
  14453. emptyText: "输入数字..."
  14454. });
  14455. Ext.define("Ext.locale.zh_CN.toolbar.Paging", {
  14456. override: "Ext.PagingToolbar",
  14457. beforePageText: "第",
  14458. // update
  14459. afterPageText: "/ {0} 页",
  14460. // update
  14461. firstText: "第一页",
  14462. prevText: "上一页",
  14463. // update
  14464. nextText: "下一页",
  14465. lastText: "最后页",
  14466. refreshText: "刷新",
  14467. displayMsg: "总共 {2} 条",
  14468. // update
  14469. emptyMsg: '没有数据'
  14470. });
  14471. /**
  14472. * 改变事件的获取方式.
  14473. * 具体见: ext-all-debug.js:23216 addListener
  14474. * https://docs.sencha.com/extjs/6.6.0/classic/Ext.util.Observable.html#method-addListener
  14475. * https://docs.sencha.com/extjs/6.6.0/classic/src/Observable.js.html#Ext.mixin.Observable-method-addListener
  14476. */
  14477. var _doAddListener = Ext.mixin.Observable.prototype.doAddListener;
  14478. Ext.mixin.Observable.prototype.doAddListener = function (ename, fn, scope, options, order, caller, manager) {
  14479. if (typeof fn === 'string' &&
  14480. (_.startsWith(fn, 'scope.') ||
  14481. _.startsWith(fn, 'system.') ||
  14482. _.startsWith(fn, 'format.'))) {
  14483. if (window["IS_DESIGN_MODE"]) {
  14484. fn = Ext.emptyFn;
  14485. }
  14486. else {
  14487. // console.log('doAddListener', ename, fn, scope, options, order, caller, manager)
  14488. // const vm = this.lookupViewModel()
  14489. // if (vm && vm.yvanScope) {
  14490. // scope = vm.yvanScope
  14491. // fn = scope[fn.substr('scope.'.length)]
  14492. // }
  14493. scope = lookupScope(this);
  14494. fn = lookupFn(scope, fn, this);
  14495. }
  14496. }
  14497. _doAddListener.call(this, ename, fn, scope, options, order, caller, manager);
  14498. };
  14499. // 将 SystemLib 扩展到 window.system 下
  14500. if (!window['system']) {
  14501. window['system'] = {};
  14502. }
  14503. _.extend(window['system'], SystemLib);
  14504. Ext.apply(Ext.util.Format, {
  14505. // 百分比
  14506. percentRenderer: function (v, rd, model) {
  14507. if (!v) {
  14508. v = 0;
  14509. }
  14510. if (typeof v === 'string') {
  14511. v = parseInt(v);
  14512. }
  14513. var valueString = v.toFixed(2);
  14514. var valueFixed = v > 100 ? 100 : v;
  14515. valueFixed = valueFixed < 0 ? 0 : valueFixed;
  14516. var cls = '';
  14517. if (v < 90) {
  14518. cls = 'danger';
  14519. }
  14520. else if (v < 100) {
  14521. cls = 'warning';
  14522. }
  14523. else {
  14524. cls = 'success';
  14525. }
  14526. return Ext.String
  14527. .format(
  14528. // '<div>'
  14529. // + '<div style="float:left;width:100%; background:#ECECEC;border:none">'
  14530. // + '<div style="float:left;text-align:center;width:100%;color:#fff;line-height:24px;font-size:13px;">{0}%</div>'
  14531. // + '<div style="width:{1}%;height:24px;" class="progress-{2}"></div>'
  14532. // + '</div></div>', valueString, valueFixed, cls);
  14533. '<div class="x-progress x-progress-default x-widthed" style="width: 100%;"><div class="x-progress-text x-progress-text-back" style="width:100%;">{0}%</div><div class="x-progress-bar progress-{1}" style="width: {2}%;"><div class="x-progress-text" style="width: {3}%">{4}%</div></div></div>', valueString, cls, valueFixed, ((100 / valueFixed) * 100), valueString); // .format(
  14534. // '<div>'
  14535. // + '<div style="float:left;border:1px solid #008000;height:15px;width:100%;">'
  14536. // + '<div style="float:left;text-align:center;width:100%;color:blue;">{0}%</div>'
  14537. // + '<div style="background: #FAB2{2};width:{1}%;height:13px;"></div>'
  14538. // + '</div></div>', v, valueFixed, valueString);
  14539. },
  14540. //button
  14541. button: function (v, rd, model) {
  14542. return "<input style=\"color:#fff\" type=\"button\" value=\"" + v + "\" class=\"area-tag\" />";
  14543. }
  14544. });
  14545. initComponent();
  14546. initPanel();
  14547. initGridColumn();
  14548. initTree();
  14549. initGrid();
  14550. initMainTab();
  14551. initTextfield();
  14552. initCombo();
  14553. initRows();
  14554. initCols();
  14555. initForm();
  14556. initToolbar();
  14557. initSplitter();
  14558. initButton();
  14559. initStores();
  14560. initSearch();
  14561. initMultipleSearch();
  14562. initDate();
  14563. initDateTimePicker();
  14564. initDateTime();
  14565. initNumber();
  14566. initCheckbox();
  14567. initCheckboxGroup();
  14568. initRadio();
  14569. initRadioGroup();
  14570. initFieldset();
  14571. initCombotree();
  14572. initPickerPlus();
  14573. initCombogrid();
  14574. initComboGridMulti();
  14575. initIframe();
  14576. initBpmn();
  14577. }
  14578. exports.axios = axios;
  14579. exports.qs = Qs;
  14580. exports.lodash = _;
  14581. exports.jquery = $$1;
  14582. exports.recast = recast;
  14583. exports.Defaults = Defaults;
  14584. exports.ExcelImportDialog = ExcelImportDialog;
  14585. exports.Lib = Lib;
  14586. exports.LibParam = LibParam;
  14587. exports.PropertyDescriptionTable = PropertyDescriptionTable;
  14588. exports.ReportScope = ReportScope;
  14589. exports.SIMPLE_RE = SIMPLE_RE;
  14590. exports.Scope = Scope;
  14591. exports.ScopeEngine = ScopeEngine;
  14592. exports.SystemEventFu = SystemEventFu;
  14593. exports.ajax = ajax;
  14594. exports.baseConfigProcess = baseConfigProcess;
  14595. exports.baseConfigProcessList = baseConfigProcessList;
  14596. exports.buildReportScope = buildReportScope;
  14597. exports.calcExpress = calcExpress;
  14598. exports.calcObject = calcObject;
  14599. exports.calcObjectFlat = calcObjectFlat;
  14600. exports.clearViewModel = clearViewModel;
  14601. exports.clearViewModelByLookup = clearViewModelByLookup;
  14602. exports.clearViewModelReloadGrid = clearViewModelReloadGrid;
  14603. exports.clearViewModelValues = clearViewModelValues;
  14604. exports.confirm = confirm;
  14605. exports.createAjax = createAjax;
  14606. exports.createUUID = createUUID;
  14607. exports.downLoad = downLoad;
  14608. exports.evalFunction = evalFunction;
  14609. exports.extend = extend;
  14610. exports.flatRow = flatRow;
  14611. exports.getApiConvert = getApiConvert;
  14612. exports.getGridEditRows = getGridEditRows;
  14613. exports.getParentGrid = getParentGrid;
  14614. exports.getPinyin = getPinyin;
  14615. exports.getRegList = getRegList;
  14616. exports.getRegParamList = getRegParamList;
  14617. exports.init = init;
  14618. exports.invokeServer = invokeServer;
  14619. exports.isDesignMode = isDesignMode;
  14620. exports.isEmpty = isEmpty;
  14621. exports.json5 = dist;
  14622. exports.keywordFilter = keywordFilter;
  14623. exports.lookupFn = lookupFn;
  14624. exports.lookupScope = lookupScope;
  14625. exports.mergeViewModel = mergeViewModel;
  14626. exports.moment = moment$1;
  14627. exports.msg = msg$1;
  14628. exports.msgError = msgError;
  14629. exports.normId = normId;
  14630. exports.pinyinMatch = pinyinMatch;
  14631. exports.prompt = prompt$1;
  14632. exports.raiseClick = raiseClick;
  14633. exports.reloadGrid = reloadGrid;
  14634. exports.replaceNA = replaceNA;
  14635. exports.serverInvokeUrlTransform = serverInvokeUrlTransform;
  14636. exports.setComboStore = setComboStore;
  14637. exports.setDesignMode = setDesignMode;
  14638. exports.showErrorDialog = showErrorDialog$1;
  14639. exports.showInfoDialog = showInfoDialog;
  14640. exports.showWidget = showWidget;
  14641. exports.sqlUrlTransform = sqlUrlTransform;
  14642. exports.stopEvent = stopEvent;
  14643. exports.toPlainObject = toPlainObject;
  14644. exports.toString = toString;
  14645. exports.tryEnable = tryEnable;
  14646. exports.tryVarSimple = tryVarSimple;
  14647. exports.tryWriteByExpress = tryWriteByExpress;
  14648. exports.tryWriteObject = tryWriteObject;
  14649. exports.watch = watch;
  14650. Object.defineProperty(exports, '__esModule', { value: true });
  14651. });
  14652. //# sourceMappingURL=yvan-ext.js.map