ivprog.bundle.js 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["ivprogCore"] = factory();
  8. else
  9. root["ivprogCore"] = factory();
  10. })(window, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./js/main.js");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "./grammar/en/ivprog.g4":
  99. /*!******************************!*\
  100. !*** ./grammar/en/ivprog.g4 ***!
  101. \******************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports, __webpack_require__) {
  104. module.exports =
  105. /******/ (function(modules) { // webpackBootstrap
  106. /******/ // The module cache
  107. /******/ var installedModules = {};
  108. /******/
  109. /******/ // The require function
  110. /******/ function __webpack_require__(moduleId) {
  111. /******/
  112. /******/ // Check if module is in cache
  113. /******/ if(installedModules[moduleId]) {
  114. /******/ return installedModules[moduleId].exports;
  115. /******/ }
  116. /******/ // Create a new module (and put it into the cache)
  117. /******/ var module = installedModules[moduleId] = {
  118. /******/ i: moduleId,
  119. /******/ l: false,
  120. /******/ exports: {}
  121. /******/ };
  122. /******/
  123. /******/ // Execute the module function
  124. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  125. /******/
  126. /******/ // Flag the module as loaded
  127. /******/ module.l = true;
  128. /******/
  129. /******/ // Return the exports of the module
  130. /******/ return module.exports;
  131. /******/ }
  132. /******/
  133. /******/
  134. /******/ // expose the modules object (__webpack_modules__)
  135. /******/ __webpack_require__.m = modules;
  136. /******/
  137. /******/ // expose the module cache
  138. /******/ __webpack_require__.c = installedModules;
  139. /******/
  140. /******/ // identity function for calling harmony imports with the correct context
  141. /******/ __webpack_require__.i = function(value) { return value; };
  142. /******/
  143. /******/ // define getter function for harmony exports
  144. /******/ __webpack_require__.d = function(exports, name, getter) {
  145. /******/ if(!__webpack_require__.o(exports, name)) {
  146. /******/ Object.defineProperty(exports, name, {
  147. /******/ configurable: false,
  148. /******/ enumerable: true,
  149. /******/ get: getter
  150. /******/ });
  151. /******/ }
  152. /******/ };
  153. /******/
  154. /******/ // getDefaultExport function for compatibility with non-harmony modules
  155. /******/ __webpack_require__.n = function(module) {
  156. /******/ var getter = module && module.__esModule ?
  157. /******/ function getDefault() { return module['default']; } :
  158. /******/ function getModuleExports() { return module; };
  159. /******/ __webpack_require__.d(getter, 'a', getter);
  160. /******/ return getter;
  161. /******/ };
  162. /******/
  163. /******/ // Object.prototype.hasOwnProperty.call
  164. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  165. /******/
  166. /******/ // __webpack_public_path__
  167. /******/ __webpack_require__.p = "";
  168. /******/
  169. /******/ // Load entry module and return exports
  170. /******/ return __webpack_require__(__webpack_require__.s = 1);
  171. /******/ })
  172. /************************************************************************/
  173. /******/ ([
  174. /* 0 */
  175. /***/ (function(module, exports, __webpack_require__) {
  176. // Generated from /tmp/tmp-4052lmQUZHnfcPb1/ivprog.g4 by ANTLR 4.7
  177. // jshint ignore: start
  178. var antlr4 = __webpack_require__(2);
  179. var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
  180. "\u0002/\u01d1\b\u0001\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004",
  181. "\u0004\t\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t",
  182. "\u0007\u0004\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004",
  183. "\f\t\f\u0004\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010",
  184. "\t\u0010\u0004\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013",
  185. "\u0004\u0014\t\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017",
  186. "\t\u0017\u0004\u0018\t\u0018\u0004\u0019\t\u0019\u0004\u001a\t\u001a",
  187. "\u0004\u001b\t\u001b\u0004\u001c\t\u001c\u0004\u001d\t\u001d\u0004\u001e",
  188. "\t\u001e\u0004\u001f\t\u001f\u0004 \t \u0004!\t!\u0004\"\t\"\u0004#",
  189. "\t#\u0004$\t$\u0004%\t%\u0004&\t&\u0004\'\t\'\u0004(\t(\u0004)\t)\u0004",
  190. "*\t*\u0004+\t+\u0004,\t,\u0004-\t-\u0004.\t.\u0004/\t/\u00040\t0\u0004",
  191. "1\t1\u00042\t2\u00043\t3\u00044\t4\u00045\t5\u00046\t6\u00047\t7\u0004",
  192. "8\t8\u00049\t9\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003",
  193. "\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0003\u0003\u0003\u0003",
  194. "\u0003\u0003\u0003\u0003\u0003\u0003\u0004\u0003\u0004\u0003\u0004\u0003",
  195. "\u0004\u0003\u0004\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003",
  196. "\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0006\u0003\u0006\u0003",
  197. "\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003\u0007\u0003",
  198. "\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003",
  199. "\u0007\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003",
  200. "\b\u0003\b\u0003\b\u0003\t\u0003\t\u0003\t\u0003\t\u0003\t\u0003\t\u0003",
  201. "\t\u0003\n\u0003\n\u0003\n\u0003\n\u0003\n\u0003\u000b\u0003\u000b\u0003",
  202. "\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003",
  203. "\u000b\u0003\u000b\u0003\f\u0003\f\u0003\f\u0003\f\u0003\f\u0003\f\u0003",
  204. "\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003",
  205. "\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003",
  206. "\u000e\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u000f\u0003\u0010\u0003",
  207. "\u0010\u0003\u0010\u0003\u0010\u0003\u0010\u0003\u0010\u0003\u0011\u0003",
  208. "\u0011\u0003\u0011\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003",
  209. "\u0012\u0003\u0012\u0003\u0013\u0003\u0013\u0003\u0013\u0003\u0014\u0003",
  210. "\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003\u0015\u0003\u0015\u0003",
  211. "\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003\u0016\u0003\u0016\u0003",
  212. "\u0016\u0003\u0016\u0003\u0016\u0003\u0017\u0003\u0017\u0003\u0017\u0003",
  213. "\u0017\u0003\u0018\u0003\u0018\u0003\u0018\u0003\u0018\u0003\u0019\u0003",
  214. "\u0019\u0003\u0019\u0003\u001a\u0003\u001a\u0003\u001b\u0003\u001b\u0003",
  215. "\u001c\u0003\u001c\u0003\u001d\u0003\u001d\u0003\u001e\u0003\u001e\u0003",
  216. "\u001f\u0003\u001f\u0003 \u0003 \u0003!\u0003!\u0003\"\u0003\"\u0003",
  217. "#\u0003#\u0003$\u0003$\u0003%\u0003%\u0003&\u0003&\u0003&\u0003&\u0003",
  218. "&\u0003&\u0003&\u0003&\u0003&\u0005&\u0125\n&\u0003\'\u0003\'\u0003",
  219. "(\u0003(\u0003)\u0003)\u0007)\u012d\n)\f)\u000e)\u0130\u000b)\u0003",
  220. "*\u0003*\u0003*\u0003*\u0003+\u0006+\u0137\n+\r+\u000e+\u0138\u0003",
  221. "+\u0003+\u0003+\u0003+\u0005+\u013f\n+\u0003+\u0006+\u0142\n+\r+\u000e",
  222. "+\u0143\u0003+\u0003+\u0003+\u0003+\u0005+\u014a\n+\u0003+\u0006+\u014d",
  223. "\n+\r+\u000e+\u014e\u0005+\u0151\n+\u0003,\u0006,\u0154\n,\r,\u000e",
  224. ",\u0155\u0003,\u0003,\u0006,\u015a\n,\r,\u000e,\u015b\u0003,\u0006,",
  225. "\u015f\n,\r,\u000e,\u0160\u0003,\u0003,\u0007,\u0165\n,\f,\u000e,\u0168",
  226. "\u000b,\u0003,\u0005,\u016b\n,\u0003-\u0003-\u0005-\u016f\n-\u0003-",
  227. "\u0006-\u0172\n-\r-\u000e-\u0173\u0003.\u0003.\u0007.\u0178\n.\f.\u000e",
  228. ".\u017b\u000b.\u0003.\u0003.\u0003/\u0003/\u0005/\u0181\n/\u00030\u0003",
  229. "0\u00030\u00050\u0186\n0\u00030\u00030\u00031\u00031\u00031\u00031\u0003",
  230. "2\u00032\u00033\u00063\u0191\n3\r3\u000e3\u0192\u00033\u00053\u0196",
  231. "\n3\u00034\u00034\u00035\u00035\u00036\u00036\u00036\u00036\u00056\u01a0",
  232. "\n6\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u0003",
  233. "7\u00037\u00057\u01ad\n7\u00038\u00038\u00038\u00038\u00038\u00038\u0003",
  234. "8\u00039\u00039\u00039\u00039\u00079\u01ba\n9\f9\u000e9\u01bd\u000b",
  235. "9\u00039\u00059\u01c0\n9\u00039\u00039\u00039\u00039\u00039\u00079\u01c7",
  236. "\n9\f9\u000e9\u01ca\u000b9\u00039\u00039\u00059\u01ce\n9\u00039\u0003",
  237. "9\u0003\u01c8\u0002:\u0003\u0003\u0005\u0004\u0007\u0005\t\u0006\u000b",
  238. "\u0007\r\b\u000f\t\u0011\n\u0013\u000b\u0015\f\u0017\r\u0019\u000e\u001b",
  239. "\u000f\u001d\u0010\u001f\u0011!\u0012#\u0013%\u0014\'\u0015)\u0016+",
  240. "\u0017-\u0002/\u00021\u00023\u00185\u00197\u001a9\u001b;\u001c=\u001d",
  241. "?\u001eA\u001fC E!G\"I#K$M%O&Q\'S(U)W*Y\u0002[+]\u0002_,a-c\u0002e.",
  242. "g\u0002i\u0002k\u0002m\u0002o\u0002q/\u0003\u0002\u0012\u0004\u0002",
  243. "--//\u0005\u0002\'\',,11\u0004\u0002>>@@\u0005\u0002C\\aac|\u0006\u0002",
  244. "2;C\\aac|\u0003\u00022;\u0003\u000223\u0004\u0002GGgg\u0006\u0002\f",
  245. "\f\u000f\u000f$$^^\u0006\u0002\f\f\u000f\u000f))^^\u0004\u0002\u000b",
  246. "\u000b\"\"\u0004\u0002\f\f\u000f\u000f\u0005\u00022;CHch\u0003\u0002",
  247. "29\n\u0002$$))^^ddhhppttvv\u0003\u000225\u0002\u01e5\u0002\u0003\u0003",
  248. "\u0002\u0002\u0002\u0002\u0005\u0003\u0002\u0002\u0002\u0002\u0007\u0003",
  249. "\u0002\u0002\u0002\u0002\t\u0003\u0002\u0002\u0002\u0002\u000b\u0003",
  250. "\u0002\u0002\u0002\u0002\r\u0003\u0002\u0002\u0002\u0002\u000f\u0003",
  251. "\u0002\u0002\u0002\u0002\u0011\u0003\u0002\u0002\u0002\u0002\u0013\u0003",
  252. "\u0002\u0002\u0002\u0002\u0015\u0003\u0002\u0002\u0002\u0002\u0017\u0003",
  253. "\u0002\u0002\u0002\u0002\u0019\u0003\u0002\u0002\u0002\u0002\u001b\u0003",
  254. "\u0002\u0002\u0002\u0002\u001d\u0003\u0002\u0002\u0002\u0002\u001f\u0003",
  255. "\u0002\u0002\u0002\u0002!\u0003\u0002\u0002\u0002\u0002#\u0003\u0002",
  256. "\u0002\u0002\u0002%\u0003\u0002\u0002\u0002\u0002\'\u0003\u0002\u0002",
  257. "\u0002\u0002)\u0003\u0002\u0002\u0002\u0002+\u0003\u0002\u0002\u0002",
  258. "\u00023\u0003\u0002\u0002\u0002\u00025\u0003\u0002\u0002\u0002\u0002",
  259. "7\u0003\u0002\u0002\u0002\u00029\u0003\u0002\u0002\u0002\u0002;\u0003",
  260. "\u0002\u0002\u0002\u0002=\u0003\u0002\u0002\u0002\u0002?\u0003\u0002",
  261. "\u0002\u0002\u0002A\u0003\u0002\u0002\u0002\u0002C\u0003\u0002\u0002",
  262. "\u0002\u0002E\u0003\u0002\u0002\u0002\u0002G\u0003\u0002\u0002\u0002",
  263. "\u0002I\u0003\u0002\u0002\u0002\u0002K\u0003\u0002\u0002\u0002\u0002",
  264. "M\u0003\u0002\u0002\u0002\u0002O\u0003\u0002\u0002\u0002\u0002Q\u0003",
  265. "\u0002\u0002\u0002\u0002S\u0003\u0002\u0002\u0002\u0002U\u0003\u0002",
  266. "\u0002\u0002\u0002W\u0003\u0002\u0002\u0002\u0002[\u0003\u0002\u0002",
  267. "\u0002\u0002_\u0003\u0002\u0002\u0002\u0002a\u0003\u0002\u0002\u0002",
  268. "\u0002e\u0003\u0002\u0002\u0002\u0002q\u0003\u0002\u0002\u0002\u0003",
  269. "s\u0003\u0002\u0002\u0002\u0005{\u0003\u0002\u0002\u0002\u0007\u0080",
  270. "\u0003\u0002\u0002\u0002\t\u0085\u0003\u0002\u0002\u0002\u000b\u008d",
  271. "\u0003\u0002\u0002\u0002\r\u0094\u0003\u0002\u0002\u0002\u000f\u009c",
  272. "\u0003\u0002\u0002\u0002\u0011\u00a6\u0003\u0002\u0002\u0002\u0013\u00ad",
  273. "\u0003\u0002\u0002\u0002\u0015\u00b2\u0003\u0002\u0002\u0002\u0017\u00bc",
  274. "\u0003\u0002\u0002\u0002\u0019\u00c2\u0003\u0002\u0002\u0002\u001b\u00cb",
  275. "\u0003\u0002\u0002\u0002\u001d\u00d2\u0003\u0002\u0002\u0002\u001f\u00d6",
  276. "\u0003\u0002\u0002\u0002!\u00dc\u0003\u0002\u0002\u0002#\u00df\u0003",
  277. "\u0002\u0002\u0002%\u00e5\u0003\u0002\u0002\u0002\'\u00e8\u0003\u0002",
  278. "\u0002\u0002)\u00ed\u0003\u0002\u0002\u0002+\u00f3\u0003\u0002\u0002",
  279. "\u0002-\u00f8\u0003\u0002\u0002\u0002/\u00fc\u0003\u0002\u0002\u0002",
  280. "1\u0100\u0003\u0002\u0002\u00023\u0103\u0003\u0002\u0002\u00025\u0105",
  281. "\u0003\u0002\u0002\u00027\u0107\u0003\u0002\u0002\u00029\u0109\u0003",
  282. "\u0002\u0002\u0002;\u010b\u0003\u0002\u0002\u0002=\u010d\u0003\u0002",
  283. "\u0002\u0002?\u010f\u0003\u0002\u0002\u0002A\u0111\u0003\u0002\u0002",
  284. "\u0002C\u0113\u0003\u0002\u0002\u0002E\u0115\u0003\u0002\u0002\u0002",
  285. "G\u0117\u0003\u0002\u0002\u0002I\u0119\u0003\u0002\u0002\u0002K\u0124",
  286. "\u0003\u0002\u0002\u0002M\u0126\u0003\u0002\u0002\u0002O\u0128\u0003",
  287. "\u0002\u0002\u0002Q\u012a\u0003\u0002\u0002\u0002S\u0131\u0003\u0002",
  288. "\u0002\u0002U\u0150\u0003\u0002\u0002\u0002W\u016a\u0003\u0002\u0002",
  289. "\u0002Y\u016c\u0003\u0002\u0002\u0002[\u0175\u0003\u0002\u0002\u0002",
  290. "]\u0180\u0003\u0002\u0002\u0002_\u0182\u0003\u0002\u0002\u0002a\u0189",
  291. "\u0003\u0002\u0002\u0002c\u018d\u0003\u0002\u0002\u0002e\u0195\u0003",
  292. "\u0002\u0002\u0002g\u0197\u0003\u0002\u0002\u0002i\u0199\u0003\u0002",
  293. "\u0002\u0002k\u019f\u0003\u0002\u0002\u0002m\u01ac\u0003\u0002\u0002",
  294. "\u0002o\u01ae\u0003\u0002\u0002\u0002q\u01cd\u0003\u0002\u0002\u0002",
  295. "st\u0007r\u0002\u0002tu\u0007t\u0002\u0002uv\u0007q\u0002\u0002vw\u0007",
  296. "i\u0002\u0002wx\u0007t\u0002\u0002xy\u0007c\u0002\u0002yz\u0007o\u0002",
  297. "\u0002z\u0004\u0003\u0002\u0002\u0002{|\u0007t\u0002\u0002|}\u0007g",
  298. "\u0002\u0002}~\u0007c\u0002\u0002~\u007f\u0007n\u0002\u0002\u007f\u0006",
  299. "\u0003\u0002\u0002\u0002\u0080\u0081\u0007x\u0002\u0002\u0081\u0082",
  300. "\u0007q\u0002\u0002\u0082\u0083\u0007k\u0002\u0002\u0083\u0084\u0007",
  301. "f\u0002\u0002\u0084\b\u0003\u0002\u0002\u0002\u0085\u0086\u0007d\u0002",
  302. "\u0002\u0086\u0087\u0007q\u0002\u0002\u0087\u0088\u0007q\u0002\u0002",
  303. "\u0088\u0089\u0007n\u0002\u0002\u0089\u008a\u0007g\u0002\u0002\u008a",
  304. "\u008b\u0007c\u0002\u0002\u008b\u008c\u0007p\u0002\u0002\u008c\n\u0003",
  305. "\u0002\u0002\u0002\u008d\u008e\u0007u\u0002\u0002\u008e\u008f\u0007",
  306. "v\u0002\u0002\u008f\u0090\u0007t\u0002\u0002\u0090\u0091\u0007k\u0002",
  307. "\u0002\u0091\u0092\u0007p\u0002\u0002\u0092\u0093\u0007i\u0002\u0002",
  308. "\u0093\f\u0003\u0002\u0002\u0002\u0094\u0095\u0007k\u0002\u0002\u0095",
  309. "\u0096\u0007p\u0002\u0002\u0096\u0097\u0007v\u0002\u0002\u0097\u0098",
  310. "\u0007g\u0002\u0002\u0098\u0099\u0007i\u0002\u0002\u0099\u009a\u0007",
  311. "g\u0002\u0002\u009a\u009b\u0007t\u0002\u0002\u009b\u000e\u0003\u0002",
  312. "\u0002\u0002\u009c\u009d\u0007e\u0002\u0002\u009d\u009e\u0007j\u0002",
  313. "\u0002\u009e\u009f\u0007c\u0002\u0002\u009f\u00a0\u0007t\u0002\u0002",
  314. "\u00a0\u00a1\u0007c\u0002\u0002\u00a1\u00a2\u0007e\u0002\u0002\u00a2",
  315. "\u00a3\u0007v\u0002\u0002\u00a3\u00a4\u0007g\u0002\u0002\u00a4\u00a5",
  316. "\u0007t\u0002\u0002\u00a5\u0010\u0003\u0002\u0002\u0002\u00a6\u00a7",
  317. "\u0007u\u0002\u0002\u00a7\u00a8\u0007y\u0002\u0002\u00a8\u00a9\u0007",
  318. "k\u0002\u0002\u00a9\u00aa\u0007v\u0002\u0002\u00aa\u00ab\u0007e\u0002",
  319. "\u0002\u00ab\u00ac\u0007j\u0002\u0002\u00ac\u0012\u0003\u0002\u0002",
  320. "\u0002\u00ad\u00ae\u0007e\u0002\u0002\u00ae\u00af\u0007c\u0002\u0002",
  321. "\u00af\u00b0\u0007u\u0002\u0002\u00b0\u00b1\u0007g\u0002\u0002\u00b1",
  322. "\u0014\u0003\u0002\u0002\u0002\u00b2\u00b3\u0007q\u0002\u0002\u00b3",
  323. "\u00b4\u0007v\u0002\u0002\u00b4\u00b5\u0007j\u0002\u0002\u00b5\u00b6",
  324. "\u0007g\u0002\u0002\u00b6\u00b7\u0007t\u0002\u0002\u00b7\u00b8\u0007",
  325. "y\u0002\u0002\u00b8\u00b9\u0007k\u0002\u0002\u00b9\u00ba\u0007u\u0002",
  326. "\u0002\u00ba\u00bb\u0007g\u0002\u0002\u00bb\u0016\u0003\u0002\u0002",
  327. "\u0002\u00bc\u00bd\u0007e\u0002\u0002\u00bd\u00be\u0007q\u0002\u0002",
  328. "\u00be\u00bf\u0007p\u0002\u0002\u00bf\u00c0\u0007u\u0002\u0002\u00c0",
  329. "\u00c1\u0007v\u0002\u0002\u00c1\u0018\u0003\u0002\u0002\u0002\u00c2",
  330. "\u00c3\u0007h\u0002\u0002\u00c3\u00c4\u0007w\u0002\u0002\u00c4\u00c5",
  331. "\u0007p\u0002\u0002\u00c5\u00c6\u0007e\u0002\u0002\u00c6\u00c7\u0007",
  332. "v\u0002\u0002\u00c7\u00c8\u0007k\u0002\u0002\u00c8\u00c9\u0007q\u0002",
  333. "\u0002\u00c9\u00ca\u0007p\u0002\u0002\u00ca\u001a\u0003\u0002\u0002",
  334. "\u0002\u00cb\u00cc\u0007t\u0002\u0002\u00cc\u00cd\u0007g\u0002\u0002",
  335. "\u00cd\u00ce\u0007v\u0002\u0002\u00ce\u00cf\u0007w\u0002\u0002\u00cf",
  336. "\u00d0\u0007t\u0002\u0002\u00d0\u00d1\u0007p\u0002\u0002\u00d1\u001c",
  337. "\u0003\u0002\u0002\u0002\u00d2\u00d3\u0007h\u0002\u0002\u00d3\u00d4",
  338. "\u0007q\u0002\u0002\u00d4\u00d5\u0007t\u0002\u0002\u00d5\u001e\u0003",
  339. "\u0002\u0002\u0002\u00d6\u00d7\u0007d\u0002\u0002\u00d7\u00d8\u0007",
  340. "t\u0002\u0002\u00d8\u00d9\u0007g\u0002\u0002\u00d9\u00da\u0007c\u0002",
  341. "\u0002\u00da\u00db\u0007m\u0002\u0002\u00db \u0003\u0002\u0002\u0002",
  342. "\u00dc\u00dd\u0007f\u0002\u0002\u00dd\u00de\u0007q\u0002\u0002\u00de",
  343. "\"\u0003\u0002\u0002\u0002\u00df\u00e0\u0007y\u0002\u0002\u00e0\u00e1",
  344. "\u0007j\u0002\u0002\u00e1\u00e2\u0007k\u0002\u0002\u00e2\u00e3\u0007",
  345. "n\u0002\u0002\u00e3\u00e4\u0007g\u0002\u0002\u00e4$\u0003\u0002\u0002",
  346. "\u0002\u00e5\u00e6\u0007k\u0002\u0002\u00e6\u00e7\u0007h\u0002\u0002",
  347. "\u00e7&\u0003\u0002\u0002\u0002\u00e8\u00e9\u0007g\u0002\u0002\u00e9",
  348. "\u00ea\u0007n\u0002\u0002\u00ea\u00eb\u0007u\u0002\u0002\u00eb\u00ec",
  349. "\u0007g\u0002\u0002\u00ec(\u0003\u0002\u0002\u0002\u00ed\u00ee\u0007",
  350. "h\u0002\u0002\u00ee\u00ef\u0007c\u0002\u0002\u00ef\u00f0\u0007n\u0002",
  351. "\u0002\u00f0\u00f1\u0007u\u0002\u0002\u00f1\u00f2\u0007g\u0002\u0002",
  352. "\u00f2*\u0003\u0002\u0002\u0002\u00f3\u00f4\u0007v\u0002\u0002\u00f4",
  353. "\u00f5\u0007t\u0002\u0002\u00f5\u00f6\u0007w\u0002\u0002\u00f6\u00f7",
  354. "\u0007g\u0002\u0002\u00f7,\u0003\u0002\u0002\u0002\u00f8\u00f9\u0007",
  355. "p\u0002\u0002\u00f9\u00fa\u0007q\u0002\u0002\u00fa\u00fb\u0007v\u0002",
  356. "\u0002\u00fb.\u0003\u0002\u0002\u0002\u00fc\u00fd\u0007C\u0002\u0002",
  357. "\u00fd\u00fe\u0007P\u0002\u0002\u00fe\u00ff\u0007F\u0002\u0002\u00ff",
  358. "0\u0003\u0002\u0002\u0002\u0100\u0101\u0007Q\u0002\u0002\u0101\u0102",
  359. "\u0007T\u0002\u0002\u01022\u0003\u0002\u0002\u0002\u0103\u0104\u0007",
  360. "*\u0002\u0002\u01044\u0003\u0002\u0002\u0002\u0105\u0106\u0007+\u0002",
  361. "\u0002\u01066\u0003\u0002\u0002\u0002\u0107\u0108\u0007]\u0002\u0002",
  362. "\u01088\u0003\u0002\u0002\u0002\u0109\u010a\u0007_\u0002\u0002\u010a",
  363. ":\u0003\u0002\u0002\u0002\u010b\u010c\u0007}\u0002\u0002\u010c<\u0003",
  364. "\u0002\u0002\u0002\u010d\u010e\u0007\u007f\u0002\u0002\u010e>\u0003",
  365. "\u0002\u0002\u0002\u010f\u0110\u0007.\u0002\u0002\u0110@\u0003\u0002",
  366. "\u0002\u0002\u0111\u0112\u0007?\u0002\u0002\u0112B\u0003\u0002\u0002",
  367. "\u0002\u0113\u0114\t\u0002\u0002\u0002\u0114D\u0003\u0002\u0002\u0002",
  368. "\u0115\u0116\t\u0003\u0002\u0002\u0116F\u0003\u0002\u0002\u0002\u0117",
  369. "\u0118\u0005/\u0018\u0002\u0118H\u0003\u0002\u0002\u0002\u0119\u011a",
  370. "\u00051\u0019\u0002\u011aJ\u0003\u0002\u0002\u0002\u011b\u011c\u0007",
  371. "@\u0002\u0002\u011c\u0125\u0007?\u0002\u0002\u011d\u011e\u0007?\u0002",
  372. "\u0002\u011e\u0125\u0007?\u0002\u0002\u011f\u0120\u0007>\u0002\u0002",
  373. "\u0120\u0125\u0007?\u0002\u0002\u0121\u0125\t\u0004\u0002\u0002\u0122",
  374. "\u0123\u0007#\u0002\u0002\u0123\u0125\u0007?\u0002\u0002\u0124\u011b",
  375. "\u0003\u0002\u0002\u0002\u0124\u011d\u0003\u0002\u0002\u0002\u0124\u011f",
  376. "\u0003\u0002\u0002\u0002\u0124\u0121\u0003\u0002\u0002\u0002\u0124\u0122",
  377. "\u0003\u0002\u0002\u0002\u0125L\u0003\u0002\u0002\u0002\u0126\u0127",
  378. "\u0007<\u0002\u0002\u0127N\u0003\u0002\u0002\u0002\u0128\u0129\u0005",
  379. "-\u0017\u0002\u0129P\u0003\u0002\u0002\u0002\u012a\u012e\t\u0005\u0002",
  380. "\u0002\u012b\u012d\t\u0006\u0002\u0002\u012c\u012b\u0003\u0002\u0002",
  381. "\u0002\u012d\u0130\u0003\u0002\u0002\u0002\u012e\u012c\u0003\u0002\u0002",
  382. "\u0002\u012e\u012f\u0003\u0002\u0002\u0002\u012fR\u0003\u0002\u0002",
  383. "\u0002\u0130\u012e\u0003\u0002\u0002\u0002\u0131\u0132\u0005Q)\u0002",
  384. "\u0132\u0133\u00070\u0002\u0002\u0133\u0134\u0005Q)\u0002\u0134T\u0003",
  385. "\u0002\u0002\u0002\u0135\u0137\t\u0007\u0002\u0002\u0136\u0135\u0003",
  386. "\u0002\u0002\u0002\u0137\u0138\u0003\u0002\u0002\u0002\u0138\u0136\u0003",
  387. "\u0002\u0002\u0002\u0138\u0139\u0003\u0002\u0002\u0002\u0139\u0151\u0003",
  388. "\u0002\u0002\u0002\u013a\u013b\u00072\u0002\u0002\u013b\u013f\u0007",
  389. "z\u0002\u0002\u013c\u013d\u00072\u0002\u0002\u013d\u013f\u0007Z\u0002",
  390. "\u0002\u013e\u013a\u0003\u0002\u0002\u0002\u013e\u013c\u0003\u0002\u0002",
  391. "\u0002\u013f\u0141\u0003\u0002\u0002\u0002\u0140\u0142\u0005g4\u0002",
  392. "\u0141\u0140\u0003\u0002\u0002\u0002\u0142\u0143\u0003\u0002\u0002\u0002",
  393. "\u0143\u0141\u0003\u0002\u0002\u0002\u0143\u0144\u0003\u0002\u0002\u0002",
  394. "\u0144\u0151\u0003\u0002\u0002\u0002\u0145\u0146\u00072\u0002\u0002",
  395. "\u0146\u014a\u0007d\u0002\u0002\u0147\u0148\u00072\u0002\u0002\u0148",
  396. "\u014a\u0007D\u0002\u0002\u0149\u0145\u0003\u0002\u0002\u0002\u0149",
  397. "\u0147\u0003\u0002\u0002\u0002\u014a\u014c\u0003\u0002\u0002\u0002\u014b",
  398. "\u014d\t\b\u0002\u0002\u014c\u014b\u0003\u0002\u0002\u0002\u014d\u014e",
  399. "\u0003\u0002\u0002\u0002\u014e\u014c\u0003\u0002\u0002\u0002\u014e\u014f",
  400. "\u0003\u0002\u0002\u0002\u014f\u0151\u0003\u0002\u0002\u0002\u0150\u0136",
  401. "\u0003\u0002\u0002\u0002\u0150\u013e\u0003\u0002\u0002\u0002\u0150\u0149",
  402. "\u0003\u0002\u0002\u0002\u0151V\u0003\u0002\u0002\u0002\u0152\u0154",
  403. "\t\u0007\u0002\u0002\u0153\u0152\u0003\u0002\u0002\u0002\u0154\u0155",
  404. "\u0003\u0002\u0002\u0002\u0155\u0153\u0003\u0002\u0002\u0002\u0155\u0156",
  405. "\u0003\u0002\u0002\u0002\u0156\u0157\u0003\u0002\u0002\u0002\u0157\u0159",
  406. "\u00070\u0002\u0002\u0158\u015a\t\u0007\u0002\u0002\u0159\u0158\u0003",
  407. "\u0002\u0002\u0002\u015a\u015b\u0003\u0002\u0002\u0002\u015b\u0159\u0003",
  408. "\u0002\u0002\u0002\u015b\u015c\u0003\u0002\u0002\u0002\u015c\u016b\u0003",
  409. "\u0002\u0002\u0002\u015d\u015f\t\u0007\u0002\u0002\u015e\u015d\u0003",
  410. "\u0002\u0002\u0002\u015f\u0160\u0003\u0002\u0002\u0002\u0160\u015e\u0003",
  411. "\u0002\u0002\u0002\u0160\u0161\u0003\u0002\u0002\u0002\u0161\u0162\u0003",
  412. "\u0002\u0002\u0002\u0162\u0166\u00070\u0002\u0002\u0163\u0165\t\u0007",
  413. "\u0002\u0002\u0164\u0163\u0003\u0002\u0002\u0002\u0165\u0168\u0003\u0002",
  414. "\u0002\u0002\u0166\u0164\u0003\u0002\u0002\u0002\u0166\u0167\u0003\u0002",
  415. "\u0002\u0002\u0167\u0169\u0003\u0002\u0002\u0002\u0168\u0166\u0003\u0002",
  416. "\u0002\u0002\u0169\u016b\u0005Y-\u0002\u016a\u0153\u0003\u0002\u0002",
  417. "\u0002\u016a\u015e\u0003\u0002\u0002\u0002\u016bX\u0003\u0002\u0002",
  418. "\u0002\u016c\u016e\t\t\u0002\u0002\u016d\u016f\t\u0002\u0002\u0002\u016e",
  419. "\u016d\u0003\u0002\u0002\u0002\u016e\u016f\u0003\u0002\u0002\u0002\u016f",
  420. "\u0171\u0003\u0002\u0002\u0002\u0170\u0172\t\u0007\u0002\u0002\u0171",
  421. "\u0170\u0003\u0002\u0002\u0002\u0172\u0173\u0003\u0002\u0002\u0002\u0173",
  422. "\u0171\u0003\u0002\u0002\u0002\u0173\u0174\u0003\u0002\u0002\u0002\u0174",
  423. "Z\u0003\u0002\u0002\u0002\u0175\u0179\u0007$\u0002\u0002\u0176\u0178",
  424. "\u0005]/\u0002\u0177\u0176\u0003\u0002\u0002\u0002\u0178\u017b\u0003",
  425. "\u0002\u0002\u0002\u0179\u0177\u0003\u0002\u0002\u0002\u0179\u017a\u0003",
  426. "\u0002\u0002\u0002\u017a\u017c\u0003\u0002\u0002\u0002\u017b\u0179\u0003",
  427. "\u0002\u0002\u0002\u017c\u017d\u0007$\u0002\u0002\u017d\\\u0003\u0002",
  428. "\u0002\u0002\u017e\u0181\n\n\u0002\u0002\u017f\u0181\u0005k6\u0002\u0180",
  429. "\u017e\u0003\u0002\u0002\u0002\u0180\u017f\u0003\u0002\u0002\u0002\u0181",
  430. "^\u0003\u0002\u0002\u0002\u0182\u0185\u0007)\u0002\u0002\u0183\u0186",
  431. "\u0005k6\u0002\u0184\u0186\n\u000b\u0002\u0002\u0185\u0183\u0003\u0002",
  432. "\u0002\u0002\u0185\u0184\u0003\u0002\u0002\u0002\u0186\u0187\u0003\u0002",
  433. "\u0002\u0002\u0187\u0188\u0007)\u0002\u0002\u0188`\u0003\u0002\u0002",
  434. "\u0002\u0189\u018a\t\f\u0002\u0002\u018a\u018b\u0003\u0002\u0002\u0002",
  435. "\u018b\u018c\b1\u0002\u0002\u018cb\u0003\u0002\u0002\u0002\u018d\u018e",
  436. "\u0007=\u0002\u0002\u018ed\u0003\u0002\u0002\u0002\u018f\u0191\t\r\u0002",
  437. "\u0002\u0190\u018f\u0003\u0002\u0002\u0002\u0191\u0192\u0003\u0002\u0002",
  438. "\u0002\u0192\u0190\u0003\u0002\u0002\u0002\u0192\u0193\u0003\u0002\u0002",
  439. "\u0002\u0193\u0196\u0003\u0002\u0002\u0002\u0194\u0196\u0005c2\u0002",
  440. "\u0195\u0190\u0003\u0002\u0002\u0002\u0195\u0194\u0003\u0002\u0002\u0002",
  441. "\u0196f\u0003\u0002\u0002\u0002\u0197\u0198\t\u000e\u0002\u0002\u0198",
  442. "h\u0003\u0002\u0002\u0002\u0199\u019a\t\u000f\u0002\u0002\u019aj\u0003",
  443. "\u0002\u0002\u0002\u019b\u019c\u0007^\u0002\u0002\u019c\u01a0\t\u0010",
  444. "\u0002\u0002\u019d\u01a0\u0005o8\u0002\u019e\u01a0\u0005m7\u0002\u019f",
  445. "\u019b\u0003\u0002\u0002\u0002\u019f\u019d\u0003\u0002\u0002\u0002\u019f",
  446. "\u019e\u0003\u0002\u0002\u0002\u01a0l\u0003\u0002\u0002\u0002\u01a1",
  447. "\u01a2\u0007^\u0002\u0002\u01a2\u01a3\t\u0011\u0002\u0002\u01a3\u01a4",
  448. "\u0005i5\u0002\u01a4\u01a5\u0005i5\u0002\u01a5\u01ad\u0003\u0002\u0002",
  449. "\u0002\u01a6\u01a7\u0007^\u0002\u0002\u01a7\u01a8\u0005i5\u0002\u01a8",
  450. "\u01a9\u0005i5\u0002\u01a9\u01ad\u0003\u0002\u0002\u0002\u01aa\u01ab",
  451. "\u0007^\u0002\u0002\u01ab\u01ad\u0005i5\u0002\u01ac\u01a1\u0003\u0002",
  452. "\u0002\u0002\u01ac\u01a6\u0003\u0002\u0002\u0002\u01ac\u01aa\u0003\u0002",
  453. "\u0002\u0002\u01adn\u0003\u0002\u0002\u0002\u01ae\u01af\u0007^\u0002",
  454. "\u0002\u01af\u01b0\u0007w\u0002\u0002\u01b0\u01b1\u0005g4\u0002\u01b1",
  455. "\u01b2\u0005g4\u0002\u01b2\u01b3\u0005g4\u0002\u01b3\u01b4\u0005g4\u0002",
  456. "\u01b4p\u0003\u0002\u0002\u0002\u01b5\u01b6\u00071\u0002\u0002\u01b6",
  457. "\u01b7\u00071\u0002\u0002\u01b7\u01bb\u0003\u0002\u0002\u0002\u01b8",
  458. "\u01ba\n\r\u0002\u0002\u01b9\u01b8\u0003\u0002\u0002\u0002\u01ba\u01bd",
  459. "\u0003\u0002\u0002\u0002\u01bb\u01b9\u0003\u0002\u0002\u0002\u01bb\u01bc",
  460. "\u0003\u0002\u0002\u0002\u01bc\u01bf\u0003\u0002\u0002\u0002\u01bd\u01bb",
  461. "\u0003\u0002\u0002\u0002\u01be\u01c0\u0007\u000f\u0002\u0002\u01bf\u01be",
  462. "\u0003\u0002\u0002\u0002\u01bf\u01c0\u0003\u0002\u0002\u0002\u01c0\u01c1",
  463. "\u0003\u0002\u0002\u0002\u01c1\u01ce\u0007\f\u0002\u0002\u01c2\u01c3",
  464. "\u00071\u0002\u0002\u01c3\u01c4\u0007,\u0002\u0002\u01c4\u01c8\u0003",
  465. "\u0002\u0002\u0002\u01c5\u01c7\u000b\u0002\u0002\u0002\u01c6\u01c5\u0003",
  466. "\u0002\u0002\u0002\u01c7\u01ca\u0003\u0002\u0002\u0002\u01c8\u01c9\u0003",
  467. "\u0002\u0002\u0002\u01c8\u01c6\u0003\u0002\u0002\u0002\u01c9\u01cb\u0003",
  468. "\u0002\u0002\u0002\u01ca\u01c8\u0003\u0002\u0002\u0002\u01cb\u01cc\u0007",
  469. ",\u0002\u0002\u01cc\u01ce\u00071\u0002\u0002\u01cd\u01b5\u0003\u0002",
  470. "\u0002\u0002\u01cd\u01c2\u0003\u0002\u0002\u0002\u01ce\u01cf\u0003\u0002",
  471. "\u0002\u0002\u01cf\u01d0\b9\u0003\u0002\u01d0r\u0003\u0002\u0002\u0002",
  472. "\u001d\u0002\u0124\u012e\u0138\u013e\u0143\u0149\u014e\u0150\u0155\u015b",
  473. "\u0160\u0166\u016a\u016e\u0173\u0179\u0180\u0185\u0192\u0195\u019f\u01ac",
  474. "\u01bb\u01bf\u01c8\u01cd\u0004\b\u0002\u0002\u0002\u0003\u0002"].join("");
  475. var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
  476. var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });
  477. function ivprog(input) {
  478. antlr4.Lexer.call(this, input);
  479. this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
  480. return this;
  481. }
  482. ivprog.prototype = Object.create(antlr4.Lexer.prototype);
  483. ivprog.prototype.constructor = ivprog;
  484. ivprog.EOF = antlr4.Token.EOF;
  485. ivprog.RK_PROGRAM = 1;
  486. ivprog.RK_REAL = 2;
  487. ivprog.RK_VOID = 3;
  488. ivprog.RK_BOOLEAN = 4;
  489. ivprog.RK_STRING = 5;
  490. ivprog.RK_INTEGER = 6;
  491. ivprog.RK_CHARACTER = 7;
  492. ivprog.RK_SWITCH = 8;
  493. ivprog.RK_CASE = 9;
  494. ivprog.RK_DEFAULT = 10;
  495. ivprog.RK_CONST = 11;
  496. ivprog.RK_FUNCTION = 12;
  497. ivprog.RK_RETURN = 13;
  498. ivprog.RK_FOR = 14;
  499. ivprog.RK_BREAK = 15;
  500. ivprog.RK_DO = 16;
  501. ivprog.RK_WHILE = 17;
  502. ivprog.RK_IF = 18;
  503. ivprog.RK_ELSE = 19;
  504. ivprog.RK_FALSE = 20;
  505. ivprog.RK_TRUE = 21;
  506. ivprog.OPEN_PARENTHESIS = 22;
  507. ivprog.CLOSE_PARENTHESIS = 23;
  508. ivprog.OPEN_BRACE = 24;
  509. ivprog.CLOSE_BRACE = 25;
  510. ivprog.OPEN_CURLY = 26;
  511. ivprog.CLOSE_CURLY = 27;
  512. ivprog.COMMA = 28;
  513. ivprog.EQUAL = 29;
  514. ivprog.SUM_OP = 30;
  515. ivprog.MULTI_OP = 31;
  516. ivprog.AND_OPERATOR = 32;
  517. ivprog.OR_OPERATOR = 33;
  518. ivprog.RELATIONAL_OPERATOR = 34;
  519. ivprog.COLON = 35;
  520. ivprog.NOT_OPERATOR = 36;
  521. ivprog.ID = 37;
  522. ivprog.LIB_ID = 38;
  523. ivprog.INTEGER = 39;
  524. ivprog.REAL = 40;
  525. ivprog.STRING = 41;
  526. ivprog.CHARACTER = 42;
  527. ivprog.WHITESPACE = 43;
  528. ivprog.EOS = 44;
  529. ivprog.COMMENTS = 45;
  530. ivprog.prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];
  531. ivprog.prototype.modeNames = [ "DEFAULT_MODE" ];
  532. ivprog.prototype.literalNames = [ null, "'program'", "'real'", "'void'",
  533. "'boolean'", "'string'", "'integer'",
  534. "'character'", "'switch'", "'case'", "'otherwise'",
  535. "'const'", "'function'", "'return'", "'for'",
  536. "'break'", "'do'", "'while'", "'if'",
  537. "'else'", "'false'", "'true'", "'('",
  538. "')'", "'['", "']'", "'{'", "'}'", "','",
  539. "'='", null, null, null, null, null, "':'" ];
  540. ivprog.prototype.symbolicNames = [ null, "RK_PROGRAM", "RK_REAL", "RK_VOID",
  541. "RK_BOOLEAN", "RK_STRING", "RK_INTEGER",
  542. "RK_CHARACTER", "RK_SWITCH", "RK_CASE",
  543. "RK_DEFAULT", "RK_CONST", "RK_FUNCTION",
  544. "RK_RETURN", "RK_FOR", "RK_BREAK", "RK_DO",
  545. "RK_WHILE", "RK_IF", "RK_ELSE", "RK_FALSE",
  546. "RK_TRUE", "OPEN_PARENTHESIS", "CLOSE_PARENTHESIS",
  547. "OPEN_BRACE", "CLOSE_BRACE", "OPEN_CURLY",
  548. "CLOSE_CURLY", "COMMA", "EQUAL", "SUM_OP",
  549. "MULTI_OP", "AND_OPERATOR", "OR_OPERATOR",
  550. "RELATIONAL_OPERATOR", "COLON", "NOT_OPERATOR",
  551. "ID", "LIB_ID", "INTEGER", "REAL", "STRING",
  552. "CHARACTER", "WHITESPACE", "EOS", "COMMENTS" ];
  553. ivprog.prototype.ruleNames = [ "RK_PROGRAM", "RK_REAL", "RK_VOID", "RK_BOOLEAN",
  554. "RK_STRING", "RK_INTEGER", "RK_CHARACTER",
  555. "RK_SWITCH", "RK_CASE", "RK_DEFAULT", "RK_CONST",
  556. "RK_FUNCTION", "RK_RETURN", "RK_FOR", "RK_BREAK",
  557. "RK_DO", "RK_WHILE", "RK_IF", "RK_ELSE",
  558. "RK_FALSE", "RK_TRUE", "RK_LOGICAL_NOT",
  559. "RK_LOGICAL_AND", "RK_LOGICAL_OR", "OPEN_PARENTHESIS",
  560. "CLOSE_PARENTHESIS", "OPEN_BRACE", "CLOSE_BRACE",
  561. "OPEN_CURLY", "CLOSE_CURLY", "COMMA", "EQUAL",
  562. "SUM_OP", "MULTI_OP", "AND_OPERATOR", "OR_OPERATOR",
  563. "RELATIONAL_OPERATOR", "COLON", "NOT_OPERATOR",
  564. "ID", "LIB_ID", "INTEGER", "REAL", "ExponentPart",
  565. "STRING", "STRING_CHARACTER", "CHARACTER",
  566. "WHITESPACE", "SEMICOLON", "EOS", "HEX_DIGIT",
  567. "OCTAL_DIGIT", "ESC_SEQ", "ESC_OCTAL", "ESC_UNICODE",
  568. "COMMENTS" ];
  569. ivprog.prototype.grammarFileName = "ivprog.g4";
  570. exports.ivprog = ivprog;
  571. /***/ }),
  572. /* 1 */
  573. /***/ (function(module, exports, __webpack_require__) {
  574. module.exports = {
  575. ivprog: __webpack_require__(0).ivprog
  576. };
  577. /***/ }),
  578. /* 2 */
  579. /***/ (function(module, exports) {
  580. module.exports = __webpack_require__(/*! antlr4/index */ "./node_modules/antlr4/index.js");
  581. /***/ })
  582. /******/ ]);
  583. /***/ }),
  584. /***/ "./grammar/en/langFunctions.js":
  585. /*!*************************************!*\
  586. !*** ./grammar/en/langFunctions.js ***!
  587. \*************************************/
  588. /*! no static exports found */
  589. /***/ (function(module, exports, __webpack_require__) {
  590. "use strict";
  591. Object.defineProperty(exports, "__esModule", {
  592. value: true
  593. });
  594. /* This is a dictionary of the language defined functions
  595. **/
  596. exports.default = {
  597. main_function: "start",
  598. $read: "read",
  599. $write: "write",
  600. $numElements: "total_of_elements",
  601. $matrixLines: "total_of_lines",
  602. $matrixColumns: "total_of_columns",
  603. $substring: "subcadeia",
  604. $length: "comprimento",
  605. $uppercase: "caixa_alta",
  606. $lowercase: "caixa_baixa",
  607. $charAt: "char_at",
  608. $isReal: "is_real",
  609. $isInt: "is_integer",
  610. $isBool: "is_logic",
  611. $castReal: "to_real",
  612. $castInt: "to_integer",
  613. $castBool: "to_logic",
  614. $castString: "to_string",
  615. $sin: "sin",
  616. $cos: "cos",
  617. $tan: "tan",
  618. $sqrt: "sqrt",
  619. $pow: "pow",
  620. $log: "log",
  621. $abs: "abs",
  622. $negate: "negate",
  623. $invert: "invert",
  624. $max: "maximum",
  625. $min: "minimum"
  626. };
  627. /***/ }),
  628. /***/ "./grammar/en/langLibs.js":
  629. /*!********************************!*\
  630. !*** ./grammar/en/langLibs.js ***!
  631. \********************************/
  632. /*! no static exports found */
  633. /***/ (function(module, exports, __webpack_require__) {
  634. "use strict";
  635. Object.defineProperty(exports, "__esModule", {
  636. value: true
  637. });
  638. /**
  639. * This is the dictionary of the language defined libraries
  640. */
  641. exports.default = {
  642. $mathLib: "Mathematic",
  643. $ioLib: "ES",
  644. $strLib: "Texto",
  645. $arrayLib: "Arranjo",
  646. $langLib: "Conversion"
  647. };
  648. /***/ }),
  649. /***/ "./grammar/es/ivprog.g4":
  650. /*!******************************!*\
  651. !*** ./grammar/es/ivprog.g4 ***!
  652. \******************************/
  653. /*! no static exports found */
  654. /***/ (function(module, exports, __webpack_require__) {
  655. module.exports =
  656. /******/ (function(modules) { // webpackBootstrap
  657. /******/ // The module cache
  658. /******/ var installedModules = {};
  659. /******/
  660. /******/ // The require function
  661. /******/ function __webpack_require__(moduleId) {
  662. /******/
  663. /******/ // Check if module is in cache
  664. /******/ if(installedModules[moduleId]) {
  665. /******/ return installedModules[moduleId].exports;
  666. /******/ }
  667. /******/ // Create a new module (and put it into the cache)
  668. /******/ var module = installedModules[moduleId] = {
  669. /******/ i: moduleId,
  670. /******/ l: false,
  671. /******/ exports: {}
  672. /******/ };
  673. /******/
  674. /******/ // Execute the module function
  675. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  676. /******/
  677. /******/ // Flag the module as loaded
  678. /******/ module.l = true;
  679. /******/
  680. /******/ // Return the exports of the module
  681. /******/ return module.exports;
  682. /******/ }
  683. /******/
  684. /******/
  685. /******/ // expose the modules object (__webpack_modules__)
  686. /******/ __webpack_require__.m = modules;
  687. /******/
  688. /******/ // expose the module cache
  689. /******/ __webpack_require__.c = installedModules;
  690. /******/
  691. /******/ // identity function for calling harmony imports with the correct context
  692. /******/ __webpack_require__.i = function(value) { return value; };
  693. /******/
  694. /******/ // define getter function for harmony exports
  695. /******/ __webpack_require__.d = function(exports, name, getter) {
  696. /******/ if(!__webpack_require__.o(exports, name)) {
  697. /******/ Object.defineProperty(exports, name, {
  698. /******/ configurable: false,
  699. /******/ enumerable: true,
  700. /******/ get: getter
  701. /******/ });
  702. /******/ }
  703. /******/ };
  704. /******/
  705. /******/ // getDefaultExport function for compatibility with non-harmony modules
  706. /******/ __webpack_require__.n = function(module) {
  707. /******/ var getter = module && module.__esModule ?
  708. /******/ function getDefault() { return module['default']; } :
  709. /******/ function getModuleExports() { return module; };
  710. /******/ __webpack_require__.d(getter, 'a', getter);
  711. /******/ return getter;
  712. /******/ };
  713. /******/
  714. /******/ // Object.prototype.hasOwnProperty.call
  715. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  716. /******/
  717. /******/ // __webpack_public_path__
  718. /******/ __webpack_require__.p = "";
  719. /******/
  720. /******/ // Load entry module and return exports
  721. /******/ return __webpack_require__(__webpack_require__.s = 1);
  722. /******/ })
  723. /************************************************************************/
  724. /******/ ([
  725. /* 0 */
  726. /***/ (function(module, exports, __webpack_require__) {
  727. // Generated from /tmp/tmp-4052xRGkTUSjBpz0/ivprog.g4 by ANTLR 4.7
  728. // jshint ignore: start
  729. var antlr4 = __webpack_require__(2);
  730. var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
  731. "\u0002/\u01dc\b\u0001\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004",
  732. "\u0004\t\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t",
  733. "\u0007\u0004\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004",
  734. "\f\t\f\u0004\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010",
  735. "\t\u0010\u0004\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013",
  736. "\u0004\u0014\t\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017",
  737. "\t\u0017\u0004\u0018\t\u0018\u0004\u0019\t\u0019\u0004\u001a\t\u001a",
  738. "\u0004\u001b\t\u001b\u0004\u001c\t\u001c\u0004\u001d\t\u001d\u0004\u001e",
  739. "\t\u001e\u0004\u001f\t\u001f\u0004 \t \u0004!\t!\u0004\"\t\"\u0004#",
  740. "\t#\u0004$\t$\u0004%\t%\u0004&\t&\u0004\'\t\'\u0004(\t(\u0004)\t)\u0004",
  741. "*\t*\u0004+\t+\u0004,\t,\u0004-\t-\u0004.\t.\u0004/\t/\u00040\t0\u0004",
  742. "1\t1\u00042\t2\u00043\t3\u00044\t4\u00045\t5\u00046\t6\u00047\t7\u0004",
  743. "8\t8\u00049\t9\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003",
  744. "\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0003\u0003",
  745. "\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0004\u0003\u0004\u0003",
  746. "\u0004\u0003\u0004\u0003\u0004\u0003\u0004\u0003\u0005\u0003\u0005\u0003",
  747. "\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0006\u0003",
  748. "\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003",
  749. "\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003",
  750. "\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003",
  751. "\b\u0003\b\u0003\b\u0003\b\u0003\t\u0003\t\u0003\t\u0003\t\u0003\t\u0003",
  752. "\t\u0003\t\u0003\t\u0003\n\u0003\n\u0003\n\u0003\n\u0003\n\u0003\u000b",
  753. "\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b",
  754. "\u0003\u000b\u0003\u000b\u0003\u000b\u0003\f\u0003\f\u0003\f\u0003\f",
  755. "\u0003\f\u0003\f\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003",
  756. "\r\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003",
  757. "\u000e\u0003\u000e\u0003\u000e\u0003\u000f\u0003\u000f\u0003\u000f\u0003",
  758. "\u000f\u0003\u000f\u0003\u0010\u0003\u0010\u0003\u0010\u0003\u0010\u0003",
  759. "\u0010\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003",
  760. "\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003",
  761. "\u0012\u0003\u0012\u0003\u0012\u0003\u0013\u0003\u0013\u0003\u0013\u0003",
  762. "\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003",
  763. "\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003",
  764. "\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003",
  765. "\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0017\u0003",
  766. "\u0017\u0003\u0017\u0003\u0017\u0003\u0018\u0003\u0018\u0003\u0019\u0003",
  767. "\u0019\u0003\u0019\u0003\u001a\u0003\u001a\u0003\u001b\u0003\u001b\u0003",
  768. "\u001c\u0003\u001c\u0003\u001d\u0003\u001d\u0003\u001e\u0003\u001e\u0003",
  769. "\u001f\u0003\u001f\u0003 \u0003 \u0003!\u0003!\u0003\"\u0003\"\u0003",
  770. "#\u0003#\u0003$\u0003$\u0003%\u0003%\u0003&\u0003&\u0003&\u0003&\u0003",
  771. "&\u0003&\u0003&\u0003&\u0003&\u0005&\u0130\n&\u0003\'\u0003\'\u0003",
  772. "(\u0003(\u0003)\u0003)\u0007)\u0138\n)\f)\u000e)\u013b\u000b)\u0003",
  773. "*\u0003*\u0003*\u0003*\u0003+\u0006+\u0142\n+\r+\u000e+\u0143\u0003",
  774. "+\u0003+\u0003+\u0003+\u0005+\u014a\n+\u0003+\u0006+\u014d\n+\r+\u000e",
  775. "+\u014e\u0003+\u0003+\u0003+\u0003+\u0005+\u0155\n+\u0003+\u0006+\u0158",
  776. "\n+\r+\u000e+\u0159\u0005+\u015c\n+\u0003,\u0006,\u015f\n,\r,\u000e",
  777. ",\u0160\u0003,\u0003,\u0006,\u0165\n,\r,\u000e,\u0166\u0003,\u0006,",
  778. "\u016a\n,\r,\u000e,\u016b\u0003,\u0003,\u0007,\u0170\n,\f,\u000e,\u0173",
  779. "\u000b,\u0003,\u0005,\u0176\n,\u0003-\u0003-\u0005-\u017a\n-\u0003-",
  780. "\u0006-\u017d\n-\r-\u000e-\u017e\u0003.\u0003.\u0007.\u0183\n.\f.\u000e",
  781. ".\u0186\u000b.\u0003.\u0003.\u0003/\u0003/\u0005/\u018c\n/\u00030\u0003",
  782. "0\u00030\u00050\u0191\n0\u00030\u00030\u00031\u00031\u00031\u00031\u0003",
  783. "2\u00032\u00033\u00063\u019c\n3\r3\u000e3\u019d\u00033\u00053\u01a1",
  784. "\n3\u00034\u00034\u00035\u00035\u00036\u00036\u00036\u00036\u00056\u01ab",
  785. "\n6\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u0003",
  786. "7\u00037\u00057\u01b8\n7\u00038\u00038\u00038\u00038\u00038\u00038\u0003",
  787. "8\u00039\u00039\u00039\u00039\u00079\u01c5\n9\f9\u000e9\u01c8\u000b",
  788. "9\u00039\u00059\u01cb\n9\u00039\u00039\u00039\u00039\u00039\u00079\u01d2",
  789. "\n9\f9\u000e9\u01d5\u000b9\u00039\u00039\u00059\u01d9\n9\u00039\u0003",
  790. "9\u0003\u01d3\u0002:\u0003\u0003\u0005\u0004\u0007\u0005\t\u0006\u000b",
  791. "\u0007\r\b\u000f\t\u0011\n\u0013\u000b\u0015\f\u0017\r\u0019\u000e\u001b",
  792. "\u000f\u001d\u0010\u001f\u0011!\u0012#\u0013%\u0014\'\u0015)\u0016+",
  793. "\u0017-\u0002/\u00021\u00023\u00185\u00197\u001a9\u001b;\u001c=\u001d",
  794. "?\u001eA\u001fC E!G\"I#K$M%O&Q\'S(U)W*Y\u0002[+]\u0002_,a-c\u0002e.",
  795. "g\u0002i\u0002k\u0002m\u0002o\u0002q/\u0003\u0002\u0012\u0004\u0002",
  796. "--//\u0005\u0002\'\',,11\u0004\u0002>>@@\u0005\u0002C\\aac|\u0006\u0002",
  797. "2;C\\aac|\u0003\u00022;\u0003\u000223\u0004\u0002GGgg\u0006\u0002\f",
  798. "\f\u000f\u000f$$^^\u0006\u0002\f\f\u000f\u000f))^^\u0004\u0002\u000b",
  799. "\u000b\"\"\u0004\u0002\f\f\u000f\u000f\u0005\u00022;CHch\u0003\u0002",
  800. "29\n\u0002$$))^^ddhhppttvv\u0003\u000225\u0002\u01f0\u0002\u0003\u0003",
  801. "\u0002\u0002\u0002\u0002\u0005\u0003\u0002\u0002\u0002\u0002\u0007\u0003",
  802. "\u0002\u0002\u0002\u0002\t\u0003\u0002\u0002\u0002\u0002\u000b\u0003",
  803. "\u0002\u0002\u0002\u0002\r\u0003\u0002\u0002\u0002\u0002\u000f\u0003",
  804. "\u0002\u0002\u0002\u0002\u0011\u0003\u0002\u0002\u0002\u0002\u0013\u0003",
  805. "\u0002\u0002\u0002\u0002\u0015\u0003\u0002\u0002\u0002\u0002\u0017\u0003",
  806. "\u0002\u0002\u0002\u0002\u0019\u0003\u0002\u0002\u0002\u0002\u001b\u0003",
  807. "\u0002\u0002\u0002\u0002\u001d\u0003\u0002\u0002\u0002\u0002\u001f\u0003",
  808. "\u0002\u0002\u0002\u0002!\u0003\u0002\u0002\u0002\u0002#\u0003\u0002",
  809. "\u0002\u0002\u0002%\u0003\u0002\u0002\u0002\u0002\'\u0003\u0002\u0002",
  810. "\u0002\u0002)\u0003\u0002\u0002\u0002\u0002+\u0003\u0002\u0002\u0002",
  811. "\u00023\u0003\u0002\u0002\u0002\u00025\u0003\u0002\u0002\u0002\u0002",
  812. "7\u0003\u0002\u0002\u0002\u00029\u0003\u0002\u0002\u0002\u0002;\u0003",
  813. "\u0002\u0002\u0002\u0002=\u0003\u0002\u0002\u0002\u0002?\u0003\u0002",
  814. "\u0002\u0002\u0002A\u0003\u0002\u0002\u0002\u0002C\u0003\u0002\u0002",
  815. "\u0002\u0002E\u0003\u0002\u0002\u0002\u0002G\u0003\u0002\u0002\u0002",
  816. "\u0002I\u0003\u0002\u0002\u0002\u0002K\u0003\u0002\u0002\u0002\u0002",
  817. "M\u0003\u0002\u0002\u0002\u0002O\u0003\u0002\u0002\u0002\u0002Q\u0003",
  818. "\u0002\u0002\u0002\u0002S\u0003\u0002\u0002\u0002\u0002U\u0003\u0002",
  819. "\u0002\u0002\u0002W\u0003\u0002\u0002\u0002\u0002[\u0003\u0002\u0002",
  820. "\u0002\u0002_\u0003\u0002\u0002\u0002\u0002a\u0003\u0002\u0002\u0002",
  821. "\u0002e\u0003\u0002\u0002\u0002\u0002q\u0003\u0002\u0002\u0002\u0003",
  822. "s\u0003\u0002\u0002\u0002\u0005|\u0003\u0002\u0002\u0002\u0007\u0081",
  823. "\u0003\u0002\u0002\u0002\t\u0087\u0003\u0002\u0002\u0002\u000b\u008e",
  824. "\u0003\u0002\u0002\u0002\r\u0095\u0003\u0002\u0002\u0002\u000f\u009d",
  825. "\u0003\u0002\u0002\u0002\u0011\u00a7\u0003\u0002\u0002\u0002\u0013\u00af",
  826. "\u0003\u0002\u0002\u0002\u0015\u00b4\u0003\u0002\u0002\u0002\u0017\u00be",
  827. "\u0003\u0002\u0002\u0002\u0019\u00c4\u0003\u0002\u0002\u0002\u001b\u00cb",
  828. "\u0003\u0002\u0002\u0002\u001d\u00d3\u0003\u0002\u0002\u0002\u001f\u00d8",
  829. "\u0003\u0002\u0002\u0002!\u00dd\u0003\u0002\u0002\u0002#\u00e2\u0003",
  830. "\u0002\u0002\u0002%\u00eb\u0003\u0002\u0002\u0002\'\u00ee\u0003\u0002",
  831. "\u0002\u0002)\u00f4\u0003\u0002\u0002\u0002+\u00fa\u0003\u0002\u0002",
  832. "\u0002-\u0105\u0003\u0002\u0002\u0002/\u0109\u0003\u0002\u0002\u0002",
  833. "1\u010b\u0003\u0002\u0002\u00023\u010e\u0003\u0002\u0002\u00025\u0110",
  834. "\u0003\u0002\u0002\u00027\u0112\u0003\u0002\u0002\u00029\u0114\u0003",
  835. "\u0002\u0002\u0002;\u0116\u0003\u0002\u0002\u0002=\u0118\u0003\u0002",
  836. "\u0002\u0002?\u011a\u0003\u0002\u0002\u0002A\u011c\u0003\u0002\u0002",
  837. "\u0002C\u011e\u0003\u0002\u0002\u0002E\u0120\u0003\u0002\u0002\u0002",
  838. "G\u0122\u0003\u0002\u0002\u0002I\u0124\u0003\u0002\u0002\u0002K\u012f",
  839. "\u0003\u0002\u0002\u0002M\u0131\u0003\u0002\u0002\u0002O\u0133\u0003",
  840. "\u0002\u0002\u0002Q\u0135\u0003\u0002\u0002\u0002S\u013c\u0003\u0002",
  841. "\u0002\u0002U\u015b\u0003\u0002\u0002\u0002W\u0175\u0003\u0002\u0002",
  842. "\u0002Y\u0177\u0003\u0002\u0002\u0002[\u0180\u0003\u0002\u0002\u0002",
  843. "]\u018b\u0003\u0002\u0002\u0002_\u018d\u0003\u0002\u0002\u0002a\u0194",
  844. "\u0003\u0002\u0002\u0002c\u0198\u0003\u0002\u0002\u0002e\u01a0\u0003",
  845. "\u0002\u0002\u0002g\u01a2\u0003\u0002\u0002\u0002i\u01a4\u0003\u0002",
  846. "\u0002\u0002k\u01aa\u0003\u0002\u0002\u0002m\u01b7\u0003\u0002\u0002",
  847. "\u0002o\u01b9\u0003\u0002\u0002\u0002q\u01d8\u0003\u0002\u0002\u0002",
  848. "st\u0007r\u0002\u0002tu\u0007t\u0002\u0002uv\u0007q\u0002\u0002vw\u0007",
  849. "i\u0002\u0002wx\u0007t\u0002\u0002xy\u0007c\u0002\u0002yz\u0007o\u0002",
  850. "\u0002z{\u0007c\u0002\u0002{\u0004\u0003\u0002\u0002\u0002|}\u0007t",
  851. "\u0002\u0002}~\u0007g\u0002\u0002~\u007f\u0007c\u0002\u0002\u007f\u0080",
  852. "\u0007n\u0002\u0002\u0080\u0006\u0003\u0002\u0002\u0002\u0081\u0082",
  853. "\u0007x\u0002\u0002\u0082\u0083\u0007c\u0002\u0002\u0083\u0084\u0007",
  854. "|\u0002\u0002\u0084\u0085\u0007k\u0002\u0002\u0085\u0086\u0007q\u0002",
  855. "\u0002\u0086\b\u0003\u0002\u0002\u0002\u0087\u0088\u0007n\u0002\u0002",
  856. "\u0088\u0089\u0007q\u0002\u0002\u0089\u008a\u0007i\u0002\u0002\u008a",
  857. "\u008b\u0007k\u0002\u0002\u008b\u008c\u0007e\u0002\u0002\u008c\u008d",
  858. "\u0007q\u0002\u0002\u008d\n\u0003\u0002\u0002\u0002\u008e\u008f\u0007",
  859. "e\u0002\u0002\u008f\u0090\u0007c\u0002\u0002\u0090\u0091\u0007f\u0002",
  860. "\u0002\u0091\u0092\u0007g\u0002\u0002\u0092\u0093\u0007k\u0002\u0002",
  861. "\u0093\u0094\u0007c\u0002\u0002\u0094\f\u0003\u0002\u0002\u0002\u0095",
  862. "\u0096\u0007k\u0002\u0002\u0096\u0097\u0007p\u0002\u0002\u0097\u0098",
  863. "\u0007v\u0002\u0002\u0098\u0099\u0007g\u0002\u0002\u0099\u009a\u0007",
  864. "k\u0002\u0002\u009a\u009b\u0007t\u0002\u0002\u009b\u009c\u0007q\u0002",
  865. "\u0002\u009c\u000e\u0003\u0002\u0002\u0002\u009d\u009e\u0007e\u0002",
  866. "\u0002\u009e\u009f\u0007c\u0002\u0002\u009f\u00a0\u0007t\u0002\u0002",
  867. "\u00a0\u00a1\u0007c\u0002\u0002\u00a1\u00a2\u0007e\u0002\u0002\u00a2",
  868. "\u00a3\u0007v\u0002\u0002\u00a3\u00a4\u0007g\u0002\u0002\u00a4\u00a5",
  869. "\u0007t\u0002\u0002\u00a5\u00a6\u0007g\u0002\u0002\u00a6\u0010\u0003",
  870. "\u0002\u0002\u0002\u00a7\u00a8\u0007g\u0002\u0002\u00a8\u00a9\u0007",
  871. "u\u0002\u0002\u00a9\u00aa\u0007e\u0002\u0002\u00aa\u00ab\u0007q\u0002",
  872. "\u0002\u00ab\u00ac\u0007n\u0002\u0002\u00ac\u00ad\u0007j\u0002\u0002",
  873. "\u00ad\u00ae\u0007c\u0002\u0002\u00ae\u0012\u0003\u0002\u0002\u0002",
  874. "\u00af\u00b0\u0007e\u0002\u0002\u00b0\u00b1\u0007c\u0002\u0002\u00b1",
  875. "\u00b2\u0007u\u0002\u0002\u00b2\u00b3\u0007q\u0002\u0002\u00b3\u0014",
  876. "\u0003\u0002\u0002\u0002\u00b4\u00b5\u0007e\u0002\u0002\u00b5\u00b6",
  877. "\u0007q\u0002\u0002\u00b6\u00b7\u0007p\u0002\u0002\u00b7\u00b8\u0007",
  878. "v\u0002\u0002\u00b8\u00b9\u0007t\u0002\u0002\u00b9\u00ba\u0007c\u0002",
  879. "\u0002\u00ba\u00bb\u0007t\u0002\u0002\u00bb\u00bc\u0007k\u0002\u0002",
  880. "\u00bc\u00bd\u0007q\u0002\u0002\u00bd\u0016\u0003\u0002\u0002\u0002",
  881. "\u00be\u00bf\u0007e\u0002\u0002\u00bf\u00c0\u0007q\u0002\u0002\u00c0",
  882. "\u00c1\u0007p\u0002\u0002\u00c1\u00c2\u0007u\u0002\u0002\u00c2\u00c3",
  883. "\u0007v\u0002\u0002\u00c3\u0018\u0003\u0002\u0002\u0002\u00c4\u00c5",
  884. "\u0007h\u0002\u0002\u00c5\u00c6\u0007w\u0002\u0002\u00c6\u00c7\u0007",
  885. "p\u0002\u0002\u00c7\u00c8\u0007e\u0002\u0002\u00c8\u00c9\u0007c\u0002",
  886. "\u0002\u00c9\u00ca\u0007q\u0002\u0002\u00ca\u001a\u0003\u0002\u0002",
  887. "\u0002\u00cb\u00cc\u0007t\u0002\u0002\u00cc\u00cd\u0007g\u0002\u0002",
  888. "\u00cd\u00ce\u0007v\u0002\u0002\u00ce\u00cf\u0007q\u0002\u0002\u00cf",
  889. "\u00d0\u0007t\u0002\u0002\u00d0\u00d1\u0007p\u0002\u0002\u00d1\u00d2",
  890. "\u0007g\u0002\u0002\u00d2\u001c\u0003\u0002\u0002\u0002\u00d3\u00d4",
  891. "\u0007r\u0002\u0002\u00d4\u00d5\u0007c\u0002\u0002\u00d5\u00d6\u0007",
  892. "t\u0002\u0002\u00d6\u00d7\u0007c\u0002\u0002\u00d7\u001e\u0003\u0002",
  893. "\u0002\u0002\u00d8\u00d9\u0007r\u0002\u0002\u00d9\u00da\u0007c\u0002",
  894. "\u0002\u00da\u00db\u0007t\u0002\u0002\u00db\u00dc\u0007g\u0002\u0002",
  895. "\u00dc \u0003\u0002\u0002\u0002\u00dd\u00de\u0007h\u0002\u0002\u00de",
  896. "\u00df\u0007c\u0002\u0002\u00df\u00e0\u0007e\u0002\u0002\u00e0\u00e1",
  897. "\u0007c\u0002\u0002\u00e1\"\u0003\u0002\u0002\u0002\u00e2\u00e3\u0007",
  898. "g\u0002\u0002\u00e3\u00e4\u0007p\u0002\u0002\u00e4\u00e5\u0007s\u0002",
  899. "\u0002\u00e5\u00e6\u0007w\u0002\u0002\u00e6\u00e7\u0007c\u0002\u0002",
  900. "\u00e7\u00e8\u0007p\u0002\u0002\u00e8\u00e9\u0007v\u0002\u0002\u00e9",
  901. "\u00ea\u0007q\u0002\u0002\u00ea$\u0003\u0002\u0002\u0002\u00eb\u00ec",
  902. "\u0007u\u0002\u0002\u00ec\u00ed\u0007g\u0002\u0002\u00ed&\u0003\u0002",
  903. "\u0002\u0002\u00ee\u00ef\u0007u\u0002\u0002\u00ef\u00f0\u0007g\u0002",
  904. "\u0002\u00f0\u00f1\u0007p\u0002\u0002\u00f1\u00f2\u0007c\u0002\u0002",
  905. "\u00f2\u00f3\u0007q\u0002\u0002\u00f3(\u0003\u0002\u0002\u0002\u00f4",
  906. "\u00f5\u0007h\u0002\u0002\u00f5\u00f6\u0007c\u0002\u0002\u00f6\u00f7",
  907. "\u0007n\u0002\u0002\u00f7\u00f8\u0007u\u0002\u0002\u00f8\u00f9\u0007",
  908. "q\u0002\u0002\u00f9*\u0003\u0002\u0002\u0002\u00fa\u00fb\u0007x\u0002",
  909. "\u0002\u00fb\u00fc\u0007g\u0002\u0002\u00fc\u00fd\u0007t\u0002\u0002",
  910. "\u00fd\u00fe\u0007f\u0002\u0002\u00fe\u00ff\u0007c\u0002\u0002\u00ff",
  911. "\u0100\u0007f\u0002\u0002\u0100\u0101\u0007g\u0002\u0002\u0101\u0102",
  912. "\u0007k\u0002\u0002\u0102\u0103\u0007t\u0002\u0002\u0103\u0104\u0007",
  913. "q\u0002\u0002\u0104,\u0003\u0002\u0002\u0002\u0105\u0106\u0007p\u0002",
  914. "\u0002\u0106\u0107\u0007c\u0002\u0002\u0107\u0108\u0007q\u0002\u0002",
  915. "\u0108.\u0003\u0002\u0002\u0002\u0109\u010a\u0007G\u0002\u0002\u010a",
  916. "0\u0003\u0002\u0002\u0002\u010b\u010c\u0007Q\u0002\u0002\u010c\u010d",
  917. "\u0007W\u0002\u0002\u010d2\u0003\u0002\u0002\u0002\u010e\u010f\u0007",
  918. "*\u0002\u0002\u010f4\u0003\u0002\u0002\u0002\u0110\u0111\u0007+\u0002",
  919. "\u0002\u01116\u0003\u0002\u0002\u0002\u0112\u0113\u0007]\u0002\u0002",
  920. "\u01138\u0003\u0002\u0002\u0002\u0114\u0115\u0007_\u0002\u0002\u0115",
  921. ":\u0003\u0002\u0002\u0002\u0116\u0117\u0007}\u0002\u0002\u0117<\u0003",
  922. "\u0002\u0002\u0002\u0118\u0119\u0007\u007f\u0002\u0002\u0119>\u0003",
  923. "\u0002\u0002\u0002\u011a\u011b\u0007.\u0002\u0002\u011b@\u0003\u0002",
  924. "\u0002\u0002\u011c\u011d\u0007?\u0002\u0002\u011dB\u0003\u0002\u0002",
  925. "\u0002\u011e\u011f\t\u0002\u0002\u0002\u011fD\u0003\u0002\u0002\u0002",
  926. "\u0120\u0121\t\u0003\u0002\u0002\u0121F\u0003\u0002\u0002\u0002\u0122",
  927. "\u0123\u0005/\u0018\u0002\u0123H\u0003\u0002\u0002\u0002\u0124\u0125",
  928. "\u00051\u0019\u0002\u0125J\u0003\u0002\u0002\u0002\u0126\u0127\u0007",
  929. "@\u0002\u0002\u0127\u0130\u0007?\u0002\u0002\u0128\u0129\u0007?\u0002",
  930. "\u0002\u0129\u0130\u0007?\u0002\u0002\u012a\u012b\u0007>\u0002\u0002",
  931. "\u012b\u0130\u0007?\u0002\u0002\u012c\u0130\t\u0004\u0002\u0002\u012d",
  932. "\u012e\u0007#\u0002\u0002\u012e\u0130\u0007?\u0002\u0002\u012f\u0126",
  933. "\u0003\u0002\u0002\u0002\u012f\u0128\u0003\u0002\u0002\u0002\u012f\u012a",
  934. "\u0003\u0002\u0002\u0002\u012f\u012c\u0003\u0002\u0002\u0002\u012f\u012d",
  935. "\u0003\u0002\u0002\u0002\u0130L\u0003\u0002\u0002\u0002\u0131\u0132",
  936. "\u0007<\u0002\u0002\u0132N\u0003\u0002\u0002\u0002\u0133\u0134\u0005",
  937. "-\u0017\u0002\u0134P\u0003\u0002\u0002\u0002\u0135\u0139\t\u0005\u0002",
  938. "\u0002\u0136\u0138\t\u0006\u0002\u0002\u0137\u0136\u0003\u0002\u0002",
  939. "\u0002\u0138\u013b\u0003\u0002\u0002\u0002\u0139\u0137\u0003\u0002\u0002",
  940. "\u0002\u0139\u013a\u0003\u0002\u0002\u0002\u013aR\u0003\u0002\u0002",
  941. "\u0002\u013b\u0139\u0003\u0002\u0002\u0002\u013c\u013d\u0005Q)\u0002",
  942. "\u013d\u013e\u00070\u0002\u0002\u013e\u013f\u0005Q)\u0002\u013fT\u0003",
  943. "\u0002\u0002\u0002\u0140\u0142\t\u0007\u0002\u0002\u0141\u0140\u0003",
  944. "\u0002\u0002\u0002\u0142\u0143\u0003\u0002\u0002\u0002\u0143\u0141\u0003",
  945. "\u0002\u0002\u0002\u0143\u0144\u0003\u0002\u0002\u0002\u0144\u015c\u0003",
  946. "\u0002\u0002\u0002\u0145\u0146\u00072\u0002\u0002\u0146\u014a\u0007",
  947. "z\u0002\u0002\u0147\u0148\u00072\u0002\u0002\u0148\u014a\u0007Z\u0002",
  948. "\u0002\u0149\u0145\u0003\u0002\u0002\u0002\u0149\u0147\u0003\u0002\u0002",
  949. "\u0002\u014a\u014c\u0003\u0002\u0002\u0002\u014b\u014d\u0005g4\u0002",
  950. "\u014c\u014b\u0003\u0002\u0002\u0002\u014d\u014e\u0003\u0002\u0002\u0002",
  951. "\u014e\u014c\u0003\u0002\u0002\u0002\u014e\u014f\u0003\u0002\u0002\u0002",
  952. "\u014f\u015c\u0003\u0002\u0002\u0002\u0150\u0151\u00072\u0002\u0002",
  953. "\u0151\u0155\u0007d\u0002\u0002\u0152\u0153\u00072\u0002\u0002\u0153",
  954. "\u0155\u0007D\u0002\u0002\u0154\u0150\u0003\u0002\u0002\u0002\u0154",
  955. "\u0152\u0003\u0002\u0002\u0002\u0155\u0157\u0003\u0002\u0002\u0002\u0156",
  956. "\u0158\t\b\u0002\u0002\u0157\u0156\u0003\u0002\u0002\u0002\u0158\u0159",
  957. "\u0003\u0002\u0002\u0002\u0159\u0157\u0003\u0002\u0002\u0002\u0159\u015a",
  958. "\u0003\u0002\u0002\u0002\u015a\u015c\u0003\u0002\u0002\u0002\u015b\u0141",
  959. "\u0003\u0002\u0002\u0002\u015b\u0149\u0003\u0002\u0002\u0002\u015b\u0154",
  960. "\u0003\u0002\u0002\u0002\u015cV\u0003\u0002\u0002\u0002\u015d\u015f",
  961. "\t\u0007\u0002\u0002\u015e\u015d\u0003\u0002\u0002\u0002\u015f\u0160",
  962. "\u0003\u0002\u0002\u0002\u0160\u015e\u0003\u0002\u0002\u0002\u0160\u0161",
  963. "\u0003\u0002\u0002\u0002\u0161\u0162\u0003\u0002\u0002\u0002\u0162\u0164",
  964. "\u00070\u0002\u0002\u0163\u0165\t\u0007\u0002\u0002\u0164\u0163\u0003",
  965. "\u0002\u0002\u0002\u0165\u0166\u0003\u0002\u0002\u0002\u0166\u0164\u0003",
  966. "\u0002\u0002\u0002\u0166\u0167\u0003\u0002\u0002\u0002\u0167\u0176\u0003",
  967. "\u0002\u0002\u0002\u0168\u016a\t\u0007\u0002\u0002\u0169\u0168\u0003",
  968. "\u0002\u0002\u0002\u016a\u016b\u0003\u0002\u0002\u0002\u016b\u0169\u0003",
  969. "\u0002\u0002\u0002\u016b\u016c\u0003\u0002\u0002\u0002\u016c\u016d\u0003",
  970. "\u0002\u0002\u0002\u016d\u0171\u00070\u0002\u0002\u016e\u0170\t\u0007",
  971. "\u0002\u0002\u016f\u016e\u0003\u0002\u0002\u0002\u0170\u0173\u0003\u0002",
  972. "\u0002\u0002\u0171\u016f\u0003\u0002\u0002\u0002\u0171\u0172\u0003\u0002",
  973. "\u0002\u0002\u0172\u0174\u0003\u0002\u0002\u0002\u0173\u0171\u0003\u0002",
  974. "\u0002\u0002\u0174\u0176\u0005Y-\u0002\u0175\u015e\u0003\u0002\u0002",
  975. "\u0002\u0175\u0169\u0003\u0002\u0002\u0002\u0176X\u0003\u0002\u0002",
  976. "\u0002\u0177\u0179\t\t\u0002\u0002\u0178\u017a\t\u0002\u0002\u0002\u0179",
  977. "\u0178\u0003\u0002\u0002\u0002\u0179\u017a\u0003\u0002\u0002\u0002\u017a",
  978. "\u017c\u0003\u0002\u0002\u0002\u017b\u017d\t\u0007\u0002\u0002\u017c",
  979. "\u017b\u0003\u0002\u0002\u0002\u017d\u017e\u0003\u0002\u0002\u0002\u017e",
  980. "\u017c\u0003\u0002\u0002\u0002\u017e\u017f\u0003\u0002\u0002\u0002\u017f",
  981. "Z\u0003\u0002\u0002\u0002\u0180\u0184\u0007$\u0002\u0002\u0181\u0183",
  982. "\u0005]/\u0002\u0182\u0181\u0003\u0002\u0002\u0002\u0183\u0186\u0003",
  983. "\u0002\u0002\u0002\u0184\u0182\u0003\u0002\u0002\u0002\u0184\u0185\u0003",
  984. "\u0002\u0002\u0002\u0185\u0187\u0003\u0002\u0002\u0002\u0186\u0184\u0003",
  985. "\u0002\u0002\u0002\u0187\u0188\u0007$\u0002\u0002\u0188\\\u0003\u0002",
  986. "\u0002\u0002\u0189\u018c\n\n\u0002\u0002\u018a\u018c\u0005k6\u0002\u018b",
  987. "\u0189\u0003\u0002\u0002\u0002\u018b\u018a\u0003\u0002\u0002\u0002\u018c",
  988. "^\u0003\u0002\u0002\u0002\u018d\u0190\u0007)\u0002\u0002\u018e\u0191",
  989. "\u0005k6\u0002\u018f\u0191\n\u000b\u0002\u0002\u0190\u018e\u0003\u0002",
  990. "\u0002\u0002\u0190\u018f\u0003\u0002\u0002\u0002\u0191\u0192\u0003\u0002",
  991. "\u0002\u0002\u0192\u0193\u0007)\u0002\u0002\u0193`\u0003\u0002\u0002",
  992. "\u0002\u0194\u0195\t\f\u0002\u0002\u0195\u0196\u0003\u0002\u0002\u0002",
  993. "\u0196\u0197\b1\u0002\u0002\u0197b\u0003\u0002\u0002\u0002\u0198\u0199",
  994. "\u0007=\u0002\u0002\u0199d\u0003\u0002\u0002\u0002\u019a\u019c\t\r\u0002",
  995. "\u0002\u019b\u019a\u0003\u0002\u0002\u0002\u019c\u019d\u0003\u0002\u0002",
  996. "\u0002\u019d\u019b\u0003\u0002\u0002\u0002\u019d\u019e\u0003\u0002\u0002",
  997. "\u0002\u019e\u01a1\u0003\u0002\u0002\u0002\u019f\u01a1\u0005c2\u0002",
  998. "\u01a0\u019b\u0003\u0002\u0002\u0002\u01a0\u019f\u0003\u0002\u0002\u0002",
  999. "\u01a1f\u0003\u0002\u0002\u0002\u01a2\u01a3\t\u000e\u0002\u0002\u01a3",
  1000. "h\u0003\u0002\u0002\u0002\u01a4\u01a5\t\u000f\u0002\u0002\u01a5j\u0003",
  1001. "\u0002\u0002\u0002\u01a6\u01a7\u0007^\u0002\u0002\u01a7\u01ab\t\u0010",
  1002. "\u0002\u0002\u01a8\u01ab\u0005o8\u0002\u01a9\u01ab\u0005m7\u0002\u01aa",
  1003. "\u01a6\u0003\u0002\u0002\u0002\u01aa\u01a8\u0003\u0002\u0002\u0002\u01aa",
  1004. "\u01a9\u0003\u0002\u0002\u0002\u01abl\u0003\u0002\u0002\u0002\u01ac",
  1005. "\u01ad\u0007^\u0002\u0002\u01ad\u01ae\t\u0011\u0002\u0002\u01ae\u01af",
  1006. "\u0005i5\u0002\u01af\u01b0\u0005i5\u0002\u01b0\u01b8\u0003\u0002\u0002",
  1007. "\u0002\u01b1\u01b2\u0007^\u0002\u0002\u01b2\u01b3\u0005i5\u0002\u01b3",
  1008. "\u01b4\u0005i5\u0002\u01b4\u01b8\u0003\u0002\u0002\u0002\u01b5\u01b6",
  1009. "\u0007^\u0002\u0002\u01b6\u01b8\u0005i5\u0002\u01b7\u01ac\u0003\u0002",
  1010. "\u0002\u0002\u01b7\u01b1\u0003\u0002\u0002\u0002\u01b7\u01b5\u0003\u0002",
  1011. "\u0002\u0002\u01b8n\u0003\u0002\u0002\u0002\u01b9\u01ba\u0007^\u0002",
  1012. "\u0002\u01ba\u01bb\u0007w\u0002\u0002\u01bb\u01bc\u0005g4\u0002\u01bc",
  1013. "\u01bd\u0005g4\u0002\u01bd\u01be\u0005g4\u0002\u01be\u01bf\u0005g4\u0002",
  1014. "\u01bfp\u0003\u0002\u0002\u0002\u01c0\u01c1\u00071\u0002\u0002\u01c1",
  1015. "\u01c2\u00071\u0002\u0002\u01c2\u01c6\u0003\u0002\u0002\u0002\u01c3",
  1016. "\u01c5\n\r\u0002\u0002\u01c4\u01c3\u0003\u0002\u0002\u0002\u01c5\u01c8",
  1017. "\u0003\u0002\u0002\u0002\u01c6\u01c4\u0003\u0002\u0002\u0002\u01c6\u01c7",
  1018. "\u0003\u0002\u0002\u0002\u01c7\u01ca\u0003\u0002\u0002\u0002\u01c8\u01c6",
  1019. "\u0003\u0002\u0002\u0002\u01c9\u01cb\u0007\u000f\u0002\u0002\u01ca\u01c9",
  1020. "\u0003\u0002\u0002\u0002\u01ca\u01cb\u0003\u0002\u0002\u0002\u01cb\u01cc",
  1021. "\u0003\u0002\u0002\u0002\u01cc\u01d9\u0007\f\u0002\u0002\u01cd\u01ce",
  1022. "\u00071\u0002\u0002\u01ce\u01cf\u0007,\u0002\u0002\u01cf\u01d3\u0003",
  1023. "\u0002\u0002\u0002\u01d0\u01d2\u000b\u0002\u0002\u0002\u01d1\u01d0\u0003",
  1024. "\u0002\u0002\u0002\u01d2\u01d5\u0003\u0002\u0002\u0002\u01d3\u01d4\u0003",
  1025. "\u0002\u0002\u0002\u01d3\u01d1\u0003\u0002\u0002\u0002\u01d4\u01d6\u0003",
  1026. "\u0002\u0002\u0002\u01d5\u01d3\u0003\u0002\u0002\u0002\u01d6\u01d7\u0007",
  1027. ",\u0002\u0002\u01d7\u01d9\u00071\u0002\u0002\u01d8\u01c0\u0003\u0002",
  1028. "\u0002\u0002\u01d8\u01cd\u0003\u0002\u0002\u0002\u01d9\u01da\u0003\u0002",
  1029. "\u0002\u0002\u01da\u01db\b9\u0003\u0002\u01dbr\u0003\u0002\u0002\u0002",
  1030. "\u001d\u0002\u012f\u0139\u0143\u0149\u014e\u0154\u0159\u015b\u0160\u0166",
  1031. "\u016b\u0171\u0175\u0179\u017e\u0184\u018b\u0190\u019d\u01a0\u01aa\u01b7",
  1032. "\u01c6\u01ca\u01d3\u01d8\u0004\b\u0002\u0002\u0002\u0003\u0002"].join("");
  1033. var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
  1034. var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });
  1035. function ivprog(input) {
  1036. antlr4.Lexer.call(this, input);
  1037. this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
  1038. return this;
  1039. }
  1040. ivprog.prototype = Object.create(antlr4.Lexer.prototype);
  1041. ivprog.prototype.constructor = ivprog;
  1042. ivprog.EOF = antlr4.Token.EOF;
  1043. ivprog.RK_PROGRAM = 1;
  1044. ivprog.RK_REAL = 2;
  1045. ivprog.RK_VOID = 3;
  1046. ivprog.RK_BOOLEAN = 4;
  1047. ivprog.RK_STRING = 5;
  1048. ivprog.RK_INTEGER = 6;
  1049. ivprog.RK_CHARACTER = 7;
  1050. ivprog.RK_SWITCH = 8;
  1051. ivprog.RK_CASE = 9;
  1052. ivprog.RK_DEFAULT = 10;
  1053. ivprog.RK_CONST = 11;
  1054. ivprog.RK_FUNCTION = 12;
  1055. ivprog.RK_RETURN = 13;
  1056. ivprog.RK_FOR = 14;
  1057. ivprog.RK_BREAK = 15;
  1058. ivprog.RK_DO = 16;
  1059. ivprog.RK_WHILE = 17;
  1060. ivprog.RK_IF = 18;
  1061. ivprog.RK_ELSE = 19;
  1062. ivprog.RK_FALSE = 20;
  1063. ivprog.RK_TRUE = 21;
  1064. ivprog.OPEN_PARENTHESIS = 22;
  1065. ivprog.CLOSE_PARENTHESIS = 23;
  1066. ivprog.OPEN_BRACE = 24;
  1067. ivprog.CLOSE_BRACE = 25;
  1068. ivprog.OPEN_CURLY = 26;
  1069. ivprog.CLOSE_CURLY = 27;
  1070. ivprog.COMMA = 28;
  1071. ivprog.EQUAL = 29;
  1072. ivprog.SUM_OP = 30;
  1073. ivprog.MULTI_OP = 31;
  1074. ivprog.AND_OPERATOR = 32;
  1075. ivprog.OR_OPERATOR = 33;
  1076. ivprog.RELATIONAL_OPERATOR = 34;
  1077. ivprog.COLON = 35;
  1078. ivprog.NOT_OPERATOR = 36;
  1079. ivprog.ID = 37;
  1080. ivprog.LIB_ID = 38;
  1081. ivprog.INTEGER = 39;
  1082. ivprog.REAL = 40;
  1083. ivprog.STRING = 41;
  1084. ivprog.CHARACTER = 42;
  1085. ivprog.WHITESPACE = 43;
  1086. ivprog.EOS = 44;
  1087. ivprog.COMMENTS = 45;
  1088. ivprog.prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];
  1089. ivprog.prototype.modeNames = [ "DEFAULT_MODE" ];
  1090. ivprog.prototype.literalNames = [ null, "'programa'", "'real'", "'vazio'",
  1091. "'logico'", "'cadeia'", "'inteiro'", "'caractere'",
  1092. "'escolha'", "'caso'", "'contrario'",
  1093. "'const'", "'funcao'", "'retorne'", "'para'",
  1094. "'pare'", "'faca'", "'enquanto'", "'se'",
  1095. "'senao'", "'falso'", "'verdadeiro'",
  1096. "'('", "')'", "'['", "']'", "'{'", "'}'",
  1097. "','", "'='", null, null, null, null,
  1098. null, "':'" ];
  1099. ivprog.prototype.symbolicNames = [ null, "RK_PROGRAM", "RK_REAL", "RK_VOID",
  1100. "RK_BOOLEAN", "RK_STRING", "RK_INTEGER",
  1101. "RK_CHARACTER", "RK_SWITCH", "RK_CASE",
  1102. "RK_DEFAULT", "RK_CONST", "RK_FUNCTION",
  1103. "RK_RETURN", "RK_FOR", "RK_BREAK", "RK_DO",
  1104. "RK_WHILE", "RK_IF", "RK_ELSE", "RK_FALSE",
  1105. "RK_TRUE", "OPEN_PARENTHESIS", "CLOSE_PARENTHESIS",
  1106. "OPEN_BRACE", "CLOSE_BRACE", "OPEN_CURLY",
  1107. "CLOSE_CURLY", "COMMA", "EQUAL", "SUM_OP",
  1108. "MULTI_OP", "AND_OPERATOR", "OR_OPERATOR",
  1109. "RELATIONAL_OPERATOR", "COLON", "NOT_OPERATOR",
  1110. "ID", "LIB_ID", "INTEGER", "REAL", "STRING",
  1111. "CHARACTER", "WHITESPACE", "EOS", "COMMENTS" ];
  1112. ivprog.prototype.ruleNames = [ "RK_PROGRAM", "RK_REAL", "RK_VOID", "RK_BOOLEAN",
  1113. "RK_STRING", "RK_INTEGER", "RK_CHARACTER",
  1114. "RK_SWITCH", "RK_CASE", "RK_DEFAULT", "RK_CONST",
  1115. "RK_FUNCTION", "RK_RETURN", "RK_FOR", "RK_BREAK",
  1116. "RK_DO", "RK_WHILE", "RK_IF", "RK_ELSE",
  1117. "RK_FALSE", "RK_TRUE", "RK_LOGICAL_NOT",
  1118. "RK_LOGICAL_AND", "RK_LOGICAL_OR", "OPEN_PARENTHESIS",
  1119. "CLOSE_PARENTHESIS", "OPEN_BRACE", "CLOSE_BRACE",
  1120. "OPEN_CURLY", "CLOSE_CURLY", "COMMA", "EQUAL",
  1121. "SUM_OP", "MULTI_OP", "AND_OPERATOR", "OR_OPERATOR",
  1122. "RELATIONAL_OPERATOR", "COLON", "NOT_OPERATOR",
  1123. "ID", "LIB_ID", "INTEGER", "REAL", "ExponentPart",
  1124. "STRING", "STRING_CHARACTER", "CHARACTER",
  1125. "WHITESPACE", "SEMICOLON", "EOS", "HEX_DIGIT",
  1126. "OCTAL_DIGIT", "ESC_SEQ", "ESC_OCTAL", "ESC_UNICODE",
  1127. "COMMENTS" ];
  1128. ivprog.prototype.grammarFileName = "ivprog.g4";
  1129. exports.ivprog = ivprog;
  1130. /***/ }),
  1131. /* 1 */
  1132. /***/ (function(module, exports, __webpack_require__) {
  1133. module.exports = {
  1134. ivprog: __webpack_require__(0).ivprog
  1135. };
  1136. /***/ }),
  1137. /* 2 */
  1138. /***/ (function(module, exports) {
  1139. module.exports = __webpack_require__(/*! antlr4/index */ "./node_modules/antlr4/index.js");
  1140. /***/ })
  1141. /******/ ]);
  1142. /***/ }),
  1143. /***/ "./grammar/es/langFunctions.js":
  1144. /*!*************************************!*\
  1145. !*** ./grammar/es/langFunctions.js ***!
  1146. \*************************************/
  1147. /*! no static exports found */
  1148. /***/ (function(module, exports, __webpack_require__) {
  1149. "use strict";
  1150. Object.defineProperty(exports, "__esModule", {
  1151. value: true
  1152. });
  1153. /* This is a dictionary of the language defined functions
  1154. **/
  1155. exports.default = {
  1156. main_function: "inicio",
  1157. $read: "leia",
  1158. $write: "escreva",
  1159. $numElements: "total_of_elements",
  1160. $matrixLines: "total_of_lines",
  1161. $matrixColumns: "total_of_columns",
  1162. $substring: "subcadeia",
  1163. $length: "comprimento",
  1164. $uppercase: "caixa_alta",
  1165. $lowercase: "caixa_baixa",
  1166. $charAt: "char_at",
  1167. $isReal: "is_real",
  1168. $isInt: "is_integer",
  1169. $isBool: "is_logic",
  1170. $castReal: "to_real",
  1171. $castInt: "to_integer",
  1172. $castBool: "to_logic",
  1173. $castString: "to_string",
  1174. $sin: "sin",
  1175. $cos: "cos",
  1176. $tan: "tan",
  1177. $sqrt: "sqrt",
  1178. $pow: "pow",
  1179. $log: "log",
  1180. $abs: "abs",
  1181. $negate: "negate",
  1182. $invert: "invert",
  1183. $max: "maximum",
  1184. $min: "minimum"
  1185. };
  1186. /***/ }),
  1187. /***/ "./grammar/es/langLibs.js":
  1188. /*!********************************!*\
  1189. !*** ./grammar/es/langLibs.js ***!
  1190. \********************************/
  1191. /*! no static exports found */
  1192. /***/ (function(module, exports, __webpack_require__) {
  1193. "use strict";
  1194. Object.defineProperty(exports, "__esModule", {
  1195. value: true
  1196. });
  1197. /**
  1198. * This is the dictionary of the language defined libraries
  1199. */
  1200. exports.default = {
  1201. $mathLib: "Mathematic",
  1202. $ioLib: "ES",
  1203. $strLib: "Texto",
  1204. $arrayLib: "Arranjo",
  1205. $langLib: "Conversion"
  1206. };
  1207. /***/ }),
  1208. /***/ "./grammar/index.js":
  1209. /*!**************************!*\
  1210. !*** ./grammar/index.js ***!
  1211. \**************************/
  1212. /*! no static exports found */
  1213. /***/ (function(module, exports, __webpack_require__) {
  1214. "use strict";
  1215. var _ivprog = __webpack_require__(/*! ./pt/ivprog.g4 */ "./grammar/pt/ivprog.g4");
  1216. var PT = _interopRequireWildcard(_ivprog);
  1217. var _langFunctions = __webpack_require__(/*! ./pt/langFunctions */ "./grammar/pt/langFunctions.js");
  1218. var _langFunctions2 = _interopRequireDefault(_langFunctions);
  1219. var _langLibs = __webpack_require__(/*! ./pt/langLibs */ "./grammar/pt/langLibs.js");
  1220. var _langLibs2 = _interopRequireDefault(_langLibs);
  1221. var _ivprog2 = __webpack_require__(/*! ./en/ivprog.g4 */ "./grammar/en/ivprog.g4");
  1222. var EN = _interopRequireWildcard(_ivprog2);
  1223. var _langFunctions3 = __webpack_require__(/*! ./en/langFunctions */ "./grammar/en/langFunctions.js");
  1224. var _langFunctions4 = _interopRequireDefault(_langFunctions3);
  1225. var _langLibs3 = __webpack_require__(/*! ./en/langLibs */ "./grammar/en/langLibs.js");
  1226. var _langLibs4 = _interopRequireDefault(_langLibs3);
  1227. var _ivprog3 = __webpack_require__(/*! ./es/ivprog.g4 */ "./grammar/es/ivprog.g4");
  1228. var ES = _interopRequireWildcard(_ivprog3);
  1229. var _langFunctions5 = __webpack_require__(/*! ./es/langFunctions */ "./grammar/es/langFunctions.js");
  1230. var _langFunctions6 = _interopRequireDefault(_langFunctions5);
  1231. var _langLibs5 = __webpack_require__(/*! ./es/langLibs */ "./grammar/es/langLibs.js");
  1232. var _langLibs6 = _interopRequireDefault(_langLibs5);
  1233. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1234. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  1235. exports.pt = { lexer: PT.ivprog, langFuncs: _langFunctions2.default, langLibs: _langLibs2.default };
  1236. exports.en = { lexer: EN.ivprog, langFuncs: _langFunctions4.default, langLibs: _langLibs4.default };
  1237. exports.es = { lexer: ES.ivprog, langFuncs: _langFunctions6.default, langLibs: _langLibs6.default };
  1238. /***/ }),
  1239. /***/ "./grammar/pt/ivprog.g4":
  1240. /*!******************************!*\
  1241. !*** ./grammar/pt/ivprog.g4 ***!
  1242. \******************************/
  1243. /*! no static exports found */
  1244. /***/ (function(module, exports, __webpack_require__) {
  1245. module.exports =
  1246. /******/ (function(modules) { // webpackBootstrap
  1247. /******/ // The module cache
  1248. /******/ var installedModules = {};
  1249. /******/
  1250. /******/ // The require function
  1251. /******/ function __webpack_require__(moduleId) {
  1252. /******/
  1253. /******/ // Check if module is in cache
  1254. /******/ if(installedModules[moduleId]) {
  1255. /******/ return installedModules[moduleId].exports;
  1256. /******/ }
  1257. /******/ // Create a new module (and put it into the cache)
  1258. /******/ var module = installedModules[moduleId] = {
  1259. /******/ i: moduleId,
  1260. /******/ l: false,
  1261. /******/ exports: {}
  1262. /******/ };
  1263. /******/
  1264. /******/ // Execute the module function
  1265. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  1266. /******/
  1267. /******/ // Flag the module as loaded
  1268. /******/ module.l = true;
  1269. /******/
  1270. /******/ // Return the exports of the module
  1271. /******/ return module.exports;
  1272. /******/ }
  1273. /******/
  1274. /******/
  1275. /******/ // expose the modules object (__webpack_modules__)
  1276. /******/ __webpack_require__.m = modules;
  1277. /******/
  1278. /******/ // expose the module cache
  1279. /******/ __webpack_require__.c = installedModules;
  1280. /******/
  1281. /******/ // identity function for calling harmony imports with the correct context
  1282. /******/ __webpack_require__.i = function(value) { return value; };
  1283. /******/
  1284. /******/ // define getter function for harmony exports
  1285. /******/ __webpack_require__.d = function(exports, name, getter) {
  1286. /******/ if(!__webpack_require__.o(exports, name)) {
  1287. /******/ Object.defineProperty(exports, name, {
  1288. /******/ configurable: false,
  1289. /******/ enumerable: true,
  1290. /******/ get: getter
  1291. /******/ });
  1292. /******/ }
  1293. /******/ };
  1294. /******/
  1295. /******/ // getDefaultExport function for compatibility with non-harmony modules
  1296. /******/ __webpack_require__.n = function(module) {
  1297. /******/ var getter = module && module.__esModule ?
  1298. /******/ function getDefault() { return module['default']; } :
  1299. /******/ function getModuleExports() { return module; };
  1300. /******/ __webpack_require__.d(getter, 'a', getter);
  1301. /******/ return getter;
  1302. /******/ };
  1303. /******/
  1304. /******/ // Object.prototype.hasOwnProperty.call
  1305. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  1306. /******/
  1307. /******/ // __webpack_public_path__
  1308. /******/ __webpack_require__.p = "";
  1309. /******/
  1310. /******/ // Load entry module and return exports
  1311. /******/ return __webpack_require__(__webpack_require__.s = 1);
  1312. /******/ })
  1313. /************************************************************************/
  1314. /******/ ([
  1315. /* 0 */
  1316. /***/ (function(module, exports, __webpack_require__) {
  1317. // Generated from /tmp/tmp-4052DITgMh7AGyPW/ivprog.g4 by ANTLR 4.7
  1318. // jshint ignore: start
  1319. var antlr4 = __webpack_require__(2);
  1320. var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
  1321. "\u0002/\u01dc\b\u0001\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004",
  1322. "\u0004\t\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t",
  1323. "\u0007\u0004\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0004",
  1324. "\f\t\f\u0004\r\t\r\u0004\u000e\t\u000e\u0004\u000f\t\u000f\u0004\u0010",
  1325. "\t\u0010\u0004\u0011\t\u0011\u0004\u0012\t\u0012\u0004\u0013\t\u0013",
  1326. "\u0004\u0014\t\u0014\u0004\u0015\t\u0015\u0004\u0016\t\u0016\u0004\u0017",
  1327. "\t\u0017\u0004\u0018\t\u0018\u0004\u0019\t\u0019\u0004\u001a\t\u001a",
  1328. "\u0004\u001b\t\u001b\u0004\u001c\t\u001c\u0004\u001d\t\u001d\u0004\u001e",
  1329. "\t\u001e\u0004\u001f\t\u001f\u0004 \t \u0004!\t!\u0004\"\t\"\u0004#",
  1330. "\t#\u0004$\t$\u0004%\t%\u0004&\t&\u0004\'\t\'\u0004(\t(\u0004)\t)\u0004",
  1331. "*\t*\u0004+\t+\u0004,\t,\u0004-\t-\u0004.\t.\u0004/\t/\u00040\t0\u0004",
  1332. "1\t1\u00042\t2\u00043\t3\u00044\t4\u00045\t5\u00046\t6\u00047\t7\u0004",
  1333. "8\t8\u00049\t9\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003",
  1334. "\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0002\u0003\u0003\u0003",
  1335. "\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0003\u0004\u0003\u0004\u0003",
  1336. "\u0004\u0003\u0004\u0003\u0004\u0003\u0004\u0003\u0005\u0003\u0005\u0003",
  1337. "\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0005\u0003\u0006\u0003",
  1338. "\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003\u0006\u0003",
  1339. "\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003\u0007\u0003",
  1340. "\u0007\u0003\u0007\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003\b\u0003",
  1341. "\b\u0003\b\u0003\b\u0003\b\u0003\t\u0003\t\u0003\t\u0003\t\u0003\t\u0003",
  1342. "\t\u0003\t\u0003\t\u0003\n\u0003\n\u0003\n\u0003\n\u0003\n\u0003\u000b",
  1343. "\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b\u0003\u000b",
  1344. "\u0003\u000b\u0003\u000b\u0003\u000b\u0003\f\u0003\f\u0003\f\u0003\f",
  1345. "\u0003\f\u0003\f\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003\r\u0003",
  1346. "\r\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003\u000e\u0003",
  1347. "\u000e\u0003\u000e\u0003\u000e\u0003\u000f\u0003\u000f\u0003\u000f\u0003",
  1348. "\u000f\u0003\u000f\u0003\u0010\u0003\u0010\u0003\u0010\u0003\u0010\u0003",
  1349. "\u0010\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003\u0011\u0003",
  1350. "\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003\u0012\u0003",
  1351. "\u0012\u0003\u0012\u0003\u0012\u0003\u0013\u0003\u0013\u0003\u0013\u0003",
  1352. "\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003\u0014\u0003",
  1353. "\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003\u0015\u0003",
  1354. "\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003",
  1355. "\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0016\u0003\u0017\u0003",
  1356. "\u0017\u0003\u0017\u0003\u0017\u0003\u0018\u0003\u0018\u0003\u0019\u0003",
  1357. "\u0019\u0003\u0019\u0003\u001a\u0003\u001a\u0003\u001b\u0003\u001b\u0003",
  1358. "\u001c\u0003\u001c\u0003\u001d\u0003\u001d\u0003\u001e\u0003\u001e\u0003",
  1359. "\u001f\u0003\u001f\u0003 \u0003 \u0003!\u0003!\u0003\"\u0003\"\u0003",
  1360. "#\u0003#\u0003$\u0003$\u0003%\u0003%\u0003&\u0003&\u0003&\u0003&\u0003",
  1361. "&\u0003&\u0003&\u0003&\u0003&\u0005&\u0130\n&\u0003\'\u0003\'\u0003",
  1362. "(\u0003(\u0003)\u0003)\u0007)\u0138\n)\f)\u000e)\u013b\u000b)\u0003",
  1363. "*\u0003*\u0003*\u0003*\u0003+\u0006+\u0142\n+\r+\u000e+\u0143\u0003",
  1364. "+\u0003+\u0003+\u0003+\u0005+\u014a\n+\u0003+\u0006+\u014d\n+\r+\u000e",
  1365. "+\u014e\u0003+\u0003+\u0003+\u0003+\u0005+\u0155\n+\u0003+\u0006+\u0158",
  1366. "\n+\r+\u000e+\u0159\u0005+\u015c\n+\u0003,\u0006,\u015f\n,\r,\u000e",
  1367. ",\u0160\u0003,\u0003,\u0006,\u0165\n,\r,\u000e,\u0166\u0003,\u0006,",
  1368. "\u016a\n,\r,\u000e,\u016b\u0003,\u0003,\u0007,\u0170\n,\f,\u000e,\u0173",
  1369. "\u000b,\u0003,\u0005,\u0176\n,\u0003-\u0003-\u0005-\u017a\n-\u0003-",
  1370. "\u0006-\u017d\n-\r-\u000e-\u017e\u0003.\u0003.\u0007.\u0183\n.\f.\u000e",
  1371. ".\u0186\u000b.\u0003.\u0003.\u0003/\u0003/\u0005/\u018c\n/\u00030\u0003",
  1372. "0\u00030\u00050\u0191\n0\u00030\u00030\u00031\u00031\u00031\u00031\u0003",
  1373. "2\u00032\u00033\u00063\u019c\n3\r3\u000e3\u019d\u00033\u00053\u01a1",
  1374. "\n3\u00034\u00034\u00035\u00035\u00036\u00036\u00036\u00036\u00056\u01ab",
  1375. "\n6\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u00037\u0003",
  1376. "7\u00037\u00057\u01b8\n7\u00038\u00038\u00038\u00038\u00038\u00038\u0003",
  1377. "8\u00039\u00039\u00039\u00039\u00079\u01c5\n9\f9\u000e9\u01c8\u000b",
  1378. "9\u00039\u00059\u01cb\n9\u00039\u00039\u00039\u00039\u00039\u00079\u01d2",
  1379. "\n9\f9\u000e9\u01d5\u000b9\u00039\u00039\u00059\u01d9\n9\u00039\u0003",
  1380. "9\u0003\u01d3\u0002:\u0003\u0003\u0005\u0004\u0007\u0005\t\u0006\u000b",
  1381. "\u0007\r\b\u000f\t\u0011\n\u0013\u000b\u0015\f\u0017\r\u0019\u000e\u001b",
  1382. "\u000f\u001d\u0010\u001f\u0011!\u0012#\u0013%\u0014\'\u0015)\u0016+",
  1383. "\u0017-\u0002/\u00021\u00023\u00185\u00197\u001a9\u001b;\u001c=\u001d",
  1384. "?\u001eA\u001fC E!G\"I#K$M%O&Q\'S(U)W*Y\u0002[+]\u0002_,a-c\u0002e.",
  1385. "g\u0002i\u0002k\u0002m\u0002o\u0002q/\u0003\u0002\u0012\u0004\u0002",
  1386. "--//\u0005\u0002\'\',,11\u0004\u0002>>@@\u0005\u0002C\\aac|\u0006\u0002",
  1387. "2;C\\aac|\u0003\u00022;\u0003\u000223\u0004\u0002GGgg\u0006\u0002\f",
  1388. "\f\u000f\u000f$$^^\u0006\u0002\f\f\u000f\u000f))^^\u0004\u0002\u000b",
  1389. "\u000b\"\"\u0004\u0002\f\f\u000f\u000f\u0005\u00022;CHch\u0003\u0002",
  1390. "29\n\u0002$$))^^ddhhppttvv\u0003\u000225\u0002\u01f0\u0002\u0003\u0003",
  1391. "\u0002\u0002\u0002\u0002\u0005\u0003\u0002\u0002\u0002\u0002\u0007\u0003",
  1392. "\u0002\u0002\u0002\u0002\t\u0003\u0002\u0002\u0002\u0002\u000b\u0003",
  1393. "\u0002\u0002\u0002\u0002\r\u0003\u0002\u0002\u0002\u0002\u000f\u0003",
  1394. "\u0002\u0002\u0002\u0002\u0011\u0003\u0002\u0002\u0002\u0002\u0013\u0003",
  1395. "\u0002\u0002\u0002\u0002\u0015\u0003\u0002\u0002\u0002\u0002\u0017\u0003",
  1396. "\u0002\u0002\u0002\u0002\u0019\u0003\u0002\u0002\u0002\u0002\u001b\u0003",
  1397. "\u0002\u0002\u0002\u0002\u001d\u0003\u0002\u0002\u0002\u0002\u001f\u0003",
  1398. "\u0002\u0002\u0002\u0002!\u0003\u0002\u0002\u0002\u0002#\u0003\u0002",
  1399. "\u0002\u0002\u0002%\u0003\u0002\u0002\u0002\u0002\'\u0003\u0002\u0002",
  1400. "\u0002\u0002)\u0003\u0002\u0002\u0002\u0002+\u0003\u0002\u0002\u0002",
  1401. "\u00023\u0003\u0002\u0002\u0002\u00025\u0003\u0002\u0002\u0002\u0002",
  1402. "7\u0003\u0002\u0002\u0002\u00029\u0003\u0002\u0002\u0002\u0002;\u0003",
  1403. "\u0002\u0002\u0002\u0002=\u0003\u0002\u0002\u0002\u0002?\u0003\u0002",
  1404. "\u0002\u0002\u0002A\u0003\u0002\u0002\u0002\u0002C\u0003\u0002\u0002",
  1405. "\u0002\u0002E\u0003\u0002\u0002\u0002\u0002G\u0003\u0002\u0002\u0002",
  1406. "\u0002I\u0003\u0002\u0002\u0002\u0002K\u0003\u0002\u0002\u0002\u0002",
  1407. "M\u0003\u0002\u0002\u0002\u0002O\u0003\u0002\u0002\u0002\u0002Q\u0003",
  1408. "\u0002\u0002\u0002\u0002S\u0003\u0002\u0002\u0002\u0002U\u0003\u0002",
  1409. "\u0002\u0002\u0002W\u0003\u0002\u0002\u0002\u0002[\u0003\u0002\u0002",
  1410. "\u0002\u0002_\u0003\u0002\u0002\u0002\u0002a\u0003\u0002\u0002\u0002",
  1411. "\u0002e\u0003\u0002\u0002\u0002\u0002q\u0003\u0002\u0002\u0002\u0003",
  1412. "s\u0003\u0002\u0002\u0002\u0005|\u0003\u0002\u0002\u0002\u0007\u0081",
  1413. "\u0003\u0002\u0002\u0002\t\u0087\u0003\u0002\u0002\u0002\u000b\u008e",
  1414. "\u0003\u0002\u0002\u0002\r\u0095\u0003\u0002\u0002\u0002\u000f\u009d",
  1415. "\u0003\u0002\u0002\u0002\u0011\u00a7\u0003\u0002\u0002\u0002\u0013\u00af",
  1416. "\u0003\u0002\u0002\u0002\u0015\u00b4\u0003\u0002\u0002\u0002\u0017\u00be",
  1417. "\u0003\u0002\u0002\u0002\u0019\u00c4\u0003\u0002\u0002\u0002\u001b\u00cb",
  1418. "\u0003\u0002\u0002\u0002\u001d\u00d3\u0003\u0002\u0002\u0002\u001f\u00d8",
  1419. "\u0003\u0002\u0002\u0002!\u00dd\u0003\u0002\u0002\u0002#\u00e2\u0003",
  1420. "\u0002\u0002\u0002%\u00eb\u0003\u0002\u0002\u0002\'\u00ee\u0003\u0002",
  1421. "\u0002\u0002)\u00f4\u0003\u0002\u0002\u0002+\u00fa\u0003\u0002\u0002",
  1422. "\u0002-\u0105\u0003\u0002\u0002\u0002/\u0109\u0003\u0002\u0002\u0002",
  1423. "1\u010b\u0003\u0002\u0002\u00023\u010e\u0003\u0002\u0002\u00025\u0110",
  1424. "\u0003\u0002\u0002\u00027\u0112\u0003\u0002\u0002\u00029\u0114\u0003",
  1425. "\u0002\u0002\u0002;\u0116\u0003\u0002\u0002\u0002=\u0118\u0003\u0002",
  1426. "\u0002\u0002?\u011a\u0003\u0002\u0002\u0002A\u011c\u0003\u0002\u0002",
  1427. "\u0002C\u011e\u0003\u0002\u0002\u0002E\u0120\u0003\u0002\u0002\u0002",
  1428. "G\u0122\u0003\u0002\u0002\u0002I\u0124\u0003\u0002\u0002\u0002K\u012f",
  1429. "\u0003\u0002\u0002\u0002M\u0131\u0003\u0002\u0002\u0002O\u0133\u0003",
  1430. "\u0002\u0002\u0002Q\u0135\u0003\u0002\u0002\u0002S\u013c\u0003\u0002",
  1431. "\u0002\u0002U\u015b\u0003\u0002\u0002\u0002W\u0175\u0003\u0002\u0002",
  1432. "\u0002Y\u0177\u0003\u0002\u0002\u0002[\u0180\u0003\u0002\u0002\u0002",
  1433. "]\u018b\u0003\u0002\u0002\u0002_\u018d\u0003\u0002\u0002\u0002a\u0194",
  1434. "\u0003\u0002\u0002\u0002c\u0198\u0003\u0002\u0002\u0002e\u01a0\u0003",
  1435. "\u0002\u0002\u0002g\u01a2\u0003\u0002\u0002\u0002i\u01a4\u0003\u0002",
  1436. "\u0002\u0002k\u01aa\u0003\u0002\u0002\u0002m\u01b7\u0003\u0002\u0002",
  1437. "\u0002o\u01b9\u0003\u0002\u0002\u0002q\u01d8\u0003\u0002\u0002\u0002",
  1438. "st\u0007r\u0002\u0002tu\u0007t\u0002\u0002uv\u0007q\u0002\u0002vw\u0007",
  1439. "i\u0002\u0002wx\u0007t\u0002\u0002xy\u0007c\u0002\u0002yz\u0007o\u0002",
  1440. "\u0002z{\u0007c\u0002\u0002{\u0004\u0003\u0002\u0002\u0002|}\u0007t",
  1441. "\u0002\u0002}~\u0007g\u0002\u0002~\u007f\u0007c\u0002\u0002\u007f\u0080",
  1442. "\u0007n\u0002\u0002\u0080\u0006\u0003\u0002\u0002\u0002\u0081\u0082",
  1443. "\u0007x\u0002\u0002\u0082\u0083\u0007c\u0002\u0002\u0083\u0084\u0007",
  1444. "|\u0002\u0002\u0084\u0085\u0007k\u0002\u0002\u0085\u0086\u0007q\u0002",
  1445. "\u0002\u0086\b\u0003\u0002\u0002\u0002\u0087\u0088\u0007n\u0002\u0002",
  1446. "\u0088\u0089\u0007q\u0002\u0002\u0089\u008a\u0007i\u0002\u0002\u008a",
  1447. "\u008b\u0007k\u0002\u0002\u008b\u008c\u0007e\u0002\u0002\u008c\u008d",
  1448. "\u0007q\u0002\u0002\u008d\n\u0003\u0002\u0002\u0002\u008e\u008f\u0007",
  1449. "e\u0002\u0002\u008f\u0090\u0007c\u0002\u0002\u0090\u0091\u0007f\u0002",
  1450. "\u0002\u0091\u0092\u0007g\u0002\u0002\u0092\u0093\u0007k\u0002\u0002",
  1451. "\u0093\u0094\u0007c\u0002\u0002\u0094\f\u0003\u0002\u0002\u0002\u0095",
  1452. "\u0096\u0007k\u0002\u0002\u0096\u0097\u0007p\u0002\u0002\u0097\u0098",
  1453. "\u0007v\u0002\u0002\u0098\u0099\u0007g\u0002\u0002\u0099\u009a\u0007",
  1454. "k\u0002\u0002\u009a\u009b\u0007t\u0002\u0002\u009b\u009c\u0007q\u0002",
  1455. "\u0002\u009c\u000e\u0003\u0002\u0002\u0002\u009d\u009e\u0007e\u0002",
  1456. "\u0002\u009e\u009f\u0007c\u0002\u0002\u009f\u00a0\u0007t\u0002\u0002",
  1457. "\u00a0\u00a1\u0007c\u0002\u0002\u00a1\u00a2\u0007e\u0002\u0002\u00a2",
  1458. "\u00a3\u0007v\u0002\u0002\u00a3\u00a4\u0007g\u0002\u0002\u00a4\u00a5",
  1459. "\u0007t\u0002\u0002\u00a5\u00a6\u0007g\u0002\u0002\u00a6\u0010\u0003",
  1460. "\u0002\u0002\u0002\u00a7\u00a8\u0007g\u0002\u0002\u00a8\u00a9\u0007",
  1461. "u\u0002\u0002\u00a9\u00aa\u0007e\u0002\u0002\u00aa\u00ab\u0007q\u0002",
  1462. "\u0002\u00ab\u00ac\u0007n\u0002\u0002\u00ac\u00ad\u0007j\u0002\u0002",
  1463. "\u00ad\u00ae\u0007c\u0002\u0002\u00ae\u0012\u0003\u0002\u0002\u0002",
  1464. "\u00af\u00b0\u0007e\u0002\u0002\u00b0\u00b1\u0007c\u0002\u0002\u00b1",
  1465. "\u00b2\u0007u\u0002\u0002\u00b2\u00b3\u0007q\u0002\u0002\u00b3\u0014",
  1466. "\u0003\u0002\u0002\u0002\u00b4\u00b5\u0007e\u0002\u0002\u00b5\u00b6",
  1467. "\u0007q\u0002\u0002\u00b6\u00b7\u0007p\u0002\u0002\u00b7\u00b8\u0007",
  1468. "v\u0002\u0002\u00b8\u00b9\u0007t\u0002\u0002\u00b9\u00ba\u0007c\u0002",
  1469. "\u0002\u00ba\u00bb\u0007t\u0002\u0002\u00bb\u00bc\u0007k\u0002\u0002",
  1470. "\u00bc\u00bd\u0007q\u0002\u0002\u00bd\u0016\u0003\u0002\u0002\u0002",
  1471. "\u00be\u00bf\u0007e\u0002\u0002\u00bf\u00c0\u0007q\u0002\u0002\u00c0",
  1472. "\u00c1\u0007p\u0002\u0002\u00c1\u00c2\u0007u\u0002\u0002\u00c2\u00c3",
  1473. "\u0007v\u0002\u0002\u00c3\u0018\u0003\u0002\u0002\u0002\u00c4\u00c5",
  1474. "\u0007h\u0002\u0002\u00c5\u00c6\u0007w\u0002\u0002\u00c6\u00c7\u0007",
  1475. "p\u0002\u0002\u00c7\u00c8\u0007e\u0002\u0002\u00c8\u00c9\u0007c\u0002",
  1476. "\u0002\u00c9\u00ca\u0007q\u0002\u0002\u00ca\u001a\u0003\u0002\u0002",
  1477. "\u0002\u00cb\u00cc\u0007t\u0002\u0002\u00cc\u00cd\u0007g\u0002\u0002",
  1478. "\u00cd\u00ce\u0007v\u0002\u0002\u00ce\u00cf\u0007q\u0002\u0002\u00cf",
  1479. "\u00d0\u0007t\u0002\u0002\u00d0\u00d1\u0007p\u0002\u0002\u00d1\u00d2",
  1480. "\u0007g\u0002\u0002\u00d2\u001c\u0003\u0002\u0002\u0002\u00d3\u00d4",
  1481. "\u0007r\u0002\u0002\u00d4\u00d5\u0007c\u0002\u0002\u00d5\u00d6\u0007",
  1482. "t\u0002\u0002\u00d6\u00d7\u0007c\u0002\u0002\u00d7\u001e\u0003\u0002",
  1483. "\u0002\u0002\u00d8\u00d9\u0007r\u0002\u0002\u00d9\u00da\u0007c\u0002",
  1484. "\u0002\u00da\u00db\u0007t\u0002\u0002\u00db\u00dc\u0007g\u0002\u0002",
  1485. "\u00dc \u0003\u0002\u0002\u0002\u00dd\u00de\u0007h\u0002\u0002\u00de",
  1486. "\u00df\u0007c\u0002\u0002\u00df\u00e0\u0007e\u0002\u0002\u00e0\u00e1",
  1487. "\u0007c\u0002\u0002\u00e1\"\u0003\u0002\u0002\u0002\u00e2\u00e3\u0007",
  1488. "g\u0002\u0002\u00e3\u00e4\u0007p\u0002\u0002\u00e4\u00e5\u0007s\u0002",
  1489. "\u0002\u00e5\u00e6\u0007w\u0002\u0002\u00e6\u00e7\u0007c\u0002\u0002",
  1490. "\u00e7\u00e8\u0007p\u0002\u0002\u00e8\u00e9\u0007v\u0002\u0002\u00e9",
  1491. "\u00ea\u0007q\u0002\u0002\u00ea$\u0003\u0002\u0002\u0002\u00eb\u00ec",
  1492. "\u0007u\u0002\u0002\u00ec\u00ed\u0007g\u0002\u0002\u00ed&\u0003\u0002",
  1493. "\u0002\u0002\u00ee\u00ef\u0007u\u0002\u0002\u00ef\u00f0\u0007g\u0002",
  1494. "\u0002\u00f0\u00f1\u0007p\u0002\u0002\u00f1\u00f2\u0007c\u0002\u0002",
  1495. "\u00f2\u00f3\u0007q\u0002\u0002\u00f3(\u0003\u0002\u0002\u0002\u00f4",
  1496. "\u00f5\u0007h\u0002\u0002\u00f5\u00f6\u0007c\u0002\u0002\u00f6\u00f7",
  1497. "\u0007n\u0002\u0002\u00f7\u00f8\u0007u\u0002\u0002\u00f8\u00f9\u0007",
  1498. "q\u0002\u0002\u00f9*\u0003\u0002\u0002\u0002\u00fa\u00fb\u0007x\u0002",
  1499. "\u0002\u00fb\u00fc\u0007g\u0002\u0002\u00fc\u00fd\u0007t\u0002\u0002",
  1500. "\u00fd\u00fe\u0007f\u0002\u0002\u00fe\u00ff\u0007c\u0002\u0002\u00ff",
  1501. "\u0100\u0007f\u0002\u0002\u0100\u0101\u0007g\u0002\u0002\u0101\u0102",
  1502. "\u0007k\u0002\u0002\u0102\u0103\u0007t\u0002\u0002\u0103\u0104\u0007",
  1503. "q\u0002\u0002\u0104,\u0003\u0002\u0002\u0002\u0105\u0106\u0007p\u0002",
  1504. "\u0002\u0106\u0107\u0007c\u0002\u0002\u0107\u0108\u0007q\u0002\u0002",
  1505. "\u0108.\u0003\u0002\u0002\u0002\u0109\u010a\u0007G\u0002\u0002\u010a",
  1506. "0\u0003\u0002\u0002\u0002\u010b\u010c\u0007Q\u0002\u0002\u010c\u010d",
  1507. "\u0007W\u0002\u0002\u010d2\u0003\u0002\u0002\u0002\u010e\u010f\u0007",
  1508. "*\u0002\u0002\u010f4\u0003\u0002\u0002\u0002\u0110\u0111\u0007+\u0002",
  1509. "\u0002\u01116\u0003\u0002\u0002\u0002\u0112\u0113\u0007]\u0002\u0002",
  1510. "\u01138\u0003\u0002\u0002\u0002\u0114\u0115\u0007_\u0002\u0002\u0115",
  1511. ":\u0003\u0002\u0002\u0002\u0116\u0117\u0007}\u0002\u0002\u0117<\u0003",
  1512. "\u0002\u0002\u0002\u0118\u0119\u0007\u007f\u0002\u0002\u0119>\u0003",
  1513. "\u0002\u0002\u0002\u011a\u011b\u0007.\u0002\u0002\u011b@\u0003\u0002",
  1514. "\u0002\u0002\u011c\u011d\u0007?\u0002\u0002\u011dB\u0003\u0002\u0002",
  1515. "\u0002\u011e\u011f\t\u0002\u0002\u0002\u011fD\u0003\u0002\u0002\u0002",
  1516. "\u0120\u0121\t\u0003\u0002\u0002\u0121F\u0003\u0002\u0002\u0002\u0122",
  1517. "\u0123\u0005/\u0018\u0002\u0123H\u0003\u0002\u0002\u0002\u0124\u0125",
  1518. "\u00051\u0019\u0002\u0125J\u0003\u0002\u0002\u0002\u0126\u0127\u0007",
  1519. "@\u0002\u0002\u0127\u0130\u0007?\u0002\u0002\u0128\u0129\u0007?\u0002",
  1520. "\u0002\u0129\u0130\u0007?\u0002\u0002\u012a\u012b\u0007>\u0002\u0002",
  1521. "\u012b\u0130\u0007?\u0002\u0002\u012c\u0130\t\u0004\u0002\u0002\u012d",
  1522. "\u012e\u0007#\u0002\u0002\u012e\u0130\u0007?\u0002\u0002\u012f\u0126",
  1523. "\u0003\u0002\u0002\u0002\u012f\u0128\u0003\u0002\u0002\u0002\u012f\u012a",
  1524. "\u0003\u0002\u0002\u0002\u012f\u012c\u0003\u0002\u0002\u0002\u012f\u012d",
  1525. "\u0003\u0002\u0002\u0002\u0130L\u0003\u0002\u0002\u0002\u0131\u0132",
  1526. "\u0007<\u0002\u0002\u0132N\u0003\u0002\u0002\u0002\u0133\u0134\u0005",
  1527. "-\u0017\u0002\u0134P\u0003\u0002\u0002\u0002\u0135\u0139\t\u0005\u0002",
  1528. "\u0002\u0136\u0138\t\u0006\u0002\u0002\u0137\u0136\u0003\u0002\u0002",
  1529. "\u0002\u0138\u013b\u0003\u0002\u0002\u0002\u0139\u0137\u0003\u0002\u0002",
  1530. "\u0002\u0139\u013a\u0003\u0002\u0002\u0002\u013aR\u0003\u0002\u0002",
  1531. "\u0002\u013b\u0139\u0003\u0002\u0002\u0002\u013c\u013d\u0005Q)\u0002",
  1532. "\u013d\u013e\u00070\u0002\u0002\u013e\u013f\u0005Q)\u0002\u013fT\u0003",
  1533. "\u0002\u0002\u0002\u0140\u0142\t\u0007\u0002\u0002\u0141\u0140\u0003",
  1534. "\u0002\u0002\u0002\u0142\u0143\u0003\u0002\u0002\u0002\u0143\u0141\u0003",
  1535. "\u0002\u0002\u0002\u0143\u0144\u0003\u0002\u0002\u0002\u0144\u015c\u0003",
  1536. "\u0002\u0002\u0002\u0145\u0146\u00072\u0002\u0002\u0146\u014a\u0007",
  1537. "z\u0002\u0002\u0147\u0148\u00072\u0002\u0002\u0148\u014a\u0007Z\u0002",
  1538. "\u0002\u0149\u0145\u0003\u0002\u0002\u0002\u0149\u0147\u0003\u0002\u0002",
  1539. "\u0002\u014a\u014c\u0003\u0002\u0002\u0002\u014b\u014d\u0005g4\u0002",
  1540. "\u014c\u014b\u0003\u0002\u0002\u0002\u014d\u014e\u0003\u0002\u0002\u0002",
  1541. "\u014e\u014c\u0003\u0002\u0002\u0002\u014e\u014f\u0003\u0002\u0002\u0002",
  1542. "\u014f\u015c\u0003\u0002\u0002\u0002\u0150\u0151\u00072\u0002\u0002",
  1543. "\u0151\u0155\u0007d\u0002\u0002\u0152\u0153\u00072\u0002\u0002\u0153",
  1544. "\u0155\u0007D\u0002\u0002\u0154\u0150\u0003\u0002\u0002\u0002\u0154",
  1545. "\u0152\u0003\u0002\u0002\u0002\u0155\u0157\u0003\u0002\u0002\u0002\u0156",
  1546. "\u0158\t\b\u0002\u0002\u0157\u0156\u0003\u0002\u0002\u0002\u0158\u0159",
  1547. "\u0003\u0002\u0002\u0002\u0159\u0157\u0003\u0002\u0002\u0002\u0159\u015a",
  1548. "\u0003\u0002\u0002\u0002\u015a\u015c\u0003\u0002\u0002\u0002\u015b\u0141",
  1549. "\u0003\u0002\u0002\u0002\u015b\u0149\u0003\u0002\u0002\u0002\u015b\u0154",
  1550. "\u0003\u0002\u0002\u0002\u015cV\u0003\u0002\u0002\u0002\u015d\u015f",
  1551. "\t\u0007\u0002\u0002\u015e\u015d\u0003\u0002\u0002\u0002\u015f\u0160",
  1552. "\u0003\u0002\u0002\u0002\u0160\u015e\u0003\u0002\u0002\u0002\u0160\u0161",
  1553. "\u0003\u0002\u0002\u0002\u0161\u0162\u0003\u0002\u0002\u0002\u0162\u0164",
  1554. "\u00070\u0002\u0002\u0163\u0165\t\u0007\u0002\u0002\u0164\u0163\u0003",
  1555. "\u0002\u0002\u0002\u0165\u0166\u0003\u0002\u0002\u0002\u0166\u0164\u0003",
  1556. "\u0002\u0002\u0002\u0166\u0167\u0003\u0002\u0002\u0002\u0167\u0176\u0003",
  1557. "\u0002\u0002\u0002\u0168\u016a\t\u0007\u0002\u0002\u0169\u0168\u0003",
  1558. "\u0002\u0002\u0002\u016a\u016b\u0003\u0002\u0002\u0002\u016b\u0169\u0003",
  1559. "\u0002\u0002\u0002\u016b\u016c\u0003\u0002\u0002\u0002\u016c\u016d\u0003",
  1560. "\u0002\u0002\u0002\u016d\u0171\u00070\u0002\u0002\u016e\u0170\t\u0007",
  1561. "\u0002\u0002\u016f\u016e\u0003\u0002\u0002\u0002\u0170\u0173\u0003\u0002",
  1562. "\u0002\u0002\u0171\u016f\u0003\u0002\u0002\u0002\u0171\u0172\u0003\u0002",
  1563. "\u0002\u0002\u0172\u0174\u0003\u0002\u0002\u0002\u0173\u0171\u0003\u0002",
  1564. "\u0002\u0002\u0174\u0176\u0005Y-\u0002\u0175\u015e\u0003\u0002\u0002",
  1565. "\u0002\u0175\u0169\u0003\u0002\u0002\u0002\u0176X\u0003\u0002\u0002",
  1566. "\u0002\u0177\u0179\t\t\u0002\u0002\u0178\u017a\t\u0002\u0002\u0002\u0179",
  1567. "\u0178\u0003\u0002\u0002\u0002\u0179\u017a\u0003\u0002\u0002\u0002\u017a",
  1568. "\u017c\u0003\u0002\u0002\u0002\u017b\u017d\t\u0007\u0002\u0002\u017c",
  1569. "\u017b\u0003\u0002\u0002\u0002\u017d\u017e\u0003\u0002\u0002\u0002\u017e",
  1570. "\u017c\u0003\u0002\u0002\u0002\u017e\u017f\u0003\u0002\u0002\u0002\u017f",
  1571. "Z\u0003\u0002\u0002\u0002\u0180\u0184\u0007$\u0002\u0002\u0181\u0183",
  1572. "\u0005]/\u0002\u0182\u0181\u0003\u0002\u0002\u0002\u0183\u0186\u0003",
  1573. "\u0002\u0002\u0002\u0184\u0182\u0003\u0002\u0002\u0002\u0184\u0185\u0003",
  1574. "\u0002\u0002\u0002\u0185\u0187\u0003\u0002\u0002\u0002\u0186\u0184\u0003",
  1575. "\u0002\u0002\u0002\u0187\u0188\u0007$\u0002\u0002\u0188\\\u0003\u0002",
  1576. "\u0002\u0002\u0189\u018c\n\n\u0002\u0002\u018a\u018c\u0005k6\u0002\u018b",
  1577. "\u0189\u0003\u0002\u0002\u0002\u018b\u018a\u0003\u0002\u0002\u0002\u018c",
  1578. "^\u0003\u0002\u0002\u0002\u018d\u0190\u0007)\u0002\u0002\u018e\u0191",
  1579. "\u0005k6\u0002\u018f\u0191\n\u000b\u0002\u0002\u0190\u018e\u0003\u0002",
  1580. "\u0002\u0002\u0190\u018f\u0003\u0002\u0002\u0002\u0191\u0192\u0003\u0002",
  1581. "\u0002\u0002\u0192\u0193\u0007)\u0002\u0002\u0193`\u0003\u0002\u0002",
  1582. "\u0002\u0194\u0195\t\f\u0002\u0002\u0195\u0196\u0003\u0002\u0002\u0002",
  1583. "\u0196\u0197\b1\u0002\u0002\u0197b\u0003\u0002\u0002\u0002\u0198\u0199",
  1584. "\u0007=\u0002\u0002\u0199d\u0003\u0002\u0002\u0002\u019a\u019c\t\r\u0002",
  1585. "\u0002\u019b\u019a\u0003\u0002\u0002\u0002\u019c\u019d\u0003\u0002\u0002",
  1586. "\u0002\u019d\u019b\u0003\u0002\u0002\u0002\u019d\u019e\u0003\u0002\u0002",
  1587. "\u0002\u019e\u01a1\u0003\u0002\u0002\u0002\u019f\u01a1\u0005c2\u0002",
  1588. "\u01a0\u019b\u0003\u0002\u0002\u0002\u01a0\u019f\u0003\u0002\u0002\u0002",
  1589. "\u01a1f\u0003\u0002\u0002\u0002\u01a2\u01a3\t\u000e\u0002\u0002\u01a3",
  1590. "h\u0003\u0002\u0002\u0002\u01a4\u01a5\t\u000f\u0002\u0002\u01a5j\u0003",
  1591. "\u0002\u0002\u0002\u01a6\u01a7\u0007^\u0002\u0002\u01a7\u01ab\t\u0010",
  1592. "\u0002\u0002\u01a8\u01ab\u0005o8\u0002\u01a9\u01ab\u0005m7\u0002\u01aa",
  1593. "\u01a6\u0003\u0002\u0002\u0002\u01aa\u01a8\u0003\u0002\u0002\u0002\u01aa",
  1594. "\u01a9\u0003\u0002\u0002\u0002\u01abl\u0003\u0002\u0002\u0002\u01ac",
  1595. "\u01ad\u0007^\u0002\u0002\u01ad\u01ae\t\u0011\u0002\u0002\u01ae\u01af",
  1596. "\u0005i5\u0002\u01af\u01b0\u0005i5\u0002\u01b0\u01b8\u0003\u0002\u0002",
  1597. "\u0002\u01b1\u01b2\u0007^\u0002\u0002\u01b2\u01b3\u0005i5\u0002\u01b3",
  1598. "\u01b4\u0005i5\u0002\u01b4\u01b8\u0003\u0002\u0002\u0002\u01b5\u01b6",
  1599. "\u0007^\u0002\u0002\u01b6\u01b8\u0005i5\u0002\u01b7\u01ac\u0003\u0002",
  1600. "\u0002\u0002\u01b7\u01b1\u0003\u0002\u0002\u0002\u01b7\u01b5\u0003\u0002",
  1601. "\u0002\u0002\u01b8n\u0003\u0002\u0002\u0002\u01b9\u01ba\u0007^\u0002",
  1602. "\u0002\u01ba\u01bb\u0007w\u0002\u0002\u01bb\u01bc\u0005g4\u0002\u01bc",
  1603. "\u01bd\u0005g4\u0002\u01bd\u01be\u0005g4\u0002\u01be\u01bf\u0005g4\u0002",
  1604. "\u01bfp\u0003\u0002\u0002\u0002\u01c0\u01c1\u00071\u0002\u0002\u01c1",
  1605. "\u01c2\u00071\u0002\u0002\u01c2\u01c6\u0003\u0002\u0002\u0002\u01c3",
  1606. "\u01c5\n\r\u0002\u0002\u01c4\u01c3\u0003\u0002\u0002\u0002\u01c5\u01c8",
  1607. "\u0003\u0002\u0002\u0002\u01c6\u01c4\u0003\u0002\u0002\u0002\u01c6\u01c7",
  1608. "\u0003\u0002\u0002\u0002\u01c7\u01ca\u0003\u0002\u0002\u0002\u01c8\u01c6",
  1609. "\u0003\u0002\u0002\u0002\u01c9\u01cb\u0007\u000f\u0002\u0002\u01ca\u01c9",
  1610. "\u0003\u0002\u0002\u0002\u01ca\u01cb\u0003\u0002\u0002\u0002\u01cb\u01cc",
  1611. "\u0003\u0002\u0002\u0002\u01cc\u01d9\u0007\f\u0002\u0002\u01cd\u01ce",
  1612. "\u00071\u0002\u0002\u01ce\u01cf\u0007,\u0002\u0002\u01cf\u01d3\u0003",
  1613. "\u0002\u0002\u0002\u01d0\u01d2\u000b\u0002\u0002\u0002\u01d1\u01d0\u0003",
  1614. "\u0002\u0002\u0002\u01d2\u01d5\u0003\u0002\u0002\u0002\u01d3\u01d4\u0003",
  1615. "\u0002\u0002\u0002\u01d3\u01d1\u0003\u0002\u0002\u0002\u01d4\u01d6\u0003",
  1616. "\u0002\u0002\u0002\u01d5\u01d3\u0003\u0002\u0002\u0002\u01d6\u01d7\u0007",
  1617. ",\u0002\u0002\u01d7\u01d9\u00071\u0002\u0002\u01d8\u01c0\u0003\u0002",
  1618. "\u0002\u0002\u01d8\u01cd\u0003\u0002\u0002\u0002\u01d9\u01da\u0003\u0002",
  1619. "\u0002\u0002\u01da\u01db\b9\u0003\u0002\u01dbr\u0003\u0002\u0002\u0002",
  1620. "\u001d\u0002\u012f\u0139\u0143\u0149\u014e\u0154\u0159\u015b\u0160\u0166",
  1621. "\u016b\u0171\u0175\u0179\u017e\u0184\u018b\u0190\u019d\u01a0\u01aa\u01b7",
  1622. "\u01c6\u01ca\u01d3\u01d8\u0004\b\u0002\u0002\u0002\u0003\u0002"].join("");
  1623. var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
  1624. var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });
  1625. function ivprog(input) {
  1626. antlr4.Lexer.call(this, input);
  1627. this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
  1628. return this;
  1629. }
  1630. ivprog.prototype = Object.create(antlr4.Lexer.prototype);
  1631. ivprog.prototype.constructor = ivprog;
  1632. ivprog.EOF = antlr4.Token.EOF;
  1633. ivprog.RK_PROGRAM = 1;
  1634. ivprog.RK_REAL = 2;
  1635. ivprog.RK_VOID = 3;
  1636. ivprog.RK_BOOLEAN = 4;
  1637. ivprog.RK_STRING = 5;
  1638. ivprog.RK_INTEGER = 6;
  1639. ivprog.RK_CHARACTER = 7;
  1640. ivprog.RK_SWITCH = 8;
  1641. ivprog.RK_CASE = 9;
  1642. ivprog.RK_DEFAULT = 10;
  1643. ivprog.RK_CONST = 11;
  1644. ivprog.RK_FUNCTION = 12;
  1645. ivprog.RK_RETURN = 13;
  1646. ivprog.RK_FOR = 14;
  1647. ivprog.RK_BREAK = 15;
  1648. ivprog.RK_DO = 16;
  1649. ivprog.RK_WHILE = 17;
  1650. ivprog.RK_IF = 18;
  1651. ivprog.RK_ELSE = 19;
  1652. ivprog.RK_FALSE = 20;
  1653. ivprog.RK_TRUE = 21;
  1654. ivprog.OPEN_PARENTHESIS = 22;
  1655. ivprog.CLOSE_PARENTHESIS = 23;
  1656. ivprog.OPEN_BRACE = 24;
  1657. ivprog.CLOSE_BRACE = 25;
  1658. ivprog.OPEN_CURLY = 26;
  1659. ivprog.CLOSE_CURLY = 27;
  1660. ivprog.COMMA = 28;
  1661. ivprog.EQUAL = 29;
  1662. ivprog.SUM_OP = 30;
  1663. ivprog.MULTI_OP = 31;
  1664. ivprog.AND_OPERATOR = 32;
  1665. ivprog.OR_OPERATOR = 33;
  1666. ivprog.RELATIONAL_OPERATOR = 34;
  1667. ivprog.COLON = 35;
  1668. ivprog.NOT_OPERATOR = 36;
  1669. ivprog.ID = 37;
  1670. ivprog.LIB_ID = 38;
  1671. ivprog.INTEGER = 39;
  1672. ivprog.REAL = 40;
  1673. ivprog.STRING = 41;
  1674. ivprog.CHARACTER = 42;
  1675. ivprog.WHITESPACE = 43;
  1676. ivprog.EOS = 44;
  1677. ivprog.COMMENTS = 45;
  1678. ivprog.prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];
  1679. ivprog.prototype.modeNames = [ "DEFAULT_MODE" ];
  1680. ivprog.prototype.literalNames = [ null, "'programa'", "'real'", "'vazio'",
  1681. "'logico'", "'cadeia'", "'inteiro'", "'caractere'",
  1682. "'escolha'", "'caso'", "'contrario'",
  1683. "'const'", "'funcao'", "'retorne'", "'para'",
  1684. "'pare'", "'faca'", "'enquanto'", "'se'",
  1685. "'senao'", "'falso'", "'verdadeiro'",
  1686. "'('", "')'", "'['", "']'", "'{'", "'}'",
  1687. "','", "'='", null, null, null, null,
  1688. null, "':'" ];
  1689. ivprog.prototype.symbolicNames = [ null, "RK_PROGRAM", "RK_REAL", "RK_VOID",
  1690. "RK_BOOLEAN", "RK_STRING", "RK_INTEGER",
  1691. "RK_CHARACTER", "RK_SWITCH", "RK_CASE",
  1692. "RK_DEFAULT", "RK_CONST", "RK_FUNCTION",
  1693. "RK_RETURN", "RK_FOR", "RK_BREAK", "RK_DO",
  1694. "RK_WHILE", "RK_IF", "RK_ELSE", "RK_FALSE",
  1695. "RK_TRUE", "OPEN_PARENTHESIS", "CLOSE_PARENTHESIS",
  1696. "OPEN_BRACE", "CLOSE_BRACE", "OPEN_CURLY",
  1697. "CLOSE_CURLY", "COMMA", "EQUAL", "SUM_OP",
  1698. "MULTI_OP", "AND_OPERATOR", "OR_OPERATOR",
  1699. "RELATIONAL_OPERATOR", "COLON", "NOT_OPERATOR",
  1700. "ID", "LIB_ID", "INTEGER", "REAL", "STRING",
  1701. "CHARACTER", "WHITESPACE", "EOS", "COMMENTS" ];
  1702. ivprog.prototype.ruleNames = [ "RK_PROGRAM", "RK_REAL", "RK_VOID", "RK_BOOLEAN",
  1703. "RK_STRING", "RK_INTEGER", "RK_CHARACTER",
  1704. "RK_SWITCH", "RK_CASE", "RK_DEFAULT", "RK_CONST",
  1705. "RK_FUNCTION", "RK_RETURN", "RK_FOR", "RK_BREAK",
  1706. "RK_DO", "RK_WHILE", "RK_IF", "RK_ELSE",
  1707. "RK_FALSE", "RK_TRUE", "RK_LOGICAL_NOT",
  1708. "RK_LOGICAL_AND", "RK_LOGICAL_OR", "OPEN_PARENTHESIS",
  1709. "CLOSE_PARENTHESIS", "OPEN_BRACE", "CLOSE_BRACE",
  1710. "OPEN_CURLY", "CLOSE_CURLY", "COMMA", "EQUAL",
  1711. "SUM_OP", "MULTI_OP", "AND_OPERATOR", "OR_OPERATOR",
  1712. "RELATIONAL_OPERATOR", "COLON", "NOT_OPERATOR",
  1713. "ID", "LIB_ID", "INTEGER", "REAL", "ExponentPart",
  1714. "STRING", "STRING_CHARACTER", "CHARACTER",
  1715. "WHITESPACE", "SEMICOLON", "EOS", "HEX_DIGIT",
  1716. "OCTAL_DIGIT", "ESC_SEQ", "ESC_OCTAL", "ESC_UNICODE",
  1717. "COMMENTS" ];
  1718. ivprog.prototype.grammarFileName = "ivprog.g4";
  1719. exports.ivprog = ivprog;
  1720. /***/ }),
  1721. /* 1 */
  1722. /***/ (function(module, exports, __webpack_require__) {
  1723. module.exports = {
  1724. ivprog: __webpack_require__(0).ivprog
  1725. };
  1726. /***/ }),
  1727. /* 2 */
  1728. /***/ (function(module, exports) {
  1729. module.exports = __webpack_require__(/*! antlr4/index */ "./node_modules/antlr4/index.js");
  1730. /***/ })
  1731. /******/ ]);
  1732. /***/ }),
  1733. /***/ "./grammar/pt/langFunctions.js":
  1734. /*!*************************************!*\
  1735. !*** ./grammar/pt/langFunctions.js ***!
  1736. \*************************************/
  1737. /*! no static exports found */
  1738. /***/ (function(module, exports, __webpack_require__) {
  1739. "use strict";
  1740. Object.defineProperty(exports, "__esModule", {
  1741. value: true
  1742. });
  1743. /* This is a dictionary of the language defined functions
  1744. **/
  1745. exports.default = {
  1746. main_function: "inicio",
  1747. $read: "leia",
  1748. $write: "escreva",
  1749. $numElements: "total_de_elementos",
  1750. $matrixLines: "total_de_linhas",
  1751. $matrixColumns: "total_de_colunas",
  1752. $substring: "subcadeia",
  1753. $length: "comprimento",
  1754. $uppercase: "caixa_alta",
  1755. $lowercase: "caixa_baixa",
  1756. $charAt: "char_at",
  1757. $isReal: "e_real",
  1758. $isInt: "e_inteiro",
  1759. $isBool: "e_logico",
  1760. $castReal: "como_real",
  1761. $castInt: "como_inteiro",
  1762. $castBool: "como_logico",
  1763. $castString: "como_cadeia",
  1764. $sin: "seno",
  1765. $cos: "cosseno",
  1766. $tan: "tangente",
  1767. $sqrt: "raiz_quadrada",
  1768. $pow: "potencia",
  1769. $log: "logaritmo",
  1770. $abs: "modulo",
  1771. $negate: "trocar_sinal",
  1772. $invert: "inverter_valor",
  1773. $max: "maximo",
  1774. $min: "minimo"
  1775. };
  1776. /***/ }),
  1777. /***/ "./grammar/pt/langLibs.js":
  1778. /*!********************************!*\
  1779. !*** ./grammar/pt/langLibs.js ***!
  1780. \********************************/
  1781. /*! no static exports found */
  1782. /***/ (function(module, exports, __webpack_require__) {
  1783. "use strict";
  1784. Object.defineProperty(exports, "__esModule", {
  1785. value: true
  1786. });
  1787. /**
  1788. * This is the dictionary of the language defined libraries
  1789. */
  1790. exports.default = {
  1791. $mathLib: "Matematica",
  1792. $ioLib: "ES",
  1793. $strLib: "Texto",
  1794. $arrayLib: "Arranjo",
  1795. $langLib: "Conversao"
  1796. };
  1797. /***/ }),
  1798. /***/ "./i18n/en/error.json":
  1799. /*!****************************!*\
  1800. !*** ./i18n/en/error.json ***!
  1801. \****************************/
  1802. /*! exports provided: token_missing_one, token_missing_two, eos_missing, invalid_type, invalid_array_dimension, invalid_array_size, extra_lines, invalid_main_return, invalid_var_declaration, invalid_break_command, invalid_terminal, const_not_init, id_missing, invalid_id_format, main_missing, invalid_global_var, not_implemented, function_missing, function_missing_full, invalid_parameters_size_full, invalid_parameters_size, invalid_ref_full, invalid_ref, invalid_parameter_type_full, invalid_parameter_type, unknown_command_full, unknown_command, loop_condition_type_full, loop_condition_type, endless_loop_full, endless_loop, for_condition_type_full, for_condition_type, if_condition_type_full, if_condition_type, invalid_return_type_full, invalid_return_type, invalid_void_return_full, invalid_void_return, unexpected_break_command_full, unexpected_break_command, invalid_dimension, void_in_expression_full, void_in_expression, invalid_array_access_full, invalid_array_access, invalid_matrix_access_full, invalid_matrix_access, matrix_column_outbounds_full, matrix_column_outbounds, matrix_line_outbounds_full, matrix_line_outbounds, vector_line_outbounds_full, vector_line_outbounds, vector_not_matrix_full, vector_not_matrix, invalid_infix_op_full, invalid_infix_op, invalid_unary_op_full, invalid_unary_op, unknown_op, duplicate_function, duplicate_variable, main_parameters, symbol_not_found_full, symbol_not_found, array_dimension_not_int_full, array_dimension_not_int, array_dimension_not_positive_full, array_dimension_not_positive, incompatible_types_full, incompatible_types, incompatible_types_array_full, incompatible_types_array, invalid_case_type_full, invalid_case_type, function_no_return, invalid_array_literal_type_full, invalid_array_literal_type, invalid_array_literal_line_full, invalid_array_literal_line, invalid_array_literal_column_full, invalid_array_literal_column, exceeded_input_request, default */
  1803. /***/ (function(module) {
  1804. module.exports = {"token_missing_one":"Erro de sintaxe: Espera-se $0, mas encontrou-se $1 na linha:$2, coluna:$3","token_missing_two":"Erro de sintaxe: Esperava-se $0 ou $1 mas encontrou-se $2 na liha:$3, coluna: $4","eos_missing":"Falta uma nova linha ou ; na linha: $0, coluna: $1","invalid_type":"$0 na linha: $1, coluna: $2 é um tipo inválido. Os tipos válidos são: $3","invalid_array_dimension":"A dimensão inválida na linha: $0, coluna: $1. Insira um $2 ou identificador válido do mesmo tipo.","invalid_array_size":"O tamnho do vetor/matriz excede o máximo de 2 na linha $0","extra_lines":"Nenhum texto é permitido após '}' em 'programa {...}'","invalid_main_return":"A função $0 deve retornar $1 na linha $2","invalid_var_declaration":"Erro na linha $0. Variáveis só podem ser declarados no corpo principal da função e de preferência nas primeiras linhas.","invalid_break_command":"Erro na linha $0. O comando $1 não pode ser usado fora de uma estrutura de repetição ou 'escolha...caso'","invalid_terminal":"Não é possível utilizar $0 na expressão da linha: $1, coluna: $2. Tente um valor númerico, variável ou chamada de função.","const_not_init":"Erro na linha: $0, coluna: $1. Uma variável declarada como const deve ser inicializada","id_missing":"Esperava-se um identificador, mas encontrou-se $0 na linha: $1, coluna: $2","invalid_id_format":"$0 na linha: $1, coluna: $2 não é um identificador válido. O símbolo '.' não é permitido neste contexto.","main_missing":"A função principal não foi encontrada","invalid_global_var":"Erro crítico: Chamada inválida da função initGlobal fora do contexto BASE","not_implemented":"Erro interno crítico: A função definida pelo sistema $0 não foi implementada.","function_missing":"A função $0 não foi encontrada","function_missing_full":"A função $0 na linha: $1, coluna: $2 não foi encontrada","invalid_parameters_size_full":"Erro na linha $0: a quantidade de parâmetros fornecidos à função $1 está incorreta. Esperava-se $2, encontrou-se $3.","invalid_parameters_size":"A quantidade de parâmetros fornecidos à função $0 está incorreta. Esperava-se $1, encontrou-se $2","invalid_ref_full":"A expressão $0 fornecida como parâmetro para a função $1 na linha $2 não é válida para esta função. Use uma variável ou posição de vetor.","invalid_ref":"A expressão $0 fornecida como parâmetro para a função $1 não é válida para esta função. Use uma variável ou posição de vetor.","invalid_parameter_type_full":"A expressão $0 fornecida como parâmetro para a função $1 na linha $2 não é compatível com o tipo esperado.","invalid_parameter_type":"A expressão $0 fornecida como parâmetro para a função $1 não é compatível com o tipo esperado.","unknown_command_full":"Erro interno crítico: comando desconhecido encontrado na linha $0","unknown_command":"Erro interno crítico: comando desconhecido encontrado!","loop_condition_type_full":"Erro na linha: $0, coluna $1: a condição dos laços de repetição deve ser do tipo lógico","loop_condition_type":"A condição dos laços de repetição deve ser do tipo lógico","endless_loop_full":"Possível laço infinito detectado no seu código. Verifique a linha $0","endless_loop":"Possível laço infinito detectado no seu código.","for_condition_type_full":"Erro na linha: $0, coluna $1: a condição de parada do comando para(...) deve ser do tipo lógico","for_condition_type":"A condição de parada do comando para(...) deve ser do tipo lógico","if_condition_type_full":"Erro na linha: $0, coluna $1: a condição de um comando se...senao deve ser do tipo lógico","if_condition_type":"A condição de um comando se...senao deve ser do tipo lógico","invalid_return_type_full":"Erro na linha $0: a expressão não produz um tipo compatível com a função $1. Tipo esperado: $2.","invalid_return_type":"A expressão não produz um tipo compatível com a função $0. Tipo esperado: $1.","invalid_void_return_full":"Erro na linha $0: a função $1 não pode retornar uma expressão vazia, use uma espressão do tipo $2","invalid_void_return":"A função $0 não pode retornar uma expressão vazia, use uma espressão do tipo $1","unexpected_break_command_full":"Erro interno crítico: comando pare encontrado fora do contexto de um laço/escolha..caso na linha $0","unexpected_break_command":"Erro interno crítico: comando pare encontrado fora do contexto de um laço/escolha..caso","invalid_dimension":"As dimensões de um vetor/matriz devem ser do tipo inteiro","void_in_expression_full":"Erro na linha: $0, coluna: $1: a função $2 não pode ser utilizada em uma expressão pois seu tipo de retorno é vazio","void_in_expression":"A função $0 não pode ser utilizada em uma expressão pois seu tipo de retorno é vazio","invalid_array_access_full":"Identificador $0 na linha: $1, coluna: $2 não se refere a um vetor/matriz válido","invalid_array_access":"Identificador $0 não se refere a um vetor/matriz válido","invalid_matrix_access_full":"Identificador $0 na linha: $1, coluna: $2 não se refere a uma matriz válida","invalid_matrix_access":"Identificador $0 não se refere a uma matriz válida","matrix_column_outbounds_full":"Erro na linha $0: número de colunas $1 é inválido para a matriz $2 que possui $3 colunas","matrix_column_outbounds":"Número de colunas $0 é inválido para a matriz $1 que possui $2 colunas","matrix_line_outbounds_full":"Erro na linha $0: número de linhas $1 é inválido para a matriz $2 que possui $3 linhas","matrix_line_outbounds":"Número de linhas $0 é inválido para a matriz $1 que possui $2 linhas","vector_line_outbounds_full":"Erro na linha $0: número de linhas $1 é inválido para a matriz $2 que possui $3 linhas","vector_line_outbounds":"Número de linhas $0 é inválido para a matriz $1 que possui $2 linhas","vector_not_matrix_full":"Erro na linha $0: $1 não é uma matriz","vector_not_matrix":"$1 não é uma matriz","invalid_infix_op_full":"Erro na linha $0: não é possível aplicar a operação $1 entre os tipos $2 e $3","invalid_infix_op":"Não é possível aplicar a operação $0 entre os tipos $1 e $2","invalid_unary_op_full":"Erro na linha $0: não é possível aplicar a operação $1 ao tipo $2","invalid_unary_op":"Não é possível aplicar a operação $0 ao tipo $1","unknown_op":"Erro interno crítico: Operação $0 desconhecida","duplicate_function":"A função $0 na linha: $1, coluna: $2 já foi definida anteriormente.","duplicate_variable":"A variável $0 na linha: $1, coluna: $2 já foi declarada anteriormente.","main_parameters":"A função inicio não pode ter parâmetros.","symbol_not_found_full":"A variável $0 na linha: $1, coluna: $2 não foi declarada","symbol_not_found":"A variável $0 não foi declarada","array_dimension_not_int_full":"As dimensões de um vetor/matriz na linha: $0 devem ser do tipo inteiro.","array_dimension_not_int":"As dimensões de um vetor/matriz devem ser do tipo inteiro.","array_dimension_not_positive_full":"As dimensões de um vetor/matriz na linha: $0 devem ser valores positivos.","array_dimension_not_positive":"As dimensões de um vetor/matriz devem ser valores positivos.","incompatible_types_full":"O tipo $0 não é compatível com o tipo resultante da expressão na linha $1","incompatible_types":"O tipo $0 não é compatível com o tipo resultante da expressão fornecida.","incompatible_types_array_full":"A expressão $0 é incompatível com o tipo $1 na linha: $2, coluna: $3.","incompatible_types_array":"A expressão $0 é incompatível com o tipo $1.","invalid_case_type_full":"O caso $0 na linha $1 é incompatível com o tipo $2.","invalid_case_type":"O caso $0 é incompatível com o tipo $1.","function_no_return":"A função $0 não possui um retorno acessível. Toda função deve ter ao menos um retorno no seu corpo principal.","invalid_array_literal_type_full":"Erro na linha $0: a expressão $1 não resulta em um tipo compatível.","invalid_array_literal_type":"A expressão $0 não resulta em um tipo compatível.","invalid_array_literal_line_full":"Erro na linha $0: esperava-se $1 linhas mas encontrou $2.","invalid_array_literal_line":"Esperava-se $0 linhas mas encontrou $1.","invalid_array_literal_column_full":"Erro na linha $0: esperava-se $1 colunas mas encontrou $2.","invalid_array_literal_column":"Esperava-se $0 colunas mas encontrou $1.","exceeded_input_request":"The amount of requests exceeded the amount of available inputs"};
  1805. /***/ }),
  1806. /***/ "./i18n/en/index.js":
  1807. /*!**************************!*\
  1808. !*** ./i18n/en/index.js ***!
  1809. \**************************/
  1810. /*! no static exports found */
  1811. /***/ (function(module, exports, __webpack_require__) {
  1812. "use strict";
  1813. Object.defineProperty(exports, "__esModule", {
  1814. value: true
  1815. });
  1816. var _error = __webpack_require__(/*! ./error.json */ "./i18n/en/error.json");
  1817. var _error2 = _interopRequireDefault(_error);
  1818. var _message = __webpack_require__(/*! ./message.json */ "./i18n/en/message.json");
  1819. var _message2 = _interopRequireDefault(_message);
  1820. var _ui = __webpack_require__(/*! ./ui.json */ "./i18n/en/ui.json");
  1821. var _ui2 = _interopRequireDefault(_ui);
  1822. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1823. exports.default = {
  1824. 'message': _message2.default,
  1825. 'error': _error2.default,
  1826. 'ui': _ui2.default
  1827. };
  1828. /***/ }),
  1829. /***/ "./i18n/en/message.json":
  1830. /*!******************************!*\
  1831. !*** ./i18n/en/message.json ***!
  1832. \******************************/
  1833. /*! exports provided: default */
  1834. /***/ (function(module) {
  1835. module.exports = {};
  1836. /***/ }),
  1837. /***/ "./i18n/en/ui.json":
  1838. /*!*************************!*\
  1839. !*** ./i18n/en/ui.json ***!
  1840. \*************************/
  1841. /*! exports provided: function, btn_clear, btn_function, btn_arithmetic_plus, btn_arithmetic_minus, btn_arithmetic_multiplication, btn_arithmetic_division, btn_arithmetic_module, btn_break, btn_case, start, void, integer, real, program, text, text_start, boolean, true, false, variable, command, new_parameter, new_variable, new_global, new_function, vector, text_comment_start, text_comment_main, text_read_var, text_write_var, text_command_read, text_command_write, text_comment, text_attribution, text_if, text_else, text_break, text_for, text_code_while, text_code_do, text_command_do, text_code_switch, text_code_case, text_logic_expression, text_arithmetic_expression, text_iftrue, text_receives, text_repeatNtimes, text_return, text_btn_return, text_whiletrue, text_dowhiletrue, text_switch, text_functioncall, text_value, text_operator, text_parentheses, text_change, text_teacher_algorithm, text_teacher_algorithm_include, text_teacher_test_case, text_teacher_config, text_teacher_data_types, text_teacher_commands, text_teacher_functions, text_teacher_create_functions, text_teacher_create_movement_functions, text_teacher_test_case_input, text_teacher_test_case_output, text_teacher_test_case_actions, text_teacher_test_case_add, text_header_ivprog_functions, text_menu_functions_math, text_menu_functions_text, text_menu_functions_arrangement, text_menu_functions_conversion, text_none_variable, text_none_variable_instruction, text_ivprog_description, tooltip_visual, tooltip_textual, tooltip_upload, tooltip_download, tooltip_undo, tooltip_redo, tooltip_run, tooltip_evaluate, tooltip_help, tooltip_add_global, tooltip_minimize, tooltip_console, var_menu_select_var, var_menu_select_all, var_menu_select_function, expression_menu_select, math, text_t, inform_valid_name, inform_valid_content, inform_valid_expression, inform_valid_name_duplicated, inform_valid_global_duplicated, inform_valid_variable_duplicated, arrangement, conversion, $sin, $cos, $tan, $sqrt, $pow, $log, $abs, $negate, $invert, $max, $min, $substring, $length, $uppercase, $lowercase, $charAt, $numElements, $matrixLines, $matrixColumns, $isReal, $isInt, $isBool, $castReal, $castInt, $castBool, $castString, text_ivprog_version, default */
  1842. /***/ (function(module) {
  1843. module.exports = {"function":"function","btn_clear":"Clear","btn_function":"Function","btn_arithmetic_plus":"Sum","btn_arithmetic_minus":"Minus","btn_arithmetic_multiplication":"Multiplication","btn_arithmetic_division":"Division","btn_arithmetic_module":"Module","btn_break":"Break","btn_case":"Case","start":"start","void":"void","integer":"integer","real":"real","program":"program","text":"string","text_start":"text","boolean":"boolean","true":"true","false":"false","variable":"Variable","command":"Command","new_parameter":"new_parameter","new_variable":"new_variable","new_global":"new_global","new_function":"new_function","vector":"vector","text_comment_start":"Initial comment of function...","text_comment_main":"This is the main function...","text_read_var":"Reading data","text_write_var":"Writing data","text_command_read":"read","text_command_write":"write","text_comment":"Comment","text_attribution":"Attribution","text_if":"if","text_else":"else","text_break":"break","text_for":"for","text_code_while":"while","text_code_do":"do","text_command_do":"do","text_code_switch":"switch","text_code_case":"case","text_logic_expression":"Logic Expression","text_arithmetic_expression":"Relational Expression","text_iftrue":"If true then","text_receives":"receives","text_repeatNtimes":"Repeat N times","text_return":"return","text_btn_return":"Return","text_whiletrue":"While true","text_dowhiletrue":"Do while true","text_switch":"Switch","text_functioncall":"Function call","text_value":"Value","text_operator":"Operator","text_parentheses":"Parentheses","text_change":"Change","text_teacher_algorithm":"Algorithm","text_teacher_algorithm_include":"Include the following algorithm in exercise","text_teacher_test_case":"Test cases","text_teacher_config":"Settings","text_teacher_data_types":"Data types","text_teacher_commands":"Commands","text_teacher_functions":"Functions","text_teacher_create_functions":"Create new functions","text_teacher_create_movement_functions":"Move functions","text_teacher_test_case_input":"Input","text_teacher_test_case_output":"Output","text_teacher_test_case_actions":"Actions","text_teacher_test_case_add":"Add test cases","text_header_ivprog_functions":"iVProg Functions","text_menu_functions_math":"Mathematic","text_menu_functions_text":"Text","text_menu_functions_arrangement":"Arrangement","text_menu_functions_conversion":"Conversion","text_none_variable":"There is no declared variable","text_none_variable_instruction":"Create a new variable to use it","text_ivprog_description":"Interactive Visual Programming on the Internet","tooltip_visual":"Visual programming","tooltip_textual":"Textual programming","tooltip_upload":"Upload code file","tooltip_download":"Download code file","tooltip_undo":"Undo","tooltip_redo":"Redo","tooltip_run":"Run program","tooltip_evaluate":"Evaluate program","tooltip_help":"Help","tooltip_add_global":"Add global variable","tooltip_minimize":"Hidde function elements","tooltip_console":"Open/Close console","var_menu_select_var":"Select a var","var_menu_select_all":"Select","var_menu_select_function":"Select a function","expression_menu_select":"Construct any logical condition","math":"Mathematic","text_t":"Text","inform_valid_name":"Inform a valid name!","inform_valid_content":"Enter some content!","inform_valid_expression":"Construct the logical condition!","inform_valid_name_duplicated":"This name is already in use by other function.","inform_valid_global_duplicated":"A global variable with this name already exists.","inform_valid_variable_duplicated":"A local variable with this name already exists.","arrangement":"Arrangement","conversion":"Conversion","$sin":"sin","$cos":"cos","$tan":"tan","$sqrt":"sqrt","$pow":"pow","$log":"log","$abs":"abs","$negate":"negate","$invert":"invert","$max":"maximum","$min":"minimum","$substring":"substring","$length":"length","$uppercase":"uppercase","$lowercase":"lowercase","$charAt":"char_at","$numElements":"total_of_elements","$matrixLines":"total_of_lines","$matrixColumns":"total_of_columns","$isReal":"is_real","$isInt":"is_integer","$isBool":"is_logic","$castReal":"to_real","$castInt":"to_integer","$castBool":"to_logic","$castString":"to_string","text_ivprog_version":"Version"};
  1844. /***/ }),
  1845. /***/ "./i18n/es/error.json":
  1846. /*!****************************!*\
  1847. !*** ./i18n/es/error.json ***!
  1848. \****************************/
  1849. /*! exports provided: token_missing_one, token_missing_two, eos_missing, invalid_type, invalid_array_dimension, invalid_array_size, extra_lines, invalid_main_return, invalid_var_declaration, invalid_break_command, invalid_terminal, const_not_init, id_missing, invalid_id_format, main_missing, invalid_global_var, not_implemented, function_missing, function_missing_full, invalid_parameters_size_full, invalid_parameters_size, invalid_ref_full, invalid_ref, invalid_parameter_type_full, invalid_parameter_type, unknown_command_full, unknown_command, loop_condition_type_full, loop_condition_type, endless_loop_full, endless_loop, for_condition_type_full, for_condition_type, if_condition_type_full, if_condition_type, invalid_return_type_full, invalid_return_type, invalid_void_return_full, invalid_void_return, unexpected_break_command_full, unexpected_break_command, invalid_dimension, void_in_expression_full, void_in_expression, invalid_array_access_full, invalid_array_access, invalid_matrix_access_full, invalid_matrix_access, matrix_column_outbounds_full, matrix_column_outbounds, matrix_line_outbounds_full, matrix_line_outbounds, vector_line_outbounds_full, vector_line_outbounds, vector_not_matrix_full, vector_not_matrix, invalid_infix_op_full, invalid_infix_op, invalid_unary_op_full, invalid_unary_op, unknown_op, duplicate_function, duplicate_variable, main_parameters, symbol_not_found_full, symbol_not_found, array_dimension_not_int_full, array_dimension_not_int, array_dimension_not_positive_full, array_dimension_not_positive, incompatible_types_full, incompatible_types, incompatible_types_array_full, incompatible_types_array, invalid_case_type_full, invalid_case_type, function_no_return, invalid_array_literal_type_full, invalid_array_literal_type, invalid_array_literal_line_full, invalid_array_literal_line, invalid_array_literal_column_full, invalid_array_literal_column, exceeded_input_request, default */
  1850. /***/ (function(module) {
  1851. module.exports = {"token_missing_one":"Erro de sintaxe: Espera-se $0, mas encontrou-se $1 na linha:$2, coluna:$3","token_missing_two":"Erro de sintaxe: Esperava-se $0 ou $1 mas encontrou-se $2 na liha:$3, coluna: $4","eos_missing":"Falta uma nova linha ou ; na linha: $0, coluna: $1","invalid_type":"$0 na linha: $1, coluna: $2 é um tipo inválido. Os tipos válidos são: $3","invalid_array_dimension":"A dimensão inválida na linha: $0, coluna: $1. Insira um $2 ou identificador válido do mesmo tipo.","invalid_array_size":"O tamnho do vetor/matriz excede o máximo de 2 na linha $0","extra_lines":"Nenhum texto é permitido após '}' em 'programa {...}'","invalid_main_return":"A função $0 deve retornar $1 na linha $2","invalid_var_declaration":"Erro na linha $0. Variáveis só podem ser declarados no corpo principal da função e de preferência nas primeiras linhas.","invalid_break_command":"Erro na linha $0. O comando $1 não pode ser usado fora de uma estrutura de repetição ou 'escolha...caso'","invalid_terminal":"Não é possível utilizar $0 na expressão da linha: $1, coluna: $2. Tente um valor númerico, variável ou chamada de função.","const_not_init":"Erro na linha: $0, coluna: $1. Uma variável declarada como const deve ser inicializada","id_missing":"Esperava-se um identificador, mas encontrou-se $0 na linha: $1, coluna: $2","invalid_id_format":"$0 na linha: $1, coluna: $2 não é um identificador válido. O símbolo '.' não é permitido neste contexto.","main_missing":"A função principal não foi encontrada","invalid_global_var":"Erro crítico: Chamada inválida da função initGlobal fora do contexto BASE","not_implemented":"Erro interno crítico: A função definida pelo sistema $0 não foi implementada.","function_missing":"A função $0 não foi encontrada","function_missing_full":"A função $0 na linha: $1, coluna: $2 não foi encontrada","invalid_parameters_size_full":"Erro na linha $0: a quantidade de parâmetros fornecidos à função $1 está incorreta. Esperava-se $2, encontrou-se $3.","invalid_parameters_size":"A quantidade de parâmetros fornecidos à função $0 está incorreta. Esperava-se $1, encontrou-se $2","invalid_ref_full":"A expressão $0 fornecida como parâmetro para a função $1 na linha $2 não é válida para esta função. Use uma variável ou posição de vetor.","invalid_ref":"A expressão $0 fornecida como parâmetro para a função $1 não é válida para esta função. Use uma variável ou posição de vetor.","invalid_parameter_type_full":"A expressão $0 fornecida como parâmetro para a função $1 na linha $2 não é compatível com o tipo esperado.","invalid_parameter_type":"A expressão $0 fornecida como parâmetro para a função $1 não é compatível com o tipo esperado.","unknown_command_full":"Erro interno crítico: comando desconhecido encontrado na linha $0","unknown_command":"Erro interno crítico: comando desconhecido encontrado!","loop_condition_type_full":"Erro na linha: $0, coluna $1: a condição dos laços de repetição deve ser do tipo lógico","loop_condition_type":"A condição dos laços de repetição deve ser do tipo lógico","endless_loop_full":"Possível laço infinito detectado no seu código. Verifique a linha $0","endless_loop":"Possível laço infinito detectado no seu código.","for_condition_type_full":"Erro na linha: $0, coluna $1: a condição de parada do comando para(...) deve ser do tipo lógico","for_condition_type":"A condição de parada do comando para(...) deve ser do tipo lógico","if_condition_type_full":"Erro na linha: $0, coluna $1: a condição de um comando se...senao deve ser do tipo lógico","if_condition_type":"A condição de um comando se...senao deve ser do tipo lógico","invalid_return_type_full":"Erro na linha $0: a expressão não produz um tipo compatível com a função $1. Tipo esperado: $2.","invalid_return_type":"A expressão não produz um tipo compatível com a função $0. Tipo esperado: $1.","invalid_void_return_full":"Erro na linha $0: a função $1 não pode retornar uma expressão vazia, use uma espressão do tipo $2","invalid_void_return":"A função $0 não pode retornar uma expressão vazia, use uma espressão do tipo $1","unexpected_break_command_full":"Erro interno crítico: comando pare encontrado fora do contexto de um laço/escolha..caso na linha $0","unexpected_break_command":"Erro interno crítico: comando pare encontrado fora do contexto de um laço/escolha..caso","invalid_dimension":"As dimensões de um vetor/matriz devem ser do tipo inteiro","void_in_expression_full":"Erro na linha: $0, coluna: $1: a função $2 não pode ser utilizada em uma expressão pois seu tipo de retorno é vazio","void_in_expression":"A função $0 não pode ser utilizada em uma expressão pois seu tipo de retorno é vazio","invalid_array_access_full":"Identificador $0 na linha: $1, coluna: $2 não se refere a um vetor/matriz válido","invalid_array_access":"Identificador $0 não se refere a um vetor/matriz válido","invalid_matrix_access_full":"Identificador $0 na linha: $1, coluna: $2 não se refere a uma matriz válida","invalid_matrix_access":"Identificador $0 não se refere a uma matriz válida","matrix_column_outbounds_full":"Erro na linha $0: número de colunas $1 é inválido para a matriz $2 que possui $3 colunas","matrix_column_outbounds":"Número de colunas $0 é inválido para a matriz $1 que possui $2 colunas","matrix_line_outbounds_full":"Erro na linha $0: número de linhas $1 é inválido para a matriz $2 que possui $3 linhas","matrix_line_outbounds":"Número de linhas $0 é inválido para a matriz $1 que possui $2 linhas","vector_line_outbounds_full":"Erro na linha $0: número de linhas $1 é inválido para a matriz $2 que possui $3 linhas","vector_line_outbounds":"Número de linhas $0 é inválido para a matriz $1 que possui $2 linhas","vector_not_matrix_full":"Erro na linha $0: $1 não é uma matriz","vector_not_matrix":"$1 não é uma matriz","invalid_infix_op_full":"Erro na linha $0: não é possível aplicar a operação $1 entre os tipos $2 e $3","invalid_infix_op":"Não é possível aplicar a operação $0 entre os tipos $1 e $2","invalid_unary_op_full":"Erro na linha $0: não é possível aplicar a operação $1 ao tipo $2","invalid_unary_op":"Não é possível aplicar a operação $0 ao tipo $1","unknown_op":"Erro interno crítico: Operação $0 desconhecida","duplicate_function":"A função $0 na linha: $1, coluna: $2 já foi definida anteriormente.","duplicate_variable":"A variável $0 na linha: $1, coluna: $2 já foi declarada anteriormente.","main_parameters":"A função inicio não pode ter parâmetros.","symbol_not_found_full":"A variável $0 na linha: $1, coluna: $2 não foi declarada","symbol_not_found":"A variável $0 não foi declarada","array_dimension_not_int_full":"As dimensões de um vetor/matriz na linha: $0 devem ser do tipo inteiro.","array_dimension_not_int":"As dimensões de um vetor/matriz devem ser do tipo inteiro.","array_dimension_not_positive_full":"As dimensões de um vetor/matriz na linha: $0 devem ser valores positivos.","array_dimension_not_positive":"As dimensões de um vetor/matriz devem ser valores positivos.","incompatible_types_full":"O tipo $0 não é compatível com o tipo resultante da expressão na linha $1","incompatible_types":"O tipo $0 não é compatível com o tipo resultante da expressão fornecida.","incompatible_types_array_full":"A expressão $0 é incompatível com o tipo $1 na linha: $2, coluna: $3.","incompatible_types_array":"A expressão $0 é incompatível com o tipo $1.","invalid_case_type_full":"O caso $0 na linha $1 é incompatível com o tipo $2.","invalid_case_type":"O caso $0 é incompatível com o tipo $1.","function_no_return":"A função $0 não possui um retorno acessível. Toda função deve ter ao menos um retorno no seu corpo principal.","invalid_array_literal_type_full":"Erro na linha $0: a expressão $1 não resulta em um tipo compatível.","invalid_array_literal_type":"A expressão $0 não resulta em um tipo compatível.","invalid_array_literal_line_full":"Erro na linha $0: esperava-se $1 linhas mas encontrou $2.","invalid_array_literal_line":"Esperava-se $0 linhas mas encontrou $1.","invalid_array_literal_column_full":"Erro na linha $0: esperava-se $1 colunas mas encontrou $2.","invalid_array_literal_column":"Esperava-se $0 colunas mas encontrou $1.","exceeded_input_request":"The amount of requests exceeded the amount of available inputs"};
  1852. /***/ }),
  1853. /***/ "./i18n/es/index.js":
  1854. /*!**************************!*\
  1855. !*** ./i18n/es/index.js ***!
  1856. \**************************/
  1857. /*! no static exports found */
  1858. /***/ (function(module, exports, __webpack_require__) {
  1859. "use strict";
  1860. Object.defineProperty(exports, "__esModule", {
  1861. value: true
  1862. });
  1863. var _error = __webpack_require__(/*! ./error.json */ "./i18n/es/error.json");
  1864. var _error2 = _interopRequireDefault(_error);
  1865. var _message = __webpack_require__(/*! ./message.json */ "./i18n/es/message.json");
  1866. var _message2 = _interopRequireDefault(_message);
  1867. var _ui = __webpack_require__(/*! ./ui.json */ "./i18n/es/ui.json");
  1868. var _ui2 = _interopRequireDefault(_ui);
  1869. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1870. exports.default = {
  1871. 'message': _message2.default,
  1872. 'error': _error2.default,
  1873. 'ui': _ui2.default
  1874. };
  1875. /***/ }),
  1876. /***/ "./i18n/es/message.json":
  1877. /*!******************************!*\
  1878. !*** ./i18n/es/message.json ***!
  1879. \******************************/
  1880. /*! exports provided: default */
  1881. /***/ (function(module) {
  1882. module.exports = {};
  1883. /***/ }),
  1884. /***/ "./i18n/es/ui.json":
  1885. /*!*************************!*\
  1886. !*** ./i18n/es/ui.json ***!
  1887. \*************************/
  1888. /*! exports provided: function, btn_clear, btn_function, btn_arithmetic_plus, btn_arithmetic_minus, btn_arithmetic_multiplication, btn_arithmetic_division, btn_arithmetic_module, btn_break, btn_case, start, void, integer, real, program, text, text_start, boolean, true, false, variable, command, new_parameter, new_variable, new_global, new_function, vector, text_comment_start, text_comment_main, text_read_var, text_write_var, text_command_read, text_command_write, text_comment, text_attribution, text_if, text_break, text_else, text_return, text_btn_return, text_for, text_code_while, text_code_do, text_command_do, text_code_switch, text_code_case, text_logic_expression, text_arithmetic_expression, text_iftrue, text_repeatNtimes, text_receives, text_whiletrue, text_dowhiletrue, text_switch, text_functioncall, text_value, text_operator, text_parentheses, text_change, text_teacher_algorithm, text_teacher_algorithm_include, text_teacher_test_case, text_teacher_config, text_teacher_data_types, text_teacher_commands, text_teacher_functions, text_teacher_create_functions, text_teacher_create_movement_functions, text_teacher_test_case_input, text_teacher_test_case_output, text_teacher_test_case_actions, text_teacher_test_case_add, text_header_ivprog_functions, text_menu_functions_math, text_menu_functions_text, text_menu_functions_arrangement, text_menu_functions_conversion, text_none_variable, text_none_variable_instruction, text_ivprog_description, tooltip_visual, tooltip_textual, tooltip_upload, tooltip_download, tooltip_undo, tooltip_redo, tooltip_run, tooltip_evaluate, tooltip_help, tooltip_add_global, tooltip_minimize, tooltip_console, var_menu_select_var, var_menu_select_all, var_menu_select_function, expression_menu_select, $sin, math, arrangement, conversion, inform_valid_name, inform_valid_content, inform_valid_expression, inform_valid_name_duplicated, inform_valid_global_duplicated, inform_valid_variable_duplicated, text_t, $cos, $tan, $sqrt, $pow, $log, $abs, $negate, $invert, $max, $min, $substring, $length, $uppercase, $lowercase, $charAt, $numElements, $matrixLines, $matrixColumns, $isReal, $isInt, $isBool, $castReal, $castInt, $castBool, $castString, text_ivprog_version, default */
  1889. /***/ (function(module) {
  1890. module.exports = {"function":"function","btn_clear":"Clear","btn_function":"Function","btn_arithmetic_plus":"Sum","btn_arithmetic_minus":"Minus","btn_arithmetic_multiplication":"Multiplication","btn_arithmetic_division":"Division","btn_arithmetic_module":"Module","btn_break":"Break","btn_case":"Case","start":"start","void":"void","integer":"integer","real":"real","program":"program","text":"Text","text_start":"text","boolean":"boolean","true":"true","false":"false","variable":"Variable","command":"Command","new_parameter":"new_parameter","new_variable":"new_variable","new_global":"new_global","new_function":"new_function","vector":"vector","text_comment_start":"Initial comment of function...","text_comment_main":"This is the main function...","text_read_var":"Reading data","text_write_var":"Writing data","text_command_read":"read","text_command_write":"write","text_comment":"Comment","text_attribution":"Attribution","text_if":"if","text_break":"break","text_else":"else","text_return":"return","text_btn_return":"Return","text_for":"for","text_code_while":"while","text_code_do":"do","text_command_do":"do","text_code_switch":"switch","text_code_case":"case","text_logic_expression":"Logic Expression","text_arithmetic_expression":"Relational Expression","text_iftrue":"If true then","text_repeatNtimes":"Repeat N times","text_receives":"receives","text_whiletrue":"While true","text_dowhiletrue":"Do while true","text_switch":"Switch","text_functioncall":"Function call","text_value":"Value","text_operator":"Operator","text_parentheses":"Parentheses","text_change":"Change","text_teacher_algorithm":"Algorithm","text_teacher_algorithm_include":"Include the following algorithm in exercise","text_teacher_test_case":"Test cases","text_teacher_config":"Settings","text_teacher_data_types":"Data types","text_teacher_commands":"Commands","text_teacher_functions":"Functions","text_teacher_create_functions":"Create new functions","text_teacher_create_movement_functions":"Move functions","text_teacher_test_case_input":"Input","text_teacher_test_case_output":"Output","text_teacher_test_case_actions":"Actions","text_teacher_test_case_add":"Add test cases","text_header_ivprog_functions":"iVProg Functions","text_menu_functions_math":"Mathematics","text_menu_functions_text":"Text","text_menu_functions_arrangement":"Arrangement","text_menu_functions_conversion":"Conversion","text_none_variable":"There is no declared variable","text_none_variable_instruction":"Create a new variable to use it","text_ivprog_description":"Interactive Visual Programming on the Internet","tooltip_visual":"Visual programming","tooltip_textual":"Textual programming","tooltip_upload":"Upload code file","tooltip_download":"Download code file","tooltip_undo":"Undo","tooltip_redo":"Redo","tooltip_run":"Run program","tooltip_evaluate":"Evaluate program","tooltip_help":"Help","tooltip_add_global":"Add global variable","tooltip_minimize":"Hidde function elements","tooltip_console":"Open/Close console","var_menu_select_var":"Select a var","var_menu_select_all":"Select","var_menu_select_function":"Select a function","expression_menu_select":"Construct any logical condition","$sin":"sin","math":"Mathematic","arrangement":"Arrangement","conversion":"Conversion","inform_valid_name":"Inform a valid name!","inform_valid_content":"Enter some content!","inform_valid_expression":"Construct the logical condition!","inform_valid_name_duplicated":"This name is already in use by other function.","inform_valid_global_duplicated":"A global variable with this name already exists.","inform_valid_variable_duplicated":"A local variable with this name already exists.","text_t":"Text","$cos":"cos","$tan":"tan","$sqrt":"sqrt","$pow":"pow","$log":"log","$abs":"abs","$negate":"negate","$invert":"invert","$max":"maximum","$min":"minimum","$substring":"substring","$length":"length","$uppercase":"uppercase","$lowercase":"lowercase","$charAt":"char_at","$numElements":"total_of_elements","$matrixLines":"total_of_lines","$matrixColumns":"total_of_columns","$isReal":"is_real","$isInt":"is_integer","$isBool":"is_logic","$castReal":"to_real","$castInt":"to_integer","$castBool":"to_logic","$castString":"to_string","text_ivprog_version":"Version"};
  1891. /***/ }),
  1892. /***/ "./i18n/index.js":
  1893. /*!***********************!*\
  1894. !*** ./i18n/index.js ***!
  1895. \***********************/
  1896. /*! no static exports found */
  1897. /***/ (function(module, exports, __webpack_require__) {
  1898. "use strict";
  1899. Object.defineProperty(exports, "__esModule", {
  1900. value: true
  1901. });
  1902. var _en = __webpack_require__(/*! ./en */ "./i18n/en/index.js");
  1903. var _en2 = _interopRequireDefault(_en);
  1904. var _pt = __webpack_require__(/*! ./pt */ "./i18n/pt/index.js");
  1905. var _pt2 = _interopRequireDefault(_pt);
  1906. var _es = __webpack_require__(/*! ./es */ "./i18n/es/index.js");
  1907. var _es2 = _interopRequireDefault(_es);
  1908. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1909. exports.default = {
  1910. 'en': _en2.default,
  1911. 'pt': _pt2.default,
  1912. 'es': _es2.default
  1913. };
  1914. /***/ }),
  1915. /***/ "./i18n/pt/error.json":
  1916. /*!****************************!*\
  1917. !*** ./i18n/pt/error.json ***!
  1918. \****************************/
  1919. /*! exports provided: token_missing_one, token_missing_two, eos_missing, invalid_type, invalid_array_dimension, invalid_array_size, extra_lines, invalid_main_return, invalid_var_declaration, invalid_break_command, invalid_terminal, const_not_init, id_missing, invalid_id_format, main_missing, invalid_global_var, not_implemented, function_missing, function_missing_full, invalid_parameters_size_full, invalid_parameters_size, invalid_ref_full, invalid_ref, invalid_parameter_type_full, invalid_parameter_type, unknown_command_full, unknown_command, loop_condition_type_full, loop_condition_type, endless_loop_full, endless_loop, for_condition_type_full, for_condition_type, if_condition_type_full, if_condition_type, invalid_return_type_full, invalid_return_type, invalid_void_return_full, invalid_void_return, unexpected_break_command_full, unexpected_break_command, invalid_dimension, void_in_expression_full, void_in_expression, invalid_array_access_full, invalid_array_access, invalid_matrix_access_full, invalid_matrix_access, matrix_column_outbounds_full, matrix_column_outbounds, matrix_line_outbounds_full, matrix_line_outbounds, vector_line_outbounds_full, vector_line_outbounds, vector_not_matrix_full, vector_not_matrix, invalid_infix_op_full, invalid_infix_op, invalid_unary_op_full, invalid_unary_op, unknown_op, duplicate_function, duplicate_variable, main_parameters, symbol_not_found_full, symbol_not_found, array_dimension_not_int_full, array_dimension_not_int, array_dimension_not_positive_full, array_dimension_not_positive, incompatible_types_full, incompatible_types, incompatible_types_array_full, incompatible_types_array, invalid_case_type_full, invalid_case_type, function_no_return, invalid_array_literal_type_full, invalid_array_literal_type, invalid_array_literal_line_full, invalid_array_literal_line, invalid_array_literal_column_full, invalid_array_literal_column, exceeded_input_request, default */
  1920. /***/ (function(module) {
  1921. module.exports = {"token_missing_one":"Erro de sintaxe: Espera-se $0, mas encontrou-se $1 na linha:$2, coluna:$3","token_missing_two":"Erro de sintaxe: Esperava-se $0 ou $1 mas encontrou-se $2 na liha:$3, coluna: $4","eos_missing":"Falta uma nova linha ou ; na linha: $0, coluna: $1","invalid_type":"$0 na linha: $1, coluna: $2 é um tipo inválido. Os tipos válidos são: $3","invalid_array_dimension":"A dimensão inválida na linha: $0, coluna: $1. Insira um $2 ou identificador válido do mesmo tipo.","invalid_array_size":"O tamnho do vetor/matriz excede o máximo de 2 na linha $0","extra_lines":"Nenhum texto é permitido após '}' em 'programa {...}'","invalid_main_return":"A função $0 deve retornar $1 na linha $2","invalid_var_declaration":"Erro na linha $0. Variáveis só podem ser declarados no corpo principal da função e de preferência nas primeiras linhas.","invalid_break_command":"Erro na linha $0. O comando $1 não pode ser usado fora de uma estrutura de repetição ou 'escolha...caso'","invalid_terminal":"Não é possível utilizar $0 na expressão da linha: $1, coluna: $2. Tente um valor númerico, variável ou chamada de função.","const_not_init":"Erro na linha: $0, coluna: $1. Uma variável declarada como const deve ser inicializada","id_missing":"Esperava-se um identificador, mas encontrou-se $0 na linha: $1, coluna: $2","invalid_id_format":"$0 na linha: $1, coluna: $2 não é um identificador válido. O símbolo '.' não é permitido neste contexto.","main_missing":"A função principal não foi encontrada","invalid_global_var":"Erro crítico: Chamada inválida da função initGlobal fora do contexto BASE","not_implemented":"Erro interno crítico: A função definida pelo sistema $0 não foi implementada.","function_missing":"A função $0 não foi encontrada","function_missing_full":"A função $0 na linha: $1, coluna: $2 não foi encontrada","invalid_parameters_size_full":"Erro na linha $0: a quantidade de parâmetros fornecidos à função $1 está incorreta. Esperava-se $2, encontrou-se $3.","invalid_parameters_size":"A quantidade de parâmetros fornecidos à função $0 está incorreta. Esperava-se $1, encontrou-se $2","invalid_ref_full":"A expressão $0 fornecida como parâmetro para a função $1 na linha $2 não é válida para esta função. Use uma variável ou posição de vetor.","invalid_ref":"A expressão $0 fornecida como parâmetro para a função $1 não é válida para esta função. Use uma variável ou posição de vetor.","invalid_parameter_type_full":"A expressão $0 fornecida como parâmetro para a função $1 na linha $2 não é compatível com o tipo esperado.","invalid_parameter_type":"A expressão $0 fornecida como parâmetro para a função $1 não é compatível com o tipo esperado.","unknown_command_full":"Erro interno crítico: comando desconhecido encontrado na linha $0","unknown_command":"Erro interno crítico: comando desconhecido encontrado!","loop_condition_type_full":"Erro na linha: $0, coluna $1: a condição dos laços de repetição deve ser do tipo lógico","loop_condition_type":"A condição dos laços de repetição deve ser do tipo lógico","endless_loop_full":"Possível laço infinito detectado no seu código. Verifique a linha $0","endless_loop":"Possível laço infinito detectado no seu código.","for_condition_type_full":"Erro na linha: $0, coluna $1: a condição de parada do comando para(...) deve ser do tipo lógico","for_condition_type":"A condição de parada do comando para(...) deve ser do tipo lógico","if_condition_type_full":"Erro na linha: $0, coluna $1: a condição de um comando se...senao deve ser do tipo lógico","if_condition_type":"A condição de um comando se...senao deve ser do tipo lógico","invalid_return_type_full":"Erro na linha $0: a expressão não produz um tipo compatível com a função $1. Tipo esperado: $2.","invalid_return_type":"A expressão não produz um tipo compatível com a função $0. Tipo esperado: $1.","invalid_void_return_full":"Erro na linha $0: a função $1 não pode retornar uma expressão vazia, use uma espressão do tipo $2","invalid_void_return":"A função $0 não pode retornar uma expressão vazia, use uma espressão do tipo $1","unexpected_break_command_full":"Erro interno crítico: comando pare encontrado fora do contexto de um laço/escolha..caso na linha $0","unexpected_break_command":"Erro interno crítico: comando pare encontrado fora do contexto de um laço/escolha..caso","invalid_dimension":"As dimensões de um vetor/matriz devem ser do tipo inteiro","void_in_expression_full":"Erro na linha: $0, coluna: $1: a função $2 não pode ser utilizada em uma expressão pois seu tipo de retorno é vazio","void_in_expression":"A função $0 não pode ser utilizada em uma expressão pois seu tipo de retorno é vazio","invalid_array_access_full":"Identificador $0 na linha: $1, coluna: $2 não se refere a um vetor/matriz válido","invalid_array_access":"Identificador $0 não se refere a um vetor/matriz válido","invalid_matrix_access_full":"Identificador $0 na linha: $1, coluna: $2 não se refere a uma matriz válida","invalid_matrix_access":"Identificador $0 não se refere a uma matriz válida","matrix_column_outbounds_full":"Erro na linha $0: número de colunas $1 é inválido para a matriz $2 que possui $3 colunas","matrix_column_outbounds":"Número de colunas $0 é inválido para a matriz $1 que possui $2 colunas","matrix_line_outbounds_full":"Erro na linha $0: número de linhas $1 é inválido para a matriz $2 que possui $3 linhas","matrix_line_outbounds":"Número de linhas $0 é inválido para a matriz $1 que possui $2 linhas","vector_line_outbounds_full":"Erro na linha $0: número de linhas $1 é inválido para a matriz $2 que possui $3 linhas","vector_line_outbounds":"Número de linhas $0 é inválido para a matriz $1 que possui $2 linhas","vector_not_matrix_full":"Erro na linha $0: $1 não é uma matriz","vector_not_matrix":"$1 não é uma matriz","invalid_infix_op_full":"Erro na linha $0: não é possível aplicar a operação $1 entre os tipos $2 e $3","invalid_infix_op":"Não é possível aplicar a operação $0 entre os tipos $1 e $2","invalid_unary_op_full":"Erro na linha $0: não é possível aplicar a operação $1 ao tipo $2","invalid_unary_op":"Não é possível aplicar a operação $0 ao tipo $1","unknown_op":"Erro interno crítico: Operação $0 desconhecida","duplicate_function":"A função $0 na linha: $1, coluna: $2 já foi definida anteriormente.","duplicate_variable":"A variável $0 na linha: $1, coluna: $2 já foi declarada anteriormente.","main_parameters":"A função inicio não pode ter parâmetros.","symbol_not_found_full":"A variável $0 na linha: $1, coluna: $2 não foi declarada","symbol_not_found":"A variável $0 não foi declarada","array_dimension_not_int_full":"As dimensões de um vetor/matriz na linha: $0 devem ser do tipo inteiro.","array_dimension_not_int":"As dimensões de um vetor/matriz devem ser do tipo inteiro.","array_dimension_not_positive_full":"As dimensões de um vetor/matriz na linha: $0 devem ser valores positivos.","array_dimension_not_positive":"As dimensões de um vetor/matriz devem ser valores positivos.","incompatible_types_full":"O tipo $0 não é compatível com o tipo resultante da expressão na linha $1","incompatible_types":"O tipo $0 não é compatível com o tipo resultante da expressão fornecida.","incompatible_types_array_full":"A expressão $0 é incompatível com o tipo $1 na linha: $2, coluna: $3.","incompatible_types_array":"A expressão $0 é incompatível com o tipo $1.","invalid_case_type_full":"O caso $0 na linha $1 é incompatível com o tipo $2.","invalid_case_type":"O caso $0 é incompatível com o tipo $1.","function_no_return":"A função $0 não possui um retorno acessível. Toda função deve ter ao menos um retorno no seu corpo principal.","invalid_array_literal_type_full":"Erro na linha $0: a expressão $1 não resulta em um tipo compatível.","invalid_array_literal_type":"A expressão $0 não resulta em um tipo compatível.","invalid_array_literal_line_full":"Erro na linha $0: esperava-se $1 linhas mas encontrou $2.","invalid_array_literal_line":"Esperava-se $0 linhas mas encontrou $1.","invalid_array_literal_column_full":"Erro na linha $0: esperava-se $1 colunas mas encontrou $2.","invalid_array_literal_column":"Esperava-se $0 colunas mas encontrou $1.","exceeded_input_request":"A quantidade de leituras requisitadas execedeu a quantidade de entradas disponíveis."};
  1922. /***/ }),
  1923. /***/ "./i18n/pt/index.js":
  1924. /*!**************************!*\
  1925. !*** ./i18n/pt/index.js ***!
  1926. \**************************/
  1927. /*! no static exports found */
  1928. /***/ (function(module, exports, __webpack_require__) {
  1929. "use strict";
  1930. Object.defineProperty(exports, "__esModule", {
  1931. value: true
  1932. });
  1933. var _error = __webpack_require__(/*! ./error.json */ "./i18n/pt/error.json");
  1934. var _error2 = _interopRequireDefault(_error);
  1935. var _message = __webpack_require__(/*! ./message.json */ "./i18n/pt/message.json");
  1936. var _message2 = _interopRequireDefault(_message);
  1937. var _ui = __webpack_require__(/*! ./ui.json */ "./i18n/pt/ui.json");
  1938. var _ui2 = _interopRequireDefault(_ui);
  1939. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1940. exports.default = {
  1941. 'message': _message2.default,
  1942. 'error': _error2.default,
  1943. 'ui': _ui2.default
  1944. };
  1945. /***/ }),
  1946. /***/ "./i18n/pt/message.json":
  1947. /*!******************************!*\
  1948. !*** ./i18n/pt/message.json ***!
  1949. \******************************/
  1950. /*! exports provided: default */
  1951. /***/ (function(module) {
  1952. module.exports = {};
  1953. /***/ }),
  1954. /***/ "./i18n/pt/ui.json":
  1955. /*!*************************!*\
  1956. !*** ./i18n/pt/ui.json ***!
  1957. \*************************/
  1958. /*! exports provided: function, btn_clear, btn_function, btn_arithmetic_plus, btn_arithmetic_minus, btn_arithmetic_multiplication, btn_arithmetic_division, btn_arithmetic_module, btn_break, btn_case, start, void, integer, and, or, not, real, program, text, text_start, boolean, true, false, variable, command, new_parameter, new_variable, new_global, new_function, vector, text_comment_start, text_comment_main, text_read_var, text_write_var, text_command_read, text_command_write, text_return, text_btn_return, text_comment, join_or, matrix_string, vector_string, text_attribution, text_if, text_break, text_else, text_for, text_code_while, text_code_do, text_command_do, text_code_switch, text_code_case, text_logic_expression, text_arithmetic_expression, text_iftrue, text_repeatNtimes, text_receives, text_whiletrue, text_dowhiletrue, text_switch, text_functioncall, text_value, text_operator, text_parentheses, text_change, text_teacher_algorithm, text_teacher_algorithm_include, text_teacher_test_case, text_teacher_config, text_teacher_data_types, text_teacher_commands, text_teacher_functions, text_teacher_create_functions, text_teacher_create_movement_functions, text_teacher_test_case_input, text_teacher_test_case_output, text_teacher_test_case_actions, text_teacher_test_case_add, text_header_ivprog_functions, text_menu_functions_math, text_menu_functions_text, text_menu_functions_arrangement, text_menu_functions_conversion, text_none_variable, text_none_variable_instruction, text_ivprog_description, tooltip_visual, tooltip_textual, tooltip_upload, tooltip_download, tooltip_undo, tooltip_redo, tooltip_run, tooltip_evaluate, tooltip_help, tooltip_add_global, tooltip_minimize, tooltip_console, var_menu_select_var, var_menu_select_all, var_menu_select_function, expression_menu_select, $sin, math, text_t, inform_valid_name, inform_valid_content, inform_valid_expression, inform_valid_name_duplicated, inform_valid_global_duplicated, inform_valid_variable_duplicated, arrangement, conversion, $cos, $tan, $sqrt, $pow, $log, $abs, $negate, $invert, $max, $min, $substring, $length, $uppercase, $lowercase, $charAt, $numElements, $matrixLines, $matrixColumns, $isReal, $isInt, $isBool, $castReal, $castInt, $castBool, $castString, text_ivprog_version, default */
  1959. /***/ (function(module) {
  1960. module.exports = {"function":"funcao","btn_clear":"Limpar","btn_function":"Função","btn_arithmetic_plus":"Adição","btn_arithmetic_minus":"Subtração","btn_arithmetic_multiplication":"Multiplicação","btn_arithmetic_division":"Divisão","btn_arithmetic_module":"Módulo","btn_break":"Pare","btn_case":"Caso","start":"inicio","void":"vazio","integer":"inteiro","and":"E","or":"OU","not":"nao","real":"real","program":"programa","text":"cadeia","text_start":"texto","boolean":"logico","true":"verdadeiro","false":"falso","variable":"Variável","command":"Comando","new_parameter":"novo_parametro","new_variable":"nova_variavel","new_global":"nova_global","new_function":"nova_funcao","vector":"vetor","text_comment_start":"Comentário inicial da função...","text_comment_main":"Esta é a função principal...","text_read_var":"Leitura de dados","text_write_var":"Escrita de dados","text_command_read":"leia","text_command_write":"escreva","text_return":"retorne","text_btn_return":"Retorno","text_comment":"Comentário","join_or":"ou","matrix_string":"matriz de $0","vector_string":"vetor de $0","text_attribution":"Atribuição","text_if":"se","text_break":"pare","text_else":"senao","text_for":"para","text_code_while":"enquanto","text_code_do":"faca","text_command_do":"faça","text_code_switch":"escolha","text_code_case":"caso","text_logic_expression":"Expressão Lógica","text_arithmetic_expression":"Expressão Relacional","text_iftrue":"Se verdadeiro então","text_repeatNtimes":"Repita N vezes","text_receives":"recebe","text_whiletrue":"Enquanto verdadeiro","text_dowhiletrue":"Faça enquanto verdadeiro","text_switch":"Escolha","text_functioncall":"Chamada de função","text_value":"Valor","text_operator":"Operador","text_parentheses":"Parênteses","text_change":"Alterar","text_teacher_algorithm":"Algoritmo","text_teacher_algorithm_include":"Incluir o algoritmo abaixo no exercício","text_teacher_test_case":"Casos de teste","text_teacher_config":"Configurações","text_teacher_data_types":"Tipos de dados","text_teacher_commands":"Comandos","text_teacher_functions":"Funções","text_teacher_create_functions":"Criar novas funções","text_teacher_create_movement_functions":"Movimentar funções","text_teacher_test_case_input":"Entrada","text_teacher_test_case_output":"Saída","text_teacher_test_case_actions":"Ações","text_teacher_test_case_add":"Adicionar caso de teste","text_header_ivprog_functions":"Funções do iVProg","text_menu_functions_math":"Matemática","text_menu_functions_text":"Texto","text_menu_functions_arrangement":"Arranjo","text_menu_functions_conversion":"Conversão","text_none_variable":"Nenhuma variável declarada","text_none_variable_instruction":"Antes de utilizar uma variável, é necessário criá-la","text_ivprog_description":"Programação Visual interativa na Internet","tooltip_visual":"Programação visual","tooltip_textual":"Programação textual","tooltip_upload":"Upload de código fonte","tooltip_download":"Download do código fonte","tooltip_undo":"Desfazer","tooltip_redo":"Refazer","tooltip_run":"Executar o programa","tooltip_evaluate":"Avaliar o programa","tooltip_help":"Ajuda","tooltip_add_global":"Adicionar variável global","tooltip_minimize":"Ocultar os elementos da função","tooltip_console":"Abrir/fechar o terminal","var_menu_select_var":"Selecione uma variável","var_menu_select_all":"Selecione","var_menu_select_function":"Selecione uma função","expression_menu_select":"Construir uma expressão lógica","$sin":"seno","math":"Matematica","text_t":"Texto","inform_valid_name":"Informe um nome válido!","inform_valid_content":"Informe o conteúdo!","inform_valid_expression":"Construa uma expressão lógica!","inform_valid_name_duplicated":"Este nome já está em uso por outra função!","inform_valid_global_duplicated":"Já existe uma variável global com o nome informado.","inform_valid_variable_duplicated":"Já existe uma variável local com o nome informado.","arrangement":"Arranjo","conversion":"Conversao","$cos":"cosseno","$tan":"tangente","$sqrt":"raiz_quadrada","$pow":"potencia","$log":"logaritmo","$abs":"modulo","$negate":"trocar_sinal","$invert":"inverter_valor","$max":"maximo","$min":"minimo","$substring":"subcadeia","$length":"comprimento","$uppercase":"caixa_alta","$lowercase":"caixa_baixa","$charAt":"texto_na_posicao","$numElements":"total_de_elementos","$matrixLines":"total_de_linhas","$matrixColumns":"total_de_colunas","$isReal":"e_real","$isInt":"e_inteiro","$isBool":"e_logico","$castReal":"como_real","$castInt":"como_inteiro","$castBool":"como_logico","$castString":"como_cadeia","text_ivprog_version":"Versão"};
  1961. /***/ }),
  1962. /***/ "./js/Sortable.js":
  1963. /*!************************!*\
  1964. !*** ./js/Sortable.js ***!
  1965. \************************/
  1966. /*! no static exports found */
  1967. /***/ (function(module, exports, __webpack_require__) {
  1968. "use strict";
  1969. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;
  1970. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  1971. /**!
  1972. * Sortable
  1973. * @author RubaXa <trash@rubaxa.org>
  1974. * @license MIT
  1975. */
  1976. (function sortableModule(factory) {
  1977. "use strict";
  1978. if (true) {
  1979. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  1980. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  1981. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
  1982. __WEBPACK_AMD_DEFINE_FACTORY__),
  1983. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1984. } else {}
  1985. })(function sortableFactory() {
  1986. "use strict";
  1987. if (typeof window == "undefined" || !window.document) {
  1988. return function sortableError() {
  1989. throw new Error("Sortable.js requires a window with a document");
  1990. };
  1991. }
  1992. var dragEl,
  1993. parentEl,
  1994. ghostEl,
  1995. cloneEl,
  1996. rootEl,
  1997. nextEl,
  1998. lastDownEl,
  1999. scrollEl,
  2000. scrollParentEl,
  2001. scrollCustomFn,
  2002. lastEl,
  2003. lastCSS,
  2004. lastParentCSS,
  2005. oldIndex,
  2006. newIndex,
  2007. activeGroup,
  2008. putSortable,
  2009. autoScroll = {},
  2010. tapEvt,
  2011. touchEvt,
  2012. moved,
  2013. /** @const */
  2014. R_SPACE = /\s+/g,
  2015. R_FLOAT = /left|right|inline/,
  2016. expando = 'Sortable' + new Date().getTime(),
  2017. win = window,
  2018. document = win.document,
  2019. parseInt = win.parseInt,
  2020. $ = win.jQuery || win.Zepto,
  2021. Polymer = win.Polymer,
  2022. captureMode = false,
  2023. supportDraggable = !!('draggable' in document.createElement('div')),
  2024. supportCssPointerEvents = function (el) {
  2025. // false when IE11
  2026. if (!!navigator.userAgent.match(/Trident.*rv[ :]?11\./)) {
  2027. return false;
  2028. }
  2029. el = document.createElement('x');
  2030. el.style.cssText = 'pointer-events:auto';
  2031. return el.style.pointerEvents === 'auto';
  2032. }(),
  2033. _silent = false,
  2034. abs = Math.abs,
  2035. min = Math.min,
  2036. savedInputChecked = [],
  2037. touchDragOverListeners = [],
  2038. _autoScroll = _throttle(function ( /**Event*/evt, /**Object*/options, /**HTMLElement*/rootEl) {
  2039. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
  2040. if (rootEl && options.scroll) {
  2041. var _this = rootEl[expando],
  2042. el,
  2043. rect,
  2044. sens = options.scrollSensitivity,
  2045. speed = options.scrollSpeed,
  2046. x = evt.clientX,
  2047. y = evt.clientY,
  2048. winWidth = window.innerWidth,
  2049. winHeight = window.innerHeight,
  2050. vx,
  2051. vy,
  2052. scrollOffsetX,
  2053. scrollOffsetY;
  2054. // Delect scrollEl
  2055. if (scrollParentEl !== rootEl) {
  2056. scrollEl = options.scroll;
  2057. scrollParentEl = rootEl;
  2058. scrollCustomFn = options.scrollFn;
  2059. if (scrollEl === true) {
  2060. scrollEl = rootEl;
  2061. do {
  2062. if (scrollEl.offsetWidth < scrollEl.scrollWidth || scrollEl.offsetHeight < scrollEl.scrollHeight) {
  2063. break;
  2064. }
  2065. /* jshint boss:true */
  2066. } while (scrollEl = scrollEl.parentNode);
  2067. }
  2068. }
  2069. if (scrollEl) {
  2070. el = scrollEl;
  2071. rect = scrollEl.getBoundingClientRect();
  2072. vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens);
  2073. vy = (abs(rect.bottom - y) <= sens) - (abs(rect.top - y) <= sens);
  2074. }
  2075. if (!(vx || vy)) {
  2076. vx = (winWidth - x <= sens) - (x <= sens);
  2077. vy = (winHeight - y <= sens) - (y <= sens);
  2078. /* jshint expr:true */
  2079. (vx || vy) && (el = win);
  2080. }
  2081. if (autoScroll.vx !== vx || autoScroll.vy !== vy || autoScroll.el !== el) {
  2082. autoScroll.el = el;
  2083. autoScroll.vx = vx;
  2084. autoScroll.vy = vy;
  2085. clearInterval(autoScroll.pid);
  2086. if (el) {
  2087. autoScroll.pid = setInterval(function () {
  2088. scrollOffsetY = vy ? vy * speed : 0;
  2089. scrollOffsetX = vx ? vx * speed : 0;
  2090. if ('function' === typeof scrollCustomFn) {
  2091. return scrollCustomFn.call(_this, scrollOffsetX, scrollOffsetY, evt);
  2092. }
  2093. if (el === win) {
  2094. win.scrollTo(win.pageXOffset + scrollOffsetX, win.pageYOffset + scrollOffsetY);
  2095. } else {
  2096. el.scrollTop += scrollOffsetY;
  2097. el.scrollLeft += scrollOffsetX;
  2098. }
  2099. }, 24);
  2100. }
  2101. }
  2102. }
  2103. }, 30),
  2104. _prepareGroup = function _prepareGroup(options) {
  2105. function toFn(value, pull) {
  2106. if (value === void 0 || value === true) {
  2107. value = group.name;
  2108. }
  2109. if (typeof value === 'function') {
  2110. return value;
  2111. } else {
  2112. return function (to, from) {
  2113. var fromGroup = from.options.group.name;
  2114. return pull ? value : value && (value.join ? value.indexOf(fromGroup) > -1 : fromGroup == value);
  2115. };
  2116. }
  2117. }
  2118. var group = {};
  2119. var originalGroup = options.group;
  2120. if (!originalGroup || (typeof originalGroup === "undefined" ? "undefined" : _typeof(originalGroup)) != 'object') {
  2121. originalGroup = { name: originalGroup };
  2122. }
  2123. group.name = originalGroup.name;
  2124. group.checkPull = toFn(originalGroup.pull, true);
  2125. group.checkPut = toFn(originalGroup.put);
  2126. group.revertClone = originalGroup.revertClone;
  2127. options.group = group;
  2128. };
  2129. /**
  2130. * @class Sortable
  2131. * @param {HTMLElement} el
  2132. * @param {Object} [options]
  2133. */
  2134. function Sortable(el, options) {
  2135. if (!(el && el.nodeType && el.nodeType === 1)) {
  2136. throw 'Sortable: `el` must be HTMLElement, and not ' + {}.toString.call(el);
  2137. }
  2138. this.el = el; // root element
  2139. this.options = options = _extend({}, options);
  2140. // Export instance
  2141. el[expando] = this;
  2142. // Default options
  2143. var defaults = {
  2144. group: Math.random(),
  2145. sort: true,
  2146. disabled: false,
  2147. store: null,
  2148. handle: null,
  2149. scroll: true,
  2150. scrollSensitivity: 30,
  2151. scrollSpeed: 10,
  2152. draggable: /[uo]l/i.test(el.nodeName) ? 'li' : '>*',
  2153. ghostClass: 'sortable-ghost',
  2154. chosenClass: 'sortable-chosen',
  2155. dragClass: 'sortable-drag',
  2156. ignore: 'a, img',
  2157. filter: null,
  2158. preventOnFilter: true,
  2159. animation: 0,
  2160. setData: function setData(dataTransfer, dragEl) {
  2161. dataTransfer.setData('Text', dragEl.textContent);
  2162. },
  2163. dropBubble: false,
  2164. dragoverBubble: false,
  2165. dataIdAttr: 'data-id',
  2166. delay: 0,
  2167. forceFallback: false,
  2168. fallbackClass: 'sortable-fallback',
  2169. fallbackOnBody: false,
  2170. fallbackTolerance: 0,
  2171. fallbackOffset: { x: 0, y: 0 }
  2172. };
  2173. // Set default options
  2174. for (var name in defaults) {
  2175. !(name in options) && (options[name] = defaults[name]);
  2176. }
  2177. _prepareGroup(options);
  2178. // Bind all private methods
  2179. for (var fn in this) {
  2180. if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
  2181. this[fn] = this[fn].bind(this);
  2182. }
  2183. }
  2184. // Setup drag mode
  2185. this.nativeDraggable = options.forceFallback ? false : supportDraggable;
  2186. // Bind events
  2187. _on(el, 'mousedown', this._onTapStart);
  2188. _on(el, 'touchstart', this._onTapStart);
  2189. _on(el, 'pointerdown', this._onTapStart);
  2190. if (this.nativeDraggable) {
  2191. _on(el, 'dragover', this);
  2192. _on(el, 'dragenter', this);
  2193. }
  2194. touchDragOverListeners.push(this._onDragOver);
  2195. // Restore sorting
  2196. options.store && this.sort(options.store.get(this));
  2197. }
  2198. Sortable.prototype = /** @lends Sortable.prototype */{
  2199. constructor: Sortable,
  2200. _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
  2201. var _this = this,
  2202. el = this.el,
  2203. options = this.options,
  2204. preventOnFilter = options.preventOnFilter,
  2205. type = evt.type,
  2206. touch = evt.touches && evt.touches[0],
  2207. target = (touch || evt).target,
  2208. originalTarget = evt.target.shadowRoot && evt.path && evt.path[0] || target,
  2209. filter = options.filter,
  2210. startIndex;
  2211. _saveInputCheckedState(el);
  2212. // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
  2213. if (dragEl) {
  2214. return;
  2215. }
  2216. if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
  2217. return; // only left button or enabled
  2218. }
  2219. target = _closest(target, options.draggable, el);
  2220. if (!target) {
  2221. return;
  2222. }
  2223. if (lastDownEl === target) {
  2224. // Ignoring duplicate `down`
  2225. return;
  2226. }
  2227. // Get the index of the dragged element within its parent
  2228. startIndex = _index(target, options.draggable);
  2229. // Check filter
  2230. if (typeof filter === 'function') {
  2231. if (filter.call(this, evt, target, this)) {
  2232. _dispatchEvent(_this, originalTarget, 'filter', target, el, startIndex);
  2233. preventOnFilter && evt.preventDefault();
  2234. return; // cancel dnd
  2235. }
  2236. } else if (filter) {
  2237. filter = filter.split(',').some(function (criteria) {
  2238. criteria = _closest(originalTarget, criteria.trim(), el);
  2239. if (criteria) {
  2240. _dispatchEvent(_this, criteria, 'filter', target, el, startIndex);
  2241. return true;
  2242. }
  2243. });
  2244. if (filter) {
  2245. preventOnFilter && evt.preventDefault();
  2246. return; // cancel dnd
  2247. }
  2248. }
  2249. if (options.handle && !_closest(originalTarget, options.handle, el)) {
  2250. return;
  2251. }
  2252. // Prepare `dragstart`
  2253. this._prepareDragStart(evt, touch, target, startIndex);
  2254. },
  2255. _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target, /** Number */startIndex) {
  2256. var _this = this,
  2257. el = _this.el,
  2258. options = _this.options,
  2259. ownerDocument = el.ownerDocument,
  2260. dragStartFn;
  2261. if (target && !dragEl && target.parentNode === el) {
  2262. tapEvt = evt;
  2263. rootEl = el;
  2264. dragEl = target;
  2265. parentEl = dragEl.parentNode;
  2266. nextEl = dragEl.nextSibling;
  2267. lastDownEl = target;
  2268. activeGroup = options.group;
  2269. oldIndex = startIndex;
  2270. this._lastX = (touch || evt).clientX;
  2271. this._lastY = (touch || evt).clientY;
  2272. dragEl.style['will-change'] = 'transform';
  2273. dragStartFn = function dragStartFn() {
  2274. // Delayed drag has been triggered
  2275. // we can re-enable the events: touchmove/mousemove
  2276. _this._disableDelayedDrag();
  2277. // Make the element draggable
  2278. dragEl.draggable = _this.nativeDraggable;
  2279. // Chosen item
  2280. _toggleClass(dragEl, options.chosenClass, true);
  2281. // Bind the events: dragstart/dragend
  2282. _this._triggerDragStart(evt, touch);
  2283. // Drag start event
  2284. _dispatchEvent(_this, rootEl, 'choose', dragEl, rootEl, oldIndex);
  2285. };
  2286. // Disable "draggable"
  2287. options.ignore.split(',').forEach(function (criteria) {
  2288. _find(dragEl, criteria.trim(), _disableDraggable);
  2289. });
  2290. _on(ownerDocument, 'mouseup', _this._onDrop);
  2291. _on(ownerDocument, 'touchend', _this._onDrop);
  2292. _on(ownerDocument, 'touchcancel', _this._onDrop);
  2293. _on(ownerDocument, 'pointercancel', _this._onDrop);
  2294. _on(ownerDocument, 'selectstart', _this);
  2295. if (options.delay) {
  2296. // If the user moves the pointer or let go the click or touch
  2297. // before the delay has been reached:
  2298. // disable the delayed drag
  2299. _on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
  2300. _on(ownerDocument, 'touchend', _this._disableDelayedDrag);
  2301. _on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
  2302. _on(ownerDocument, 'mousemove', _this._disableDelayedDrag);
  2303. _on(ownerDocument, 'touchmove', _this._disableDelayedDrag);
  2304. _on(ownerDocument, 'pointermove', _this._disableDelayedDrag);
  2305. _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
  2306. } else {
  2307. dragStartFn();
  2308. }
  2309. }
  2310. },
  2311. _disableDelayedDrag: function _disableDelayedDrag() {
  2312. var ownerDocument = this.el.ownerDocument;
  2313. clearTimeout(this._dragStartTimer);
  2314. _off(ownerDocument, 'mouseup', this._disableDelayedDrag);
  2315. _off(ownerDocument, 'touchend', this._disableDelayedDrag);
  2316. _off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
  2317. _off(ownerDocument, 'mousemove', this._disableDelayedDrag);
  2318. _off(ownerDocument, 'touchmove', this._disableDelayedDrag);
  2319. _off(ownerDocument, 'pointermove', this._disableDelayedDrag);
  2320. },
  2321. _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
  2322. touch = touch || (evt.pointerType == 'touch' ? evt : null);
  2323. if (touch) {
  2324. // Touch device support
  2325. tapEvt = {
  2326. target: dragEl,
  2327. clientX: touch.clientX,
  2328. clientY: touch.clientY
  2329. };
  2330. this._onDragStart(tapEvt, 'touch');
  2331. } else if (!this.nativeDraggable) {
  2332. this._onDragStart(tapEvt, true);
  2333. } else {
  2334. _on(dragEl, 'dragend', this);
  2335. _on(rootEl, 'dragstart', this._onDragStart);
  2336. }
  2337. try {
  2338. if (document.selection) {
  2339. // Timeout neccessary for IE9
  2340. setTimeout(function () {
  2341. document.selection.empty();
  2342. });
  2343. } else {
  2344. window.getSelection().removeAllRanges();
  2345. }
  2346. } catch (err) {}
  2347. },
  2348. _dragStarted: function _dragStarted() {
  2349. if (rootEl && dragEl) {
  2350. var options = this.options;
  2351. // Apply effect
  2352. _toggleClass(dragEl, options.ghostClass, true);
  2353. _toggleClass(dragEl, options.dragClass, false);
  2354. Sortable.active = this;
  2355. // Drag start event
  2356. _dispatchEvent(this, rootEl, 'start', dragEl, rootEl, oldIndex);
  2357. } else {
  2358. this._nulling();
  2359. }
  2360. },
  2361. _emulateDragOver: function _emulateDragOver() {
  2362. if (touchEvt) {
  2363. if (this._lastX === touchEvt.clientX && this._lastY === touchEvt.clientY) {
  2364. return;
  2365. }
  2366. this._lastX = touchEvt.clientX;
  2367. this._lastY = touchEvt.clientY;
  2368. if (!supportCssPointerEvents) {
  2369. _css(ghostEl, 'display', 'none');
  2370. }
  2371. var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY),
  2372. parent = target,
  2373. i = touchDragOverListeners.length;
  2374. if (parent) {
  2375. do {
  2376. if (parent[expando]) {
  2377. while (i--) {
  2378. touchDragOverListeners[i]({
  2379. clientX: touchEvt.clientX,
  2380. clientY: touchEvt.clientY,
  2381. target: target,
  2382. rootEl: parent
  2383. });
  2384. }
  2385. break;
  2386. }
  2387. target = parent; // store last element
  2388. }
  2389. /* jshint boss:true */
  2390. while (parent = parent.parentNode);
  2391. }
  2392. if (!supportCssPointerEvents) {
  2393. _css(ghostEl, 'display', '');
  2394. }
  2395. }
  2396. },
  2397. _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
  2398. if (tapEvt) {
  2399. var options = this.options,
  2400. fallbackTolerance = options.fallbackTolerance,
  2401. fallbackOffset = options.fallbackOffset,
  2402. touch = evt.touches ? evt.touches[0] : evt,
  2403. dx = touch.clientX - tapEvt.clientX + fallbackOffset.x,
  2404. dy = touch.clientY - tapEvt.clientY + fallbackOffset.y,
  2405. translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
  2406. // only set the status to dragging, when we are actually dragging
  2407. if (!Sortable.active) {
  2408. if (fallbackTolerance && min(abs(touch.clientX - this._lastX), abs(touch.clientY - this._lastY)) < fallbackTolerance) {
  2409. return;
  2410. }
  2411. this._dragStarted();
  2412. }
  2413. // as well as creating the ghost element on the document body
  2414. this._appendGhost();
  2415. moved = true;
  2416. touchEvt = touch;
  2417. _css(ghostEl, 'webkitTransform', translate3d);
  2418. _css(ghostEl, 'mozTransform', translate3d);
  2419. _css(ghostEl, 'msTransform', translate3d);
  2420. _css(ghostEl, 'transform', translate3d);
  2421. evt.preventDefault();
  2422. }
  2423. },
  2424. _appendGhost: function _appendGhost() {
  2425. if (!ghostEl) {
  2426. var rect = dragEl.getBoundingClientRect(),
  2427. css = _css(dragEl),
  2428. options = this.options,
  2429. ghostRect;
  2430. ghostEl = dragEl.cloneNode(true);
  2431. _toggleClass(ghostEl, options.ghostClass, false);
  2432. _toggleClass(ghostEl, options.fallbackClass, true);
  2433. _toggleClass(ghostEl, options.dragClass, true);
  2434. _css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10));
  2435. _css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10));
  2436. _css(ghostEl, 'width', rect.width);
  2437. _css(ghostEl, 'height', rect.height);
  2438. _css(ghostEl, 'opacity', '0.8');
  2439. _css(ghostEl, 'position', 'fixed');
  2440. _css(ghostEl, 'zIndex', '100000');
  2441. _css(ghostEl, 'pointerEvents', 'none');
  2442. options.fallbackOnBody && document.body.appendChild(ghostEl) || rootEl.appendChild(ghostEl);
  2443. // Fixing dimensions.
  2444. ghostRect = ghostEl.getBoundingClientRect();
  2445. _css(ghostEl, 'width', rect.width * 2 - ghostRect.width);
  2446. _css(ghostEl, 'height', rect.height * 2 - ghostRect.height);
  2447. }
  2448. },
  2449. _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/useFallback) {
  2450. var dataTransfer = evt.dataTransfer,
  2451. options = this.options;
  2452. this._offUpEvents();
  2453. if (activeGroup.checkPull(this, this, dragEl, evt)) {
  2454. cloneEl = _clone(dragEl);
  2455. cloneEl.draggable = false;
  2456. cloneEl.style['will-change'] = '';
  2457. _css(cloneEl, 'display', 'none');
  2458. _toggleClass(cloneEl, this.options.chosenClass, false);
  2459. rootEl.insertBefore(cloneEl, dragEl);
  2460. _dispatchEvent(this, rootEl, 'clone', dragEl);
  2461. }
  2462. _toggleClass(dragEl, options.dragClass, true);
  2463. if (useFallback) {
  2464. if (useFallback === 'touch') {
  2465. // Bind touch events
  2466. _on(document, 'touchmove', this._onTouchMove);
  2467. _on(document, 'touchend', this._onDrop);
  2468. _on(document, 'touchcancel', this._onDrop);
  2469. _on(document, 'pointermove', this._onTouchMove);
  2470. _on(document, 'pointerup', this._onDrop);
  2471. } else {
  2472. // Old brwoser
  2473. _on(document, 'mousemove', this._onTouchMove);
  2474. _on(document, 'mouseup', this._onDrop);
  2475. }
  2476. this._loopId = setInterval(this._emulateDragOver, 50);
  2477. } else {
  2478. if (dataTransfer) {
  2479. dataTransfer.effectAllowed = 'move';
  2480. options.setData && options.setData.call(this, dataTransfer, dragEl);
  2481. }
  2482. _on(document, 'drop', this);
  2483. setTimeout(this._dragStarted, 0);
  2484. }
  2485. },
  2486. _onDragOver: function _onDragOver( /**Event*/evt) {
  2487. var el = this.el,
  2488. target,
  2489. dragRect,
  2490. targetRect,
  2491. revert,
  2492. options = this.options,
  2493. group = options.group,
  2494. activeSortable = Sortable.active,
  2495. isOwner = activeGroup === group,
  2496. isMovingBetweenSortable = false,
  2497. canSort = options.sort;
  2498. if (evt.preventDefault !== void 0) {
  2499. evt.preventDefault();
  2500. !options.dragoverBubble && evt.stopPropagation();
  2501. }
  2502. if (dragEl.animated) {
  2503. return;
  2504. }
  2505. moved = true;
  2506. if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
  2507. : putSortable === this || (activeSortable.lastPullMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt)) && (evt.rootEl === void 0 || evt.rootEl === this.el) // touch fallback
  2508. ) {
  2509. // Smart auto-scrolling
  2510. _autoScroll(evt, options, this.el);
  2511. if (_silent) {
  2512. return;
  2513. }
  2514. target = _closest(evt.target, options.draggable, el);
  2515. dragRect = dragEl.getBoundingClientRect();
  2516. if (putSortable !== this) {
  2517. putSortable = this;
  2518. isMovingBetweenSortable = true;
  2519. }
  2520. if (revert) {
  2521. _cloneHide(activeSortable, true);
  2522. parentEl = rootEl; // actualization
  2523. if (cloneEl || nextEl) {
  2524. rootEl.insertBefore(dragEl, cloneEl || nextEl);
  2525. } else if (!canSort) {
  2526. rootEl.appendChild(dragEl);
  2527. }
  2528. return;
  2529. }
  2530. if (el.children.length === 0 || el.children[0] === ghostEl || el === evt.target && _ghostIsLast(el, evt)) {
  2531. //assign target only if condition is true
  2532. if (el.children.length !== 0 && el.children[0] !== ghostEl && el === evt.target) {
  2533. target = el.lastElementChild;
  2534. }
  2535. if (target) {
  2536. if (target.animated) {
  2537. return;
  2538. }
  2539. targetRect = target.getBoundingClientRect();
  2540. }
  2541. _cloneHide(activeSortable, isOwner);
  2542. if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) {
  2543. if (!dragEl.contains(el)) {
  2544. el.appendChild(dragEl);
  2545. parentEl = el; // actualization
  2546. }
  2547. this._animate(dragRect, dragEl);
  2548. target && this._animate(targetRect, target);
  2549. }
  2550. } else if (target && !target.animated && target !== dragEl && target.parentNode[expando] !== void 0) {
  2551. if (lastEl !== target) {
  2552. lastEl = target;
  2553. lastCSS = _css(target);
  2554. lastParentCSS = _css(target.parentNode);
  2555. }
  2556. targetRect = target.getBoundingClientRect();
  2557. var width = targetRect.right - targetRect.left,
  2558. height = targetRect.bottom - targetRect.top,
  2559. floating = R_FLOAT.test(lastCSS.cssFloat + lastCSS.display) || lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0,
  2560. isWide = target.offsetWidth > dragEl.offsetWidth,
  2561. isLong = target.offsetHeight > dragEl.offsetHeight,
  2562. halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5,
  2563. nextSibling = target.nextElementSibling,
  2564. after = false;
  2565. if (floating) {
  2566. var elTop = dragEl.offsetTop,
  2567. tgTop = target.offsetTop;
  2568. if (elTop === tgTop) {
  2569. after = target.previousElementSibling === dragEl && !isWide || halfway && isWide;
  2570. } else if (target.previousElementSibling === dragEl || dragEl.previousElementSibling === target) {
  2571. after = (evt.clientY - targetRect.top) / height > 0.5;
  2572. } else {
  2573. after = tgTop > elTop;
  2574. }
  2575. } else if (!isMovingBetweenSortable) {
  2576. after = nextSibling !== dragEl && !isLong || halfway && isLong;
  2577. }
  2578. var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
  2579. if (moveVector !== false) {
  2580. if (moveVector === 1 || moveVector === -1) {
  2581. after = moveVector === 1;
  2582. }
  2583. _silent = true;
  2584. setTimeout(_unsilent, 30);
  2585. _cloneHide(activeSortable, isOwner);
  2586. if (!dragEl.contains(el)) {
  2587. if (after && !nextSibling) {
  2588. el.appendChild(dragEl);
  2589. } else {
  2590. target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
  2591. }
  2592. }
  2593. parentEl = dragEl.parentNode; // actualization
  2594. this._animate(dragRect, dragEl);
  2595. this._animate(targetRect, target);
  2596. }
  2597. }
  2598. }
  2599. },
  2600. _animate: function _animate(prevRect, target) {
  2601. var ms = this.options.animation;
  2602. if (ms) {
  2603. var currentRect = target.getBoundingClientRect();
  2604. if (prevRect.nodeType === 1) {
  2605. prevRect = prevRect.getBoundingClientRect();
  2606. }
  2607. _css(target, 'transition', 'none');
  2608. _css(target, 'transform', 'translate3d(' + (prevRect.left - currentRect.left) + 'px,' + (prevRect.top - currentRect.top) + 'px,0)');
  2609. target.offsetWidth; // repaint
  2610. _css(target, 'transition', 'all ' + ms + 'ms');
  2611. _css(target, 'transform', 'translate3d(0,0,0)');
  2612. clearTimeout(target.animated);
  2613. target.animated = setTimeout(function () {
  2614. _css(target, 'transition', '');
  2615. _css(target, 'transform', '');
  2616. target.animated = false;
  2617. }, ms);
  2618. }
  2619. },
  2620. _offUpEvents: function _offUpEvents() {
  2621. var ownerDocument = this.el.ownerDocument;
  2622. _off(document, 'touchmove', this._onTouchMove);
  2623. _off(document, 'pointermove', this._onTouchMove);
  2624. _off(ownerDocument, 'mouseup', this._onDrop);
  2625. _off(ownerDocument, 'touchend', this._onDrop);
  2626. _off(ownerDocument, 'pointerup', this._onDrop);
  2627. _off(ownerDocument, 'touchcancel', this._onDrop);
  2628. _off(ownerDocument, 'pointercancel', this._onDrop);
  2629. _off(ownerDocument, 'selectstart', this);
  2630. },
  2631. _onDrop: function _onDrop( /**Event*/evt) {
  2632. var el = this.el,
  2633. options = this.options;
  2634. clearInterval(this._loopId);
  2635. clearInterval(autoScroll.pid);
  2636. clearTimeout(this._dragStartTimer);
  2637. // Unbind events
  2638. _off(document, 'mousemove', this._onTouchMove);
  2639. if (this.nativeDraggable) {
  2640. _off(document, 'drop', this);
  2641. _off(el, 'dragstart', this._onDragStart);
  2642. }
  2643. this._offUpEvents();
  2644. if (evt) {
  2645. if (moved) {
  2646. evt.preventDefault();
  2647. !options.dropBubble && evt.stopPropagation();
  2648. }
  2649. ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
  2650. if (rootEl === parentEl || Sortable.active.lastPullMode !== 'clone') {
  2651. // Remove clone
  2652. cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
  2653. }
  2654. if (dragEl) {
  2655. if (this.nativeDraggable) {
  2656. _off(dragEl, 'dragend', this);
  2657. }
  2658. _disableDraggable(dragEl);
  2659. dragEl.style['will-change'] = '';
  2660. // Remove class's
  2661. _toggleClass(dragEl, this.options.ghostClass, false);
  2662. _toggleClass(dragEl, this.options.chosenClass, false);
  2663. // Drag stop event
  2664. _dispatchEvent(this, rootEl, 'unchoose', dragEl, rootEl, oldIndex);
  2665. if (rootEl !== parentEl) {
  2666. newIndex = _index(dragEl, options.draggable);
  2667. if (newIndex >= 0) {
  2668. // Add event
  2669. _dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex);
  2670. // Remove event
  2671. _dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex);
  2672. // drag from one list and drop into another
  2673. _dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
  2674. _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
  2675. }
  2676. } else {
  2677. if (dragEl.nextSibling !== nextEl) {
  2678. // Get the index of the dragged element within its parent
  2679. newIndex = _index(dragEl, options.draggable);
  2680. if (newIndex >= 0) {
  2681. // drag & drop within the same list
  2682. _dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex);
  2683. _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
  2684. }
  2685. }
  2686. }
  2687. if (Sortable.active) {
  2688. /* jshint eqnull:true */
  2689. if (newIndex == null || newIndex === -1) {
  2690. newIndex = oldIndex;
  2691. }
  2692. _dispatchEvent(this, rootEl, 'end', dragEl, rootEl, oldIndex, newIndex);
  2693. // Save sorting
  2694. this.save();
  2695. }
  2696. }
  2697. }
  2698. this._nulling();
  2699. },
  2700. _nulling: function _nulling() {
  2701. rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = scrollEl = scrollParentEl = tapEvt = touchEvt = moved = newIndex = lastEl = lastCSS = putSortable = activeGroup = Sortable.active = null;
  2702. savedInputChecked.forEach(function (el) {
  2703. el.checked = true;
  2704. });
  2705. savedInputChecked.length = 0;
  2706. },
  2707. handleEvent: function handleEvent( /**Event*/evt) {
  2708. switch (evt.type) {
  2709. case 'drop':
  2710. case 'dragend':
  2711. this._onDrop(evt);
  2712. break;
  2713. case 'dragover':
  2714. case 'dragenter':
  2715. if (dragEl) {
  2716. this._onDragOver(evt);
  2717. _globalDragOver(evt);
  2718. }
  2719. break;
  2720. case 'selectstart':
  2721. evt.preventDefault();
  2722. break;
  2723. }
  2724. },
  2725. /**
  2726. * Serializes the item into an array of string.
  2727. * @returns {String[]}
  2728. */
  2729. toArray: function toArray() {
  2730. var order = [],
  2731. el,
  2732. children = this.el.children,
  2733. i = 0,
  2734. n = children.length,
  2735. options = this.options;
  2736. for (; i < n; i++) {
  2737. el = children[i];
  2738. if (_closest(el, options.draggable, this.el)) {
  2739. order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
  2740. }
  2741. }
  2742. return order;
  2743. },
  2744. /**
  2745. * Sorts the elements according to the array.
  2746. * @param {String[]} order order of the items
  2747. */
  2748. sort: function sort(order) {
  2749. var items = {},
  2750. rootEl = this.el;
  2751. this.toArray().forEach(function (id, i) {
  2752. var el = rootEl.children[i];
  2753. if (_closest(el, this.options.draggable, rootEl)) {
  2754. items[id] = el;
  2755. }
  2756. }, this);
  2757. order.forEach(function (id) {
  2758. if (items[id]) {
  2759. rootEl.removeChild(items[id]);
  2760. rootEl.appendChild(items[id]);
  2761. }
  2762. });
  2763. },
  2764. /**
  2765. * Save the current sorting
  2766. */
  2767. save: function save() {
  2768. var store = this.options.store;
  2769. store && store.set(this);
  2770. },
  2771. /**
  2772. * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
  2773. * @param {HTMLElement} el
  2774. * @param {String} [selector] default: `options.draggable`
  2775. * @returns {HTMLElement|null}
  2776. */
  2777. closest: function closest(el, selector) {
  2778. return _closest(el, selector || this.options.draggable, this.el);
  2779. },
  2780. /**
  2781. * Set/get option
  2782. * @param {string} name
  2783. * @param {*} [value]
  2784. * @returns {*}
  2785. */
  2786. option: function option(name, value) {
  2787. var options = this.options;
  2788. if (value === void 0) {
  2789. return options[name];
  2790. } else {
  2791. options[name] = value;
  2792. if (name === 'group') {
  2793. _prepareGroup(options);
  2794. }
  2795. }
  2796. },
  2797. /**
  2798. * Destroy
  2799. */
  2800. destroy: function destroy() {
  2801. var el = this.el;
  2802. el[expando] = null;
  2803. _off(el, 'mousedown', this._onTapStart);
  2804. _off(el, 'touchstart', this._onTapStart);
  2805. _off(el, 'pointerdown', this._onTapStart);
  2806. if (this.nativeDraggable) {
  2807. _off(el, 'dragover', this);
  2808. _off(el, 'dragenter', this);
  2809. }
  2810. // Remove draggable attributes
  2811. Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
  2812. el.removeAttribute('draggable');
  2813. });
  2814. touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver), 1);
  2815. this._onDrop();
  2816. this.el = el = null;
  2817. }
  2818. };
  2819. function _cloneHide(sortable, state) {
  2820. if (sortable.lastPullMode !== 'clone') {
  2821. state = true;
  2822. }
  2823. if (cloneEl && cloneEl.state !== state) {
  2824. _css(cloneEl, 'display', state ? 'none' : '');
  2825. if (!state) {
  2826. if (cloneEl.state) {
  2827. if (sortable.options.group.revertClone) {
  2828. rootEl.insertBefore(cloneEl, nextEl);
  2829. sortable._animate(dragEl, cloneEl);
  2830. } else {
  2831. rootEl.insertBefore(cloneEl, dragEl);
  2832. }
  2833. }
  2834. }
  2835. cloneEl.state = state;
  2836. }
  2837. }
  2838. function _closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx) {
  2839. if (el) {
  2840. ctx = ctx || document;
  2841. do {
  2842. if (selector === '>*' && el.parentNode === ctx || _matches(el, selector)) {
  2843. return el;
  2844. }
  2845. /* jshint boss:true */
  2846. } while (el = _getParentOrHost(el));
  2847. }
  2848. return null;
  2849. }
  2850. function _getParentOrHost(el) {
  2851. var parent = el.host;
  2852. return parent && parent.nodeType ? parent : el.parentNode;
  2853. }
  2854. function _globalDragOver( /**Event*/evt) {
  2855. if (evt.dataTransfer) {
  2856. evt.dataTransfer.dropEffect = 'move';
  2857. }
  2858. evt.preventDefault();
  2859. }
  2860. function _on(el, event, fn) {
  2861. el.addEventListener(event, fn, captureMode);
  2862. }
  2863. function _off(el, event, fn) {
  2864. el.removeEventListener(event, fn, captureMode);
  2865. }
  2866. function _toggleClass(el, name, state) {
  2867. if (el) {
  2868. if (el.classList) {
  2869. el.classList[state ? 'add' : 'remove'](name);
  2870. } else {
  2871. var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
  2872. el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
  2873. }
  2874. }
  2875. }
  2876. function _css(el, prop, val) {
  2877. var style = el && el.style;
  2878. if (style) {
  2879. if (val === void 0) {
  2880. if (document.defaultView && document.defaultView.getComputedStyle) {
  2881. val = document.defaultView.getComputedStyle(el, '');
  2882. } else if (el.currentStyle) {
  2883. val = el.currentStyle;
  2884. }
  2885. return prop === void 0 ? val : val[prop];
  2886. } else {
  2887. if (!(prop in style)) {
  2888. prop = '-webkit-' + prop;
  2889. }
  2890. style[prop] = val + (typeof val === 'string' ? '' : 'px');
  2891. }
  2892. }
  2893. }
  2894. function _find(ctx, tagName, iterator) {
  2895. if (ctx) {
  2896. var list = ctx.getElementsByTagName(tagName),
  2897. i = 0,
  2898. n = list.length;
  2899. if (iterator) {
  2900. for (; i < n; i++) {
  2901. iterator(list[i], i);
  2902. }
  2903. }
  2904. return list;
  2905. }
  2906. return [];
  2907. }
  2908. function _dispatchEvent(sortable, rootEl, name, targetEl, fromEl, startIndex, newIndex) {
  2909. sortable = sortable || rootEl[expando];
  2910. var evt = document.createEvent('Event'),
  2911. options = sortable.options,
  2912. onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
  2913. evt.initEvent(name, true, true);
  2914. evt.to = rootEl;
  2915. evt.from = fromEl || rootEl;
  2916. evt.item = targetEl || rootEl;
  2917. evt.clone = cloneEl;
  2918. evt.oldIndex = startIndex;
  2919. evt.newIndex = newIndex;
  2920. rootEl.dispatchEvent(evt);
  2921. if (options[onName]) {
  2922. options[onName].call(sortable, evt);
  2923. }
  2924. }
  2925. function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt, willInsertAfter) {
  2926. var evt,
  2927. sortable = fromEl[expando],
  2928. onMoveFn = sortable.options.onMove,
  2929. retVal;
  2930. evt = document.createEvent('Event');
  2931. evt.initEvent('move', true, true);
  2932. evt.to = toEl;
  2933. evt.from = fromEl;
  2934. evt.dragged = dragEl;
  2935. evt.draggedRect = dragRect;
  2936. evt.related = targetEl || toEl;
  2937. evt.relatedRect = targetRect || toEl.getBoundingClientRect();
  2938. evt.willInsertAfter = willInsertAfter;
  2939. fromEl.dispatchEvent(evt);
  2940. if (onMoveFn) {
  2941. retVal = onMoveFn.call(sortable, evt, originalEvt);
  2942. }
  2943. return retVal;
  2944. }
  2945. function _disableDraggable(el) {
  2946. el.draggable = false;
  2947. }
  2948. function _unsilent() {
  2949. _silent = false;
  2950. }
  2951. /** @returns {HTMLElement|false} */
  2952. function _ghostIsLast(el, evt) {
  2953. var lastEl = el.lastElementChild,
  2954. rect = lastEl.getBoundingClientRect();
  2955. // 5 — min delta
  2956. // abs — нельзя добавлять, а то глюки при наведении сверху
  2957. return evt.clientY - (rect.top + rect.height) > 5 || evt.clientX - (rect.left + rect.width) > 5;
  2958. }
  2959. /**
  2960. * Generate id
  2961. * @param {HTMLElement} el
  2962. * @returns {String}
  2963. * @private
  2964. */
  2965. function _generateId(el) {
  2966. var str = el.tagName + el.className + el.src + el.href + el.textContent,
  2967. i = str.length,
  2968. sum = 0;
  2969. while (i--) {
  2970. sum += str.charCodeAt(i);
  2971. }
  2972. return sum.toString(36);
  2973. }
  2974. /**
  2975. * Returns the index of an element within its parent for a selected set of
  2976. * elements
  2977. * @param {HTMLElement} el
  2978. * @param {selector} selector
  2979. * @return {number}
  2980. */
  2981. function _index(el, selector) {
  2982. var index = 0;
  2983. if (!el || !el.parentNode) {
  2984. return -1;
  2985. }
  2986. while (el && (el = el.previousElementSibling)) {
  2987. if (el.nodeName.toUpperCase() !== 'TEMPLATE' && (selector === '>*' || _matches(el, selector))) {
  2988. index++;
  2989. }
  2990. }
  2991. return index;
  2992. }
  2993. function _matches( /**HTMLElement*/el, /**String*/selector) {
  2994. if (el) {
  2995. selector = selector.split('.');
  2996. var tag = selector.shift().toUpperCase(),
  2997. re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g');
  2998. return (tag === '' || el.nodeName.toUpperCase() == tag) && (!selector.length || ((' ' + el.className + ' ').match(re) || []).length == selector.length);
  2999. }
  3000. return false;
  3001. }
  3002. function _throttle(callback, ms) {
  3003. var args, _this;
  3004. return function () {
  3005. if (args === void 0) {
  3006. args = arguments;
  3007. _this = this;
  3008. setTimeout(function () {
  3009. if (args.length === 1) {
  3010. callback.call(_this, args[0]);
  3011. } else {
  3012. callback.apply(_this, args);
  3013. }
  3014. args = void 0;
  3015. }, ms);
  3016. }
  3017. };
  3018. }
  3019. function _extend(dst, src) {
  3020. if (dst && src) {
  3021. for (var key in src) {
  3022. if (src.hasOwnProperty(key)) {
  3023. dst[key] = src[key];
  3024. }
  3025. }
  3026. }
  3027. return dst;
  3028. }
  3029. function _clone(el) {
  3030. return $ ? $(el).clone(true)[0] : Polymer && Polymer.dom ? Polymer.dom(el).cloneNode(true) : el.cloneNode(true);
  3031. }
  3032. function _saveInputCheckedState(root) {
  3033. var inputs = root.getElementsByTagName('input');
  3034. var idx = inputs.length;
  3035. while (idx--) {
  3036. var el = inputs[idx];
  3037. el.checked && savedInputChecked.push(el);
  3038. }
  3039. }
  3040. // Fixed #973:
  3041. _on(document, 'touchmove', function (evt) {
  3042. if (Sortable.active) {
  3043. evt.preventDefault();
  3044. }
  3045. });
  3046. try {
  3047. window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
  3048. get: function get() {
  3049. captureMode = {
  3050. capture: false,
  3051. passive: false
  3052. };
  3053. }
  3054. }));
  3055. } catch (err) {}
  3056. // Export utils
  3057. Sortable.utils = {
  3058. on: _on,
  3059. off: _off,
  3060. css: _css,
  3061. find: _find,
  3062. is: function is(el, selector) {
  3063. return !!_closest(el, selector, el);
  3064. },
  3065. extend: _extend,
  3066. throttle: _throttle,
  3067. closest: _closest,
  3068. toggleClass: _toggleClass,
  3069. clone: _clone,
  3070. index: _index
  3071. };
  3072. /**
  3073. * Create sortable instance
  3074. * @param {HTMLElement} el
  3075. * @param {Object} [options]
  3076. */
  3077. Sortable.create = function (el, options) {
  3078. return new Sortable(el, options);
  3079. };
  3080. // Export
  3081. Sortable.version = '1.6.1';
  3082. return Sortable;
  3083. });
  3084. /***/ }),
  3085. /***/ "./js/assessment/ivprogAssessment.js":
  3086. /*!*******************************************!*\
  3087. !*** ./js/assessment/ivprogAssessment.js ***!
  3088. \*******************************************/
  3089. /*! no static exports found */
  3090. /***/ (function(module, exports, __webpack_require__) {
  3091. "use strict";
  3092. Object.defineProperty(exports, "__esModule", {
  3093. value: true
  3094. });
  3095. exports.IVProgAssessment = undefined;
  3096. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3097. var _ivprogParser = __webpack_require__(/*! ./../ast/ivprogParser */ "./js/ast/ivprogParser.js");
  3098. var _semanticAnalyser = __webpack_require__(/*! ./../processor/semantic/semanticAnalyser */ "./js/processor/semantic/semanticAnalyser.js");
  3099. var _ivprogProcessor = __webpack_require__(/*! ./../processor/ivprogProcessor */ "./js/processor/ivprogProcessor.js");
  3100. var _inputTest = __webpack_require__(/*! ./../util/inputTest */ "./js/util/inputTest.js");
  3101. var _outputTest = __webpack_require__(/*! ./../util/outputTest */ "./js/util/outputTest.js");
  3102. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3103. var IVProgAssessment = exports.IVProgAssessment = function () {
  3104. function IVProgAssessment(textCode, testCases, domConsole) {
  3105. _classCallCheck(this, IVProgAssessment);
  3106. this.textCode = textCode;
  3107. this.testCases = testCases;
  3108. this.domConsole = domConsole;
  3109. }
  3110. _createClass(IVProgAssessment, [{
  3111. key: "runTest",
  3112. value: function runTest() {
  3113. var _this = this;
  3114. try {
  3115. // try and show error messages through domconsole
  3116. var parser = _ivprogParser.IVProgParser.createParser(this.textCode);
  3117. var semantic = new _semanticAnalyser.SemanticAnalyser(parser.parseTree());
  3118. var validTree = semantic.analyseTree();
  3119. // loop test cases and show messages through domconsole
  3120. var partialTests = this.testCases.map(function (t, name) {
  3121. return _this.partialEvaluateTestCase(new _ivprogProcessor.IVProgProcessor(validTree), t.input, t.output, name);
  3122. });
  3123. var testResult = partialTests.reduce(function (acc, curr) {
  3124. return acc.then(curr);
  3125. }, Promise.resolve(0));
  3126. return testResult.then(function (total) {
  3127. return Promise.resolve(total / _this.testCases.length);
  3128. }).catch(function (err) {
  3129. _this.domConsole.err("Erro durante a execução do programa"); // try and show error messages through domconsole
  3130. _this.domConsole.err(err.message);
  3131. return Promise.resolve(0);
  3132. });
  3133. } catch (error) {
  3134. this.domConsole.err("Erro durante a execução do programa"); // try and show error messages through domconsole
  3135. this.domConsole.err(error.message);
  3136. return Promise.resolve(0);
  3137. }
  3138. }
  3139. }, {
  3140. key: "evaluateTestCase",
  3141. value: function evaluateTestCase(prog, inputList, outputList, name, accumulator) {
  3142. var _this2 = this;
  3143. var outerThis = this;
  3144. var input = new _inputTest.InputTest(inputList);
  3145. var output = new _outputTest.OutputTest();
  3146. prog.registerInput(input);
  3147. prog.registerOutput(output);
  3148. var startTime = Date.now();
  3149. return prog.interpretAST().then(function (_) {
  3150. var millis = Date.now() - startTime;
  3151. if (input.inputList.length !== input.index) {
  3152. outerThis.domConsole.err("Caso de teste " + (name + 1) + ": Falhou, ainda restam entradas!");
  3153. outerThis.domConsole.info("Levou " + millis + "ms");
  3154. return Promise.resolve(accumulator + 1 * (input.index / inputList.length));
  3155. } else if (output.list.length < outputList.length) {
  3156. outerThis.domConsole.err("Caso de teste " + (name + 1) + ": Falhou <" + inputList.join(", ") + ";" + outputList.join(", ") + ";" + output.list.join(", ") + ">");
  3157. outerThis.domConsole.info("Levou " + millis + "ms");
  3158. return Promise.resolve(accumulator + 1 * (output.list.length / outputList.length));
  3159. } else if (output.list.length > outputList.length) {
  3160. outerThis.domConsole.err("Caso de teste " + (name + 1) + ": Falhou <" + inputList.join(", ") + ";" + outputList.join(", ") + ";" + output.list.join(", ") + ">");
  3161. outerThis.domConsole.info("Levou " + millis + "ms");
  3162. return Promise.resolve(accumulator + 1 * (outputList.length / output.list.length));
  3163. } else {
  3164. var isOk = outerThis.checkOutput(output.list, outputList);
  3165. if (!isOk) {
  3166. outerThis.domConsole.err("Caso de teste " + (name + 1) + ": Falhou <" + inputList.join(", ") + ";" + outputList.join(", ") + ";" + output.list.join(", ") + ">");
  3167. outerThis.domConsole.info("Levou " + millis + "ms");
  3168. return Promise.resolve(accumulator);
  3169. } else {
  3170. outerThis.domConsole.info("Caso de teste " + (name + 1) + ": OK!");
  3171. outerThis.domConsole.info("Levou " + millis + "ms");
  3172. return Promise.resolve(accumulator + 1);
  3173. }
  3174. }
  3175. }).catch(function (error) {
  3176. _this2.domConsole.err("Execu\xE7\xE3o do caso de teste " + (name + 1) + " falhou!"); // try and show error messages through domconsole
  3177. _this2.domConsole.err(error.message);
  3178. return Promise.resolve(accumulator);
  3179. });
  3180. }
  3181. }, {
  3182. key: "partialEvaluateTestCase",
  3183. value: function partialEvaluateTestCase(prog, inputList, outputList, name) {
  3184. return this.evaluateTestCase.bind(this, prog, inputList, outputList, name);
  3185. }
  3186. }, {
  3187. key: "checkOutput",
  3188. value: function checkOutput(aList, bList) {
  3189. for (var i = 0; i < aList.length; i++) {
  3190. var outValue = aList[i];
  3191. if (outValue != bList[i]) {
  3192. return false;
  3193. }
  3194. }
  3195. return true;
  3196. }
  3197. }]);
  3198. return IVProgAssessment;
  3199. }();
  3200. /***/ }),
  3201. /***/ "./js/ast/commands/arrayAssign.js":
  3202. /*!****************************************!*\
  3203. !*** ./js/ast/commands/arrayAssign.js ***!
  3204. \****************************************/
  3205. /*! no static exports found */
  3206. /***/ (function(module, exports, __webpack_require__) {
  3207. "use strict";
  3208. Object.defineProperty(exports, "__esModule", {
  3209. value: true
  3210. });
  3211. exports.ArrayIndexAssign = undefined;
  3212. var _assign = __webpack_require__(/*! ./assign */ "./js/ast/commands/assign.js");
  3213. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3214. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3215. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3216. var ArrayIndexAssign = exports.ArrayIndexAssign = function (_Assign) {
  3217. _inherits(ArrayIndexAssign, _Assign);
  3218. function ArrayIndexAssign(id, lineExpression, columnExpression, expression) {
  3219. _classCallCheck(this, ArrayIndexAssign);
  3220. var _this = _possibleConstructorReturn(this, (ArrayIndexAssign.__proto__ || Object.getPrototypeOf(ArrayIndexAssign)).call(this, id, expression));
  3221. _this.line = lineExpression;
  3222. _this.column = columnExpression;
  3223. return _this;
  3224. }
  3225. return ArrayIndexAssign;
  3226. }(_assign.Assign);
  3227. /***/ }),
  3228. /***/ "./js/ast/commands/arrayDeclaration.js":
  3229. /*!*********************************************!*\
  3230. !*** ./js/ast/commands/arrayDeclaration.js ***!
  3231. \*********************************************/
  3232. /*! no static exports found */
  3233. /***/ (function(module, exports, __webpack_require__) {
  3234. "use strict";
  3235. Object.defineProperty(exports, "__esModule", {
  3236. value: true
  3237. });
  3238. exports.ArrayDeclaration = undefined;
  3239. var _declaration = __webpack_require__(/*! ./declaration */ "./js/ast/commands/declaration.js");
  3240. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3241. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3242. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3243. var ArrayDeclaration = exports.ArrayDeclaration = function (_Declaration) {
  3244. _inherits(ArrayDeclaration, _Declaration);
  3245. function ArrayDeclaration(id, type, lines, columns, initial, isConst) {
  3246. _classCallCheck(this, ArrayDeclaration);
  3247. var _this = _possibleConstructorReturn(this, (ArrayDeclaration.__proto__ || Object.getPrototypeOf(ArrayDeclaration)).call(this, id, type, initial, isConst));
  3248. _this.lines = lines;
  3249. _this.columns = columns;
  3250. return _this;
  3251. }
  3252. return ArrayDeclaration;
  3253. }(_declaration.Declaration);
  3254. /***/ }),
  3255. /***/ "./js/ast/commands/assign.js":
  3256. /*!***********************************!*\
  3257. !*** ./js/ast/commands/assign.js ***!
  3258. \***********************************/
  3259. /*! no static exports found */
  3260. /***/ (function(module, exports, __webpack_require__) {
  3261. "use strict";
  3262. Object.defineProperty(exports, "__esModule", {
  3263. value: true
  3264. });
  3265. exports.Assign = undefined;
  3266. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3267. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3268. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3269. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3270. var Assign = exports.Assign = function (_Command) {
  3271. _inherits(Assign, _Command);
  3272. function Assign(id, expression) {
  3273. _classCallCheck(this, Assign);
  3274. var _this = _possibleConstructorReturn(this, (Assign.__proto__ || Object.getPrototypeOf(Assign)).call(this));
  3275. _this.id = id;
  3276. _this.expression = expression;
  3277. return _this;
  3278. }
  3279. return Assign;
  3280. }(_command.Command);
  3281. /***/ }),
  3282. /***/ "./js/ast/commands/break.js":
  3283. /*!**********************************!*\
  3284. !*** ./js/ast/commands/break.js ***!
  3285. \**********************************/
  3286. /*! no static exports found */
  3287. /***/ (function(module, exports, __webpack_require__) {
  3288. "use strict";
  3289. Object.defineProperty(exports, "__esModule", {
  3290. value: true
  3291. });
  3292. exports.Break = undefined;
  3293. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3294. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3295. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3296. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3297. var Break = exports.Break = function (_Command) {
  3298. _inherits(Break, _Command);
  3299. function Break() {
  3300. _classCallCheck(this, Break);
  3301. return _possibleConstructorReturn(this, (Break.__proto__ || Object.getPrototypeOf(Break)).call(this));
  3302. }
  3303. return Break;
  3304. }(_command.Command);
  3305. /***/ }),
  3306. /***/ "./js/ast/commands/case.js":
  3307. /*!*********************************!*\
  3308. !*** ./js/ast/commands/case.js ***!
  3309. \*********************************/
  3310. /*! no static exports found */
  3311. /***/ (function(module, exports, __webpack_require__) {
  3312. "use strict";
  3313. Object.defineProperty(exports, "__esModule", {
  3314. value: true
  3315. });
  3316. exports.Case = undefined;
  3317. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3318. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3319. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3320. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3321. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3322. var Case = exports.Case = function (_Command) {
  3323. _inherits(Case, _Command);
  3324. function Case(expression) {
  3325. _classCallCheck(this, Case);
  3326. var _this = _possibleConstructorReturn(this, (Case.__proto__ || Object.getPrototypeOf(Case)).call(this));
  3327. _this.expression = expression;
  3328. _this.commands = [];
  3329. return _this;
  3330. }
  3331. _createClass(Case, [{
  3332. key: 'setCommands',
  3333. value: function setCommands(commands) {
  3334. this.commands = commands;
  3335. }
  3336. }, {
  3337. key: 'isDefault',
  3338. get: function get() {
  3339. return this.expression === null;
  3340. }
  3341. }]);
  3342. return Case;
  3343. }(_command.Command);
  3344. /***/ }),
  3345. /***/ "./js/ast/commands/command.js":
  3346. /*!************************************!*\
  3347. !*** ./js/ast/commands/command.js ***!
  3348. \************************************/
  3349. /*! no static exports found */
  3350. /***/ (function(module, exports, __webpack_require__) {
  3351. "use strict";
  3352. Object.defineProperty(exports, "__esModule", {
  3353. value: true
  3354. });
  3355. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3356. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3357. var Command = exports.Command = function () {
  3358. function Command() {
  3359. _classCallCheck(this, Command);
  3360. this._sourceInfo = null;
  3361. }
  3362. _createClass(Command, [{
  3363. key: "sourceInfo",
  3364. set: function set(sourceInfo) {
  3365. this._sourceInfo = sourceInfo;
  3366. },
  3367. get: function get() {
  3368. return this._sourceInfo;
  3369. }
  3370. }]);
  3371. return Command;
  3372. }();
  3373. /***/ }),
  3374. /***/ "./js/ast/commands/commandBlock.js":
  3375. /*!*****************************************!*\
  3376. !*** ./js/ast/commands/commandBlock.js ***!
  3377. \*****************************************/
  3378. /*! no static exports found */
  3379. /***/ (function(module, exports, __webpack_require__) {
  3380. "use strict";
  3381. Object.defineProperty(exports, "__esModule", {
  3382. value: true
  3383. });
  3384. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3385. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3386. var CommandBlock = exports.CommandBlock = function () {
  3387. function CommandBlock(variables, commands) {
  3388. _classCallCheck(this, CommandBlock);
  3389. this.variables = variables;
  3390. this.commands = commands;
  3391. this._sourceInfo = null;
  3392. }
  3393. _createClass(CommandBlock, [{
  3394. key: "sourceInfo",
  3395. set: function set(sourceInfo) {
  3396. this._sourceInfo = sourceInfo;
  3397. },
  3398. get: function get() {
  3399. return this._sourceInfo;
  3400. }
  3401. }]);
  3402. return CommandBlock;
  3403. }();
  3404. /***/ }),
  3405. /***/ "./js/ast/commands/declaration.js":
  3406. /*!****************************************!*\
  3407. !*** ./js/ast/commands/declaration.js ***!
  3408. \****************************************/
  3409. /*! no static exports found */
  3410. /***/ (function(module, exports, __webpack_require__) {
  3411. "use strict";
  3412. Object.defineProperty(exports, "__esModule", {
  3413. value: true
  3414. });
  3415. exports.Declaration = undefined;
  3416. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3417. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3418. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3419. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3420. var Declaration = exports.Declaration = function (_Command) {
  3421. _inherits(Declaration, _Command);
  3422. function Declaration(id, type, initial, isConst) {
  3423. _classCallCheck(this, Declaration);
  3424. var _this = _possibleConstructorReturn(this, (Declaration.__proto__ || Object.getPrototypeOf(Declaration)).call(this));
  3425. _this.id = id;
  3426. _this.type = type;
  3427. _this.initial = initial;
  3428. _this.isConst = isConst;
  3429. return _this;
  3430. }
  3431. return Declaration;
  3432. }(_command.Command);
  3433. /***/ }),
  3434. /***/ "./js/ast/commands/doWhile.js":
  3435. /*!************************************!*\
  3436. !*** ./js/ast/commands/doWhile.js ***!
  3437. \************************************/
  3438. /*! no static exports found */
  3439. /***/ (function(module, exports, __webpack_require__) {
  3440. "use strict";
  3441. Object.defineProperty(exports, "__esModule", {
  3442. value: true
  3443. });
  3444. exports.DoWhile = undefined;
  3445. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3446. var _while = __webpack_require__(/*! ./while */ "./js/ast/commands/while.js");
  3447. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3448. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3449. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3450. var DoWhile = exports.DoWhile = function (_While) {
  3451. _inherits(DoWhile, _While);
  3452. function DoWhile(condition, commandBlock) {
  3453. _classCallCheck(this, DoWhile);
  3454. return _possibleConstructorReturn(this, (DoWhile.__proto__ || Object.getPrototypeOf(DoWhile)).call(this, condition, commandBlock));
  3455. }
  3456. _createClass(DoWhile, [{
  3457. key: 'testFirst',
  3458. get: function get() {
  3459. return false;
  3460. }
  3461. }]);
  3462. return DoWhile;
  3463. }(_while.While);
  3464. /***/ }),
  3465. /***/ "./js/ast/commands/for.js":
  3466. /*!********************************!*\
  3467. !*** ./js/ast/commands/for.js ***!
  3468. \********************************/
  3469. /*! no static exports found */
  3470. /***/ (function(module, exports, __webpack_require__) {
  3471. "use strict";
  3472. Object.defineProperty(exports, "__esModule", {
  3473. value: true
  3474. });
  3475. exports.For = undefined;
  3476. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3477. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3478. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3479. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3480. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3481. var For = exports.For = function (_Command) {
  3482. _inherits(For, _Command);
  3483. function For(assignment, condition, increment, commandBlock) {
  3484. _classCallCheck(this, For);
  3485. var _this = _possibleConstructorReturn(this, (For.__proto__ || Object.getPrototypeOf(For)).call(this));
  3486. _this.assignment = assignment;
  3487. _this.condition = condition;
  3488. _this.increment = increment;
  3489. _this.commandBlock = commandBlock;
  3490. return _this;
  3491. }
  3492. _createClass(For, [{
  3493. key: 'commands',
  3494. get: function get() {
  3495. return this.commandBlock.commands;
  3496. }
  3497. }]);
  3498. return For;
  3499. }(_command.Command);
  3500. /***/ }),
  3501. /***/ "./js/ast/commands/formalParameter.js":
  3502. /*!********************************************!*\
  3503. !*** ./js/ast/commands/formalParameter.js ***!
  3504. \********************************************/
  3505. /*! no static exports found */
  3506. /***/ (function(module, exports, __webpack_require__) {
  3507. "use strict";
  3508. Object.defineProperty(exports, "__esModule", {
  3509. value: true
  3510. });
  3511. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3512. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3513. var FormalParameter = exports.FormalParameter = function () {
  3514. function FormalParameter(type, id) {
  3515. var byRef = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3516. _classCallCheck(this, FormalParameter);
  3517. this.type = type;
  3518. this.id = id;
  3519. this.byRef = byRef;
  3520. this._sourceInfo = null;
  3521. }
  3522. _createClass(FormalParameter, [{
  3523. key: "sourceInfo",
  3524. set: function set(sourceInfo) {
  3525. this._sourceInfo = sourceInfo;
  3526. },
  3527. get: function get() {
  3528. return this._sourceInfo;
  3529. }
  3530. }]);
  3531. return FormalParameter;
  3532. }();
  3533. /***/ }),
  3534. /***/ "./js/ast/commands/function.js":
  3535. /*!*************************************!*\
  3536. !*** ./js/ast/commands/function.js ***!
  3537. \*************************************/
  3538. /*! no static exports found */
  3539. /***/ (function(module, exports, __webpack_require__) {
  3540. "use strict";
  3541. Object.defineProperty(exports, "__esModule", {
  3542. value: true
  3543. });
  3544. exports.Function = undefined;
  3545. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3546. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  3547. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3548. var Function = exports.Function = function () {
  3549. function Function(name, returnType, formalParameters, commandBlock) {
  3550. _classCallCheck(this, Function);
  3551. this.name = name;
  3552. this.returnType = returnType;
  3553. this.formalParameters = formalParameters;
  3554. this.commandBlock = commandBlock;
  3555. this._sourceInfo = null;
  3556. }
  3557. _createClass(Function, [{
  3558. key: 'isMain',
  3559. get: function get() {
  3560. return this.name === null && this.returnType.isCompatible(_types.Types.VOID);
  3561. }
  3562. }, {
  3563. key: 'commands',
  3564. get: function get() {
  3565. return this.commandBlock.commands;
  3566. }
  3567. }, {
  3568. key: 'variablesDeclarations',
  3569. get: function get() {
  3570. return this.commandBlock.variables;
  3571. }
  3572. }, {
  3573. key: 'sourceInfo',
  3574. set: function set(sourceInfo) {
  3575. this._sourceInfo = sourceInfo;
  3576. },
  3577. get: function get() {
  3578. return this._sourceInfo;
  3579. }
  3580. }]);
  3581. return Function;
  3582. }();
  3583. /***/ }),
  3584. /***/ "./js/ast/commands/ifThenElse.js":
  3585. /*!***************************************!*\
  3586. !*** ./js/ast/commands/ifThenElse.js ***!
  3587. \***************************************/
  3588. /*! no static exports found */
  3589. /***/ (function(module, exports, __webpack_require__) {
  3590. "use strict";
  3591. Object.defineProperty(exports, "__esModule", {
  3592. value: true
  3593. });
  3594. exports.IfThenElse = undefined;
  3595. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3596. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3597. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3598. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3599. var IfThenElse = exports.IfThenElse = function (_Command) {
  3600. _inherits(IfThenElse, _Command);
  3601. function IfThenElse(condition, ifTrue, ifFalse) {
  3602. _classCallCheck(this, IfThenElse);
  3603. var _this = _possibleConstructorReturn(this, (IfThenElse.__proto__ || Object.getPrototypeOf(IfThenElse)).call(this));
  3604. _this.condition = condition;
  3605. _this.ifTrue = ifTrue;
  3606. _this.ifFalse = ifFalse;
  3607. return _this;
  3608. }
  3609. return IfThenElse;
  3610. }(_command.Command);
  3611. /***/ }),
  3612. /***/ "./js/ast/commands/index.js":
  3613. /*!**********************************!*\
  3614. !*** ./js/ast/commands/index.js ***!
  3615. \**********************************/
  3616. /*! no static exports found */
  3617. /***/ (function(module, exports, __webpack_require__) {
  3618. "use strict";
  3619. Object.defineProperty(exports, "__esModule", {
  3620. value: true
  3621. });
  3622. exports.FunctionCall = exports.FormalParameter = exports.SysCall = exports.Case = exports.Switch = exports.DoWhile = exports.CommandBlock = exports.IfThenElse = exports.Function = exports.For = exports.While = exports.ArrayDeclaration = exports.Declaration = exports.ArrayIndexAssign = exports.Assign = exports.Return = exports.Break = undefined;
  3623. var _break = __webpack_require__(/*! ./break */ "./js/ast/commands/break.js");
  3624. var _return = __webpack_require__(/*! ./return */ "./js/ast/commands/return.js");
  3625. var _assign = __webpack_require__(/*! ./assign */ "./js/ast/commands/assign.js");
  3626. var _arrayAssign = __webpack_require__(/*! ./arrayAssign */ "./js/ast/commands/arrayAssign.js");
  3627. var _declaration = __webpack_require__(/*! ./declaration */ "./js/ast/commands/declaration.js");
  3628. var _arrayDeclaration = __webpack_require__(/*! ./arrayDeclaration */ "./js/ast/commands/arrayDeclaration.js");
  3629. var _while = __webpack_require__(/*! ./while */ "./js/ast/commands/while.js");
  3630. var _for = __webpack_require__(/*! ./for */ "./js/ast/commands/for.js");
  3631. var _function = __webpack_require__(/*! ./function */ "./js/ast/commands/function.js");
  3632. var _ifThenElse = __webpack_require__(/*! ./ifThenElse */ "./js/ast/commands/ifThenElse.js");
  3633. var _commandBlock = __webpack_require__(/*! ./commandBlock */ "./js/ast/commands/commandBlock.js");
  3634. var _doWhile = __webpack_require__(/*! ./doWhile */ "./js/ast/commands/doWhile.js");
  3635. var _switch = __webpack_require__(/*! ./switch */ "./js/ast/commands/switch.js");
  3636. var _case = __webpack_require__(/*! ./case */ "./js/ast/commands/case.js");
  3637. var _sysCall = __webpack_require__(/*! ./sysCall */ "./js/ast/commands/sysCall.js");
  3638. var _formalParameter = __webpack_require__(/*! ./formalParameter */ "./js/ast/commands/formalParameter.js");
  3639. var _functionCall = __webpack_require__(/*! ./../expressions/functionCall */ "./js/ast/expressions/functionCall.js");
  3640. //Proxy to expression since they do exatcly the same thing
  3641. exports.Break = _break.Break;
  3642. exports.Return = _return.Return;
  3643. exports.Assign = _assign.Assign;
  3644. exports.ArrayIndexAssign = _arrayAssign.ArrayIndexAssign;
  3645. exports.Declaration = _declaration.Declaration;
  3646. exports.ArrayDeclaration = _arrayDeclaration.ArrayDeclaration;
  3647. exports.While = _while.While;
  3648. exports.For = _for.For;
  3649. exports.Function = _function.Function;
  3650. exports.IfThenElse = _ifThenElse.IfThenElse;
  3651. exports.CommandBlock = _commandBlock.CommandBlock;
  3652. exports.DoWhile = _doWhile.DoWhile;
  3653. exports.Switch = _switch.Switch;
  3654. exports.Case = _case.Case;
  3655. exports.SysCall = _sysCall.SysCall;
  3656. exports.FormalParameter = _formalParameter.FormalParameter;
  3657. exports.FunctionCall = _functionCall.FunctionCall;
  3658. /***/ }),
  3659. /***/ "./js/ast/commands/return.js":
  3660. /*!***********************************!*\
  3661. !*** ./js/ast/commands/return.js ***!
  3662. \***********************************/
  3663. /*! no static exports found */
  3664. /***/ (function(module, exports, __webpack_require__) {
  3665. "use strict";
  3666. Object.defineProperty(exports, "__esModule", {
  3667. value: true
  3668. });
  3669. exports.Return = undefined;
  3670. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3671. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3672. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3673. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3674. var Return = exports.Return = function (_Command) {
  3675. _inherits(Return, _Command);
  3676. function Return(expression) {
  3677. _classCallCheck(this, Return);
  3678. var _this = _possibleConstructorReturn(this, (Return.__proto__ || Object.getPrototypeOf(Return)).call(this));
  3679. _this.expression = expression;
  3680. return _this;
  3681. }
  3682. return Return;
  3683. }(_command.Command);
  3684. /***/ }),
  3685. /***/ "./js/ast/commands/switch.js":
  3686. /*!***********************************!*\
  3687. !*** ./js/ast/commands/switch.js ***!
  3688. \***********************************/
  3689. /*! no static exports found */
  3690. /***/ (function(module, exports, __webpack_require__) {
  3691. "use strict";
  3692. Object.defineProperty(exports, "__esModule", {
  3693. value: true
  3694. });
  3695. exports.Switch = undefined;
  3696. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3697. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3698. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3699. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3700. var Switch = exports.Switch = function (_Command) {
  3701. _inherits(Switch, _Command);
  3702. function Switch(expression, cases) {
  3703. _classCallCheck(this, Switch);
  3704. var _this = _possibleConstructorReturn(this, (Switch.__proto__ || Object.getPrototypeOf(Switch)).call(this));
  3705. _this.expression = expression;
  3706. _this.cases = cases;
  3707. return _this;
  3708. }
  3709. return Switch;
  3710. }(_command.Command);
  3711. /***/ }),
  3712. /***/ "./js/ast/commands/sysCall.js":
  3713. /*!************************************!*\
  3714. !*** ./js/ast/commands/sysCall.js ***!
  3715. \************************************/
  3716. /*! no static exports found */
  3717. /***/ (function(module, exports, __webpack_require__) {
  3718. "use strict";
  3719. Object.defineProperty(exports, "__esModule", {
  3720. value: true
  3721. });
  3722. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3723. /**
  3724. * This class represents all the language defined functions.
  3725. * The language processor uses the id provided here to properly execute the desired function.
  3726. * The function is actually implemented inside the language processor.
  3727. * All the functions can be found at: js/processor/definedFunctions.js
  3728. */
  3729. var SysCall = exports.SysCall = function SysCall(langFunc) {
  3730. _classCallCheck(this, SysCall);
  3731. this.langFunc = langFunc;
  3732. };
  3733. /***/ }),
  3734. /***/ "./js/ast/commands/while.js":
  3735. /*!**********************************!*\
  3736. !*** ./js/ast/commands/while.js ***!
  3737. \**********************************/
  3738. /*! no static exports found */
  3739. /***/ (function(module, exports, __webpack_require__) {
  3740. "use strict";
  3741. Object.defineProperty(exports, "__esModule", {
  3742. value: true
  3743. });
  3744. exports.While = undefined;
  3745. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3746. var _command = __webpack_require__(/*! ./command */ "./js/ast/commands/command.js");
  3747. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3748. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3749. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3750. var While = exports.While = function (_Command) {
  3751. _inherits(While, _Command);
  3752. function While(expression, commandBlock) {
  3753. _classCallCheck(this, While);
  3754. var _this = _possibleConstructorReturn(this, (While.__proto__ || Object.getPrototypeOf(While)).call(this));
  3755. _this.expression = expression;
  3756. _this.commandBlock = commandBlock;
  3757. return _this;
  3758. }
  3759. _createClass(While, [{
  3760. key: 'commands',
  3761. get: function get() {
  3762. return this.commandBlock.commands;
  3763. }
  3764. }, {
  3765. key: 'testFirst',
  3766. get: function get() {
  3767. return true;
  3768. }
  3769. }]);
  3770. return While;
  3771. }(_command.Command);
  3772. /***/ }),
  3773. /***/ "./js/ast/error/syntaxError.js":
  3774. /*!*************************************!*\
  3775. !*** ./js/ast/error/syntaxError.js ***!
  3776. \*************************************/
  3777. /*! no static exports found */
  3778. /***/ (function(module, exports, __webpack_require__) {
  3779. "use strict";
  3780. Object.defineProperty(exports, "__esModule", {
  3781. value: true
  3782. });
  3783. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3784. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3785. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3786. var SyntaxError = exports.SyntaxError = function (_Error) {
  3787. _inherits(SyntaxError, _Error);
  3788. function SyntaxError() {
  3789. var _ref;
  3790. _classCallCheck(this, SyntaxError);
  3791. for (var _len = arguments.length, msg = Array(_len), _key = 0; _key < _len; _key++) {
  3792. msg[_key] = arguments[_key];
  3793. }
  3794. var _this = _possibleConstructorReturn(this, (_ref = SyntaxError.__proto__ || Object.getPrototypeOf(SyntaxError)).call.apply(_ref, [this].concat(msg)));
  3795. if (Error.captureStackTrace) Error.captureStackTrace(_this, SyntaxError);
  3796. return _this;
  3797. }
  3798. return SyntaxError;
  3799. }(Error);
  3800. /***/ }),
  3801. /***/ "./js/ast/error/syntaxErrorFactory.js":
  3802. /*!********************************************!*\
  3803. !*** ./js/ast/error/syntaxErrorFactory.js ***!
  3804. \********************************************/
  3805. /*! no static exports found */
  3806. /***/ (function(module, exports, __webpack_require__) {
  3807. "use strict";
  3808. Object.defineProperty(exports, "__esModule", {
  3809. value: true
  3810. });
  3811. exports.SyntaxErrorFactory = undefined;
  3812. var _localizedStringsService = __webpack_require__(/*! ./../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  3813. var _syntaxError = __webpack_require__(/*! ./syntaxError */ "./js/ast/error/syntaxError.js");
  3814. var SyntaxErrorFactory = exports.SyntaxErrorFactory = Object.freeze({
  3815. extra_lines: function extra_lines() {
  3816. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("extra_lines"));
  3817. },
  3818. token_missing_one: function token_missing_one(expected, token) {
  3819. var context = [expected, token.text, token.line, token.column];
  3820. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("token_missing_one", context));
  3821. },
  3822. token_missing_list: function token_missing_list(expectedList, token) {
  3823. var line = expectedList.join(_localizedStringsService.LocalizedStrings.getOR());
  3824. return SyntaxErrorFactory.token_missing_one(line, token);
  3825. },
  3826. id_missing: function id_missing(token) {
  3827. var context = [token.text, token.line, token.column];
  3828. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("id_missing", context));
  3829. },
  3830. eos_missing: function eos_missing(token) {
  3831. var context = [token.line, token.column];
  3832. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("eos_missing", context));
  3833. },
  3834. invalid_array_dimension: function invalid_array_dimension(typeName, token) {
  3835. var context = [token.line, token.column, typeName];
  3836. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("invalid_array_dimension", context));
  3837. },
  3838. invalid_array_size: function invalid_array_size(token) {
  3839. var context = [token.line];
  3840. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("invalid_array_size", context));
  3841. },
  3842. invalid_main_return: function invalid_main_return(name, typeName, token) {
  3843. var context = [name, typeName, token.line];
  3844. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("invalid_main_return", context));
  3845. },
  3846. invalid_var_declaration: function invalid_var_declaration(token) {
  3847. var context = [token.line];
  3848. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("invalid_var_declaration", context));
  3849. },
  3850. invalid_break_command: function invalid_break_command(cmdName, token) {
  3851. var context = [token.line, cmdName];
  3852. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("invalid_break_command", context));
  3853. },
  3854. invalid_terminal: function invalid_terminal(token) {
  3855. var context = [token.text, token.line, token.column];
  3856. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError('invalid_terminal', context));
  3857. },
  3858. invalid_type: function invalid_type(list, token) {
  3859. var line = list.join(_localizedStringsService.LocalizedStrings.getOR());
  3860. var context = [token.text, token.line, token.column, line];
  3861. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("invalid_type", context));
  3862. },
  3863. const_not_init: function const_not_init(token) {
  3864. var context = [token.line, token.column];
  3865. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("const_not_init", context));
  3866. },
  3867. invalid_id_format: function invalid_id_format(token) {
  3868. var context = [token.text, token.line, token.column];
  3869. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("invalid_id_format", context));
  3870. },
  3871. duplicate_function: function duplicate_function(token) {
  3872. var context = [token.text, token.line, token.column];
  3873. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("duplicate_function", context));
  3874. },
  3875. main_parameters: function main_parameters() {
  3876. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("main_parameters"));
  3877. },
  3878. duplicate_variable: function duplicate_variable(token) {
  3879. var context = [token.text, token.line, token.column];
  3880. return new _syntaxError.SyntaxError(_localizedStringsService.LocalizedStrings.getError("duplicate_variable", context));
  3881. }
  3882. });
  3883. /***/ }),
  3884. /***/ "./js/ast/expressions/arrayAccess.js":
  3885. /*!*******************************************!*\
  3886. !*** ./js/ast/expressions/arrayAccess.js ***!
  3887. \*******************************************/
  3888. /*! no static exports found */
  3889. /***/ (function(module, exports, __webpack_require__) {
  3890. "use strict";
  3891. Object.defineProperty(exports, "__esModule", {
  3892. value: true
  3893. });
  3894. exports.ArrayAccess = undefined;
  3895. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3896. var _expression = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
  3897. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3898. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3899. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3900. var ArrayAccess = exports.ArrayAccess = function (_Expression) {
  3901. _inherits(ArrayAccess, _Expression);
  3902. function ArrayAccess(id, line, column) {
  3903. _classCallCheck(this, ArrayAccess);
  3904. var _this = _possibleConstructorReturn(this, (ArrayAccess.__proto__ || Object.getPrototypeOf(ArrayAccess)).call(this));
  3905. _this.id = id;
  3906. _this.line = line;
  3907. _this.column = column;
  3908. return _this;
  3909. }
  3910. _createClass(ArrayAccess, [{
  3911. key: 'toString',
  3912. value: function toString() {
  3913. var strLine = this.line.toString();
  3914. var strColumn = null;
  3915. if (this.column) {
  3916. strColumn = this.column.toString();
  3917. }
  3918. if (strColumn) {
  3919. return this.id + '[' + strLine + '][' + strColumn + ']';
  3920. } else {
  3921. return this.id + '[' + strLine + ']';
  3922. }
  3923. }
  3924. }]);
  3925. return ArrayAccess;
  3926. }(_expression.Expression);
  3927. /***/ }),
  3928. /***/ "./js/ast/expressions/arrayLiteral.js":
  3929. /*!********************************************!*\
  3930. !*** ./js/ast/expressions/arrayLiteral.js ***!
  3931. \********************************************/
  3932. /*! no static exports found */
  3933. /***/ (function(module, exports, __webpack_require__) {
  3934. "use strict";
  3935. Object.defineProperty(exports, "__esModule", {
  3936. value: true
  3937. });
  3938. exports.ArrayLiteral = undefined;
  3939. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3940. var _literal = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
  3941. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3942. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3943. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  3944. var ArrayLiteral = exports.ArrayLiteral = function (_Literal) {
  3945. _inherits(ArrayLiteral, _Literal);
  3946. function ArrayLiteral(type, value) {
  3947. _classCallCheck(this, ArrayLiteral);
  3948. var _this = _possibleConstructorReturn(this, (ArrayLiteral.__proto__ || Object.getPrototypeOf(ArrayLiteral)).call(this, type));
  3949. _this.value = value;
  3950. return _this;
  3951. }
  3952. _createClass(ArrayLiteral, [{
  3953. key: 'validateType',
  3954. value: function validateType() {
  3955. // let valid = true;
  3956. // if(this.columns !== null) {
  3957. // const len = this.columns;
  3958. // const len2 = this.lines;
  3959. // for (let i = len - 1; i >= 0; i--) {
  3960. // for (let j = len2 - 1; j >= 0; j--) {
  3961. // if(this.value[i].value[j].type !== this.subtype) {
  3962. // valid = false;
  3963. // break;
  3964. // }
  3965. // }
  3966. // }
  3967. // } else {
  3968. // const len = this.lines;
  3969. // for (var i = len - 1; i >= 0; i--) {
  3970. // if(this.value[i].type !== this.subtype) {
  3971. // valid = false;
  3972. // break;
  3973. // }
  3974. // }
  3975. // }
  3976. return true; //valid;
  3977. }
  3978. }, {
  3979. key: 'validateSize',
  3980. value: function validateSize() {
  3981. var valid = true;
  3982. if (this.columns !== null) {
  3983. var equalityTest = data.value.map(function (v) {
  3984. return v.length;
  3985. }).reduce(function (old, next) {
  3986. if (old === null) {
  3987. return next;
  3988. } else if (old === next) {
  3989. return old;
  3990. } else {
  3991. return -1;
  3992. }
  3993. }, null);
  3994. valid = equalityTest !== -1;
  3995. }
  3996. return valid;
  3997. }
  3998. }, {
  3999. key: 'toString',
  4000. value: function toString() {
  4001. var strList = this.value.map(function (arrayLiteral) {
  4002. return arrayLiteral.toString();
  4003. });
  4004. return "{" + strList.join(',') + "}";
  4005. }
  4006. }, {
  4007. key: 'subtype',
  4008. get: function get() {
  4009. var element = this.value[0];
  4010. if (element instanceof ArrayLiteral) {
  4011. return element.value[0].type;
  4012. } else {
  4013. return element.type;
  4014. }
  4015. }
  4016. }, {
  4017. key: 'lines',
  4018. get: function get() {
  4019. return this.value.length;
  4020. }
  4021. }, {
  4022. key: 'columns',
  4023. get: function get() {
  4024. var element = this.value[0];
  4025. if (!(element instanceof ArrayLiteral)) {
  4026. return null;
  4027. } else {
  4028. return element.value[0].length;
  4029. }
  4030. }
  4031. }, {
  4032. key: 'isVector',
  4033. get: function get() {
  4034. return this.columns === null;
  4035. }
  4036. }, {
  4037. key: 'isValid',
  4038. get: function get() {
  4039. return true; //this.validateType() && this.validateSize();
  4040. }
  4041. }]);
  4042. return ArrayLiteral;
  4043. }(_literal.Literal);
  4044. /***/ }),
  4045. /***/ "./js/ast/expressions/boolLiteral.js":
  4046. /*!*******************************************!*\
  4047. !*** ./js/ast/expressions/boolLiteral.js ***!
  4048. \*******************************************/
  4049. /*! no static exports found */
  4050. /***/ (function(module, exports, __webpack_require__) {
  4051. "use strict";
  4052. Object.defineProperty(exports, "__esModule", {
  4053. value: true
  4054. });
  4055. exports.BoolLiteral = undefined;
  4056. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4057. var _literal = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
  4058. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  4059. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  4060. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4061. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4062. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4063. var BoolLiteral = exports.BoolLiteral = function (_Literal) {
  4064. _inherits(BoolLiteral, _Literal);
  4065. function BoolLiteral(value) {
  4066. _classCallCheck(this, BoolLiteral);
  4067. var _this = _possibleConstructorReturn(this, (BoolLiteral.__proto__ || Object.getPrototypeOf(BoolLiteral)).call(this, _types.Types.BOOLEAN));
  4068. _this.value = value;
  4069. return _this;
  4070. }
  4071. _createClass(BoolLiteral, [{
  4072. key: 'toString',
  4073. value: function toString() {
  4074. return (0, _parsers.convertBoolToString)(this.value);
  4075. }
  4076. }]);
  4077. return BoolLiteral;
  4078. }(_literal.Literal);
  4079. /***/ }),
  4080. /***/ "./js/ast/expressions/expression.js":
  4081. /*!******************************************!*\
  4082. !*** ./js/ast/expressions/expression.js ***!
  4083. \******************************************/
  4084. /*! no static exports found */
  4085. /***/ (function(module, exports, __webpack_require__) {
  4086. "use strict";
  4087. Object.defineProperty(exports, "__esModule", {
  4088. value: true
  4089. });
  4090. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4091. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4092. var Expression = exports.Expression = function () {
  4093. function Expression() {
  4094. _classCallCheck(this, Expression);
  4095. this._sourceInfo = null;
  4096. }
  4097. _createClass(Expression, [{
  4098. key: "sourceInfo",
  4099. set: function set(sourceInfo) {
  4100. this._sourceInfo = sourceInfo;
  4101. },
  4102. get: function get() {
  4103. return this._sourceInfo;
  4104. }
  4105. }]);
  4106. return Expression;
  4107. }();
  4108. /***/ }),
  4109. /***/ "./js/ast/expressions/functionCall.js":
  4110. /*!********************************************!*\
  4111. !*** ./js/ast/expressions/functionCall.js ***!
  4112. \********************************************/
  4113. /*! no static exports found */
  4114. /***/ (function(module, exports, __webpack_require__) {
  4115. "use strict";
  4116. Object.defineProperty(exports, "__esModule", {
  4117. value: true
  4118. });
  4119. exports.FunctionCall = undefined;
  4120. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4121. var _expression = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
  4122. var _definedFunctions = __webpack_require__(/*! ../../processor/definedFunctions */ "./js/processor/definedFunctions.js");
  4123. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4124. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4125. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4126. var FunctionCall = exports.FunctionCall = function (_Expression) {
  4127. _inherits(FunctionCall, _Expression);
  4128. function FunctionCall(id, actualParameters) {
  4129. _classCallCheck(this, FunctionCall);
  4130. var _this = _possibleConstructorReturn(this, (FunctionCall.__proto__ || Object.getPrototypeOf(FunctionCall)).call(this));
  4131. _this.id = id;
  4132. _this.actualParameters = actualParameters;
  4133. return _this;
  4134. }
  4135. _createClass(FunctionCall, [{
  4136. key: 'toString',
  4137. value: function toString() {
  4138. var name = null;
  4139. if (this.isMainCall) {
  4140. name = _definedFunctions.LanguageDefinedFunction.getMainFunctionName();
  4141. } else {
  4142. name = _definedFunctions.LanguageDefinedFunction.getLocalName(this.id);
  4143. }
  4144. var params = null;
  4145. if (this.actualParameters.length == 0) {
  4146. params = "()";
  4147. } else {
  4148. var strParams = this.actualParameters.map(function (v) {
  4149. return v.toString();
  4150. });
  4151. params = "(" + strParams.join(",") + ")";
  4152. }
  4153. return name + params;
  4154. }
  4155. }, {
  4156. key: 'isMainCall',
  4157. get: function get() {
  4158. return this.id === null;
  4159. }
  4160. }, {
  4161. key: 'parametersSize',
  4162. get: function get() {
  4163. return this.actualParameters.length;
  4164. }
  4165. }]);
  4166. return FunctionCall;
  4167. }(_expression.Expression);
  4168. /***/ }),
  4169. /***/ "./js/ast/expressions/index.js":
  4170. /*!*************************************!*\
  4171. !*** ./js/ast/expressions/index.js ***!
  4172. \*************************************/
  4173. /*! no static exports found */
  4174. /***/ (function(module, exports, __webpack_require__) {
  4175. "use strict";
  4176. Object.defineProperty(exports, "__esModule", {
  4177. value: true
  4178. });
  4179. exports.UnaryApp = exports.InfixApp = exports.VariableLiteral = exports.ArrayLiteral = exports.StringLiteral = exports.BoolLiteral = exports.RealLiteral = exports.IntLiteral = exports.FunctionCall = exports.ArrayAccess = undefined;
  4180. var _arrayAccess = __webpack_require__(/*! ./arrayAccess */ "./js/ast/expressions/arrayAccess.js");
  4181. var _functionCall = __webpack_require__(/*! ./functionCall */ "./js/ast/expressions/functionCall.js");
  4182. var _intLiteral = __webpack_require__(/*! ./intLiteral */ "./js/ast/expressions/intLiteral.js");
  4183. var _realLiteral = __webpack_require__(/*! ./realLiteral */ "./js/ast/expressions/realLiteral.js");
  4184. var _boolLiteral = __webpack_require__(/*! ./boolLiteral */ "./js/ast/expressions/boolLiteral.js");
  4185. var _stringLiteral = __webpack_require__(/*! ./stringLiteral */ "./js/ast/expressions/stringLiteral.js");
  4186. var _arrayLiteral = __webpack_require__(/*! ./arrayLiteral */ "./js/ast/expressions/arrayLiteral.js");
  4187. var _variableLiteral = __webpack_require__(/*! ./variableLiteral */ "./js/ast/expressions/variableLiteral.js");
  4188. var _infixApp = __webpack_require__(/*! ./infixApp */ "./js/ast/expressions/infixApp.js");
  4189. var _unaryApp = __webpack_require__(/*! ./unaryApp */ "./js/ast/expressions/unaryApp.js");
  4190. exports.ArrayAccess = _arrayAccess.ArrayAccess;
  4191. exports.FunctionCall = _functionCall.FunctionCall;
  4192. exports.IntLiteral = _intLiteral.IntLiteral;
  4193. exports.RealLiteral = _realLiteral.RealLiteral;
  4194. exports.BoolLiteral = _boolLiteral.BoolLiteral;
  4195. exports.StringLiteral = _stringLiteral.StringLiteral;
  4196. exports.ArrayLiteral = _arrayLiteral.ArrayLiteral;
  4197. exports.VariableLiteral = _variableLiteral.VariableLiteral;
  4198. exports.InfixApp = _infixApp.InfixApp;
  4199. exports.UnaryApp = _unaryApp.UnaryApp;
  4200. /***/ }),
  4201. /***/ "./js/ast/expressions/infixApp.js":
  4202. /*!****************************************!*\
  4203. !*** ./js/ast/expressions/infixApp.js ***!
  4204. \****************************************/
  4205. /*! no static exports found */
  4206. /***/ (function(module, exports, __webpack_require__) {
  4207. "use strict";
  4208. Object.defineProperty(exports, "__esModule", {
  4209. value: true
  4210. });
  4211. exports.InfixApp = undefined;
  4212. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4213. var _expression = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
  4214. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4215. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4216. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4217. var InfixApp = exports.InfixApp = function (_Expression) {
  4218. _inherits(InfixApp, _Expression);
  4219. function InfixApp(op, left, right) {
  4220. _classCallCheck(this, InfixApp);
  4221. var _this = _possibleConstructorReturn(this, (InfixApp.__proto__ || Object.getPrototypeOf(InfixApp)).call(this));
  4222. _this.op = op;
  4223. _this.left = left;
  4224. _this.right = right;
  4225. return _this;
  4226. }
  4227. _createClass(InfixApp, [{
  4228. key: 'toString',
  4229. value: function toString() {
  4230. var l = this.left.toString();
  4231. var op = this.op.value;
  4232. var r = this.right.toString();
  4233. return l + op + r;
  4234. }
  4235. }]);
  4236. return InfixApp;
  4237. }(_expression.Expression);
  4238. /***/ }),
  4239. /***/ "./js/ast/expressions/intLiteral.js":
  4240. /*!******************************************!*\
  4241. !*** ./js/ast/expressions/intLiteral.js ***!
  4242. \******************************************/
  4243. /*! no static exports found */
  4244. /***/ (function(module, exports, __webpack_require__) {
  4245. "use strict";
  4246. Object.defineProperty(exports, "__esModule", {
  4247. value: true
  4248. });
  4249. exports.IntLiteral = undefined;
  4250. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4251. var _literal = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
  4252. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  4253. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  4254. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4255. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4256. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4257. var IntLiteral = exports.IntLiteral = function (_Literal) {
  4258. _inherits(IntLiteral, _Literal);
  4259. function IntLiteral(value) {
  4260. _classCallCheck(this, IntLiteral);
  4261. var _this = _possibleConstructorReturn(this, (IntLiteral.__proto__ || Object.getPrototypeOf(IntLiteral)).call(this, _types.Types.INTEGER));
  4262. _this.value = value;
  4263. return _this;
  4264. }
  4265. _createClass(IntLiteral, [{
  4266. key: 'toString',
  4267. value: function toString() {
  4268. return (0, _parsers.convertToString)(this.value, this.type);
  4269. }
  4270. }]);
  4271. return IntLiteral;
  4272. }(_literal.Literal);
  4273. /***/ }),
  4274. /***/ "./js/ast/expressions/literal.js":
  4275. /*!***************************************!*\
  4276. !*** ./js/ast/expressions/literal.js ***!
  4277. \***************************************/
  4278. /*! no static exports found */
  4279. /***/ (function(module, exports, __webpack_require__) {
  4280. "use strict";
  4281. Object.defineProperty(exports, "__esModule", {
  4282. value: true
  4283. });
  4284. exports.Literal = undefined;
  4285. var _expression = __webpack_require__(/*! ./expression */ "./js/ast/expressions/expression.js");
  4286. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4287. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4288. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4289. var Literal = exports.Literal = function (_Expression) {
  4290. _inherits(Literal, _Expression);
  4291. function Literal(type) {
  4292. _classCallCheck(this, Literal);
  4293. var _this = _possibleConstructorReturn(this, (Literal.__proto__ || Object.getPrototypeOf(Literal)).call(this));
  4294. _this.type = type;
  4295. return _this;
  4296. }
  4297. return Literal;
  4298. }(_expression.Expression);
  4299. /***/ }),
  4300. /***/ "./js/ast/expressions/realLiteral.js":
  4301. /*!*******************************************!*\
  4302. !*** ./js/ast/expressions/realLiteral.js ***!
  4303. \*******************************************/
  4304. /*! no static exports found */
  4305. /***/ (function(module, exports, __webpack_require__) {
  4306. "use strict";
  4307. Object.defineProperty(exports, "__esModule", {
  4308. value: true
  4309. });
  4310. exports.RealLiteral = undefined;
  4311. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4312. var _literal = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
  4313. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  4314. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  4315. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4316. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4317. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4318. var RealLiteral = exports.RealLiteral = function (_Literal) {
  4319. _inherits(RealLiteral, _Literal);
  4320. function RealLiteral(value) {
  4321. _classCallCheck(this, RealLiteral);
  4322. var _this = _possibleConstructorReturn(this, (RealLiteral.__proto__ || Object.getPrototypeOf(RealLiteral)).call(this, _types.Types.REAL));
  4323. _this.value = value;
  4324. return _this;
  4325. }
  4326. _createClass(RealLiteral, [{
  4327. key: 'toString',
  4328. value: function toString() {
  4329. return (0, _parsers.convertToString)(this.value, this.type);
  4330. }
  4331. }]);
  4332. return RealLiteral;
  4333. }(_literal.Literal);
  4334. /***/ }),
  4335. /***/ "./js/ast/expressions/stringLiteral.js":
  4336. /*!*********************************************!*\
  4337. !*** ./js/ast/expressions/stringLiteral.js ***!
  4338. \*********************************************/
  4339. /*! no static exports found */
  4340. /***/ (function(module, exports, __webpack_require__) {
  4341. "use strict";
  4342. Object.defineProperty(exports, "__esModule", {
  4343. value: true
  4344. });
  4345. exports.StringLiteral = undefined;
  4346. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4347. var _literal = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
  4348. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  4349. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4350. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4351. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4352. var StringLiteral = exports.StringLiteral = function (_Literal) {
  4353. _inherits(StringLiteral, _Literal);
  4354. function StringLiteral(value) {
  4355. _classCallCheck(this, StringLiteral);
  4356. var _this = _possibleConstructorReturn(this, (StringLiteral.__proto__ || Object.getPrototypeOf(StringLiteral)).call(this, _types.Types.STRING));
  4357. _this.value = value;
  4358. return _this;
  4359. }
  4360. _createClass(StringLiteral, [{
  4361. key: 'toString',
  4362. value: function toString() {
  4363. return this.value;
  4364. }
  4365. }]);
  4366. return StringLiteral;
  4367. }(_literal.Literal);
  4368. /***/ }),
  4369. /***/ "./js/ast/expressions/unaryApp.js":
  4370. /*!****************************************!*\
  4371. !*** ./js/ast/expressions/unaryApp.js ***!
  4372. \****************************************/
  4373. /*! no static exports found */
  4374. /***/ (function(module, exports, __webpack_require__) {
  4375. "use strict";
  4376. Object.defineProperty(exports, "__esModule", {
  4377. value: true
  4378. });
  4379. exports.UnaryApp = undefined;
  4380. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4381. var _infixApp = __webpack_require__(/*! ./infixApp */ "./js/ast/expressions/infixApp.js");
  4382. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4383. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4384. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4385. var UnaryApp = exports.UnaryApp = function (_InfixApp) {
  4386. _inherits(UnaryApp, _InfixApp);
  4387. function UnaryApp(op, left) {
  4388. _classCallCheck(this, UnaryApp);
  4389. return _possibleConstructorReturn(this, (UnaryApp.__proto__ || Object.getPrototypeOf(UnaryApp)).call(this, op, left, null));
  4390. }
  4391. _createClass(UnaryApp, [{
  4392. key: 'toString',
  4393. value: function toString() {
  4394. var l = this.left.toString();
  4395. var op = this.op.value;
  4396. return op + l;
  4397. }
  4398. }]);
  4399. return UnaryApp;
  4400. }(_infixApp.InfixApp);
  4401. /***/ }),
  4402. /***/ "./js/ast/expressions/variableLiteral.js":
  4403. /*!***********************************************!*\
  4404. !*** ./js/ast/expressions/variableLiteral.js ***!
  4405. \***********************************************/
  4406. /*! no static exports found */
  4407. /***/ (function(module, exports, __webpack_require__) {
  4408. "use strict";
  4409. Object.defineProperty(exports, "__esModule", {
  4410. value: true
  4411. });
  4412. exports.VariableLiteral = undefined;
  4413. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4414. var _literal = __webpack_require__(/*! ./literal */ "./js/ast/expressions/literal.js");
  4415. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  4416. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4417. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4418. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4419. var VariableLiteral = exports.VariableLiteral = function (_Literal) {
  4420. _inherits(VariableLiteral, _Literal);
  4421. function VariableLiteral(id) {
  4422. _classCallCheck(this, VariableLiteral);
  4423. var _this = _possibleConstructorReturn(this, (VariableLiteral.__proto__ || Object.getPrototypeOf(VariableLiteral)).call(this, _types.Types.UNDEFINED));
  4424. _this.id = id;
  4425. return _this;
  4426. }
  4427. _createClass(VariableLiteral, [{
  4428. key: 'toString',
  4429. value: function toString() {
  4430. return this.id;
  4431. }
  4432. }]);
  4433. return VariableLiteral;
  4434. }(_literal.Literal);
  4435. /***/ }),
  4436. /***/ "./js/ast/ivprogParser.js":
  4437. /*!********************************!*\
  4438. !*** ./js/ast/ivprogParser.js ***!
  4439. \********************************/
  4440. /*! no static exports found */
  4441. /***/ (function(module, exports, __webpack_require__) {
  4442. "use strict";
  4443. Object.defineProperty(exports, "__esModule", {
  4444. value: true
  4445. });
  4446. exports.IVProgParser = undefined;
  4447. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4448. var _index = __webpack_require__(/*! antlr4/index */ "./node_modules/antlr4/index.js");
  4449. var _expressions = __webpack_require__(/*! ./expressions/ */ "./js/ast/expressions/index.js");
  4450. var Expressions = _interopRequireWildcard(_expressions);
  4451. var _commands = __webpack_require__(/*! ./commands/ */ "./js/ast/commands/index.js");
  4452. var Commands = _interopRequireWildcard(_commands);
  4453. var _parsers = __webpack_require__(/*! ./../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  4454. var _types = __webpack_require__(/*! ./../typeSystem/types */ "./js/typeSystem/types.js");
  4455. var _compoundType = __webpack_require__(/*! ./../typeSystem/compoundType */ "./js/typeSystem/compoundType.js");
  4456. var _sourceInfo2 = __webpack_require__(/*! ./sourceInfo */ "./js/ast/sourceInfo.js");
  4457. var _operators = __webpack_require__(/*! ./operators */ "./js/ast/operators.js");
  4458. var _syntaxErrorFactory = __webpack_require__(/*! ./error/syntaxErrorFactory */ "./js/ast/error/syntaxErrorFactory.js");
  4459. var _definedFunctions = __webpack_require__(/*! ./../processor/definedFunctions */ "./js/processor/definedFunctions.js");
  4460. var _languageService = __webpack_require__(/*! ../services/languageService */ "./js/services/languageService.js");
  4461. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  4462. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4463. var IVProgParser = exports.IVProgParser = function () {
  4464. _createClass(IVProgParser, null, [{
  4465. key: 'createParser',
  4466. value: function createParser(input) {
  4467. var lexerClass = _languageService.LanguageService.getCurrentLexer();
  4468. return new IVProgParser(input, lexerClass);
  4469. }
  4470. // <BEGIN scope consts>
  4471. }, {
  4472. key: 'BASE',
  4473. get: function get() {
  4474. return 0;
  4475. }
  4476. }, {
  4477. key: 'FUNCTION',
  4478. get: function get() {
  4479. return 1;
  4480. }
  4481. }, {
  4482. key: 'COMMAND',
  4483. get: function get() {
  4484. return 2;
  4485. }
  4486. }, {
  4487. key: 'BREAKABLE',
  4488. get: function get() {
  4489. return 4;
  4490. }
  4491. // </ END scope consts>
  4492. }]);
  4493. function IVProgParser(input, lexerClass) {
  4494. _classCallCheck(this, IVProgParser);
  4495. this.lexerClass = lexerClass;
  4496. this.lexer = new lexerClass(new _index.InputStream(input));
  4497. this.tokenStream = new _index.CommonTokenStream(this.lexer);
  4498. this.tokenStream.fill();
  4499. this.pos = 1;
  4500. this.variableTypes = [this.lexerClass.RK_INTEGER, this.lexerClass.RK_REAL, this.lexerClass.RK_BOOLEAN, this.lexerClass.RK_STRING];
  4501. this.functionTypes = this.variableTypes.concat(this.lexerClass.RK_VOID);
  4502. this.parsingArrayDimension = 0;
  4503. this.scope = [];
  4504. this.langFuncs = _languageService.LanguageService.getCurrentLangFuncs();
  4505. this.definedFuncsNameList = [];
  4506. this.definedVariablesStack = [];
  4507. }
  4508. _createClass(IVProgParser, [{
  4509. key: 'parseTree',
  4510. value: function parseTree() {
  4511. return this.parseProgram();
  4512. }
  4513. }, {
  4514. key: 'getToken',
  4515. value: function getToken() {
  4516. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.pos;
  4517. // if(index === null)
  4518. // index = this.pos;
  4519. return this.tokenStream.LT(index);
  4520. }
  4521. }, {
  4522. key: 'insideScope',
  4523. value: function insideScope(scope) {
  4524. if (this.scope.length <= 0) {
  4525. return IVProgParser.BASE === scope;
  4526. } else {
  4527. return this.scope[this.scope.length - 1] === scope;
  4528. }
  4529. }
  4530. }, {
  4531. key: 'pushScope',
  4532. value: function pushScope(scope) {
  4533. this.scope.push(scope);
  4534. }
  4535. }, {
  4536. key: 'pushVariableStack',
  4537. value: function pushVariableStack() {
  4538. this.definedVariablesStack.push([]);
  4539. }
  4540. }, {
  4541. key: 'popScope',
  4542. value: function popScope() {
  4543. return this.scope.pop();
  4544. }
  4545. }, {
  4546. key: 'popVariableStack',
  4547. value: function popVariableStack() {
  4548. return this.definedVariablesStack.pop();
  4549. }
  4550. }, {
  4551. key: 'getCurrentVariableStack',
  4552. value: function getCurrentVariableStack() {
  4553. return this.definedVariablesStack[this.definedVariablesStack.length - 1];
  4554. }
  4555. }, {
  4556. key: 'isEOF',
  4557. value: function isEOF() {
  4558. this.getToken(this.pos);
  4559. return this.tokenStream.fetchedEOF;
  4560. }
  4561. }, {
  4562. key: 'parseProgram',
  4563. value: function parseProgram() {
  4564. var token = this.getToken();
  4565. var globalVars = [];
  4566. var functions = [];
  4567. if (this.lexerClass.RK_PROGRAM === token.type) {
  4568. this.pos++;
  4569. this.consumeNewLines();
  4570. this.checkOpenCurly();
  4571. this.pos++;
  4572. this.pushVariableStack();
  4573. while (true) {
  4574. this.consumeNewLines();
  4575. var _token = this.getToken();
  4576. if (_token.type === this.lexerClass.RK_CONST || this.isVariableType(_token)) {
  4577. globalVars = globalVars.concat(this.parseGlobalVariables());
  4578. } else if (_token.type === this.lexerClass.RK_FUNCTION) {
  4579. this.pushVariableStack();
  4580. functions = functions.concat(this.parseFunction());
  4581. this.popVariableStack();
  4582. } else {
  4583. break;
  4584. }
  4585. }
  4586. this.consumeNewLines();
  4587. this.checkCloseCurly();
  4588. this.pos++;
  4589. this.consumeNewLines();
  4590. if (!this.isEOF()) {
  4591. throw _syntaxErrorFactory.SyntaxErrorFactory.extra_lines();
  4592. }
  4593. this.popVariableStack();
  4594. return { global: globalVars, functions: functions };
  4595. } else {
  4596. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(this.lexer.literalNames[this.lexerClass.RK_PROGRAM], token);
  4597. }
  4598. }
  4599. }, {
  4600. key: 'checkOpenCurly',
  4601. value: function checkOpenCurly() {
  4602. var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4603. var token = this.getToken();
  4604. if (this.lexerClass.OPEN_CURLY !== token.type) {
  4605. if (!attempt) throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one('{', token);else return false;
  4606. }
  4607. return true;
  4608. }
  4609. }, {
  4610. key: 'checkCloseCurly',
  4611. value: function checkCloseCurly() {
  4612. var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4613. var token = this.getToken();
  4614. if (this.lexerClass.CLOSE_CURLY !== token.type) {
  4615. if (!attempt) throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one('}', token);else return false;
  4616. }
  4617. return true;
  4618. }
  4619. /* It checks if the current token at position pos is a ']'.
  4620. * As a check function it doesn't increment pos.
  4621. *
  4622. * @params bool:attempt, indicates that the token is optional. Defaults: false
  4623. *
  4624. * @returns true if the attempt is true and current token is '[',
  4625. * false is attempt is true and current token is not '['
  4626. **/
  4627. }, {
  4628. key: 'checkOpenBrace',
  4629. value: function checkOpenBrace() {
  4630. var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4631. var token = this.getToken();
  4632. if (this.lexerClass.OPEN_BRACE !== token.type) {
  4633. if (!attempt) {
  4634. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one('[', token);
  4635. } else {
  4636. return false;
  4637. }
  4638. }
  4639. return true;
  4640. }
  4641. }, {
  4642. key: 'checkCloseBrace',
  4643. value: function checkCloseBrace() {
  4644. var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4645. var token = this.getToken();
  4646. if (this.lexerClass.CLOSE_BRACE !== token.type) {
  4647. if (!attempt) {
  4648. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(']', token);
  4649. } else {
  4650. return false;
  4651. }
  4652. }
  4653. return true;
  4654. }
  4655. }, {
  4656. key: 'checkOpenParenthesis',
  4657. value: function checkOpenParenthesis() {
  4658. var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4659. var token = this.getToken();
  4660. if (this.lexerClass.OPEN_PARENTHESIS !== token.type) {
  4661. if (!attempt) {
  4662. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one('(', token);
  4663. } else {
  4664. return false;
  4665. }
  4666. }
  4667. return true;
  4668. }
  4669. }, {
  4670. key: 'checkCloseParenthesis',
  4671. value: function checkCloseParenthesis() {
  4672. var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4673. var token = this.getToken();
  4674. if (this.lexerClass.CLOSE_PARENTHESIS !== token.type) {
  4675. if (!attempt) {
  4676. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(')', token);
  4677. } else {
  4678. return false;
  4679. }
  4680. }
  4681. return true;
  4682. }
  4683. }, {
  4684. key: 'checkEOS',
  4685. value: function checkEOS() {
  4686. var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4687. var eosToken = this.getToken();
  4688. if (eosToken.type !== this.lexerClass.EOS) {
  4689. if (!attempt) throw _syntaxErrorFactory.SyntaxErrorFactory.eos_missing(eosToken);else return false;
  4690. }
  4691. return true;
  4692. }
  4693. }, {
  4694. key: 'checkFunctionDuplicate',
  4695. value: function checkFunctionDuplicate(functionID, funcIDToken) {
  4696. var id = functionID === null ? "$main" : functionID;
  4697. var index = this.definedFuncsNameList.indexOf(id);
  4698. if (index !== -1) {
  4699. throw _syntaxErrorFactory.SyntaxErrorFactory.duplicate_function(funcIDToken);
  4700. }
  4701. this.definedFuncsNameList.push(id);
  4702. }
  4703. }, {
  4704. key: 'checkVariableDuplicate',
  4705. value: function checkVariableDuplicate(variableID, variableIDToken) {
  4706. var index = this.getCurrentVariableStack().indexOf(variableID);
  4707. if (index !== -1) {
  4708. throw _syntaxErrorFactory.SyntaxErrorFactory.duplicate_variable(variableIDToken);
  4709. }
  4710. this.getCurrentVariableStack().push(variableID);
  4711. }
  4712. }, {
  4713. key: 'consumeForSemiColon',
  4714. value: function consumeForSemiColon() {
  4715. var eosToken = this.getToken();
  4716. if (eosToken.type === this.lexerClass.EOS && eosToken.text.match(';')) {
  4717. this.pos++;
  4718. return;
  4719. }
  4720. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(';', eosToken);
  4721. }
  4722. }, {
  4723. key: 'parseGlobalVariables',
  4724. value: function parseGlobalVariables() {
  4725. var decl = this.parseMaybeConst();
  4726. this.checkEOS();
  4727. this.pos++;
  4728. return decl;
  4729. }
  4730. /*
  4731. * Checks if the next token is PR_CONST. It's only available
  4732. * at global variables declaration level
  4733. * @returns Declararion(const, type, id, initVal?)
  4734. **/
  4735. }, {
  4736. key: 'parseMaybeConst',
  4737. value: function parseMaybeConst() {
  4738. var constToken = this.getToken();
  4739. if (constToken.type === this.lexerClass.RK_CONST) {
  4740. this.pos++;
  4741. var typeString = this.parseType();
  4742. return this.parseDeclaration(typeString, true);
  4743. } else if (this.isVariableType(constToken)) {
  4744. var _typeString = this.parseType();
  4745. return this.parseDeclaration(_typeString);
  4746. } else {
  4747. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_list([this.lexer.literalNames[this.lexerClass.RK_CONST]].concat(this.getTypeArray()), constToken);
  4748. }
  4749. }
  4750. /*
  4751. * Parses a declarion of the form: type --- id --- (= --- EAnd)?
  4752. * @returns a list of Declararion(const, type, id, initVal?)
  4753. **/
  4754. }, {
  4755. key: 'parseDeclaration',
  4756. value: function parseDeclaration(typeString) {
  4757. var isConst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4758. var initial = null;
  4759. var dim1 = null;
  4760. var dim2 = null;
  4761. var idToken = this.getToken();
  4762. var idString = this.parseID();
  4763. this.checkVariableDuplicate(idString, idToken);
  4764. // Check for array or vector
  4765. // ID[int/IDi][int/IDj]
  4766. if (this.checkOpenBrace(true)) {
  4767. this.pos++;
  4768. this.consumeNewLines();
  4769. dim1 = this.parseArrayDimension();
  4770. this.consumeNewLines();
  4771. this.checkCloseBrace();
  4772. this.pos++;
  4773. if (this.checkOpenBrace(true)) {
  4774. this.pos++;
  4775. this.consumeNewLines();
  4776. dim2 = this.parseArrayDimension();
  4777. this.consumeNewLines();
  4778. this.checkCloseBrace();
  4779. this.pos++;
  4780. }
  4781. }
  4782. var equalsToken = this.getToken();
  4783. if (isConst && equalsToken.type !== this.lexerClass.EQUAL) {
  4784. throw _syntaxErrorFactory.SyntaxErrorFactory.const_not_init(idToken);
  4785. }
  4786. if (equalsToken.type === this.lexerClass.EQUAL) {
  4787. this.pos++;
  4788. initial = this.parseExpressionOR();
  4789. }
  4790. var declaration = null;
  4791. var dimensions = 0;
  4792. if (dim1 !== null) {
  4793. dimensions++;
  4794. if (dim2 !== null) {
  4795. dimensions++;
  4796. }
  4797. declaration = new Commands.ArrayDeclaration(idString, new _compoundType.CompoundType(typeString, dimensions), dim1, dim2, initial, isConst);
  4798. } else {
  4799. declaration = new Commands.Declaration(idString, typeString, initial, isConst);
  4800. }
  4801. declaration.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(idToken);
  4802. var commaToken = this.getToken();
  4803. if (commaToken.type === this.lexerClass.COMMA) {
  4804. this.pos++;
  4805. this.consumeNewLines();
  4806. return [declaration].concat(this.parseDeclaration(typeString, isConst));
  4807. } else {
  4808. return [declaration];
  4809. }
  4810. }
  4811. }, {
  4812. key: 'consumeNewLines',
  4813. value: function consumeNewLines() {
  4814. var token = this.getToken();
  4815. while (token.type === this.lexerClass.EOS && token.text.match('[\r\n]+')) {
  4816. this.pos++;
  4817. token = this.getToken();
  4818. }
  4819. }
  4820. }, {
  4821. key: 'isVariableType',
  4822. value: function isVariableType(token) {
  4823. return this.variableTypes.find(function (v) {
  4824. return v === token.type;
  4825. });
  4826. }
  4827. /*
  4828. * Reads the next token of the stream to check if it is a Integer or an ID.
  4829. * @returns Integer | ID
  4830. **/
  4831. }, {
  4832. key: 'parseArrayDimension',
  4833. value: function parseArrayDimension() {
  4834. var dimToken = this.getToken();
  4835. if (dimToken.type === this.lexerClass.INTEGER) {
  4836. //parse as int literal
  4837. this.pos++;
  4838. return this.getIntLiteral(dimToken);
  4839. } else if (dimToken.type === this.lexerClass.ID) {
  4840. //parse as variable
  4841. this.pos++;
  4842. return this.parseVariable(dimToken);
  4843. } else {
  4844. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_array_dimension(this.lexer.literalNames[this.lexerClass.RK_INTEGER], dimToken);
  4845. }
  4846. }
  4847. /*
  4848. * Returns an object {type: 'int', value: value}.
  4849. * It checks for binary and hexadecimal integers.
  4850. * @returns object with fields type and value
  4851. **/
  4852. }, {
  4853. key: 'getIntLiteral',
  4854. value: function getIntLiteral(token) {
  4855. var text = token.text;
  4856. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(token);
  4857. var exp = new Expressions.IntLiteral((0, _parsers.toInt)(text));
  4858. exp.sourceInfo = sourceInfo;
  4859. return exp;
  4860. }
  4861. }, {
  4862. key: 'getRealLiteral',
  4863. value: function getRealLiteral(token) {
  4864. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(token);
  4865. var exp = new Expressions.RealLiteral((0, _parsers.toReal)(token.text));
  4866. exp.sourceInfo = sourceInfo;
  4867. return exp;
  4868. }
  4869. }, {
  4870. key: 'getStringLiteral',
  4871. value: function getStringLiteral(token) {
  4872. var text = token.text;
  4873. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(token);
  4874. var exp = new Expressions.StringLiteral((0, _parsers.toString)(text));
  4875. exp.sourceInfo = sourceInfo;
  4876. return exp;
  4877. }
  4878. }, {
  4879. key: 'getBoolLiteral',
  4880. value: function getBoolLiteral(token) {
  4881. var val = (0, _parsers.toBool)(token.text);
  4882. var exp = new Expressions.BoolLiteral(val);
  4883. exp.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(token);;
  4884. return exp;
  4885. }
  4886. }, {
  4887. key: 'parseArrayLiteral',
  4888. value: function parseArrayLiteral() {
  4889. this.checkOpenCurly();
  4890. var beginArray = this.getToken();
  4891. if (this.parsingArrayDimension >= 2) {
  4892. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_list('Array dimensions exceed maximum size of 2 at line ' + beginArray.line);
  4893. }
  4894. this.pos++;
  4895. this.parsingArrayDimension++;
  4896. this.consumeNewLines();
  4897. var data = this.parseExpressionList();
  4898. this.consumeNewLines();
  4899. this.checkCloseCurly();
  4900. var endArray = this.getToken();
  4901. this.pos++;
  4902. this.parsingArrayDimension--;
  4903. if (this.parsingArrayDimension === 0) {
  4904. // if (!data.isValid) {
  4905. // // TODO: better error message
  4906. // console.log('invalid array');
  4907. // throw new Error(`Invalid array at line ${beginArray.line}`);
  4908. // }
  4909. }
  4910. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfoFromList(beginArray, endArray);
  4911. var dataDim = 1;
  4912. if (data[0] instanceof Expressions.ArrayLiteral) {
  4913. dataDim++;
  4914. }
  4915. var type = new _compoundType.CompoundType(_types.Types.UNDEFINED, dataDim);
  4916. var exp = new Expressions.ArrayLiteral(type, data);
  4917. exp.sourceInfo = sourceInfo;
  4918. return exp;
  4919. }
  4920. /*
  4921. * Returns an object {type: 'variable', value: value}.
  4922. * @returns object with fields type and value
  4923. **/
  4924. }, {
  4925. key: 'parseVariable',
  4926. value: function parseVariable(token) {
  4927. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(token);
  4928. var exp = new Expressions.VariableLiteral(token.text);
  4929. exp.sourceInfo = sourceInfo;
  4930. return exp;
  4931. }
  4932. /*
  4933. * Returns an object representing a function. It has
  4934. * four attributes: returnType, id, formalParams and block.
  4935. * The block object has two attributes: declarations and commands
  4936. **/
  4937. }, {
  4938. key: 'parseFunction',
  4939. value: function parseFunction() {
  4940. this.pushScope(IVProgParser.FUNCTION);
  4941. var formalParams = [];
  4942. var token = this.getToken();
  4943. if (token.type !== this.lexerClass.RK_FUNCTION) {
  4944. //throw SyntaxError.createError(this.lexer.literalNames[this.lexerClass.PR_FUNCAO], token);
  4945. return null;
  4946. }
  4947. this.pos++;
  4948. var funType = this.parseType();
  4949. var dimensions = 0;
  4950. if (this.checkOpenBrace(true)) {
  4951. this.pos++;
  4952. this.checkCloseBrace();
  4953. this.pos++;
  4954. dimensions++;
  4955. if (this.checkOpenBrace(true)) {
  4956. this.pos++;
  4957. this.checkCloseBrace();
  4958. this.pos++;
  4959. dimensions++;
  4960. }
  4961. }
  4962. var funcIDToken = this.getToken();
  4963. var functionID = this.parseID();
  4964. this.checkFunctionDuplicate(functionID, funcIDToken);
  4965. this.checkOpenParenthesis();
  4966. this.pos++;
  4967. this.consumeNewLines();
  4968. if (!this.checkCloseParenthesis(true)) {
  4969. formalParams = this.parseFormalParameters(); // formal parameters
  4970. this.consumeNewLines();
  4971. this.checkCloseParenthesis();
  4972. this.pos++;
  4973. } else {
  4974. this.pos++;
  4975. }
  4976. this.consumeNewLines();
  4977. var commandsBlock = this.parseCommandBlock();
  4978. var returnType = funType;
  4979. if (dimensions > 0) {
  4980. returnType = new _compoundType.CompoundType(funType, dimensions);
  4981. }
  4982. var func = new Commands.Function(functionID, returnType, formalParams, commandsBlock);
  4983. if (functionID === null && !func.isMain) {
  4984. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_main_return(_definedFunctions.LanguageDefinedFunction.getMainFunctionName(), this.lexer.literalNames[this.lexerClass.RK_VOID], token.line);
  4985. } else if (func.isMain && formalParams.length !== 0) {
  4986. throw _syntaxErrorFactory.SyntaxErrorFactory.main_parameters();
  4987. }
  4988. this.popScope();
  4989. return func;
  4990. }
  4991. /*
  4992. * Parse the formal parameters of a function.
  4993. * @returns a list of objects with the following attributes: type, id and dimensions.
  4994. **/
  4995. }, {
  4996. key: 'parseFormalParameters',
  4997. value: function parseFormalParameters() {
  4998. var list = [];
  4999. while (true) {
  5000. var dimensions = 0;
  5001. var typeString = this.parseType();
  5002. var idToken = this.getToken();
  5003. var idString = this.parseID();
  5004. this.checkVariableDuplicate(idString, idToken);
  5005. if (this.checkOpenBrace(true)) {
  5006. this.pos++;
  5007. dimensions++;
  5008. this.checkCloseBrace();
  5009. this.pos++;
  5010. if (this.checkOpenBrace(true)) {
  5011. this.pos++;
  5012. dimensions++;
  5013. this.checkCloseBrace();
  5014. this.pos++;
  5015. }
  5016. }
  5017. var type = null;
  5018. if (dimensions > 0) {
  5019. type = new _compoundType.CompoundType(typeString, dimensions);
  5020. } else {
  5021. type = typeString;
  5022. }
  5023. list.push(new Commands.FormalParameter(type, idString));
  5024. var commaToken = this.getToken();
  5025. if (commaToken.type !== this.lexerClass.COMMA) break;
  5026. this.pos++;
  5027. this.consumeNewLines();
  5028. }
  5029. return list;
  5030. }
  5031. }, {
  5032. key: 'parseID',
  5033. value: function parseID() {
  5034. var token = this.getToken();
  5035. if (token.type !== this.lexerClass.ID) {
  5036. throw _syntaxErrorFactory.SyntaxErrorFactory.id_missing(token);
  5037. }
  5038. this.pos++;
  5039. if (this.insideScope(IVProgParser.FUNCTION)) {
  5040. if (token.text === _definedFunctions.LanguageDefinedFunction.getMainFunctionName()) {
  5041. return null;
  5042. }
  5043. }
  5044. return token.text;
  5045. }
  5046. }, {
  5047. key: 'parseMaybeLibID',
  5048. value: function parseMaybeLibID() {
  5049. var token = this.getToken();
  5050. if (token.type !== this.lexerClass.ID && token.type !== this.lexerClass.LIB_ID) {
  5051. throw _syntaxErrorFactory.SyntaxErrorFactory.id_missing(token);
  5052. }
  5053. this.pos++;
  5054. return token.text;
  5055. }
  5056. }, {
  5057. key: 'parseType',
  5058. value: function parseType() {
  5059. var token = this.getToken();
  5060. if (token.type === this.lexerClass.ID && this.insideScope(IVProgParser.FUNCTION)) {
  5061. return _types.Types.VOID;
  5062. } else if (token.type === this.lexerClass.RK_VOID && this.insideScope(IVProgParser.FUNCTION)) {
  5063. this.pos++;
  5064. return _types.Types.VOID;
  5065. } else if (this.isVariableType(token)) {
  5066. this.pos++;
  5067. switch (token.type) {
  5068. case this.lexerClass.RK_INTEGER:
  5069. return _types.Types.INTEGER;
  5070. case this.lexerClass.RK_BOOLEAN:
  5071. return _types.Types.BOOLEAN;
  5072. case this.lexerClass.RK_REAL:
  5073. return _types.Types.REAL;
  5074. case this.lexerClass.RK_STRING:
  5075. return _types.Types.STRING;
  5076. default:
  5077. break;
  5078. }
  5079. }
  5080. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_type(this.getTypeArray(), token);
  5081. }
  5082. }, {
  5083. key: 'parseCommandBlock',
  5084. value: function parseCommandBlock() {
  5085. var optionalCurly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5086. var variablesDecl = [];
  5087. var commands = [];
  5088. var hasOpen = false;
  5089. if (this.checkOpenCurly(optionalCurly)) {
  5090. this.pos++;
  5091. hasOpen = true;
  5092. }
  5093. this.consumeNewLines();
  5094. while (true) {
  5095. var cmd = this.parseCommand();
  5096. if (cmd === null) break;
  5097. if (cmd !== -1) {
  5098. if (cmd instanceof Array) {
  5099. variablesDecl = variablesDecl.concat(cmd);
  5100. } else {
  5101. commands.push(cmd);
  5102. }
  5103. }
  5104. }
  5105. this.consumeNewLines();
  5106. if (hasOpen) {
  5107. this.checkCloseCurly();
  5108. this.pos++;
  5109. this.consumeNewLines();
  5110. }
  5111. return new Commands.CommandBlock(variablesDecl, commands);
  5112. }
  5113. }, {
  5114. key: 'parseCommand',
  5115. value: function parseCommand() {
  5116. var token = this.getToken();
  5117. if (this.isVariableType(token)) {
  5118. if (!this.insideScope(IVProgParser.FUNCTION)) {
  5119. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_var_declaration(token.line);
  5120. }
  5121. this.pushScope(IVProgParser.BASE);
  5122. var varType = this.parseType();
  5123. this.popScope();
  5124. var cmd = this.parseDeclaration(varType);
  5125. this.checkEOS();
  5126. this.pos++;
  5127. return cmd;
  5128. } else if (token.type === this.lexerClass.ID) {
  5129. return this.parseIDCommand();
  5130. } else if (token.type === this.lexerClass.LIB_ID) {
  5131. return this.parseIDCommand();
  5132. } else if (token.type === this.lexerClass.RK_RETURN) {
  5133. return this.parseReturn();
  5134. } else if (token.type === this.lexerClass.RK_WHILE) {
  5135. return this.parseWhile();
  5136. } else if (token.type === this.lexerClass.RK_FOR) {
  5137. return this.parseFor();
  5138. } else if (token.type === this.lexerClass.RK_BREAK) {
  5139. if (!this.insideScope(IVProgParser.BREAKABLE)) {
  5140. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_break_command(this.lexer.literalNames[this.lexerClass.RK_BREAK], token);
  5141. }
  5142. return this.parseBreak();
  5143. } else if (token.type === this.lexerClass.RK_SWITCH) {
  5144. return this.parseSwitchCase();
  5145. } else if (token.type === this.lexerClass.RK_DO) {
  5146. return this.parseDoWhile();
  5147. } else if (token.type === this.lexerClass.RK_IF) {
  5148. return this.parseIfThenElse();
  5149. } else if (this.checkEOS(true)) {
  5150. this.pos++;
  5151. return -1;
  5152. } else {
  5153. return null;
  5154. }
  5155. }
  5156. }, {
  5157. key: 'parseSwitchCase',
  5158. value: function parseSwitchCase() {
  5159. this.pushScope(IVProgParser.BREAKABLE);
  5160. this.pos++;
  5161. this.checkOpenParenthesis();
  5162. this.pos++;
  5163. this.consumeNewLines();
  5164. var exp = this.parseExpressionOR();
  5165. this.consumeNewLines();
  5166. this.checkCloseParenthesis();
  5167. this.pos++;
  5168. this.consumeNewLines();
  5169. this.checkOpenCurly();
  5170. this.pos++;
  5171. this.consumeNewLines();
  5172. var casesList = this.parseCases();
  5173. this.consumeNewLines();
  5174. this.checkCloseCurly();
  5175. this.pos++;
  5176. this.consumeNewLines();
  5177. this.popScope();
  5178. return new Commands.Switch(exp, casesList);
  5179. }
  5180. }, {
  5181. key: 'parseDoWhile',
  5182. value: function parseDoWhile() {
  5183. this.pos++;
  5184. this.consumeNewLines();
  5185. this.pushScope(IVProgParser.BREAKABLE);
  5186. var commandsBlock = this.parseCommandBlock();
  5187. this.consumeNewLines(); //Maybe not...
  5188. var whileToken = this.getToken();
  5189. if (whileToken.type !== this.lexerClass.RK_WHILE) {
  5190. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(this.lexer.literalNames[this.lexerClass.RK_WHILE], whileToken);
  5191. }
  5192. this.pos++;
  5193. this.checkOpenParenthesis();
  5194. this.pos++;
  5195. this.consumeNewLines();
  5196. var condition = this.parseExpressionOR();
  5197. this.consumeNewLines();
  5198. this.checkCloseParenthesis();
  5199. this.pos++;
  5200. this.checkEOS();
  5201. this.popScope();
  5202. return new Commands.DoWhile(condition, commandsBlock);
  5203. }
  5204. }, {
  5205. key: 'parseIfThenElse',
  5206. value: function parseIfThenElse() {
  5207. if (this.insideScope(IVProgParser.BREAKABLE)) {
  5208. this.pushScope(IVProgParser.BREAKABLE);
  5209. } else {
  5210. this.pushScope(IVProgParser.COMMAND);
  5211. }
  5212. this.pos++;
  5213. this.checkOpenParenthesis();
  5214. this.pos++;
  5215. this.consumeNewLines();
  5216. var logicalExpression = this.parseExpressionOR();
  5217. this.consumeNewLines();
  5218. this.checkCloseParenthesis();
  5219. this.pos++;
  5220. this.consumeNewLines();
  5221. var cmdBlocks = this.parseCommandBlock();
  5222. var maybeElse = this.getToken();
  5223. if (maybeElse.type === this.lexerClass.RK_ELSE) {
  5224. this.pos++;
  5225. this.consumeNewLines();
  5226. var maybeIf = this.getToken();
  5227. var elseBlock = null;
  5228. if (this.checkOpenCurly(true)) {
  5229. elseBlock = this.parseCommandBlock();
  5230. } else if (maybeIf.type === this.lexerClass.RK_IF) {
  5231. elseBlock = this.parseIfThenElse();
  5232. } else {
  5233. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_list([this.lexer.literalNames[this.lexerClass.RK_IF], '{'], maybeIf);
  5234. }
  5235. return new Commands.IfThenElse(logicalExpression, cmdBlocks, elseBlock);
  5236. }
  5237. this.popScope();
  5238. return new Commands.IfThenElse(logicalExpression, cmdBlocks, null);
  5239. }
  5240. }, {
  5241. key: 'parseFor',
  5242. value: function parseFor() {
  5243. this.pushScope(IVProgParser.BREAKABLE);
  5244. this.pos++;
  5245. this.checkOpenParenthesis();
  5246. this.pos++;
  5247. this.consumeNewLines();
  5248. var attribution = this.parseForAssign();
  5249. this.consumeNewLines();
  5250. var condition = this.parseExpressionOR();
  5251. this.consumeForSemiColon();
  5252. var increment = this.parseForAssign(true);
  5253. this.checkCloseParenthesis();
  5254. this.pos++;
  5255. this.consumeNewLines();
  5256. var commandsBlock = this.parseCommandBlock();
  5257. this.popScope();
  5258. return new Commands.For(attribution, condition, increment, commandsBlock);
  5259. }
  5260. }, {
  5261. key: 'parseWhile',
  5262. value: function parseWhile() {
  5263. this.pushScope(IVProgParser.BREAKABLE);
  5264. this.pos++;
  5265. this.checkOpenParenthesis();
  5266. this.pos++;
  5267. this.consumeNewLines();
  5268. var logicalExpression = this.parseExpressionOR();
  5269. this.consumeNewLines();
  5270. this.checkCloseParenthesis();
  5271. this.pos++;
  5272. this.consumeNewLines();
  5273. var cmdBlocks = this.parseCommandBlock();
  5274. this.popScope();
  5275. return new Commands.While(logicalExpression, cmdBlocks);
  5276. }
  5277. }, {
  5278. key: 'parseBreak',
  5279. value: function parseBreak() {
  5280. this.pos++;
  5281. this.checkEOS();
  5282. this.pos++;
  5283. return new Commands.Break();
  5284. }
  5285. }, {
  5286. key: 'parseReturn',
  5287. value: function parseReturn() {
  5288. this.pos++;
  5289. var exp = null;
  5290. if (!this.checkEOS(true)) {
  5291. exp = this.parseExpressionOR();
  5292. this.checkEOS();
  5293. }
  5294. this.pos++;
  5295. return new Commands.Return(exp);
  5296. }
  5297. }, {
  5298. key: 'parseIDCommand',
  5299. value: function parseIDCommand() {
  5300. var refToken = this.getToken();
  5301. var isID = refToken.type === this.lexerClass.ID;
  5302. var id = this.parseMaybeLibID();
  5303. if (this.checkOpenBrace(true)) {
  5304. this.pos++;
  5305. var lineExpression = null;
  5306. var columnExpression = null;
  5307. this.consumeNewLines();
  5308. lineExpression = this.parseExpression();
  5309. this.consumeNewLines();
  5310. this.checkCloseBrace();
  5311. this.pos++;
  5312. if (this.checkOpenBrace(true)) {
  5313. this.pos++;
  5314. this.consumeNewLines();
  5315. columnExpression = this.parseExpression();
  5316. this.consumeNewLines();
  5317. this.checkCloseBrace();
  5318. this.pos++;
  5319. }
  5320. var equalToken = this.getToken();
  5321. if (equalToken.type !== this.lexerClass.EQUAL) {
  5322. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one('=', equalToken);
  5323. }
  5324. this.pos++;
  5325. var exp = this.parseExpressionOR();
  5326. this.checkEOS();
  5327. this.pos++;
  5328. var cmd = new Commands.ArrayIndexAssign(id, lineExpression, columnExpression, exp);
  5329. cmd.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(equalToken);
  5330. return cmd;
  5331. }
  5332. var equalOrParenthesis = this.getToken();
  5333. if (isID && equalOrParenthesis.type === this.lexerClass.EQUAL) {
  5334. this.pos++;
  5335. var _exp = this.parseExpressionOR();
  5336. this.checkEOS();
  5337. this.pos++;
  5338. var _cmd = new Commands.Assign(id, _exp);
  5339. _cmd.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(equalOrParenthesis);
  5340. return _cmd;
  5341. } else if (equalOrParenthesis.type === this.lexerClass.OPEN_PARENTHESIS) {
  5342. var funcCall = this.parseFunctionCallCommand(id);
  5343. this.checkEOS();
  5344. this.pos++;
  5345. return funcCall;
  5346. } else if (isID) {
  5347. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_list(['=', '('], equalOrParenthesis);
  5348. } else {
  5349. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_id_format(refToken);
  5350. }
  5351. }
  5352. }, {
  5353. key: 'parseForAssign',
  5354. value: function parseForAssign() {
  5355. var isLast = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5356. if (!isLast) this.consumeNewLines();
  5357. if (this.checkEOS(true)) {
  5358. return null;
  5359. }
  5360. var id = this.parseID();
  5361. var equal = this.getToken();
  5362. if (equal.type !== this.lexerClass.EQUAL) {
  5363. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one('=', equal);
  5364. }
  5365. this.pos++;
  5366. var exp = this.parseExpressionOR();
  5367. if (!isLast) {
  5368. this.consumeForSemiColon();
  5369. }
  5370. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(equal);
  5371. var cmd = new Commands.Assign(id, exp);
  5372. cmd.sourceInfo = sourceInfo;
  5373. return cmd;
  5374. }
  5375. }, {
  5376. key: 'parseCases',
  5377. value: function parseCases() {
  5378. var token = this.getToken();
  5379. if (token.type !== this.lexerClass.RK_CASE) {
  5380. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(this.lexer.literalNames[this.lexerClass.RK_CASE], token);
  5381. }
  5382. this.pos++;
  5383. var nextToken = this.getToken();
  5384. if (nextToken.type === this.lexerClass.RK_DEFAULT) {
  5385. this.pos++;
  5386. var colonToken = this.getToken();
  5387. if (colonToken.type !== this.lexerClass.COLON) {
  5388. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(':', colonToken);
  5389. }
  5390. this.pos++;
  5391. this.consumeNewLines();
  5392. var block = this.parseCommandBlock(true);
  5393. var defaultCase = new Commands.Case(null);
  5394. defaultCase.setCommands(block.commands);
  5395. return [defaultCase];
  5396. } else {
  5397. var exp = this.parseExpressionOR();
  5398. var _colonToken = this.getToken();
  5399. if (_colonToken.type !== this.lexerClass.COLON) {
  5400. throw _syntaxErrorFactory.SyntaxErrorFactory.token_missing_one(':', _colonToken);
  5401. }
  5402. this.pos++;
  5403. this.consumeNewLines();
  5404. var _block = this.parseCommandBlock(true);
  5405. var aCase = new Commands.Case(exp);
  5406. aCase.setCommands(_block.commands);
  5407. var caseToken = this.getToken();
  5408. if (caseToken.type === this.lexerClass.RK_CASE) {
  5409. return [aCase].concat(this.parseCases());
  5410. } else {
  5411. return [aCase];
  5412. }
  5413. }
  5414. }
  5415. /*
  5416. * Parses an Expression following the structure:
  5417. *
  5418. * EOR => EAnd ( 'or' EOR)? #expression and
  5419. *
  5420. * EOR => ENot ('and' EOR)? #expression or
  5421. *
  5422. * ENot => 'not'? ER #expression not
  5423. *
  5424. * ER => E ((>=, <=, ==, >, <) E)? #expression relational
  5425. *
  5426. * E => factor ((+, -) E)? #expression
  5427. *
  5428. * factor=> term ((*, /, %) factor)?
  5429. *
  5430. * term => literal || arrayAccess || FuncCall || ID || '('EAnd')'
  5431. **/
  5432. }, {
  5433. key: 'parseExpressionOR',
  5434. value: function parseExpressionOR() {
  5435. var exp1 = this.parseExpressionAND();
  5436. while (this.getToken().type === this.lexerClass.OR_OPERATOR) {
  5437. var opToken = this.getToken();
  5438. this.pos++;
  5439. var or = (0, _operators.convertFromString)('or');
  5440. this.consumeNewLines();
  5441. var exp2 = this.parseExpressionAND();
  5442. var _finalExp = new Expressions.InfixApp(or, exp1, exp2);
  5443. _finalExp.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(opToken);
  5444. exp1 = _finalExp;
  5445. }
  5446. return exp1;
  5447. }
  5448. }, {
  5449. key: 'parseExpressionAND',
  5450. value: function parseExpressionAND() {
  5451. var exp1 = this.parseExpressionNot();
  5452. while (this.getToken().type === this.lexerClass.AND_OPERATOR) {
  5453. var opToken = this.getToken();
  5454. this.pos++;
  5455. var and = (0, _operators.convertFromString)('and');
  5456. this.consumeNewLines();
  5457. var exp2 = this.parseExpressionNot();
  5458. var _finalExp2 = new Expressions.InfixApp(and, exp1, exp2);
  5459. _finalExp2.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(opToken);
  5460. exp1 = _finalExp2;
  5461. }
  5462. return exp1;
  5463. }
  5464. }, {
  5465. key: 'parseExpressionNot',
  5466. value: function parseExpressionNot() {
  5467. var maybeNotToken = this.getToken();
  5468. if (maybeNotToken.type === this.lexerClass.NOT_OPERATOR) {
  5469. var opToken = this.getToken();
  5470. this.pos++;
  5471. var not = (0, _operators.convertFromString)('not');
  5472. var exp1 = this.parseExpressionRel();
  5473. finalExp = new Expressions.UnaryApp(not, exp1);
  5474. finalExp.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(opToken);
  5475. return finalExp;
  5476. } else {
  5477. return this.parseExpressionRel();
  5478. }
  5479. }
  5480. }, {
  5481. key: 'parseExpressionRel',
  5482. value: function parseExpressionRel() {
  5483. var exp1 = this.parseExpression();
  5484. while (this.getToken().type === this.lexerClass.RELATIONAL_OPERATOR) {
  5485. var relToken = this.getToken();
  5486. this.pos++;
  5487. var rel = (0, _operators.convertFromString)(relToken.text);
  5488. var exp2 = this.parseExpression();
  5489. var _finalExp3 = new Expressions.InfixApp(rel, exp1, exp2);
  5490. _finalExp3.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(relToken);
  5491. exp1 = _finalExp3;
  5492. }
  5493. return exp1;
  5494. }
  5495. }, {
  5496. key: 'parseExpression',
  5497. value: function parseExpression() {
  5498. var factor = this.parseFactor();
  5499. while (this.getToken().type === this.lexerClass.SUM_OP) {
  5500. var sumOpToken = this.getToken();
  5501. this.pos++;
  5502. var op = (0, _operators.convertFromString)(sumOpToken.text);
  5503. var factor2 = this.parseFactor();
  5504. var _finalExp4 = new Expressions.InfixApp(op, factor, factor2);
  5505. _finalExp4.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(sumOpToken);
  5506. factor = _finalExp4;
  5507. }
  5508. return factor;
  5509. }
  5510. }, {
  5511. key: 'parseFactor',
  5512. value: function parseFactor() {
  5513. var term = this.parseTerm();
  5514. while (this.getToken().type === this.lexerClass.MULTI_OP) {
  5515. var multOpToken = this.getToken();
  5516. this.pos++;
  5517. var op = (0, _operators.convertFromString)(multOpToken.text);
  5518. var term2 = this.parseTerm();
  5519. var _finalExp5 = new Expressions.InfixApp(op, term, term2);
  5520. _finalExp5.sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(multOpToken);
  5521. term = _finalExp5;
  5522. }
  5523. return term;
  5524. }
  5525. }, {
  5526. key: 'parseTerm',
  5527. value: function parseTerm() {
  5528. var token = this.getToken();
  5529. var sourceInfo = null;
  5530. switch (token.type) {
  5531. case this.lexerClass.SUM_OP:
  5532. this.pos++;
  5533. sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(token);
  5534. var exp = new Expressions.UnaryApp((0, _operators.convertFromString)(token.text), this.parseTerm());
  5535. exp.sourceInfo = sourceInfo;
  5536. return exp;
  5537. case this.lexerClass.INTEGER:
  5538. this.pos++;
  5539. return this.getIntLiteral(token);
  5540. case this.lexerClass.REAL:
  5541. this.pos++;
  5542. return this.getRealLiteral(token);
  5543. case this.lexerClass.STRING:
  5544. this.pos++;
  5545. return this.getStringLiteral(token);
  5546. case this.lexerClass.RK_TRUE:
  5547. case this.lexerClass.RK_FALSE:
  5548. this.pos++;
  5549. return this.getBoolLiteral(token);
  5550. case this.lexerClass.OPEN_CURLY:
  5551. return this.parseArrayLiteral();
  5552. case this.lexerClass.ID:
  5553. case this.lexerClass.LIB_ID:
  5554. return this.parseIDTerm();
  5555. case this.lexerClass.OPEN_PARENTHESIS:
  5556. return this.parseParenthesisExp();
  5557. default:
  5558. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_terminal(token);
  5559. }
  5560. }
  5561. }, {
  5562. key: 'parseIDTerm',
  5563. value: function parseIDTerm() {
  5564. var tokenA = this.getToken();
  5565. var id = this.parseMaybeLibID();
  5566. var isID = tokenA.type === this.lexerClass.ID;
  5567. if (isID && this.checkOpenBrace(true)) {
  5568. var tokenB = null;
  5569. this.pos++;
  5570. var firstIndex = this.parseExpression();
  5571. var secondIndex = null;
  5572. this.consumeNewLines();
  5573. this.checkCloseBrace();
  5574. tokenB = this.getToken();
  5575. this.pos++;
  5576. if (this.checkOpenBrace(true)) {
  5577. this.pos++;
  5578. secondIndex = this.parseExpression();
  5579. this.consumeNewLines();
  5580. this.checkCloseBrace();
  5581. tokenB = this.getToken();
  5582. this.pos++;
  5583. }
  5584. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfoFromList(tokenA, tokenB);
  5585. var exp = new Expressions.ArrayAccess(id, firstIndex, secondIndex);
  5586. exp.sourceInfo = sourceInfo;
  5587. return exp;
  5588. } else if (this.checkOpenParenthesis(true)) {
  5589. return this.parseFunctionCallExpression(id);
  5590. } else if (isID) {
  5591. var _sourceInfo = _sourceInfo2.SourceInfo.createSourceInfo(tokenA);
  5592. var _exp2 = new Expressions.VariableLiteral(id);
  5593. _exp2.sourceInfo = _sourceInfo;
  5594. return _exp2;
  5595. } else {
  5596. throw _syntaxErrorFactory.SyntaxErrorFactory.invalid_id_format(tokenA);
  5597. }
  5598. }
  5599. }, {
  5600. key: 'getFunctionName',
  5601. value: function getFunctionName(id) {
  5602. var name = _definedFunctions.LanguageDefinedFunction.getInternalName(id);
  5603. if (name === null) {
  5604. if (id === _definedFunctions.LanguageDefinedFunction.getMainFunctionName()) {
  5605. return null;
  5606. }
  5607. return id;
  5608. } else {
  5609. return name;
  5610. }
  5611. }
  5612. }, {
  5613. key: 'parseFunctionCallExpression',
  5614. value: function parseFunctionCallExpression(id) {
  5615. var tokenA = this.getToken(this.pos - 1);
  5616. var actualParameters = this.parseActualParameters();
  5617. var tokenB = this.getToken(this.pos - 1);
  5618. var funcName = this.getFunctionName(id);
  5619. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfoFromList(tokenA, tokenB);
  5620. var cmd = new Expressions.FunctionCall(funcName, actualParameters);
  5621. cmd.sourceInfo = sourceInfo;
  5622. return cmd;
  5623. }
  5624. }, {
  5625. key: 'parseFunctionCallCommand',
  5626. value: function parseFunctionCallCommand(id) {
  5627. return this.parseFunctionCallExpression(id);
  5628. }
  5629. }, {
  5630. key: 'parseParenthesisExp',
  5631. value: function parseParenthesisExp() {
  5632. this.checkOpenParenthesis();
  5633. var tokenA = this.getToken();
  5634. this.pos++;
  5635. this.consumeNewLines();
  5636. var exp = this.parseExpressionOR();
  5637. this.consumeNewLines();
  5638. this.checkCloseParenthesis();
  5639. var tokenB = this.getToken();
  5640. var sourceInfo = _sourceInfo2.SourceInfo.createSourceInfoFromList(tokenA, tokenB);
  5641. this.pos++;
  5642. exp.sourceInfo = sourceInfo;
  5643. return exp;
  5644. }
  5645. }, {
  5646. key: 'parseActualParameters',
  5647. value: function parseActualParameters() {
  5648. this.checkOpenParenthesis();
  5649. this.pos++;
  5650. if (this.checkCloseParenthesis(true)) {
  5651. this.pos++;
  5652. return [];
  5653. }
  5654. this.consumeNewLines();
  5655. var list = this.parseExpressionList();
  5656. this.consumeNewLines();
  5657. this.checkCloseParenthesis();
  5658. this.pos++;
  5659. return list;
  5660. }
  5661. }, {
  5662. key: 'parseExpressionList',
  5663. value: function parseExpressionList() {
  5664. var list = [];
  5665. while (true) {
  5666. var exp = this.parseExpressionOR();
  5667. list.push(exp);
  5668. var maybeToken = this.getToken();
  5669. if (maybeToken.type !== this.lexerClass.COMMA) {
  5670. break;
  5671. } else {
  5672. this.pos++;
  5673. this.consumeNewLines();
  5674. }
  5675. }
  5676. return list;
  5677. }
  5678. }, {
  5679. key: 'getTypeArray',
  5680. value: function getTypeArray() {
  5681. var _this = this;
  5682. var types = this.insideScope(IVProgParser.FUNCTION) ? this.functionTypes : this.variableTypes;
  5683. return types.map(function (x) {
  5684. return _this.lexer.literalNames[x];
  5685. });
  5686. }
  5687. }]);
  5688. return IVProgParser;
  5689. }();
  5690. /***/ }),
  5691. /***/ "./js/ast/operators.js":
  5692. /*!*****************************!*\
  5693. !*** ./js/ast/operators.js ***!
  5694. \*****************************/
  5695. /*! no static exports found */
  5696. /***/ (function(module, exports, __webpack_require__) {
  5697. "use strict";
  5698. Object.defineProperty(exports, "__esModule", {
  5699. value: true
  5700. });
  5701. exports.convertFromString = convertFromString;
  5702. var Operators = exports.Operators = Object.freeze({
  5703. ADD: { ord: 0, value: "+" },
  5704. SUB: { ord: 1, value: "-" },
  5705. MULT: { ord: 2, value: '*' },
  5706. DIV: { ord: 3, value: '/' },
  5707. MOD: { ord: 4, value: '%' },
  5708. GT: { ord: 5, value: '>' },
  5709. GE: { ord: 6, value: '>=' },
  5710. LT: { ord: 7, value: '<' },
  5711. LE: { ord: 8, value: '<=' },
  5712. EQ: { ord: 9, value: '==' },
  5713. NEQ: { ord: 10, value: '!=' },
  5714. AND: { ord: 11, value: 'and' },
  5715. OR: { ord: 12, value: 'or' },
  5716. NOT: { ord: 13, value: 'not' }
  5717. });
  5718. function convertFromString(op) {
  5719. switch (op) {
  5720. case '+':
  5721. return Operators.ADD;
  5722. case '-':
  5723. return Operators.SUB;
  5724. case '*':
  5725. return Operators.MULT;
  5726. case '/':
  5727. return Operators.DIV;
  5728. case '%':
  5729. return Operators.MOD;
  5730. case '>':
  5731. return Operators.GT;
  5732. case '>=':
  5733. return Operators.GE;
  5734. case '<':
  5735. return Operators.LT;
  5736. case '<=':
  5737. return Operators.LE;
  5738. case '==':
  5739. return Operators.EQ;
  5740. case '!=':
  5741. return Operators.NEQ;
  5742. case 'and':
  5743. return Operators.AND;
  5744. case 'or':
  5745. return Operators.OR;
  5746. case 'not':
  5747. return Operators.NOT;
  5748. }
  5749. }
  5750. /***/ }),
  5751. /***/ "./js/ast/sourceInfo.js":
  5752. /*!******************************!*\
  5753. !*** ./js/ast/sourceInfo.js ***!
  5754. \******************************/
  5755. /*! no static exports found */
  5756. /***/ (function(module, exports, __webpack_require__) {
  5757. "use strict";
  5758. Object.defineProperty(exports, "__esModule", {
  5759. value: true
  5760. });
  5761. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5762. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5763. var SourceInfo = exports.SourceInfo = function () {
  5764. _createClass(SourceInfo, null, [{
  5765. key: "createSourceInfo",
  5766. value: function createSourceInfo(token) {
  5767. return new SourceInfo(token.line, token.column, token.text.length);
  5768. }
  5769. }, {
  5770. key: "createSourceInfoFromList",
  5771. value: function createSourceInfoFromList(tokenA, tokenB) {
  5772. var line = tokenA.line;
  5773. var column = tokenA.column;
  5774. // copied from https://github.com/UNIVALI-LITE/Portugol-Studio/blob/master/core/src/main/java/br/univali/portugol/nucleo/analise/sintatica/Portugol.g
  5775. // No idea why...
  5776. var size = tokenB.tokenIndex + 1 - tokenA.tokenIndex;
  5777. return new SourceInfo(line, column, size);
  5778. }
  5779. }]);
  5780. function SourceInfo(line, column, size) {
  5781. _classCallCheck(this, SourceInfo);
  5782. this.line = line;
  5783. this.column = column;
  5784. this.size = size;
  5785. }
  5786. return SourceInfo;
  5787. }();
  5788. /***/ }),
  5789. /***/ "./js/io/domConsole.js":
  5790. /*!*****************************!*\
  5791. !*** ./js/io/domConsole.js ***!
  5792. \*****************************/
  5793. /*! no static exports found */
  5794. /***/ (function(module, exports, __webpack_require__) {
  5795. "use strict";
  5796. Object.defineProperty(exports, "__esModule", {
  5797. value: true
  5798. });
  5799. exports.DOMConsole = undefined;
  5800. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5801. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  5802. var _jquery2 = _interopRequireDefault(_jquery);
  5803. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5804. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5805. var DOMConsole = exports.DOMConsole = function () {
  5806. _createClass(DOMConsole, null, [{
  5807. key: 'USER',
  5808. get: function get() {
  5809. return 0;
  5810. }
  5811. }, {
  5812. key: 'INFO',
  5813. get: function get() {
  5814. return 1;
  5815. }
  5816. }, {
  5817. key: 'ERR',
  5818. get: function get() {
  5819. return 2;
  5820. }
  5821. }]);
  5822. function DOMConsole(elementID) {
  5823. _classCallCheck(this, DOMConsole);
  5824. this.input = null;
  5825. this.needInput = false;
  5826. this.termDiv = null;
  5827. this.anyKey = false;
  5828. this.parent = (0, _jquery2.default)(elementID);
  5829. this.setup();
  5830. this.inputListeners = [];
  5831. }
  5832. _createClass(DOMConsole, [{
  5833. key: 'setup',
  5834. value: function setup() {
  5835. this._setupDom();
  5836. this._setupEvents();
  5837. }
  5838. }, {
  5839. key: '_setupEvents',
  5840. value: function _setupEvents() {
  5841. var _this = this;
  5842. this.input.on("keydown", function (event) {
  5843. if (!_this.needInput) {
  5844. event.preventDefault();
  5845. return;
  5846. }
  5847. var keyCode = event.which;
  5848. if (keyCode === 13 || _this.anyKey) {
  5849. var text = _this.input.val();
  5850. text = text.replace('[\n\r]+', '');
  5851. _this.notifyListeners(text);
  5852. _this.write(text);
  5853. _this.input.val("");
  5854. }
  5855. });
  5856. }
  5857. }, {
  5858. key: '_setupDom',
  5859. value: function _setupDom() {
  5860. this.termDiv = (0, _jquery2.default)("<div></div>");
  5861. this.termDiv.addClass("ivprog-term-div");
  5862. this.input = (0, _jquery2.default)('<input text="type">');
  5863. this.input.addClass("ivprog-term-input");
  5864. this.termDiv.append(this.input);
  5865. this.parent.append(this.termDiv);
  5866. }
  5867. }, {
  5868. key: 'notifyListeners',
  5869. value: function notifyListeners(text) {
  5870. this.inputListeners.forEach(function (resolve) {
  5871. return resolve(text);
  5872. });
  5873. this.inputListeners.splice(0, this.inputListeners.length);
  5874. this.hideInput();
  5875. this.anyKey = false;
  5876. }
  5877. }, {
  5878. key: 'write',
  5879. value: function write(text) {
  5880. this._appendText(text, DOMConsole.USER);
  5881. }
  5882. }, {
  5883. key: 'info',
  5884. value: function info(text) {
  5885. this._appendText(text, DOMConsole.INFO);
  5886. }
  5887. }, {
  5888. key: 'err',
  5889. value: function err(text) {
  5890. this._appendText(text, DOMConsole.ERR);
  5891. }
  5892. }, {
  5893. key: '_appendText',
  5894. value: function _appendText(text, type) {
  5895. var divClass = this.getClassForType(type);
  5896. var textDiv = (0, _jquery2.default)("<div></div>");
  5897. textDiv.addClass(divClass);
  5898. textDiv.append(text);
  5899. textDiv.insertBefore(this.input);
  5900. this.scrollTerm();
  5901. }
  5902. }, {
  5903. key: 'scrollTerm',
  5904. value: function scrollTerm() {
  5905. this.termDiv.animate({
  5906. scrollTop: this.termDiv.prop('scrollHeight')
  5907. }, 0);
  5908. }
  5909. }, {
  5910. key: 'getClassForType',
  5911. value: function getClassForType(type) {
  5912. switch (type) {
  5913. case DOMConsole.USER:
  5914. return "ivprog-term-userText";
  5915. case DOMConsole.INFO:
  5916. return "ivprog-term-info";
  5917. case DOMConsole.ERR:
  5918. return "ivprog-term-error";
  5919. }
  5920. }
  5921. }, {
  5922. key: 'dispose',
  5923. value: function dispose() {
  5924. this.parent.off();
  5925. this.input.off();
  5926. this.input = null;
  5927. this.parent.empty();
  5928. }
  5929. }, {
  5930. key: 'showInput',
  5931. value: function showInput() {
  5932. this.needInput = true;
  5933. this.input.show();
  5934. this.input.focus();
  5935. }
  5936. }, {
  5937. key: 'hideInput',
  5938. value: function hideInput() {
  5939. this.needInput = false;
  5940. this.input.hide();
  5941. }
  5942. }, {
  5943. key: 'requestInput',
  5944. value: function requestInput(callback) {
  5945. var anyKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5946. this.inputListeners.push(callback);
  5947. this.anyKey = anyKey;
  5948. this.showInput();
  5949. }
  5950. }, {
  5951. key: 'sendOutput',
  5952. value: function sendOutput(text) {
  5953. var _this2 = this;
  5954. var output = "" + text;
  5955. output.split("\n").forEach(function (t) {
  5956. t = t.replace(/\t/g, '&#9;');
  5957. _this2.write(t);
  5958. });
  5959. }
  5960. }, {
  5961. key: 'clear',
  5962. value: function clear() {
  5963. this.input.parent().children().not(this.input).remove();
  5964. this.input.val("");
  5965. }
  5966. }]);
  5967. return DOMConsole;
  5968. }();
  5969. /***/ }),
  5970. /***/ "./js/io/input.js":
  5971. /*!************************!*\
  5972. !*** ./js/io/input.js ***!
  5973. \************************/
  5974. /*! no static exports found */
  5975. /***/ (function(module, exports, __webpack_require__) {
  5976. "use strict";
  5977. Object.defineProperty(exports, "__esModule", {
  5978. value: true
  5979. });
  5980. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5981. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5982. var Input = exports.Input = function () {
  5983. function Input() {
  5984. _classCallCheck(this, Input);
  5985. }
  5986. _createClass(Input, [{
  5987. key: "requestInput",
  5988. value: function requestInput(callback) {
  5989. throw new Error("Must be implemented");
  5990. }
  5991. }]);
  5992. return Input;
  5993. }();
  5994. /***/ }),
  5995. /***/ "./js/io/output.js":
  5996. /*!*************************!*\
  5997. !*** ./js/io/output.js ***!
  5998. \*************************/
  5999. /*! no static exports found */
  6000. /***/ (function(module, exports, __webpack_require__) {
  6001. "use strict";
  6002. Object.defineProperty(exports, "__esModule", {
  6003. value: true
  6004. });
  6005. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  6006. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6007. var Output = exports.Output = function () {
  6008. function Output() {
  6009. _classCallCheck(this, Output);
  6010. }
  6011. _createClass(Output, [{
  6012. key: "sendOutput",
  6013. value: function sendOutput(text) {
  6014. throw new Error("Must be implemented");
  6015. }
  6016. }]);
  6017. return Output;
  6018. }();
  6019. /***/ }),
  6020. /***/ "./js/main.js":
  6021. /*!********************!*\
  6022. !*** ./js/main.js ***!
  6023. \********************/
  6024. /*! no static exports found */
  6025. /***/ (function(module, exports, __webpack_require__) {
  6026. "use strict";
  6027. Object.defineProperty(exports, "__esModule", {
  6028. value: true
  6029. });
  6030. exports.i18n = exports.LocalizedStrings = exports.initVisualUI = exports.runner = undefined;
  6031. var _runner = __webpack_require__(/*! ./runner */ "./js/runner.js");
  6032. var _functions = __webpack_require__(/*! ./visualUI/functions */ "./js/visualUI/functions.js");
  6033. var _localizedStringsService = __webpack_require__(/*! ./services/localizedStringsService */ "./js/services/localizedStringsService.js");
  6034. var _i18nHelper = __webpack_require__(/*! ./services/i18nHelper */ "./js/services/i18nHelper.js");
  6035. var i18n = _i18nHelper.i18nHelper.i18n;
  6036. exports.runner = _runner.runner;
  6037. exports.initVisualUI = _functions.initVisualUI;
  6038. exports.LocalizedStrings = _localizedStringsService.LocalizedStrings;
  6039. exports.i18n = i18n;
  6040. /***/ }),
  6041. /***/ "./js/processor/compatibilityTable.js":
  6042. /*!********************************************!*\
  6043. !*** ./js/processor/compatibilityTable.js ***!
  6044. \********************************************/
  6045. /*! no static exports found */
  6046. /***/ (function(module, exports, __webpack_require__) {
  6047. "use strict";
  6048. Object.defineProperty(exports, "__esModule", {
  6049. value: true
  6050. });
  6051. exports.resultTypeAfterInfixOp = resultTypeAfterInfixOp;
  6052. exports.resultTypeAfterUnaryOp = resultTypeAfterUnaryOp;
  6053. var _types = __webpack_require__(/*! ./../typeSystem/types */ "./js/typeSystem/types.js");
  6054. var _operators = __webpack_require__(/*! ./../ast/operators */ "./js/ast/operators.js");
  6055. var _multiType = __webpack_require__(/*! ../typeSystem/multiType */ "./js/typeSystem/multiType.js");
  6056. var _config = __webpack_require__(/*! ../util/config */ "./js/util/config.js");
  6057. function buildInfixAddTable() {
  6058. var table = [[], [], [], []];
  6059. table[_types.Types.INTEGER.ord][_types.Types.INTEGER.ord] = _types.Types.INTEGER;
  6060. table[_types.Types.INTEGER.ord][_types.Types.REAL.ord] = _types.Types.REAL;
  6061. table[_types.Types.INTEGER.ord][_types.Types.STRING.ord] = _types.Types.STRING;
  6062. table[_types.Types.REAL.ord][_types.Types.INTEGER.ord] = _types.Types.REAL;
  6063. table[_types.Types.REAL.ord][_types.Types.REAL.ord] = _types.Types.REAL;
  6064. table[_types.Types.REAL.ord][_types.Types.STRING.ord] = _types.Types.STRING;
  6065. table[_types.Types.STRING.ord][_types.Types.INTEGER.ord] = _types.Types.STRING;
  6066. table[_types.Types.STRING.ord][_types.Types.REAL.ord] = _types.Types.STRING;
  6067. table[_types.Types.STRING.ord][_types.Types.STRING.ord] = _types.Types.STRING;
  6068. table[_types.Types.STRING.ord][_types.Types.BOOLEAN.ord] = _types.Types.STRING;
  6069. return table;
  6070. }
  6071. function buildInfixMultiDivSubTable() {
  6072. var table = [[], [], [], []];
  6073. table[_types.Types.INTEGER.ord][_types.Types.INTEGER.ord] = _types.Types.INTEGER;
  6074. table[_types.Types.INTEGER.ord][_types.Types.REAL.ord] = _types.Types.REAL;
  6075. table[_types.Types.REAL.ord][_types.Types.INTEGER.ord] = _types.Types.REAL;
  6076. table[_types.Types.REAL.ord][_types.Types.REAL.ord] = _types.Types.REAL;
  6077. return table;
  6078. }
  6079. function buildInfixEqualityInequalityTable() {
  6080. var table = [[], [], [], []];
  6081. table[_types.Types.INTEGER.ord][_types.Types.INTEGER.ord] = _types.Types.BOOLEAN;
  6082. table[_types.Types.REAL.ord][_types.Types.REAL.ord] = _types.Types.BOOLEAN;
  6083. table[_types.Types.BOOLEAN.ord][_types.Types.BOOLEAN.ord] = _types.Types.BOOLEAN;
  6084. table[_types.Types.STRING.ord][_types.Types.STRING.ord] = _types.Types.BOOLEAN;
  6085. return table;
  6086. }
  6087. function buildInfixRelationalTable() {
  6088. var table = [[], [], [], []];
  6089. table[_types.Types.INTEGER.ord][_types.Types.INTEGER.ord] = _types.Types.BOOLEAN;
  6090. table[_types.Types.REAL.ord][_types.Types.REAL.ord] = _types.Types.BOOLEAN;
  6091. table[_types.Types.STRING.ord][_types.Types.STRING.ord] = _types.Types.BOOLEAN;
  6092. return table;
  6093. }
  6094. function buildInfixAndOrTable() {
  6095. var table = [[], [], [], []];
  6096. table[_types.Types.BOOLEAN.ord][_types.Types.BOOLEAN.ord] = _types.Types.BOOLEAN;
  6097. return table;
  6098. }
  6099. function buildInfixModTable() {
  6100. var table = [[], [], [], []];
  6101. table[_types.Types.INTEGER.ord][_types.Types.INTEGER.ord] = _types.Types.INTEGER;
  6102. return table;
  6103. }
  6104. function buildUnarySumSubList() {
  6105. var list = [];
  6106. list[_types.Types.INTEGER.ord] = _types.Types.INTEGER;
  6107. list[_types.Types.REAL.ord] = _types.Types.REAL;
  6108. return list;
  6109. }
  6110. function buildUnaryNegList() {
  6111. var list = [];
  6112. list[_types.Types.BOOLEAN.ord] = _types.Types.BOOLEAN;
  6113. return list;
  6114. }
  6115. function buildInfixCompatibilityTable() {
  6116. var compatibilityMap = new WeakMap();
  6117. compatibilityMap.set(_operators.Operators.ADD, buildInfixAddTable());
  6118. compatibilityMap.set(_operators.Operators.SUB, buildInfixMultiDivSubTable());
  6119. compatibilityMap.set(_operators.Operators.MULT, buildInfixMultiDivSubTable());
  6120. compatibilityMap.set(_operators.Operators.DIV, buildInfixMultiDivSubTable());
  6121. compatibilityMap.set(_operators.Operators.EQ, buildInfixEqualityInequalityTable());
  6122. compatibilityMap.set(_operators.Operators.NEQ, buildInfixEqualityInequalityTable());
  6123. compatibilityMap.set(_operators.Operators.GE, buildInfixRelationalTable());
  6124. compatibilityMap.set(_operators.Operators.GT, buildInfixRelationalTable());
  6125. compatibilityMap.set(_operators.Operators.LE, buildInfixRelationalTable());
  6126. compatibilityMap.set(_operators.Operators.LT, buildInfixRelationalTable());
  6127. compatibilityMap.set(_operators.Operators.OR, buildInfixAndOrTable());
  6128. compatibilityMap.set(_operators.Operators.AND, buildInfixAndOrTable());
  6129. compatibilityMap.set(_operators.Operators.MOD, buildInfixModTable());
  6130. return compatibilityMap;
  6131. }
  6132. function buildUnaryCompatibilityTable() {
  6133. var compatibilityMap = new WeakMap();
  6134. compatibilityMap.set(_operators.Operators.ADD, buildUnarySumSubList());
  6135. compatibilityMap.set(_operators.Operators.SUB, buildUnarySumSubList());
  6136. compatibilityMap.set(_operators.Operators.NOT, buildUnaryNegList());
  6137. return compatibilityMap;
  6138. }
  6139. var infixMap = buildInfixCompatibilityTable();
  6140. var unaryMap = buildUnaryCompatibilityTable();
  6141. function resultTypeAfterInfixOp(operator, leftExpressionType, rightExpressionType) {
  6142. try {
  6143. if (leftExpressionType instanceof _multiType.MultiType && rightExpressionType instanceof _multiType.MultiType) {
  6144. var newMulti = [];
  6145. for (var i = 0; i < leftExpressionType.types.length; i++) {
  6146. var element = leftExpressionType.types[i];
  6147. if (rightExpressionType.types.indexOf(element) !== -1) {
  6148. newMulti.push(element);
  6149. }
  6150. }
  6151. if (newMulti.length <= 0) {
  6152. if (_config.Config.enable_type_casting) {
  6153. if (leftExpressionType.isCompatible(_types.Types.INTEGER) || leftExpressionType.isCompatible(_types.Types.REAL)) {
  6154. if (rightExpressionType.isCompatible(_types.Types.INTEGER) || rightExpressionType.isCompatible(_types.Types.REAL)) {
  6155. return new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]);
  6156. }
  6157. }
  6158. }
  6159. return _types.Types.UNDEFINED;
  6160. } else {
  6161. return new _multiType.MultiType(newMulti);
  6162. }
  6163. } else if (leftExpressionType instanceof _multiType.MultiType) {
  6164. if (leftExpressionType.isCompatible(rightExpressionType)) {
  6165. return rightExpressionType;
  6166. } else {
  6167. if (_config.Config.enable_type_casting) {
  6168. if (leftExpressionType.isCompatible(_types.Types.INTEGER) || leftExpressionType.isCompatible(_types.Types.REAL)) {
  6169. if (rightExpressionType.isCompatible(_types.Types.INTEGER) || rightExpressionType.isCompatible(_types.Types.REAL)) {
  6170. return rightExpressionType;
  6171. }
  6172. }
  6173. }
  6174. return _types.Types.UNDEFINED;
  6175. }
  6176. } else if (rightExpressionType instanceof _multiType.MultiType) {
  6177. if (rightExpressionType.isCompatible(leftExpressionType)) {
  6178. return leftExpressionType;
  6179. } else {
  6180. if (_config.Config.enable_type_casting) {
  6181. if (leftExpressionType.isCompatible(_types.Types.INTEGER) || leftExpressionType.isCompatible(_types.Types.REAL)) {
  6182. if (rightExpressionType.isCompatible(_types.Types.INTEGER) || rightExpressionType.isCompatible(_types.Types.REAL)) {
  6183. return leftExpressionType;
  6184. }
  6185. }
  6186. }
  6187. return _types.Types.UNDEFINED;
  6188. }
  6189. }
  6190. var resultType = infixMap.get(operator)[leftExpressionType.ord][rightExpressionType.ord];
  6191. if (resultType === null || resultType === undefined) {
  6192. if (_config.Config.enable_type_casting) {
  6193. if (leftExpressionType.isCompatible(_types.Types.INTEGER) || leftExpressionType.isCompatible(_types.Types.REAL)) {
  6194. if (rightExpressionType.isCompatible(_types.Types.INTEGER) || rightExpressionType.isCompatible(_types.Types.REAL)) {
  6195. if (operator === _operators.Operators.MOD) {
  6196. return _types.Types.INTEGER;
  6197. } else if (operator.ord >= 5 && operator.ord <= 10) {
  6198. return _types.Types.BOOLEAN;
  6199. }
  6200. }
  6201. }
  6202. }
  6203. return _types.Types.UNDEFINED;
  6204. }
  6205. return resultType;
  6206. } catch (e) {
  6207. if (e instanceof TypeError) {
  6208. return _types.Types.UNDEFINED;
  6209. } else {
  6210. throw e;
  6211. }
  6212. }
  6213. }
  6214. function resultTypeAfterUnaryOp(operator, leftExpressionType) {
  6215. try {
  6216. if (leftExpressionType instanceof _multiType.MultiType) {
  6217. return leftExpressionType;
  6218. }
  6219. return unaryMap.get(operator)[leftExpressionType.ord];
  6220. } catch (e) {
  6221. if (e instanceof TypeError) {
  6222. return _types.Types.UNDEFINED;
  6223. } else {
  6224. throw e;
  6225. }
  6226. }
  6227. }
  6228. /***/ }),
  6229. /***/ "./js/processor/context.js":
  6230. /*!*********************************!*\
  6231. !*** ./js/processor/context.js ***!
  6232. \*********************************/
  6233. /*! no static exports found */
  6234. /***/ (function(module, exports, __webpack_require__) {
  6235. "use strict";
  6236. Object.defineProperty(exports, "__esModule", {
  6237. value: true
  6238. });
  6239. var Context = exports.Context = Object.freeze({
  6240. BASE: Symbol('context:base'),
  6241. BREAKABLE: Symbol('context:breakable'),
  6242. FUNCTION: Symbol('context:function')
  6243. });
  6244. /***/ }),
  6245. /***/ "./js/processor/definedFunctions.js":
  6246. /*!******************************************!*\
  6247. !*** ./js/processor/definedFunctions.js ***!
  6248. \******************************************/
  6249. /*! no static exports found */
  6250. /***/ (function(module, exports, __webpack_require__) {
  6251. "use strict";
  6252. Object.defineProperty(exports, "__esModule", {
  6253. value: true
  6254. });
  6255. exports.LanguageDefinedFunction = undefined;
  6256. var _languageService = __webpack_require__(/*! ../services/languageService */ "./js/services/languageService.js");
  6257. var _io = __webpack_require__(/*! ./lib/io */ "./js/processor/lib/io.js");
  6258. var _strings = __webpack_require__(/*! ./lib/strings */ "./js/processor/lib/strings.js");
  6259. var _arrays = __webpack_require__(/*! ./lib/arrays */ "./js/processor/lib/arrays.js");
  6260. var _lang = __webpack_require__(/*! ./lib/lang */ "./js/processor/lib/lang.js");
  6261. var _math = __webpack_require__(/*! ./lib/math */ "./js/processor/lib/math.js");
  6262. function valueToKey(value, object) {
  6263. for (var key in object) {
  6264. if (object.hasOwnProperty(key)) {
  6265. if (object[key] === value) {
  6266. return key;
  6267. }
  6268. }
  6269. }
  6270. return null;
  6271. }
  6272. function concatObjects() {
  6273. var result = {};
  6274. for (var _len = arguments.length, objs = Array(_len), _key = 0; _key < _len; _key++) {
  6275. objs[_key] = arguments[_key];
  6276. }
  6277. for (var i = 0; i < objs.length; i++) {
  6278. var obj = objs[i];
  6279. for (var key in obj) {
  6280. if (obj.hasOwnProperty(key)) {
  6281. result[key] = obj[key];
  6282. }
  6283. }
  6284. }
  6285. return result;
  6286. }
  6287. var libsObject = {
  6288. $mathLib: {
  6289. $sin: (0, _math.createSinFun)(),
  6290. $cos: (0, _math.createCosFun)(),
  6291. $tan: (0, _math.createTanFun)(),
  6292. $sqrt: (0, _math.createSqrtFun)(),
  6293. $pow: (0, _math.createPowFun)(),
  6294. $log: (0, _math.createLogFun)(),
  6295. $abs: (0, _math.createAbsFun)(),
  6296. $negate: (0, _math.createNegateFun)(),
  6297. $invert: (0, _math.createInvertFun)(),
  6298. $max: (0, _math.createMaxFun)(),
  6299. $min: (0, _math.createMinFun)()
  6300. },
  6301. $ioLib: {
  6302. $read: (0, _io.createInputFun)(),
  6303. $write: (0, _io.createOutputFun)()
  6304. },
  6305. $strLib: {
  6306. $substring: (0, _strings.createSubstringFun)(),
  6307. $length: (0, _strings.createLengthFun)(),
  6308. $uppercase: (0, _strings.createUppercaseFun)(),
  6309. $lowercase: (0, _strings.createLowercaseFun)(),
  6310. $charAt: (0, _strings.createrCharAtFun)()
  6311. },
  6312. $arrayLib: {
  6313. $numElements: (0, _arrays.createNumElementsFun)(),
  6314. $matrixLines: (0, _arrays.createMatrixLinesFun)(),
  6315. $matrixColumns: (0, _arrays.createMatrixColumnsFun)()
  6316. },
  6317. $langLib: {
  6318. $isReal: (0, _lang.createIsRealFun)(),
  6319. $isInt: (0, _lang.createIsIntFun)(),
  6320. $isBool: (0, _lang.createIsBoolFun)(),
  6321. $castReal: (0, _lang.createCastRealFun)(),
  6322. $castInt: (0, _lang.createCastIntFun)(),
  6323. $castBool: (0, _lang.createCastBoolFun)(),
  6324. $castString: (0, _lang.createCastStringFun)()
  6325. }
  6326. };
  6327. var funcsObject = concatObjects(libsObject.$ioLib, libsObject.$langLib, libsObject.$strLib, libsObject.$arrayLib);
  6328. var LanguageDefinedFunction = exports.LanguageDefinedFunction = Object.freeze({
  6329. getMainFunctionName: function getMainFunctionName() {
  6330. return _languageService.LanguageService.getCurrentLangFuncs().main_function;
  6331. },
  6332. getInternalName: function getInternalName(localName) {
  6333. if (localName.indexOf(".") !== -1) {
  6334. var names = localName.split(".");
  6335. var lib = valueToKey(names[0], _languageService.LanguageService.getCurrentLangLibs());
  6336. var internalName = valueToKey(names[1], _languageService.LanguageService.getCurrentLangFuncs());
  6337. if (lib === null || internalName === null) {
  6338. return null;
  6339. }
  6340. return lib + "." + internalName;
  6341. }
  6342. var funcName = valueToKey(localName, _languageService.LanguageService.getCurrentLangFuncs());
  6343. if (funcName !== null) {
  6344. if (funcsObject[funcName]) {
  6345. return funcName;
  6346. }
  6347. }
  6348. return null;
  6349. },
  6350. getFunction: function getFunction(internalName) {
  6351. if (internalName.indexOf(".") !== -1) {
  6352. var names = internalName.split(".");
  6353. var libName = names[0];
  6354. var funName = names[1];
  6355. return libsObject[libName][funName];
  6356. }
  6357. return funcsObject[internalName];
  6358. },
  6359. getLocalName: function getLocalName(internalName) {
  6360. if (internalName.indexOf(".") !== -1) {
  6361. var names = internalName.split(".");
  6362. var libName = _languageService.LanguageService.getCurrentLangLibs()[names[0]];
  6363. var funName = _languageService.LanguageService.getCurrentLangFuncs()[names[1]];
  6364. return libName + '.' + funName;
  6365. } else if (_languageService.LanguageService.getCurrentLangFuncs()[internalName]) {
  6366. return _languageService.LanguageService.getCurrentLangFuncs()[internalName];
  6367. } else {
  6368. return internalName;
  6369. }
  6370. }
  6371. });
  6372. /***/ }),
  6373. /***/ "./js/processor/error/processorErrorFactory.js":
  6374. /*!*****************************************************!*\
  6375. !*** ./js/processor/error/processorErrorFactory.js ***!
  6376. \*****************************************************/
  6377. /*! no static exports found */
  6378. /***/ (function(module, exports, __webpack_require__) {
  6379. "use strict";
  6380. Object.defineProperty(exports, "__esModule", {
  6381. value: true
  6382. });
  6383. exports.ProcessorErrorFactory = undefined;
  6384. var _runtimeError = __webpack_require__(/*! ./runtimeError */ "./js/processor/error/runtimeError.js");
  6385. var _semanticError = __webpack_require__(/*! ./semanticError */ "./js/processor/error/semanticError.js");
  6386. var _localizedStringsService = __webpack_require__(/*! ./../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  6387. var _operators = __webpack_require__(/*! ../../ast/operators */ "./js/ast/operators.js");
  6388. function translateType(type, dim) {
  6389. switch (dim) {
  6390. case 0:
  6391. return _localizedStringsService.LocalizedStrings.getUI(type);
  6392. default:
  6393. var transType = _localizedStringsService.LocalizedStrings.getUI(type);
  6394. if (dim === 1) return _localizedStringsService.LocalizedStrings.getUI("vector_string", [transType]);else return _localizedStringsService.LocalizedStrings.getUI("matrix_string", [transType]);
  6395. }
  6396. }
  6397. function translateOp(op) {
  6398. switch (op.ord) {
  6399. case _operators.Operators.AND.ord:
  6400. case _operators.Operators.OR.ord:
  6401. case _operators.Operators.NOT.ord:
  6402. return _localizedStringsService.LocalizedStrings.getUI(op.value);
  6403. default:
  6404. return op.value;
  6405. }
  6406. }
  6407. var ProcessorErrorFactory = exports.ProcessorErrorFactory = Object.freeze({
  6408. symbol_not_found_full: function symbol_not_found_full(id, sourceInfo) {
  6409. if (sourceInfo) {
  6410. var context = [id, sourceInfo.line, sourceInfo.column];
  6411. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("symbol_not_found_full", context));
  6412. } else {
  6413. return ProcessorErrorFactory.symbol_not_found(id);
  6414. }
  6415. },
  6416. symbol_not_found: function symbol_not_found(id) {
  6417. var context = [id];
  6418. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("symbol_not_found", context));
  6419. },
  6420. function_missing_full: function function_missing_full(id, sourceInfo) {
  6421. if (sourceInfo) {
  6422. var context = [id, sourceInfo.line, sourceInfo.column];
  6423. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("function_missing_full", context));
  6424. } else {
  6425. return ProcessorErrorFactory.function_missing(id);
  6426. }
  6427. },
  6428. function_missing: function function_missing(id) {
  6429. var context = [id];
  6430. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("function_missing", context));
  6431. },
  6432. main_missing: function main_missing() {
  6433. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("main_missing"));
  6434. }, // TODO: better urgent error message
  6435. array_dimension_not_int_full: function array_dimension_not_int_full(sourceInfo) {
  6436. if (sourceInfo) {
  6437. var context = [sourceInfo.line];
  6438. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("array_dimension_not_int_full", context));
  6439. } else {
  6440. return ProcessorErrorFactory.array_dimension_not_int();
  6441. }
  6442. },
  6443. array_dimension_not_int: function array_dimension_not_int() {
  6444. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("array_dimension_not_int"));
  6445. },
  6446. unknown_command_full: function unknown_command_full(sourceInfo) {
  6447. if (sourceInfo) {
  6448. var context = [sourceInfo.line];
  6449. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("unknown_command_full", context));
  6450. } else {
  6451. return ProcessorErrorFactory.unknown_command();
  6452. }
  6453. },
  6454. unknown_command: function unknown_command() {
  6455. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("unknown_command"));
  6456. },
  6457. incompatible_types_full: function incompatible_types_full(type, dim, sourceInfo) {
  6458. if (sourceInfo) {
  6459. var context = [translateType(type, dim), sourceInfo.line, sourceInfo.column];
  6460. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("incompatible_types_full", context));
  6461. } else {
  6462. return ProcessorErrorFactory.incompatible_types(type, dim);
  6463. }
  6464. },
  6465. incompatible_types: function incompatible_types(type, dim) {
  6466. var context = [translateType(type, dim)];
  6467. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("incompatible_types", context));
  6468. },
  6469. incompatible_types_array_full: function incompatible_types_array_full(exp, type, dim, sourceInfo) {
  6470. if (sourceInfo) {
  6471. var context = [exp, translateType(type, dim), sourceInfo.line, sourceInfo.column];
  6472. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("incompatible_types_array_full", context));
  6473. } else {
  6474. return ProcessorErrorFactory.incompatible_types_array(exp, type, dim);
  6475. }
  6476. },
  6477. incompatible_types_array: function incompatible_types_array(exp, type, dim) {
  6478. var context = [exp, translateType(type, dim)];
  6479. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("incompatible_types_array", context));
  6480. },
  6481. loop_condition_type_full: function loop_condition_type_full(sourceInfo) {
  6482. if (sourceInfo) {
  6483. var context = [sourceInfo.line, sourceInfo.column];
  6484. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("loop_condition_type_full", context));
  6485. } else {
  6486. return ProcessorErrorFactory.loop_condition_type();
  6487. }
  6488. },
  6489. loop_condition_type: function loop_condition_type() {
  6490. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("loop_condition_type"));
  6491. },
  6492. endless_loop_full: function endless_loop_full(sourceInfo) {
  6493. if (sourceInfo) {
  6494. var context = [sourceInfo.line];
  6495. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("endless_loop_full", context));
  6496. } else {
  6497. return ProcessorErrorFactory.endless_loop();
  6498. }
  6499. },
  6500. endless_loop: function endless_loop() {
  6501. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("endless_loop"));
  6502. },
  6503. for_condition_type_full: function for_condition_type_full(sourceInfo) {
  6504. if (sourceInfo) {
  6505. var context = [sourceInfo.line, sourceInfo.column];
  6506. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("for_condition_type_full", context));
  6507. } else {
  6508. return ProcessorErrorFactory.for_condition_type();
  6509. }
  6510. },
  6511. for_condition_type: function for_condition_type() {
  6512. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("for_condition_type"));
  6513. },
  6514. if_condition_type_full: function if_condition_type_full(sourceInfo) {
  6515. if (sourceInfo) {
  6516. var context = [sourceInfo.line, sourceInfo.column];
  6517. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("if_condition_type_full", context));
  6518. } else {
  6519. return ProcessorErrorFactory.if_condition_type();
  6520. }
  6521. },
  6522. if_condition_type: function if_condition_type() {
  6523. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("if_condition_type"));
  6524. },
  6525. invalid_global_var: function invalid_global_var() {
  6526. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_global_var"));
  6527. },
  6528. not_implemented: function not_implemented(id) {
  6529. var context = [id];
  6530. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("not_implemented", context));
  6531. },
  6532. invalid_case_type_full: function invalid_case_type_full(exp, type, dim, sourceInfo) {
  6533. if (sourceInfo) {
  6534. var context = [exp, translateType(type, dim), sourceInfo.line, sourceInfo.column];
  6535. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_case_type_full", context));
  6536. } else {
  6537. return ProcessorErrorFactory.invalid_case_type(exp, type, dim);
  6538. }
  6539. },
  6540. invalid_case_type: function invalid_case_type(exp, type, dim) {
  6541. var context = [exp, translateType(type, dim)];
  6542. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_case_type", context));
  6543. },
  6544. void_in_expression_full: function void_in_expression_full(id, sourceInfo) {
  6545. if (sourceInfo) {
  6546. var context = [sourceInfo.line, sourceInfo.column, id];
  6547. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("void_in_expression_full", context));
  6548. } else {
  6549. return ProcessorErrorFactory.void_in_expression(id);
  6550. }
  6551. },
  6552. void_in_expression: function void_in_expression(id) {
  6553. var context = [id];
  6554. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("void_in_expression", context));
  6555. },
  6556. invalid_array_access_full: function invalid_array_access_full(id, sourceInfo) {
  6557. if (sourceInfo) {
  6558. var context = [id, sourceInfo.line, sourceInfo.column];
  6559. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_array_access_full", context));
  6560. } else {
  6561. return ProcessorErrorFactory.invalid_array_access(id);
  6562. }
  6563. },
  6564. invalid_array_access: function invalid_array_access(id) {
  6565. var context = [id];
  6566. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_array_access", context));
  6567. },
  6568. invalid_matrix_access_full: function invalid_matrix_access_full(id, sourceInfo) {
  6569. if (sourceInfo) {
  6570. var context = [id, sourceInfo.line, sourceInfo.column];
  6571. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_matrix_access_full", context));
  6572. } else {
  6573. return ProcessorErrorFactory.invalid_matrix_access(id);
  6574. }
  6575. },
  6576. invalid_matrix_access: function invalid_matrix_access(id) {
  6577. var context = [id];
  6578. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_matrix_access", context));
  6579. },
  6580. matrix_column_outbounds_full: function matrix_column_outbounds_full(id, value, columns, sourceInfo) {
  6581. if (sourceInfo) {
  6582. var context = [sourceInfo.line, value, id, columns];
  6583. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("matrix_column_outbounds_full", context));
  6584. } else {
  6585. return ProcessorErrorFactory.matrix_column_outbounds(id, value, columns);
  6586. }
  6587. },
  6588. matrix_column_outbounds: function matrix_column_outbounds(id, value, columns) {
  6589. var context = [value, id, columns];
  6590. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("matrix_column_outbounds", context));
  6591. },
  6592. matrix_line_outbounds_full: function matrix_line_outbounds_full(id, value, lines, sourceInfo) {
  6593. if (sourceInfo) {
  6594. var context = [sourceInfo.line, value, id, lines];
  6595. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("matrix_line_outbounds_full", context));
  6596. } else {
  6597. return ProcessorErrorFactory.matrix_line_outbounds(id, value, lines);
  6598. }
  6599. },
  6600. matrix_line_outbounds: function matrix_line_outbounds(id, value, lines) {
  6601. var context = [value, id, lines];
  6602. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("matrix_line_outbounds", context));
  6603. },
  6604. vector_line_outbounds_full: function vector_line_outbounds_full(id, value, lines, sourceInfo) {
  6605. if (sourceInfo) {
  6606. var context = [sourceInfo.line, value, id, lines];
  6607. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("vector_line_outbounds_full", context));
  6608. } else {
  6609. return ProcessorErrorFactory.vector_line_outbounds(id, value, lines);
  6610. }
  6611. },
  6612. vector_line_outbounds: function vector_line_outbounds(id, value, lines) {
  6613. var context = [value, id, lines];
  6614. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("vector_line_outbounds", context));
  6615. },
  6616. vector_not_matrix_full: function vector_not_matrix_full(id, sourceInfo) {
  6617. if (sourceInfo) {
  6618. var context = [sourceInfo.line, id];
  6619. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("vector_not_matrix_full", context));
  6620. } else {
  6621. return ProcessorErrorFactory.vector_not_matrix(id);
  6622. }
  6623. },
  6624. vector_not_matrix: function vector_not_matrix(id) {
  6625. var context = [id];
  6626. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("vector_not_matrix", context));
  6627. },
  6628. function_no_return: function function_no_return(id) {
  6629. var context = [id];
  6630. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("function_no_return", context));
  6631. },
  6632. invalid_void_return_full: function invalid_void_return_full(id, type, dim, sourceInfo) {
  6633. if (sourceInfo) {
  6634. var context = [sourceInfo.line, id, translateType(type, dim)];
  6635. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_void_return_full", context));
  6636. } else {
  6637. return ProcessorErrorFactory.invalid_void_return(id, type, dim);
  6638. }
  6639. },
  6640. invalid_void_return: function invalid_void_return(id, type, dim) {
  6641. var context = [id, translateType(type, dim)];
  6642. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_void_return_full", context));
  6643. },
  6644. invalid_return_type_full: function invalid_return_type_full(id, type, dim, sourceInfo) {
  6645. if (sourceInfo) {
  6646. var context = [sourceInfo.line, id, translateType(type, dim)];
  6647. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_return_type_full", context));
  6648. } else {
  6649. return ProcessorErrorFactory.invalid_return_type(id, type, dim);
  6650. }
  6651. },
  6652. invalid_return_type: function invalid_return_type(id, type, dim) {
  6653. var context = [id, translateType(type, dim)];
  6654. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_return_type", context));
  6655. },
  6656. invalid_parameters_size_full: function invalid_parameters_size_full(id, expected, actual, sourceInfo) {
  6657. if (sourceInfo) {
  6658. var context = [sourceInfo.line, id, expected, actual];
  6659. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_parameters_size_full", context));
  6660. } else {
  6661. return ProcessorErrorFactory.invalid_parameters_size(id, expected, actual);
  6662. }
  6663. },
  6664. invalid_parameters_size: function invalid_parameters_size(id, expected, actual) {
  6665. var context = [id, expected, actual];
  6666. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_parameters_size", context));
  6667. },
  6668. invalid_parameter_type_full: function invalid_parameter_type_full(id, exp, sourceInfo) {
  6669. if (sourceInfo) {
  6670. var context = [exp, id, sourceInfo.line];
  6671. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_parameter_type_full", context));
  6672. } else {
  6673. return ProcessorErrorFactory.invalid_parameter_type(id, exp);
  6674. }
  6675. },
  6676. invalid_parameter_type: function invalid_parameter_type(id, exp) {
  6677. var context = [exp, id];
  6678. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_parameter_type_full", context));
  6679. },
  6680. invalid_ref_full: function invalid_ref_full(id, exp, sourceInfo) {
  6681. if (sourceInfo) {
  6682. var context = [exp, id, sourceInfo.line];
  6683. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_ref_full", context));
  6684. } else {
  6685. return ProcessorErrorFactory.invalid_ref(id, exp);
  6686. }
  6687. },
  6688. invalid_ref: function invalid_ref(id, exp) {
  6689. var context = [exp, id];
  6690. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("invalid_ref", context));
  6691. },
  6692. unexpected_break_command_full: function unexpected_break_command_full(sourceInfo) {
  6693. if (sourceInfo) {
  6694. var context = [sourceInfo.line];
  6695. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("unexpected_break_command_full", context));
  6696. } else {
  6697. return ProcessorErrorFactory.unexpected_break_command();
  6698. }
  6699. },
  6700. unexpected_break_command: function unexpected_break_command() {
  6701. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("unexpected_break_command"));
  6702. },
  6703. invalid_array_literal_type_full: function invalid_array_literal_type_full(exp, sourceInfo) {
  6704. if (sourceInfo) {
  6705. var context = [sourceInfo.line, exp];
  6706. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_array_literal_type_full", context));
  6707. } else {
  6708. return ProcessorErrorFactory.invalid_array_literal_type(exp);
  6709. }
  6710. },
  6711. invalid_array_literal_type: function invalid_array_literal_type(exp) {
  6712. var context = [exp];
  6713. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_array_literal_type", context));
  6714. },
  6715. invalid_array_literal_line_full: function invalid_array_literal_line_full(expected, actual, sourceInfo) {
  6716. if (sourceInfo) {
  6717. var context = [sourceInfo.line, expected, actual];
  6718. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_array_literal_line_full", context));
  6719. } else {
  6720. return ProcessorErrorFactory.invalid_array_literal_type(expected, actual);
  6721. }
  6722. },
  6723. invalid_array_literal_line: function invalid_array_literal_line(expected, actual) {
  6724. var context = [expected, actual];
  6725. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_array_literal_line", context));
  6726. },
  6727. invalid_array_literal_column_full: function invalid_array_literal_column_full(expected, actual, sourceInfo) {
  6728. if (sourceInfo) {
  6729. var context = [sourceInfo.line, expected, actual];
  6730. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_array_literal_column_full", context));
  6731. } else {
  6732. return ProcessorErrorFactory.invalid_array_literal_column(expected, actual);
  6733. }
  6734. },
  6735. invalid_array_literal_column: function invalid_array_literal_column(expected, actual) {
  6736. var context = [expected, actual];
  6737. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_array_literal_column", context));
  6738. },
  6739. invalid_unary_op_full: function invalid_unary_op_full(opName, type, dim, sourceInfo) {
  6740. if (sourceInfo) {
  6741. var context = [sourceInfo.line, translateOp(opName), translateType(type, dim)];
  6742. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_unary_op_full", context));
  6743. } else {
  6744. return ProcessorErrorFactory.invalid_unary_op(opName, type, dim);
  6745. }
  6746. },
  6747. invalid_unary_op: function invalid_unary_op(opName, type, dim) {
  6748. var context = [translateOp(opName), translateType(type, dim)];
  6749. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_unary_op", context));
  6750. },
  6751. invalid_infix_op_full: function invalid_infix_op_full(opName, typeLeft, dimLeft, typeRight, dimRight, sourceInfo) {
  6752. if (sourceInfo) {
  6753. var context = [sourceInfo.line, translateOp(opName), translateType(typeLeft, dimLeft), translateType(typeRight, dimRight)];
  6754. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_infix_op_full", context));
  6755. } else {
  6756. return ProcessorErrorFactory.invalid_infix_op(opName, typeLeft, dimLeft, typeRight, dimRight);
  6757. }
  6758. },
  6759. invalid_infix_op: function invalid_infix_op(opName, typeLeft, dimLeft, typeRight, dimRight) {
  6760. var context = [translateOp(opName), translateType(typeLeft, dimLeft), translateType(typeRight, dimRight)];
  6761. return new _runtimeError.RuntimeError(_localizedStringsService.LocalizedStrings.getError("invalid_infix_op", context));
  6762. },
  6763. array_dimension_not_positive_full: function array_dimension_not_positive_full(sourceInfo) {
  6764. if (sourceInfo) {
  6765. var context = [sourceInfo.line];
  6766. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("array_dimension_not_positive_full", context));
  6767. } else {
  6768. return ProcessorErrorFactory.array_dimension_not_positive();
  6769. }
  6770. },
  6771. array_dimension_not_positive: function array_dimension_not_positive() {
  6772. return new _semanticError.SemanticError(_localizedStringsService.LocalizedStrings.getError("array_dimension_not_positive"));
  6773. }
  6774. });
  6775. /***/ }),
  6776. /***/ "./js/processor/error/runtimeError.js":
  6777. /*!********************************************!*\
  6778. !*** ./js/processor/error/runtimeError.js ***!
  6779. \********************************************/
  6780. /*! no static exports found */
  6781. /***/ (function(module, exports, __webpack_require__) {
  6782. "use strict";
  6783. Object.defineProperty(exports, "__esModule", {
  6784. value: true
  6785. });
  6786. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6787. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  6788. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6789. var RuntimeError = exports.RuntimeError = function (_Error) {
  6790. _inherits(RuntimeError, _Error);
  6791. function RuntimeError() {
  6792. var _ref;
  6793. _classCallCheck(this, RuntimeError);
  6794. for (var _len = arguments.length, msg = Array(_len), _key = 0; _key < _len; _key++) {
  6795. msg[_key] = arguments[_key];
  6796. }
  6797. var _this = _possibleConstructorReturn(this, (_ref = RuntimeError.__proto__ || Object.getPrototypeOf(RuntimeError)).call.apply(_ref, [this].concat(msg)));
  6798. if (Error.captureStackTrace) Error.captureStackTrace(_this, RuntimeError);
  6799. return _this;
  6800. }
  6801. return RuntimeError;
  6802. }(Error);
  6803. /***/ }),
  6804. /***/ "./js/processor/error/semanticError.js":
  6805. /*!*********************************************!*\
  6806. !*** ./js/processor/error/semanticError.js ***!
  6807. \*********************************************/
  6808. /*! no static exports found */
  6809. /***/ (function(module, exports, __webpack_require__) {
  6810. "use strict";
  6811. Object.defineProperty(exports, "__esModule", {
  6812. value: true
  6813. });
  6814. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6815. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  6816. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6817. var SemanticError = exports.SemanticError = function (_Error) {
  6818. _inherits(SemanticError, _Error);
  6819. function SemanticError() {
  6820. var _ref;
  6821. _classCallCheck(this, SemanticError);
  6822. for (var _len = arguments.length, msg = Array(_len), _key = 0; _key < _len; _key++) {
  6823. msg[_key] = arguments[_key];
  6824. }
  6825. var _this = _possibleConstructorReturn(this, (_ref = SemanticError.__proto__ || Object.getPrototypeOf(SemanticError)).call.apply(_ref, [this].concat(msg)));
  6826. if (Error.captureStackTrace) Error.captureStackTrace(_this, SemanticError);
  6827. return _this;
  6828. }
  6829. return SemanticError;
  6830. }(Error);
  6831. /***/ }),
  6832. /***/ "./js/processor/ivprogProcessor.js":
  6833. /*!*****************************************!*\
  6834. !*** ./js/processor/ivprogProcessor.js ***!
  6835. \*****************************************/
  6836. /*! no static exports found */
  6837. /***/ (function(module, exports, __webpack_require__) {
  6838. "use strict";
  6839. Object.defineProperty(exports, "__esModule", {
  6840. value: true
  6841. });
  6842. exports.IVProgProcessor = undefined;
  6843. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  6844. var _store = __webpack_require__(/*! ./store/store */ "./js/processor/store/store.js");
  6845. var _storeObject = __webpack_require__(/*! ./store/storeObject */ "./js/processor/store/storeObject.js");
  6846. var _storeObjectArray = __webpack_require__(/*! ./store/storeObjectArray */ "./js/processor/store/storeObjectArray.js");
  6847. var _storeObjectRef = __webpack_require__(/*! ./store/storeObjectRef */ "./js/processor/store/storeObjectRef.js");
  6848. var _modes = __webpack_require__(/*! ./modes */ "./js/processor/modes.js");
  6849. var _context = __webpack_require__(/*! ./context */ "./js/processor/context.js");
  6850. var _types = __webpack_require__(/*! ./../typeSystem/types */ "./js/typeSystem/types.js");
  6851. var _operators = __webpack_require__(/*! ./../ast/operators */ "./js/ast/operators.js");
  6852. var _definedFunctions = __webpack_require__(/*! ./definedFunctions */ "./js/processor/definedFunctions.js");
  6853. var _compatibilityTable = __webpack_require__(/*! ./compatibilityTable */ "./js/processor/compatibilityTable.js");
  6854. var _commands = __webpack_require__(/*! ./../ast/commands/ */ "./js/ast/commands/index.js");
  6855. var Commands = _interopRequireWildcard(_commands);
  6856. var _expressions = __webpack_require__(/*! ./../ast/expressions/ */ "./js/ast/expressions/index.js");
  6857. var Expressions = _interopRequireWildcard(_expressions);
  6858. var _storeObjectArrayAddress = __webpack_require__(/*! ./store/storeObjectArrayAddress */ "./js/processor/store/storeObjectArrayAddress.js");
  6859. var _storeObjectArrayAddressRef = __webpack_require__(/*! ./store/storeObjectArrayAddressRef */ "./js/processor/store/storeObjectArrayAddressRef.js");
  6860. var _compoundType = __webpack_require__(/*! ./../typeSystem/compoundType */ "./js/typeSystem/compoundType.js");
  6861. var _parsers = __webpack_require__(/*! ../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  6862. var _config = __webpack_require__(/*! ../util/config */ "./js/util/config.js");
  6863. var _decimal = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
  6864. var _decimal2 = _interopRequireDefault(_decimal);
  6865. var _processorErrorFactory = __webpack_require__(/*! ./error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
  6866. var _runtimeError = __webpack_require__(/*! ./error/runtimeError */ "./js/processor/error/runtimeError.js");
  6867. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6868. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  6869. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6870. var IVProgProcessor = exports.IVProgProcessor = function () {
  6871. _createClass(IVProgProcessor, null, [{
  6872. key: 'LOOP_TIMEOUT',
  6873. get: function get() {
  6874. return _config.Config.loopTimeout;
  6875. },
  6876. set: function set(ms) {
  6877. _config.Config.setConfig({ loopTimeout: ms });
  6878. }
  6879. }, {
  6880. key: 'MAIN_INTERNAL_ID',
  6881. get: function get() {
  6882. return "$main";
  6883. }
  6884. }]);
  6885. function IVProgProcessor(ast) {
  6886. _classCallCheck(this, IVProgProcessor);
  6887. this.ast = ast;
  6888. this.globalStore = new _store.Store("$global");
  6889. this.stores = [this.globalStore];
  6890. this.context = [_context.Context.BASE];
  6891. this.input = null;
  6892. this.forceKill = false;
  6893. this.loopTimers = [];
  6894. this.output = null;
  6895. }
  6896. _createClass(IVProgProcessor, [{
  6897. key: 'registerInput',
  6898. value: function registerInput(input) {
  6899. if (this.input !== null) this.input = null;
  6900. this.input = input;
  6901. }
  6902. }, {
  6903. key: 'registerOutput',
  6904. value: function registerOutput(output) {
  6905. if (this.output !== null) this.output = null;
  6906. this.output = output;
  6907. }
  6908. }, {
  6909. key: 'checkContext',
  6910. value: function checkContext(context) {
  6911. return this.context[this.context.length - 1] === context;
  6912. }
  6913. }, {
  6914. key: 'ignoreSwitchCases',
  6915. value: function ignoreSwitchCases(store) {
  6916. if (store.mode === _modes.Modes.RETURN) {
  6917. return true;
  6918. } else if (store.mode === _modes.Modes.BREAK) {
  6919. return true;
  6920. } else {
  6921. return false;
  6922. }
  6923. }
  6924. }, {
  6925. key: 'prepareState',
  6926. value: function prepareState() {
  6927. if (this.stores !== null) {
  6928. for (var i = 0; i < this.stores.length; i++) {
  6929. delete this.stores[i];
  6930. }
  6931. this.stores = null;
  6932. }
  6933. if (this.globalStore !== null) this.globalStore = null;
  6934. this.globalStore = new _store.Store("$global");
  6935. this.stores = [this.globalStore];
  6936. this.context = [_context.Context.BASE];
  6937. }
  6938. }, {
  6939. key: 'interpretAST',
  6940. value: function interpretAST() {
  6941. var _this = this;
  6942. this.prepareState();
  6943. return this.initGlobal().then(function (_) {
  6944. var mainFunc = _this.findMainFunction();
  6945. if (mainFunc === null) {
  6946. throw _processorErrorFactory.ProcessorErrorFactory.main_missing();
  6947. }
  6948. return _this.runFunction(mainFunc, [], _this.globalStore);
  6949. });
  6950. }
  6951. }, {
  6952. key: 'initGlobal',
  6953. value: function initGlobal() {
  6954. if (!this.checkContext(_context.Context.BASE)) {
  6955. throw _processorErrorFactory.ProcessorErrorFactory.invalid_global_var();
  6956. }
  6957. return this.executeCommands(this.globalStore, this.ast.global);
  6958. }
  6959. }, {
  6960. key: 'findMainFunction',
  6961. value: function findMainFunction() {
  6962. return this.ast.functions.find(function (v) {
  6963. return v.isMain;
  6964. });
  6965. }
  6966. }, {
  6967. key: 'findFunction',
  6968. value: function findFunction(name) {
  6969. if (name.match(/^\$.+$/)) {
  6970. var fun = _definedFunctions.LanguageDefinedFunction.getFunction(name);
  6971. if (!!!fun) {
  6972. throw _processorErrorFactory.ProcessorErrorFactory.not_implemented(name);
  6973. }
  6974. return fun;
  6975. } else {
  6976. var val = this.ast.functions.find(function (v) {
  6977. return v.name === name;
  6978. });
  6979. if (!!!val) {
  6980. // TODO: better error message;
  6981. throw _processorErrorFactory.ProcessorErrorFactory.function_missing(name);
  6982. }
  6983. return val;
  6984. }
  6985. }
  6986. }, {
  6987. key: 'runFunction',
  6988. value: function runFunction(func, actualParameters, store) {
  6989. var _this2 = this;
  6990. var funcName = func.isMain ? IVProgProcessor.MAIN_INTERNAL_ID : func.name;
  6991. var funcStore = new _store.Store(funcName);
  6992. funcStore.extendStore(this.globalStore);
  6993. var returnStoreObject = null;
  6994. if (func.returnType instanceof _compoundType.CompoundType) {
  6995. if (func.returnType.dimensions > 1) {
  6996. returnStoreObject = new _storeObjectArray.StoreObjectArray(func.returnType, -1, -1, [[]]);
  6997. } else {
  6998. returnStoreObject = new _storeObjectArray.StoreObjectArray(func.returnType, -1, null, []);
  6999. }
  7000. } else {
  7001. returnStoreObject = new _storeObject.StoreObject(func.returnType, null);
  7002. }
  7003. funcStore.insertStore('$', returnStoreObject);
  7004. var newFuncStore$ = this.associateParameters(func.formalParameters, actualParameters, store, funcStore);
  7005. return newFuncStore$.then(function (sto) {
  7006. _this2.context.push(_context.Context.FUNCTION);
  7007. _this2.stores.push(sto);
  7008. return _this2.executeCommands(sto, func.variablesDeclarations).then(function (stoWithVars) {
  7009. return _this2.executeCommands(stoWithVars, func.commands);
  7010. }).then(function (finalSto) {
  7011. _this2.stores.pop();
  7012. _this2.context.pop();
  7013. return finalSto;
  7014. });
  7015. });
  7016. }
  7017. }, {
  7018. key: 'associateParameters',
  7019. value: function associateParameters(formalList, actualList, callerStore, calleeStore) {
  7020. var _this3 = this;
  7021. var funcName = calleeStore.name === IVProgProcessor.MAIN_INTERNAL_ID ? _definedFunctions.LanguageDefinedFunction.getMainFunctionName() : calleeStore.name;
  7022. if (formalList.length != actualList.length) {
  7023. throw _processorErrorFactory.ProcessorErrorFactory.invalid_parameters_size(funcName, formalList.length, actualList.length);
  7024. }
  7025. var promises$ = actualList.map(function (actualParameter) {
  7026. return _this3.evaluateExpression(callerStore, actualParameter);
  7027. });
  7028. return Promise.all(promises$).then(function (values) {
  7029. for (var i = 0; i < values.length; i++) {
  7030. var stoObj = values[i];
  7031. var exp = actualList[i];
  7032. var shouldTypeCast = false;
  7033. var formalParameter = formalList[i];
  7034. if (!formalParameter.type.isCompatible(stoObj.type)) {
  7035. if (_config.Config.enable_type_casting && !formalParameter.byRef && _store.Store.canImplicitTypeCast(formalParameter.type, stoObj.type)) {
  7036. shouldTypeCast = true;
  7037. } else {
  7038. throw _processorErrorFactory.ProcessorErrorFactory.invalid_parameter_type(funcName, exp.toString());
  7039. }
  7040. }
  7041. if (formalParameter.byRef && !stoObj.inStore) {
  7042. throw _processorErrorFactory.ProcessorErrorFactory.invalid_ref(funcName, exp.toString());
  7043. }
  7044. if (formalParameter.byRef) {
  7045. var ref = null;
  7046. if (stoObj instanceof _storeObjectArrayAddress.StoreObjectArrayAddress) {
  7047. ref = new _storeObjectArrayAddressRef.StoreObjectArrayAddressRef(stoObj);
  7048. } else {
  7049. ref = new _storeObjectRef.StoreObjectRef(stoObj.id, callerStore);
  7050. }
  7051. calleeStore.insertStore(formalParameter.id, ref);
  7052. } else {
  7053. var realValue = _this3.parseStoreObjectValue(stoObj);
  7054. if (shouldTypeCast) {
  7055. realValue = _store.Store.doImplicitCasting(formalParameter.type, realValue);
  7056. }
  7057. calleeStore.insertStore(formalParameter.id, realValue);
  7058. }
  7059. }
  7060. return calleeStore;
  7061. });
  7062. }
  7063. }, {
  7064. key: 'executeCommands',
  7065. value: function executeCommands(store, cmds) {
  7066. // helper to partially apply a function, in this case executeCommand
  7067. var outerRef = this;
  7068. var partial = function partial(fun, cmd) {
  7069. return function (sto) {
  7070. return fun(sto, cmd);
  7071. };
  7072. };
  7073. return cmds.reduce(function (lastCommand, next) {
  7074. var nextCommand = partial(outerRef.executeCommand.bind(outerRef), next);
  7075. return lastCommand.then(nextCommand);
  7076. }, Promise.resolve(store));
  7077. }
  7078. }, {
  7079. key: 'executeCommand',
  7080. value: function executeCommand(store, cmd) {
  7081. if (this.forceKill) {
  7082. return Promise.reject("FORCED_KILL!");
  7083. } else if (store.mode === _modes.Modes.PAUSE) {
  7084. return Promise.resolve(this.executeCommand(store, cmd));
  7085. } else if (store.mode === _modes.Modes.RETURN) {
  7086. return Promise.resolve(store);
  7087. } else if (this.checkContext(_context.Context.BREAKABLE) && store.mode === _modes.Modes.BREAK) {
  7088. return Promise.resolve(store);
  7089. }
  7090. if (cmd instanceof Commands.Declaration) {
  7091. return this.executeDeclaration(store, cmd);
  7092. } else if (cmd instanceof Commands.ArrayIndexAssign) {
  7093. return this.executeArrayIndexAssign(store, cmd);
  7094. } else if (cmd instanceof Commands.Assign) {
  7095. return this.executeAssign(store, cmd);
  7096. } else if (cmd instanceof Commands.Break) {
  7097. return this.executeBreak(store, cmd);
  7098. } else if (cmd instanceof Commands.Return) {
  7099. return this.executeReturn(store, cmd);
  7100. } else if (cmd instanceof Commands.IfThenElse) {
  7101. return this.executeIfThenElse(store, cmd);
  7102. } else if (cmd instanceof Commands.DoWhile) {
  7103. return this.executeDoWhile(store, cmd);
  7104. } else if (cmd instanceof Commands.While) {
  7105. return this.executeWhile(store, cmd);
  7106. } else if (cmd instanceof Commands.For) {
  7107. return this.executeFor(store, cmd);
  7108. } else if (cmd instanceof Commands.Switch) {
  7109. return this.executeSwitch(store, cmd);
  7110. } else if (cmd instanceof Expressions.FunctionCall) {
  7111. return this.executeFunctionCall(store, cmd);
  7112. } else if (cmd instanceof Commands.SysCall) {
  7113. return this.executeSysCall(store, cmd);
  7114. } else {
  7115. throw _processorErrorFactory.ProcessorErrorFactory.unknown_command(cmd.sourceInfo);
  7116. }
  7117. }
  7118. }, {
  7119. key: 'executeSysCall',
  7120. value: function executeSysCall(store, cmd) {
  7121. var func = cmd.langFunc.bind(this);
  7122. return func(store, cmd);
  7123. }
  7124. }, {
  7125. key: 'executeFunctionCall',
  7126. value: function executeFunctionCall(store, cmd) {
  7127. var func = null;
  7128. if (cmd.isMainCall) {
  7129. func = this.findMainFunction();
  7130. } else {
  7131. func = this.findFunction(cmd.id);
  7132. }
  7133. return this.runFunction(func, cmd.actualParameters, store).then(function (sto) {
  7134. if (!_types.Types.VOID.isCompatible(func.returnType) && sto.mode !== _modes.Modes.RETURN) {
  7135. var funcName = func.name === IVProgProcessor.MAIN_INTERNAL_ID ? _definedFunctions.LanguageDefinedFunction.getMainFunctionName() : func.name;
  7136. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.function_no_return(funcName));
  7137. } else {
  7138. return store;
  7139. }
  7140. });
  7141. }
  7142. }, {
  7143. key: 'executeSwitch',
  7144. value: function executeSwitch(store, cmd) {
  7145. var _this4 = this;
  7146. this.context.push(_context.Context.BREAKABLE);
  7147. var auxCaseFun = function auxCaseFun(promise, switchExp, aCase) {
  7148. return promise.then(function (result) {
  7149. var sto = result.sto;
  7150. if (_this4.ignoreSwitchCases(sto)) {
  7151. return Promise.resolve(result);
  7152. } else if (result.wasTrue || aCase.isDefault) {
  7153. var $newSto = _this4.executeCommands(result.sto, aCase.commands);
  7154. return $newSto.then(function (nSto) {
  7155. return Promise.resolve({ wasTrue: true, sto: nSto });
  7156. });
  7157. } else {
  7158. var $value = _this4.evaluateExpression(sto, new Expressions.InfixApp(_operators.Operators.EQ, switchExp, aCase.expression));
  7159. return $value.then(function (vl) {
  7160. if (vl.value) {
  7161. var _$newSto = _this4.executeCommands(result.sto, aCase.commands);
  7162. return _$newSto.then(function (nSto) {
  7163. return Promise.resolve({ wasTrue: true, sto: nSto });
  7164. });
  7165. } else {
  7166. return Promise.resolve({ wasTrue: false, sto: sto });
  7167. }
  7168. });
  7169. }
  7170. });
  7171. };
  7172. try {
  7173. var breakLoop = false;
  7174. var $result = Promise.resolve({ wasTrue: false, sto: store });
  7175. for (var index = 0; index < cmd.cases.length && !breakLoop; index++) {
  7176. var aCase = cmd.cases[index];
  7177. $result = auxCaseFun($result, cmd.expression, aCase);
  7178. $result.then(function (r) {
  7179. return breakLoop = _this4.ignoreSwitchCases(r.sto);
  7180. });
  7181. }
  7182. return $result.then(function (r) {
  7183. _this4.context.pop();
  7184. if (r.sto.mode === _modes.Modes.BREAK) {
  7185. r.sto.mode = _modes.Modes.RUN;
  7186. }
  7187. return r.sto;
  7188. });
  7189. } catch (error) {
  7190. return Promise.reject(error);
  7191. }
  7192. }
  7193. }, {
  7194. key: 'executeFor',
  7195. value: function executeFor(store, cmd) {
  7196. try {
  7197. //BEGIN for -> while rewrite
  7198. var initCmd = cmd.assignment;
  7199. var condition = cmd.condition;
  7200. var increment = cmd.increment;
  7201. var whileBlock = new Commands.CommandBlock([], cmd.commands.concat(increment));
  7202. var forAsWhile = new Commands.While(condition, whileBlock);
  7203. forAsWhile.sourceInfo = cmd.sourceInfo;
  7204. //END for -> while rewrite
  7205. var newCmdList = [initCmd, forAsWhile];
  7206. return this.executeCommands(store, newCmdList);
  7207. } catch (error) {
  7208. return Promise.reject(error);
  7209. }
  7210. }
  7211. }, {
  7212. key: 'executeDoWhile',
  7213. value: function executeDoWhile(store, cmd) {
  7214. var outerRef = this;
  7215. try {
  7216. outerRef.loopTimers.push(Date.now());
  7217. outerRef.context.push(_context.Context.BREAKABLE);
  7218. var $newStore = outerRef.executeCommands(store, cmd.commands);
  7219. return $newStore.then(function (sto) {
  7220. if (sto.mode === _modes.Modes.BREAK) {
  7221. outerRef.context.pop();
  7222. sto.mode = _modes.Modes.RUN;
  7223. outerRef.loopTimers.pop();
  7224. return sto;
  7225. }
  7226. var $value = outerRef.evaluateExpression(sto, cmd.expression);
  7227. return $value.then(function (vl) {
  7228. if (!vl.type.isCompatible(_types.Types.BOOLEAN)) {
  7229. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.loop_condition_type_full(cmd.sourceInfo));
  7230. }
  7231. if (vl.value) {
  7232. outerRef.context.pop();
  7233. for (var i = 0; i < outerRef.loopTimers.length; i++) {
  7234. var time = outerRef.loopTimers[i];
  7235. if (Date.now() - time >= IVProgProcessor.LOOP_TIMEOUT) {
  7236. outerRef.forceKill = true;
  7237. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.endless_loop_full(cmd.sourceInfo));
  7238. }
  7239. }
  7240. return outerRef.executeCommand(sto, cmd);
  7241. } else {
  7242. outerRef.context.pop();
  7243. outerRef.loopTimers.pop();
  7244. return sto;
  7245. }
  7246. });
  7247. });
  7248. } catch (error) {
  7249. return Promise.reject(error);
  7250. }
  7251. }
  7252. }, {
  7253. key: 'executeWhile',
  7254. value: function executeWhile(store, cmd) {
  7255. var outerRef = this;
  7256. try {
  7257. outerRef.loopTimers.push(Date.now());
  7258. outerRef.context.push(_context.Context.BREAKABLE);
  7259. var $value = outerRef.evaluateExpression(store, cmd.expression);
  7260. return $value.then(function (vl) {
  7261. if (vl.type.isCompatible(_types.Types.BOOLEAN)) {
  7262. if (vl.value) {
  7263. var $newStore = outerRef.executeCommands(store, cmd.commands);
  7264. return $newStore.then(function (sto) {
  7265. outerRef.context.pop();
  7266. if (sto.mode === _modes.Modes.BREAK) {
  7267. outerRef.loopTimers.pop();
  7268. sto.mode = _modes.Modes.RUN;
  7269. return sto;
  7270. }
  7271. for (var i = 0; i < outerRef.loopTimers.length; i++) {
  7272. var time = outerRef.loopTimers[i];
  7273. if (Date.now() - time >= IVProgProcessor.LOOP_TIMEOUT) {
  7274. outerRef.forceKill = true;
  7275. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.endless_loop_full(cmd.sourceInfo));
  7276. }
  7277. }
  7278. return outerRef.executeCommand(sto, cmd);
  7279. });
  7280. } else {
  7281. outerRef.context.pop();
  7282. outerRef.loopTimers.pop();
  7283. return store;
  7284. }
  7285. } else {
  7286. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.loop_condition_type_full(cmd.sourceInfo));
  7287. }
  7288. });
  7289. } catch (error) {
  7290. return Promise.reject(error);
  7291. }
  7292. }
  7293. }, {
  7294. key: 'executeIfThenElse',
  7295. value: function executeIfThenElse(store, cmd) {
  7296. var _this5 = this;
  7297. try {
  7298. var $value = this.evaluateExpression(store, cmd.condition);
  7299. return $value.then(function (vl) {
  7300. if (vl.type.isCompatible(_types.Types.BOOLEAN)) {
  7301. if (vl.value) {
  7302. return _this5.executeCommands(store, cmd.ifTrue.commands);
  7303. } else if (cmd.ifFalse !== null) {
  7304. if (cmd.ifFalse instanceof Commands.IfThenElse) {
  7305. return _this5.executeCommand(store, cmd.ifFalse);
  7306. } else {
  7307. return _this5.executeCommands(store, cmd.ifFalse.commands);
  7308. }
  7309. } else {
  7310. return Promise.resolve(store);
  7311. }
  7312. } else {
  7313. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.if_condition_type_full(cmd.sourceInfo));
  7314. }
  7315. });
  7316. } catch (error) {
  7317. return Promise.reject(error);
  7318. }
  7319. }
  7320. }, {
  7321. key: 'executeReturn',
  7322. value: function executeReturn(store, cmd) {
  7323. var _this6 = this;
  7324. try {
  7325. var funcType = store.applyStore('$').type;
  7326. var $value = this.evaluateExpression(store, cmd.expression);
  7327. var funcName = store.name === IVProgProcessor.MAIN_INTERNAL_ID ? _definedFunctions.LanguageDefinedFunction.getMainFunctionName() : store.name;
  7328. return $value.then(function (vl) {
  7329. if (vl === null && funcType.isCompatible(_types.Types.VOID)) {
  7330. return Promise.resolve(store);
  7331. }
  7332. if (vl === null || !funcType.isCompatible(vl.type)) {
  7333. var stringInfo = funcType.stringInfo();
  7334. var info = stringInfo[0];
  7335. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_return_type_full(funcName, info.type, info.dim, cmd.sourceInfo));
  7336. } else {
  7337. var realValue = _this6.parseStoreObjectValue(vl);
  7338. store.updateStore('$', realValue);
  7339. store.mode = _modes.Modes.RETURN;
  7340. return Promise.resolve(store);
  7341. }
  7342. });
  7343. } catch (error) {
  7344. return Promise.reject(error);
  7345. }
  7346. }
  7347. }, {
  7348. key: 'executeBreak',
  7349. value: function executeBreak(store, cmd) {
  7350. if (this.checkContext(_context.Context.BREAKABLE)) {
  7351. store.mode = _modes.Modes.BREAK;
  7352. return Promise.resolve(store);
  7353. } else {
  7354. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.unexpected_break_command_full(cmd.sourceInfo));
  7355. }
  7356. }
  7357. }, {
  7358. key: 'executeAssign',
  7359. value: function executeAssign(store, cmd) {
  7360. var _this7 = this;
  7361. try {
  7362. var inStore = store.applyStore(cmd.id);
  7363. var $value = this.evaluateExpression(store, cmd.expression);
  7364. return $value.then(function (vl) {
  7365. var realValue = _this7.parseStoreObjectValue(vl);
  7366. if (!inStore.type.isCompatible(realValue.type)) {
  7367. if (_config.Config.enable_type_casting && _store.Store.canImplicitTypeCast(inStore.type, vl.type)) {
  7368. realValue = _store.Store.doImplicitCasting(inStore.type, realValue);
  7369. } else {
  7370. var stringInfo = inStore.type.stringInfo();
  7371. var info = stringInfo[0];
  7372. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.incompatible_types_full(info.type, info.dim, cmd.sourceInfo));
  7373. }
  7374. }
  7375. store.updateStore(cmd.id, realValue);
  7376. return store;
  7377. });
  7378. } catch (error) {
  7379. return Promise.reject(error);
  7380. }
  7381. }
  7382. }, {
  7383. key: 'executeArrayIndexAssign',
  7384. value: function executeArrayIndexAssign(store, cmd) {
  7385. var _this8 = this;
  7386. var mustBeArray = store.applyStore(cmd.id);
  7387. if (!(mustBeArray.type instanceof _compoundType.CompoundType)) {
  7388. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_array_access_full(cmd.id, cmd.sourceInfo));
  7389. }
  7390. var line$ = this.evaluateExpression(store, cmd.line);
  7391. var column$ = this.evaluateExpression(store, cmd.column);
  7392. var value$ = this.evaluateExpression(store, cmd.expression);
  7393. return Promise.all([line$, column$, value$]).then(function (results) {
  7394. var lineSO = results[0];
  7395. if (!_types.Types.INTEGER.isCompatible(lineSO.type)) {
  7396. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(cmd.sourceInfo));
  7397. }
  7398. var line = lineSO.number;
  7399. var columnSO = results[1];
  7400. var column = null;
  7401. if (columnSO !== null) {
  7402. if (!_types.Types.INTEGER.isCompatible(columnSO.type)) {
  7403. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(cmd.sourceInfo));
  7404. }
  7405. column = columnSO.number;
  7406. }
  7407. var value = _this8.parseStoreObjectValue(results[2]);
  7408. if (line >= mustBeArray.lines) {
  7409. if (mustBeArray.isVector) {
  7410. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.vector_line_outbounds_full(cmd.id, line, mustBeArray.lines, cmd.sourceInfo));
  7411. } else {
  7412. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.matrix_line_outbounds_full(cmd.id, line, mustBeArray.lines, cmd.sourceInfo));
  7413. }
  7414. } else if (line < 0) {
  7415. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_positive_full(cmd.sourceInfo);
  7416. }
  7417. if (column !== null && mustBeArray.columns === null) {
  7418. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.vector_not_matrix_full(cmd.id, cmd.sourceInfo));
  7419. }
  7420. if (column !== null) {
  7421. if (column >= mustBeArray.columns) {
  7422. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.matrix_column_outbounds_full(cmd.id, column, mustBeArray.columns, cmd.sourceInfo));
  7423. } else if (column < 0) {
  7424. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_positive_full(cmd.sourceInfo);
  7425. }
  7426. }
  7427. var newArray = Object.assign(new _storeObjectArray.StoreObjectArray(null, null, null), mustBeArray);
  7428. if (column !== null) {
  7429. if (value.type instanceof _compoundType.CompoundType || !newArray.type.canAccept(value.type)) {
  7430. var type = mustBeArray.type.innerType;
  7431. var stringInfo = type.stringInfo();
  7432. var info = stringInfo[0];
  7433. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.incompatible_types_full(info.type, info.dim, cmd.sourceInfo));
  7434. }
  7435. newArray.value[line].value[column] = value;
  7436. store.updateStore(cmd.id, newArray);
  7437. } else {
  7438. if (mustBeArray.columns !== null && value.type instanceof _compoundType.CompoundType || !newArray.type.canAccept(value.type)) {
  7439. var _type = mustBeArray.type;
  7440. var _stringInfo = _type.stringInfo();
  7441. var _info = _stringInfo[0];
  7442. var exp = cmd.expression.toString();
  7443. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.incompatible_types_array_full(exp, _info.type, _info.dim - 1, cmd.sourceInfo));
  7444. }
  7445. newArray.value[line] = value;
  7446. store.updateStore(cmd.id, newArray);
  7447. }
  7448. return store;
  7449. });
  7450. }
  7451. }, {
  7452. key: 'executeDeclaration',
  7453. value: function executeDeclaration(store, cmd) {
  7454. try {
  7455. var $value = this.evaluateExpression(store, cmd.initial);
  7456. if (cmd instanceof Commands.ArrayDeclaration) {
  7457. var $lines = this.evaluateExpression(store, cmd.lines);
  7458. var $columns = cmd.columns === null ? null : this.evaluateExpression(store, cmd.columns);
  7459. return Promise.all([$lines, $columns, $value]).then(function (values) {
  7460. var lineSO = values[0];
  7461. if (!_types.Types.INTEGER.isCompatible(lineSO.type)) {
  7462. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(cmd.sourceInfo));
  7463. }
  7464. var line = lineSO.number;
  7465. if (line < 0) {
  7466. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_positive_full(cmd.sourceInfo);
  7467. }
  7468. var columnSO = values[1];
  7469. var column = null;
  7470. if (columnSO !== null) {
  7471. if (!_types.Types.INTEGER.isCompatible(columnSO.type)) {
  7472. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(cmd.sourceInfo));
  7473. }
  7474. column = columnSO.number;
  7475. if (column < 0) {
  7476. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_positive_full(cmd.sourceInfo);
  7477. }
  7478. }
  7479. var value = values[2];
  7480. var temp = new _storeObjectArray.StoreObjectArray(cmd.type, line, column, null);
  7481. store.insertStore(cmd.id, temp);
  7482. var realValue = value;
  7483. if (value !== null) {
  7484. if (value instanceof _storeObjectArrayAddress.StoreObjectArrayAddress) {
  7485. if (value.type instanceof _compoundType.CompoundType) {
  7486. realValue = Object.assign(new _storeObjectArray.StoreObjectArray(null, null, null), value.refValue);
  7487. } else {
  7488. realValue = Object.assign(new _storeObject.StoreObject(null, null), value.refValue);
  7489. }
  7490. }
  7491. } else {
  7492. realValue = new _storeObjectArray.StoreObjectArray(cmd.type, line, column, []);
  7493. if (column !== null) {
  7494. for (var i = 0; i < line; i++) {
  7495. realValue.value.push(new _storeObjectArray.StoreObjectArray(new _compoundType.CompoundType(cmd.type.innerType, 1), column, null, []));
  7496. }
  7497. }
  7498. }
  7499. realValue.readOnly = cmd.isConst;
  7500. store.updateStore(cmd.id, realValue);
  7501. return store;
  7502. });
  7503. } else {
  7504. var temp = new _storeObject.StoreObject(cmd.type, null);
  7505. store.insertStore(cmd.id, temp);
  7506. return $value.then(function (vl) {
  7507. var realValue = vl;
  7508. if (vl !== null) {
  7509. if (!vl.type.isCompatible(cmd.type)) {
  7510. if (_config.Config.enable_type_casting && _store.Store.canImplicitTypeCast(cmd.type, vl.type)) {
  7511. realValue = _store.Store.doImplicitCasting(cmd.type, realValue);
  7512. } else {
  7513. var stringInfo = typeInfo.type.stringInfo();
  7514. var info = stringInfo[0];
  7515. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.incompatible_types_full(info.type, info.dim, cmd.sourceInfo));
  7516. }
  7517. }
  7518. if (vl instanceof _storeObjectArrayAddress.StoreObjectArrayAddress) {
  7519. if (vl.type instanceof _compoundType.CompoundType) {
  7520. return Promise.reject(new Error("!!!Critical Error: Compatibility check failed, a Type accepts a CompoundType"));
  7521. } else {
  7522. realValue = Object.assign(new _storeObject.StoreObject(null, null), vl.refValue);
  7523. }
  7524. }
  7525. } else {
  7526. realValue = new _storeObject.StoreObject(cmd.type, 0);
  7527. }
  7528. realValue.readOnly = cmd.isConst;
  7529. store.updateStore(cmd.id, realValue);
  7530. return store;
  7531. });
  7532. }
  7533. } catch (e) {
  7534. return Promise.reject(e);
  7535. }
  7536. }
  7537. }, {
  7538. key: 'evaluateExpression',
  7539. value: function evaluateExpression(store, exp) {
  7540. if (exp instanceof Expressions.UnaryApp) {
  7541. return this.evaluateUnaryApp(store, exp);
  7542. } else if (exp instanceof Expressions.InfixApp) {
  7543. return this.evaluateInfixApp(store, exp);
  7544. } else if (exp instanceof Expressions.ArrayAccess) {
  7545. return this.evaluateArrayAccess(store, exp);
  7546. } else if (exp instanceof Expressions.VariableLiteral) {
  7547. return this.evaluateVariableLiteral(store, exp);
  7548. } else if (exp instanceof Expressions.IntLiteral) {
  7549. return this.evaluateLiteral(store, exp);
  7550. } else if (exp instanceof Expressions.RealLiteral) {
  7551. return this.evaluateLiteral(store, exp);
  7552. } else if (exp instanceof Expressions.BoolLiteral) {
  7553. return this.evaluateLiteral(store, exp);
  7554. } else if (exp instanceof Expressions.StringLiteral) {
  7555. return this.evaluateLiteral(store, exp);
  7556. } else if (exp instanceof Expressions.ArrayLiteral) {
  7557. return this.evaluateArrayLiteral(store, exp);
  7558. } else if (exp instanceof Expressions.FunctionCall) {
  7559. return this.evaluateFunctionCall(store, exp);
  7560. }
  7561. return Promise.resolve(null);
  7562. }
  7563. }, {
  7564. key: 'evaluateFunctionCall',
  7565. value: function evaluateFunctionCall(store, exp) {
  7566. if (exp.isMainCall) {
  7567. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.void_in_expression_full(_definedFunctions.LanguageDefinedFunction.getMainFunctionName(), exp.sourceInfo));
  7568. }
  7569. var func = this.findFunction(exp.id);
  7570. if (_types.Types.VOID.isCompatible(func.returnType)) {
  7571. // TODO: better error message
  7572. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.void_in_expression_full(exp.id, exp.sourceInfo));
  7573. }
  7574. var $newStore = this.runFunction(func, exp.actualParameters, store);
  7575. return $newStore.then(function (sto) {
  7576. if (sto.mode !== _modes.Modes.RETURN) {
  7577. return Promise.reject(new Error("The function that was called did not had a return command: " + exp.id));
  7578. }
  7579. var val = sto.applyStore('$');
  7580. if (val instanceof _storeObjectArray.StoreObjectArray) {
  7581. return Promise.resolve(Object.assign(new _storeObjectArray.StoreObjectArray(null, null, null, null, null), val));
  7582. } else {
  7583. return Promise.resolve(Object.assign(new _storeObject.StoreObject(null, null), val));
  7584. }
  7585. });
  7586. }
  7587. }, {
  7588. key: 'evaluateArrayLiteral',
  7589. value: function evaluateArrayLiteral(store, exp) {
  7590. var errorHelperFunction = function errorHelperFunction(validationResult, exp) {
  7591. var errorCode = validationResult[0];
  7592. switch (errorCode) {
  7593. case _storeObjectArray.StoreObjectArray.WRONG_COLUMN_NUMBER:
  7594. {
  7595. var columnValue = validationResult[1];
  7596. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_array_literal_column_full(arr.columns, columnValue, exp.sourceInfo));
  7597. }
  7598. case _storeObjectArray.StoreObjectArray.WRONG_LINE_NUMBER:
  7599. {
  7600. var lineValue = validationResult[1];
  7601. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_array_literal_line_full(arr.lines, lineValue, exp.sourceInfo));
  7602. }
  7603. case _storeObjectArray.StoreObjectArray.WRONG_TYPE:
  7604. {
  7605. var line = null;
  7606. var strExp = null;
  7607. if (validationResult.length > 2) {
  7608. line = validationResult[1];
  7609. var column = validationResult[2];
  7610. strExp = exp.value[line].value[column].toString();
  7611. } else {
  7612. line = validationResult[1];
  7613. strExp = exp.value[line].toString();
  7614. }
  7615. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_array_literal_type_full(strExp, exp.sourceInfo));
  7616. }
  7617. }
  7618. };
  7619. if (!exp.isVector) {
  7620. var $matrix = this.evaluateMatrix(store, exp.value);
  7621. return $matrix.then(function (list) {
  7622. var type = new _compoundType.CompoundType(list[0].type.innerType, 2);
  7623. var arr = new _storeObjectArray.StoreObjectArray(type, list.length, list[0].lines, list);
  7624. var checkResult = arr.isValid;
  7625. if (checkResult.length == 0) return Promise.resolve(arr);else {
  7626. return errorHelperFunction(checkResult, exp);
  7627. }
  7628. });
  7629. } else {
  7630. return this.evaluateVector(store, exp.value).then(function (list) {
  7631. var type = new _compoundType.CompoundType(list[0].type, 1);
  7632. var stoArray = new _storeObjectArray.StoreObjectArray(type, list.length, null, list);
  7633. var checkResult = stoArray.isValid;
  7634. if (checkResult.length == 0) return Promise.resolve(stoArray);else {
  7635. return errorHelperFunction(checkResult, exp);
  7636. }
  7637. });
  7638. }
  7639. }
  7640. }, {
  7641. key: 'evaluateVector',
  7642. value: function evaluateVector(store, exps) {
  7643. var _this9 = this;
  7644. return Promise.all(exps.map(function (exp) {
  7645. return _this9.evaluateExpression(store, exp);
  7646. }));
  7647. }
  7648. }, {
  7649. key: 'evaluateMatrix',
  7650. value: function evaluateMatrix(store, exps) {
  7651. var _this10 = this;
  7652. return Promise.all(exps.map(function (vector) {
  7653. var $vector = _this10.evaluateVector(store, vector.value);
  7654. return $vector.then(function (list) {
  7655. var type = new _compoundType.CompoundType(list[0].type, 1);
  7656. return new _storeObjectArray.StoreObjectArray(type, list.length, null, list);
  7657. });
  7658. }));
  7659. }
  7660. }, {
  7661. key: 'evaluateLiteral',
  7662. value: function evaluateLiteral(_, exp) {
  7663. return Promise.resolve(new _storeObject.StoreObject(exp.type, exp.value));
  7664. }
  7665. }, {
  7666. key: 'evaluateVariableLiteral',
  7667. value: function evaluateVariableLiteral(store, exp) {
  7668. try {
  7669. var val = store.applyStore(exp.id);
  7670. if (val instanceof _storeObjectArray.StoreObjectArray) {
  7671. return Promise.resolve(Object.assign(new _storeObjectArray.StoreObjectArray(null, null, null, null), val));
  7672. } else {
  7673. return Promise.resolve(Object.assign(new _storeObject.StoreObject(null, null), val));
  7674. }
  7675. } catch (error) {
  7676. return Promise.reject(error);
  7677. }
  7678. }
  7679. }, {
  7680. key: 'evaluateArrayAccess',
  7681. value: function evaluateArrayAccess(store, exp) {
  7682. var mustBeArray = store.applyStore(exp.id);
  7683. if (!(mustBeArray.type instanceof _compoundType.CompoundType)) {
  7684. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_array_access_full(exp.id, exp.sourceInfo));
  7685. }
  7686. var $line = this.evaluateExpression(store, exp.line);
  7687. var $column = this.evaluateExpression(store, exp.column);
  7688. return Promise.all([$line, $column]).then(function (values) {
  7689. var lineSO = values[0];
  7690. var columnSO = values[1];
  7691. if (!_types.Types.INTEGER.isCompatible(lineSO.type)) {
  7692. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(exp.sourceInfo));
  7693. }
  7694. var line = lineSO.number;
  7695. var column = null;
  7696. if (columnSO !== null) {
  7697. if (!_types.Types.INTEGER.isCompatible(columnSO.type)) {
  7698. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(exp.sourceInfo));
  7699. }
  7700. column = columnSO.number;
  7701. }
  7702. if (line >= mustBeArray.lines) {
  7703. if (mustBeArray.isVector) {
  7704. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.vector_line_outbounds_full(exp.id, line, mustBeArray.lines, exp.sourceInfo));
  7705. } else {
  7706. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.matrix_line_outbounds_full(exp.id, line, mustBeArray.lines, exp.sourceInfo));
  7707. }
  7708. } else if (line < 0) {
  7709. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_positive_full(exp.sourceInfo);
  7710. }
  7711. if (column !== null && mustBeArray.columns === null) {
  7712. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.vector_not_matrix_full(exp.id, exp.sourceInfo));
  7713. }
  7714. if (column !== null) {
  7715. if (column >= mustBeArray.columns) {
  7716. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.matrix_column_outbounds_full(exp.id, column, mustBeArray.columns, exp.sourceInfo));
  7717. } else if (column < 0) {
  7718. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_positive_full(exp.sourceInfo);
  7719. }
  7720. }
  7721. return Promise.resolve(new _storeObjectArrayAddress.StoreObjectArrayAddress(mustBeArray.id, line, column, store));
  7722. });
  7723. }
  7724. }, {
  7725. key: 'evaluateUnaryApp',
  7726. value: function evaluateUnaryApp(store, unaryApp) {
  7727. var $left = this.evaluateExpression(store, unaryApp.left);
  7728. return $left.then(function (left) {
  7729. var resultType = (0, _compatibilityTable.resultTypeAfterUnaryOp)(unaryApp.op, left.type);
  7730. if (_types.Types.UNDEFINED.isCompatible(resultType)) {
  7731. var stringInfo = left.type.stringInfo();
  7732. var info = stringInfo[0];
  7733. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_unary_op_full(unaryApp.op, info.type, info.dim, unaryApp.sourceInfo));
  7734. }
  7735. switch (unaryApp.op.ord) {
  7736. case _operators.Operators.ADD.ord:
  7737. return new _storeObject.StoreObject(resultType, left.value);
  7738. case _operators.Operators.SUB.ord:
  7739. return new _storeObject.StoreObject(resultType, left.value.negated());
  7740. case _operators.Operators.NOT.ord:
  7741. return new _storeObject.StoreObject(resultType, !left.value);
  7742. default:
  7743. return Promise.reject(new _runtimeError.RuntimeError('!!!Critical Invalid UnaryApp ' + unaryApp.op));
  7744. }
  7745. });
  7746. }
  7747. }, {
  7748. key: 'evaluateInfixApp',
  7749. value: function evaluateInfixApp(store, infixApp) {
  7750. var $left = this.evaluateExpression(store, infixApp.left);
  7751. var $right = this.evaluateExpression(store, infixApp.right);
  7752. return Promise.all([$left, $right]).then(function (values) {
  7753. var shouldImplicitCast = false;
  7754. var left = values[0];
  7755. var right = values[1];
  7756. var resultType = (0, _compatibilityTable.resultTypeAfterInfixOp)(infixApp.op, left.type, right.type);
  7757. if (_types.Types.UNDEFINED.isCompatible(resultType)) {
  7758. if (_config.Config.enable_type_casting && _store.Store.canImplicitTypeCast(left.type, right.type)) {
  7759. shouldImplicitCast = true;
  7760. } else {
  7761. var stringInfoLeft = left.type.stringInfo();
  7762. var infoLeft = stringInfoLeft[0];
  7763. var stringInfoRight = right.type.stringInfo();
  7764. var infoRight = stringInfoRight[0];
  7765. return Promise.reject(_processorErrorFactory.ProcessorErrorFactory.invalid_infix_op_full(infixApp.op, infoLeft.type, infoLeft.dim, infoRight.type, infoRight.dim, infixApp.sourceInfo));
  7766. }
  7767. }
  7768. var result = null;
  7769. switch (infixApp.op.ord) {
  7770. case _operators.Operators.ADD.ord:
  7771. {
  7772. if (_types.Types.STRING.isCompatible(left.type)) {
  7773. var rightStr = (0, _parsers.convertToString)(right.value, right.type);
  7774. return new _storeObject.StoreObject(resultType, left.value + rightStr);
  7775. } else if (_types.Types.STRING.isCompatible(right.type)) {
  7776. var leftStr = (0, _parsers.convertToString)(left.value, left.type);
  7777. return new _storeObject.StoreObject(resultType, leftStr + right.value);
  7778. } else {
  7779. return new _storeObject.StoreObject(resultType, left.value.plus(right.value));
  7780. }
  7781. }
  7782. case _operators.Operators.SUB.ord:
  7783. return new _storeObject.StoreObject(resultType, left.value.minus(right.value));
  7784. case _operators.Operators.MULT.ord:
  7785. {
  7786. result = left.value.times(right.value);
  7787. if (result.dp() > _config.Config.decimalPlaces) {
  7788. result = new _decimal2.default(result.toFixed(_config.Config.decimalPlaces));
  7789. }
  7790. return new _storeObject.StoreObject(resultType, result);
  7791. }
  7792. case _operators.Operators.DIV.ord:
  7793. {
  7794. if (_types.Types.INTEGER.isCompatible(resultType)) result = left.value.divToInt(right.value);else result = left.value.div(right.value);
  7795. if (result.dp() > _config.Config.decimalPlaces) {
  7796. result = new _decimal2.default(result.toFixed(_config.Config.decimalPlaces));
  7797. }
  7798. return new _storeObject.StoreObject(resultType, result);
  7799. }
  7800. case _operators.Operators.MOD.ord:
  7801. {
  7802. var leftValue = left.value;
  7803. var rightValue = right.value;
  7804. if (shouldImplicitCast) {
  7805. resultType = _types.Types.INTEGER;
  7806. leftValue = leftValue.trunc();
  7807. rightValue = rightValue.trunc();
  7808. }
  7809. result = leftValue.modulo(rightValue);
  7810. if (result.dp() > _config.Config.decimalPlaces) {
  7811. result = new _decimal2.default(result.toFixed(_config.Config.decimalPlaces));
  7812. }
  7813. return new _storeObject.StoreObject(resultType, result);
  7814. }
  7815. case _operators.Operators.GT.ord:
  7816. {
  7817. var _leftValue = left.value;
  7818. var _rightValue = right.value;
  7819. if (_types.Types.STRING.isCompatible(left.type)) {
  7820. result = left.value.length > right.value.length;
  7821. } else {
  7822. if (shouldImplicitCast) {
  7823. resultType = _types.Types.BOOLEAN;
  7824. _leftValue = _leftValue.trunc();
  7825. _rightValue = _rightValue.trunc();
  7826. }
  7827. result = _leftValue.gt(_rightValue);
  7828. }
  7829. return new _storeObject.StoreObject(resultType, result);
  7830. }
  7831. case _operators.Operators.GE.ord:
  7832. {
  7833. var _leftValue2 = left.value;
  7834. var _rightValue2 = right.value;
  7835. if (_types.Types.STRING.isCompatible(left.type)) {
  7836. result = left.value.length >= right.value.length;
  7837. } else {
  7838. if (shouldImplicitCast) {
  7839. resultType = _types.Types.BOOLEAN;
  7840. _leftValue2 = _leftValue2.trunc();
  7841. _rightValue2 = _rightValue2.trunc();
  7842. }
  7843. result = _leftValue2.gte(_rightValue2);
  7844. }
  7845. return new _storeObject.StoreObject(resultType, result);
  7846. }
  7847. case _operators.Operators.LT.ord:
  7848. {
  7849. var _leftValue3 = left.value;
  7850. var _rightValue3 = right.value;
  7851. if (_types.Types.STRING.isCompatible(left.type)) {
  7852. result = left.value.length < right.value.length;
  7853. } else {
  7854. if (shouldImplicitCast) {
  7855. resultType = _types.Types.BOOLEAN;
  7856. _leftValue3 = _leftValue3.trunc();
  7857. _rightValue3 = _rightValue3.trunc();
  7858. }
  7859. result = _leftValue3.lt(_rightValue3);
  7860. }
  7861. return new _storeObject.StoreObject(resultType, result);
  7862. }
  7863. case _operators.Operators.LE.ord:
  7864. {
  7865. var _leftValue4 = left.value;
  7866. var _rightValue4 = right.value;
  7867. if (_types.Types.STRING.isCompatible(left.type)) {
  7868. result = left.value.length <= right.value.length;
  7869. } else {
  7870. if (shouldImplicitCast) {
  7871. resultType = _types.Types.BOOLEAN;
  7872. _leftValue4 = _leftValue4.trunc();
  7873. _rightValue4 = _rightValue4.trunc();
  7874. }
  7875. result = _leftValue4.lte(_rightValue4);
  7876. }
  7877. return new _storeObject.StoreObject(resultType, result);
  7878. }
  7879. case _operators.Operators.EQ.ord:
  7880. {
  7881. var _leftValue5 = left.value;
  7882. var _rightValue5 = right.value;
  7883. if (_types.Types.INTEGER.isCompatible(left.type) || _types.Types.REAL.isCompatible(left.type)) {
  7884. if (shouldImplicitCast) {
  7885. resultType = _types.Types.BOOLEAN;
  7886. _leftValue5 = _leftValue5.trunc();
  7887. _rightValue5 = _rightValue5.trunc();
  7888. }
  7889. result = _leftValue5.eq(_rightValue5);
  7890. } else {
  7891. result = left.value === right.value;
  7892. }
  7893. return new _storeObject.StoreObject(resultType, result);
  7894. }
  7895. case _operators.Operators.NEQ.ord:
  7896. {
  7897. var _leftValue6 = left.value;
  7898. var _rightValue6 = right.value;
  7899. if (_types.Types.INTEGER.isCompatible(left.type) || _types.Types.REAL.isCompatible(left.type)) {
  7900. if (shouldImplicitCast) {
  7901. resultType = _types.Types.BOOLEAN;
  7902. _leftValue6 = _leftValue6.trunc();
  7903. _rightValue6 = _rightValue6.trunc();
  7904. }
  7905. result = !_leftValue6.eq(_rightValue6);
  7906. } else {
  7907. result = left.value !== right.value;
  7908. }
  7909. return new _storeObject.StoreObject(resultType, result);
  7910. }
  7911. case _operators.Operators.AND.ord:
  7912. return new _storeObject.StoreObject(resultType, left.value && right.value);
  7913. case _operators.Operators.OR.ord:
  7914. return new _storeObject.StoreObject(resultType, left.value || right.value);
  7915. default:
  7916. return Promise.reject(new _runtimeError.RuntimeError('!!!Critical Invalid InfixApp ' + infixApp.op));
  7917. }
  7918. });
  7919. }
  7920. }, {
  7921. key: 'parseStoreObjectValue',
  7922. value: function parseStoreObjectValue(vl) {
  7923. var realValue = vl;
  7924. if (vl instanceof _storeObjectArrayAddress.StoreObjectArrayAddress) {
  7925. if (vl.type instanceof _compoundType.CompoundType) {
  7926. switch (vl.type.dimensions) {
  7927. case 1:
  7928. {
  7929. realValue = new _storeObjectArray.StoreObjectArray(vl.type, vl.value);
  7930. break;
  7931. }
  7932. default:
  7933. {
  7934. throw new _runtimeError.RuntimeError("Three dimensional array address...");
  7935. }
  7936. }
  7937. } else {
  7938. realValue = new _storeObject.StoreObject(vl.type, vl.value);
  7939. }
  7940. }
  7941. return realValue;
  7942. }
  7943. }]);
  7944. return IVProgProcessor;
  7945. }();
  7946. /***/ }),
  7947. /***/ "./js/processor/lib/arrays.js":
  7948. /*!************************************!*\
  7949. !*** ./js/processor/lib/arrays.js ***!
  7950. \************************************/
  7951. /*! no static exports found */
  7952. /***/ (function(module, exports, __webpack_require__) {
  7953. "use strict";
  7954. Object.defineProperty(exports, "__esModule", {
  7955. value: true
  7956. });
  7957. exports.createNumElementsFun = createNumElementsFun;
  7958. exports.createMatrixLinesFun = createMatrixLinesFun;
  7959. exports.createMatrixColumnsFun = createMatrixColumnsFun;
  7960. var _storeObject = __webpack_require__(/*! ../store/storeObject */ "./js/processor/store/storeObject.js");
  7961. var _commands = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
  7962. var Commands = _interopRequireWildcard(_commands);
  7963. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  7964. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  7965. var _compoundType = __webpack_require__(/*! ../../typeSystem/compoundType */ "./js/typeSystem/compoundType.js");
  7966. var _modes = __webpack_require__(/*! ../modes */ "./js/processor/modes.js");
  7967. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  7968. /**
  7969. * num_elements
  7970. * matrix_lines
  7971. * matrix_columns
  7972. */
  7973. function createNumElementsFun() {
  7974. var numElementsFun = function numElementsFun(sto, _) {
  7975. var vector = sto.applyStore("vector");
  7976. var temp = new _storeObject.StoreObject(_types.Types.INTEGER, (0, _parsers.toInt)(vector.lines));
  7977. sto.mode = _modes.Modes.RETURN;
  7978. return Promise.resolve(sto.updateStore("$", temp));
  7979. };
  7980. var block = new Commands.CommandBlock([], [new Commands.SysCall(numElementsFun)]);
  7981. var func = new Commands.Function('$numElements', _types.Types.INTEGER, [new Commands.FormalParameter(new _compoundType.CompoundType(_types.Types.ALL, 1), 'vector', false)], block);
  7982. return func;
  7983. }
  7984. function createMatrixLinesFun() {
  7985. var matrixLinesFun = function matrixLinesFun(sto, _) {
  7986. var matrix = sto.applyStore("matrix");
  7987. var temp = new _storeObject.StoreObject(_types.Types.INTEGER, (0, _parsers.toInt)(matrix.lines));
  7988. sto.mode = _modes.Modes.RETURN;
  7989. return Promise.resolve(sto.updateStore("$", temp));
  7990. };
  7991. var block = new Commands.CommandBlock([], [new Commands.SysCall(matrixLinesFun)]);
  7992. var func = new Commands.Function('$matrixLines', _types.Types.INTEGER, [new Commands.FormalParameter(new _compoundType.CompoundType(_types.Types.ALL, 2), 'matrix', false)], block);
  7993. return func;
  7994. }
  7995. function createMatrixColumnsFun() {
  7996. var matrixColumnsFun = function matrixColumnsFun(sto, _) {
  7997. var matrix = sto.applyStore("matrix");
  7998. var temp = new _storeObject.StoreObject(_types.Types.INTEGER, (0, _parsers.toInt)(matrix.columns));
  7999. sto.mode = _modes.Modes.RETURN;
  8000. return Promise.resolve(sto.updateStore("$", temp));
  8001. };
  8002. var block = new Commands.CommandBlock([], [new Commands.SysCall(matrixColumnsFun)]);
  8003. var func = new Commands.Function('$matrixColumns', _types.Types.INTEGER, [new Commands.FormalParameter(new _compoundType.CompoundType(_types.Types.ALL, 2), 'matrix', false)], block);
  8004. return func;
  8005. }
  8006. /***/ }),
  8007. /***/ "./js/processor/lib/io.js":
  8008. /*!********************************!*\
  8009. !*** ./js/processor/lib/io.js ***!
  8010. \********************************/
  8011. /*! no static exports found */
  8012. /***/ (function(module, exports, __webpack_require__) {
  8013. "use strict";
  8014. Object.defineProperty(exports, "__esModule", {
  8015. value: true
  8016. });
  8017. exports.createOutputFun = createOutputFun;
  8018. exports.createInputFun = createInputFun;
  8019. var _storeObject = __webpack_require__(/*! ./../store/storeObject */ "./js/processor/store/storeObject.js");
  8020. var _commands = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
  8021. var Commands = _interopRequireWildcard(_commands);
  8022. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  8023. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  8024. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  8025. function createOutputFun() {
  8026. var writeFunction = function writeFunction(store, _) {
  8027. var val = store.applyStore('p1');
  8028. this.output.sendOutput((0, _parsers.convertToString)(val.value, val.type));
  8029. return Promise.resolve(store);
  8030. };
  8031. var block = new Commands.CommandBlock([], [new Commands.SysCall(writeFunction)]);
  8032. var func = new Commands.Function('$write', _types.Types.VOID, [new Commands.FormalParameter(_types.Types.ALL, 'p1', false)], block);
  8033. return func;
  8034. }
  8035. function createInputFun() {
  8036. var readFunction = function readFunction(store, _) {
  8037. var _this = this;
  8038. var request = new Promise(function (resolve, _) {
  8039. _this.input.requestInput(resolve);
  8040. });
  8041. return request.then(function (text) {
  8042. var typeToConvert = store.applyStore('p1').type;
  8043. var stoObj = null;
  8044. if (typeToConvert.isCompatible(_types.Types.INTEGER)) {
  8045. var val = (0, _parsers.toInt)(text);
  8046. stoObj = new _storeObject.StoreObject(_types.Types.INTEGER, val.trunc());
  8047. } else if (typeToConvert.isCompatible(_types.Types.REAL)) {
  8048. stoObj = new _storeObject.StoreObject(_types.Types.REAL, (0, _parsers.toReal)(text));
  8049. } else if (typeToConvert.isCompatible(_types.Types.BOOLEAN)) {
  8050. stoObj = new _storeObject.StoreObject(_types.Types.BOOLEAN, (0, _parsers.toBool)(text));
  8051. } else if (typeToConvert.isCompatible(_types.Types.STRING)) {
  8052. stoObj = new _storeObject.StoreObject(_types.Types.STRING, (0, _parsers.toString)(text));
  8053. }
  8054. _this.loopTimers.splice(0, _this.loopTimers.length);
  8055. store.updateStore('p1', stoObj);
  8056. return Promise.resolve(store);
  8057. });
  8058. };
  8059. var block = new Commands.CommandBlock([], [new Commands.SysCall(readFunction)]);
  8060. var func = new Commands.Function('$read', _types.Types.VOID, [new Commands.FormalParameter(_types.Types.ALL, 'p1', true)], block);
  8061. return func;
  8062. }
  8063. /***/ }),
  8064. /***/ "./js/processor/lib/lang.js":
  8065. /*!**********************************!*\
  8066. !*** ./js/processor/lib/lang.js ***!
  8067. \**********************************/
  8068. /*! no static exports found */
  8069. /***/ (function(module, exports, __webpack_require__) {
  8070. "use strict";
  8071. Object.defineProperty(exports, "__esModule", {
  8072. value: true
  8073. });
  8074. exports.createIsRealFun = createIsRealFun;
  8075. exports.createIsIntFun = createIsIntFun;
  8076. exports.createIsBoolFun = createIsBoolFun;
  8077. exports.createCastRealFun = createCastRealFun;
  8078. exports.createCastIntFun = createCastIntFun;
  8079. exports.createCastBoolFun = createCastBoolFun;
  8080. exports.createCastStringFun = createCastStringFun;
  8081. var _storeObject = __webpack_require__(/*! ../store/storeObject */ "./js/processor/store/storeObject.js");
  8082. var _commands = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
  8083. var Commands = _interopRequireWildcard(_commands);
  8084. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  8085. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  8086. var _ivprogParser = __webpack_require__(/*! ../../ast/ivprogParser */ "./js/ast/ivprogParser.js");
  8087. var _expressions = __webpack_require__(/*! ../../ast/expressions */ "./js/ast/expressions/index.js");
  8088. var _modes = __webpack_require__(/*! ../modes */ "./js/processor/modes.js");
  8089. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  8090. /**
  8091. *
  8092. * is_real
  8093. * is_int
  8094. * is_bool
  8095. * cast_real
  8096. * cast_int
  8097. * cast_bool
  8098. * cast_string
  8099. */
  8100. function createIsRealFun() {
  8101. var isRealFun = function isRealFun(sto, _) {
  8102. var str = sto.applyStore("str");
  8103. var parser = _ivprogParser.IVProgParser.createParser(str.value);
  8104. var result = false;
  8105. try {
  8106. var val = parser.parseTerm();
  8107. if (val instanceof _expressions.RealLiteral) {
  8108. result = true;
  8109. }
  8110. } catch (error) {}
  8111. var temp = new _storeObject.StoreObject(_types.Types.BOOLEAN, result);
  8112. sto.mode = _modes.Modes.RETURN;
  8113. return Promise.resolve(sto.updateStore("$", temp));
  8114. };
  8115. var block = new Commands.CommandBlock([], [new Commands.SysCall(isRealFun)]);
  8116. var func = new Commands.Function('$isReal', _types.Types.BOOLEAN, [new Commands.FormalParameter(_types.Types.STRING, 'str', false)], block);
  8117. return func;
  8118. }
  8119. function createIsIntFun() {
  8120. var isIntFun = function isIntFun(sto, _) {
  8121. var str = sto.applyStore("str");
  8122. var parser = _ivprogParser.IVProgParser.createParser(str.value);
  8123. var result = false;
  8124. try {
  8125. var val = parser.parseTerm();
  8126. if (val instanceof _expressions.IntLiteral) {
  8127. result = true;
  8128. }
  8129. } catch (error) {}
  8130. var temp = new _storeObject.StoreObject(_types.Types.BOOLEAN, result);
  8131. sto.mode = _modes.Modes.RETURN;
  8132. return Promise.resolve(sto.updateStore("$", temp));
  8133. };
  8134. var block = new Commands.CommandBlock([], [new Commands.SysCall(isIntFun)]);
  8135. var func = new Commands.Function('$isInt', _types.Types.BOOLEAN, [new Commands.FormalParameter(_types.Types.STRING, 'str', false)], block);
  8136. return func;
  8137. }
  8138. function createIsBoolFun() {
  8139. var isBoolFun = function isBoolFun(sto, _) {
  8140. var str = sto.applyStore("str");
  8141. var parser = _ivprogParser.IVProgParser.createParser(str.value);
  8142. var result = false;
  8143. try {
  8144. var val = parser.parseTerm();
  8145. if (val instanceof _expressions.BoolLiteral) {
  8146. result = true;
  8147. }
  8148. } catch (error) {}
  8149. var temp = new _storeObject.StoreObject(_types.Types.BOOLEAN, result);
  8150. sto.mode = _modes.Modes.RETURN;
  8151. return Promise.resolve(sto.updateStore("$", temp));
  8152. };
  8153. var block = new Commands.CommandBlock([], [new Commands.SysCall(isBoolFun)]);
  8154. var func = new Commands.Function('$isBool', _types.Types.BOOLEAN, [new Commands.FormalParameter(_types.Types.STRING, 'str', false)], block);
  8155. return func;
  8156. }
  8157. function createCastRealFun() {
  8158. var castRealFun = function castRealFun(sto, _) {
  8159. var val = sto.applyStore("val");
  8160. switch (val.type.ord) {
  8161. case _types.Types.INTEGER.ord:
  8162. {
  8163. var temp = new _storeObject.StoreObject(_types.Types.REAL, (0, _parsers.toReal)(val.number));
  8164. sto.mode = _modes.Modes.RETURN;
  8165. return Promise.resolve(sto.updateStore("$", temp));
  8166. }
  8167. case _types.Types.STRING.ord:
  8168. {
  8169. var parser = _ivprogParser.IVProgParser.createParser(val.value);
  8170. try {
  8171. var result = parser.parseTerm();
  8172. if (result instanceof _expressions.RealLiteral) {
  8173. var _temp = new _storeObject.StoreObject(_types.Types.REAL, result.value);
  8174. sto.mode = _modes.Modes.RETURN;
  8175. return Promise.resolve(sto.updateStore("$", _temp));
  8176. }
  8177. } catch (error) {
  8178. return Promise.reject("cannot convert string to real");
  8179. }
  8180. }
  8181. }
  8182. };
  8183. var block = new Commands.CommandBlock([], [new Commands.SysCall(castRealFun)]);
  8184. var func = new Commands.Function('$castReal', _types.Types.REAL, [new Commands.FormalParameter(_types.Types.ALL, 'val', false)], block);
  8185. return func;
  8186. }
  8187. function createCastIntFun() {
  8188. var castIntFun = function castIntFun(sto, _) {
  8189. var val = sto.applyStore("val");
  8190. switch (val.type.ord) {
  8191. case _types.Types.REAL.ord:
  8192. {
  8193. var temp = new _storeObject.StoreObject(_types.Types.INTEGER, Math.floor(val.number));
  8194. sto.mode = _modes.Modes.RETURN;
  8195. return Promise.resolve(sto.updateStore("$", temp));
  8196. }
  8197. case _types.Types.STRING.ord:
  8198. {
  8199. var parser = _ivprogParser.IVProgParser.createParser(val.value);
  8200. try {
  8201. var result = parser.parseTerm();
  8202. if (result instanceof _expressions.IntLiteral) {
  8203. var _temp2 = new _storeObject.StoreObject(_types.Types.INTEGER, result.value);
  8204. sto.mode = _modes.Modes.RETURN;
  8205. return Promise.resolve(sto.updateStore("$", _temp2));
  8206. }
  8207. } catch (error) {
  8208. return Promise.reject("cannot convert string to real");
  8209. }
  8210. }
  8211. }
  8212. };
  8213. var block = new Commands.CommandBlock([], [new Commands.SysCall(castIntFun)]);
  8214. var func = new Commands.Function('$castInt', _types.Types.INTEGER, [new Commands.FormalParameter(_types.Types.ALL, 'val', false)], block);
  8215. return func;
  8216. }
  8217. function createCastBoolFun() {
  8218. var castBoolFun = function castBoolFun(sto, _) {
  8219. var str = sto.applyStore("str");
  8220. var parser = _ivprogParser.IVProgParser.createParser(str.value);
  8221. try {
  8222. var val = parser.parseTerm();
  8223. if (val instanceof _expressions.BoolLiteral) {
  8224. var temp = new _storeObject.StoreObject(_types.Types.BOOLEAN, val.value);
  8225. sto.mode = _modes.Modes.RETURN;
  8226. return Promise.resolve(sto.updateStore("$", temp));
  8227. }
  8228. } catch (error) {}
  8229. return Promise.reject("cannot convert " + str.value + " to boolean");
  8230. };
  8231. var block = new Commands.CommandBlock([], [new Commands.SysCall(castBoolFun)]);
  8232. var func = new Commands.Function('$castBool', _types.Types.BOOLEAN, [new Commands.FormalParameter(_types.Types.STRING, 'str', false)], block);
  8233. return func;
  8234. }
  8235. function createCastStringFun() {
  8236. var castStringFun = function castStringFun(store, _) {
  8237. var val = store.applyStore('str');
  8238. var result = (0, _parsers.convertToString)(val);
  8239. var temp = new _storeObject.StoreObject(_types.Types.STRING, result);
  8240. sto.mode = _modes.Modes.RETURN;
  8241. return Promise.resolve(sto.updateStore("$", temp));
  8242. };
  8243. var block = new Commands.CommandBlock([], [new Commands.SysCall(castStringFun)]);
  8244. var func = new Commands.Function('$castString', _types.Types.STRING, [new Commands.FormalParameter(_types.Types.ALL, 'str', false)], block);
  8245. return func;
  8246. }
  8247. /***/ }),
  8248. /***/ "./js/processor/lib/math.js":
  8249. /*!**********************************!*\
  8250. !*** ./js/processor/lib/math.js ***!
  8251. \**********************************/
  8252. /*! no static exports found */
  8253. /***/ (function(module, exports, __webpack_require__) {
  8254. "use strict";
  8255. Object.defineProperty(exports, "__esModule", {
  8256. value: true
  8257. });
  8258. exports.createSinFun = createSinFun;
  8259. exports.createCosFun = createCosFun;
  8260. exports.createTanFun = createTanFun;
  8261. exports.createSqrtFun = createSqrtFun;
  8262. exports.createPowFun = createPowFun;
  8263. exports.createLogFun = createLogFun;
  8264. exports.createAbsFun = createAbsFun;
  8265. exports.createNegateFun = createNegateFun;
  8266. exports.createInvertFun = createInvertFun;
  8267. exports.createMaxFun = createMaxFun;
  8268. exports.createMinFun = createMinFun;
  8269. var _storeObject = __webpack_require__(/*! ../store/storeObject */ "./js/processor/store/storeObject.js");
  8270. var _commands = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
  8271. var Commands = _interopRequireWildcard(_commands);
  8272. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  8273. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  8274. var _decimal = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
  8275. var _multiType = __webpack_require__(/*! ../../typeSystem/multiType */ "./js/typeSystem/multiType.js");
  8276. var _compoundType = __webpack_require__(/*! ../../typeSystem/compoundType */ "./js/typeSystem/compoundType.js");
  8277. var _modes = __webpack_require__(/*! ../modes */ "./js/processor/modes.js");
  8278. var _config = __webpack_require__(/*! ../../util/config */ "./js/util/config.js");
  8279. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  8280. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  8281. /**
  8282. * sin
  8283. * cos
  8284. * tan
  8285. * sqrt
  8286. * pow
  8287. * log
  8288. * abs
  8289. * negate
  8290. * invert
  8291. * max
  8292. * min
  8293. */
  8294. function convertToRadians(degrees) {
  8295. return degrees.times(_decimal.Decimal.acos(-1)).div(180);
  8296. }
  8297. function createSinFun() {
  8298. var sinFun = function sinFun(sto, _) {
  8299. var x = sto.applyStore('x');
  8300. var angle = x.value.mod(360);
  8301. var result = null;
  8302. if (angle.eq(90)) {
  8303. result = new _decimal.Decimal(1);
  8304. } else if (angle.eq(180)) {
  8305. result = new _decimal.Decimal(0);
  8306. } else if (angle.eq(270)) {
  8307. result = new _decimal.Decimal(-1);
  8308. } else {
  8309. result = _decimal.Decimal.sin(convertToRadians(angle));
  8310. }
  8311. if (result.dp() > _config.Config.decimalPlaces) {
  8312. result = new _decimal.Decimal(result.toFixed(_config.Config.decimalPlaces));
  8313. }
  8314. var temp = new _storeObject.StoreObject(_types.Types.REAL, result);
  8315. sto.mode = _modes.Modes.RETURN;
  8316. return Promise.resolve(sto.updateStore('$', temp));
  8317. };
  8318. var block = new Commands.CommandBlock([], [new Commands.SysCall(sinFun)]);
  8319. var func = new Commands.Function('$sin', _types.Types.REAL, [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8320. return func;
  8321. }
  8322. function createCosFun() {
  8323. var cosFun = function cosFun(sto, _) {
  8324. var x = sto.applyStore('x');
  8325. var angle = x.value.mod(360);
  8326. var result = null;
  8327. if (angle.eq(90)) {
  8328. result = new _decimal.Decimal(0);
  8329. } else if (angle.eq(180)) {
  8330. result = new _decimal.Decimal(-1);
  8331. } else if (angle.eq(270)) {
  8332. result = new _decimal.Decimal(0);
  8333. }
  8334. result = _decimal.Decimal.cos(convertToRadians(angle));
  8335. if (result.dp() > _config.Config.decimalPlaces) {
  8336. result = new _decimal.Decimal(result.toFixed(_config.Config.decimalPlaces));
  8337. }
  8338. var temp = new _storeObject.StoreObject(_types.Types.REAL, result);
  8339. sto.mode = _modes.Modes.RETURN;
  8340. return Promise.resolve(sto.updateStore('$', temp));
  8341. };
  8342. var block = new Commands.CommandBlock([], [new Commands.SysCall(cosFun)]);
  8343. var func = new Commands.Function('$cos', _types.Types.REAL, [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8344. return func;
  8345. }
  8346. function createTanFun() {
  8347. var tanFun = function tanFun(sto, _) {
  8348. var x = sto.applyStore('x');
  8349. var angle = x.value.mod(360);
  8350. if (angle.eq(90) || angle.eq(270)) {
  8351. return Promise.reject("Tangent of " + x.value.toNumber() + "° is undefined.");
  8352. }
  8353. var result = _decimal.Decimal.tan(convertToRadians(angle));
  8354. if (result.dp() > _config.Config.decimalPlaces) {
  8355. result = new _decimal.Decimal(result.toFixed(_config.Config.decimalPlaces));
  8356. }
  8357. var temp = new _storeObject.StoreObject(_types.Types.REAL, result);
  8358. sto.mode = _modes.Modes.RETURN;
  8359. return Promise.resolve(sto.updateStore('$', temp));
  8360. };
  8361. var block = new Commands.CommandBlock([], [new Commands.SysCall(tanFun)]);
  8362. var func = new Commands.Function('$tan', _types.Types.REAL, [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8363. return func;
  8364. }
  8365. function createSqrtFun() {
  8366. var sqrtFun = function sqrtFun(sto, _) {
  8367. var x = sto.applyStore('x');
  8368. var result = x.value.sqrt();
  8369. if (result.dp() > _config.Config.decimalPlaces) {
  8370. result = new _decimal.Decimal(result.toFixed(_config.Config.decimalPlaces));
  8371. }
  8372. var temp = new _storeObject.StoreObject(_types.Types.REAL, result);
  8373. sto.mode = _modes.Modes.RETURN;
  8374. return Promise.resolve(sto.updateStore('$', temp));
  8375. };
  8376. var block = new Commands.CommandBlock([], [new Commands.SysCall(sqrtFun)]);
  8377. var func = new Commands.Function('$sqrt', _types.Types.REAL, [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8378. return func;
  8379. }
  8380. function createPowFun() {
  8381. var powFun = function powFun(sto, _) {
  8382. var x = sto.applyStore('x');
  8383. var y = sto.applyStore('y');
  8384. var result = x.value.pow(y.value);
  8385. if (result.dp() > _config.Config.decimalPlaces) {
  8386. result = new _decimal.Decimal(result.toFixed(_config.Config.decimalPlaces));
  8387. }
  8388. var temp = new _storeObject.StoreObject(_types.Types.REAL, result);
  8389. sto.mode = _modes.Modes.RETURN;
  8390. return Promise.resolve(sto.updateStore('$', temp));
  8391. };
  8392. var block = new Commands.CommandBlock([], [new Commands.SysCall(powFun)]);
  8393. var func = new Commands.Function('$pow', _types.Types.REAL, [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false), new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'y', false)], block);
  8394. return func;
  8395. }
  8396. function createLogFun() {
  8397. var logFun = function logFun(sto, _) {
  8398. var x = sto.applyStore('x');
  8399. if (x.value.isNegative()) {
  8400. return Promise.reject("the value passed to log function cannot be negative");
  8401. }
  8402. var result = _decimal.Decimal.log10(x.value);
  8403. if (result.dp() > _config.Config.decimalPlaces) {
  8404. result = new _decimal.Decimal(result.toFixed(_config.Config.decimalPlaces));
  8405. }
  8406. var temp = new _storeObject.StoreObject(_types.Types.REAL, result);
  8407. sto.mode = _modes.Modes.RETURN;
  8408. return Promise.resolve(sto.updateStore('$', temp));
  8409. };
  8410. var block = new Commands.CommandBlock([], [new Commands.SysCall(logFun)]);
  8411. var func = new Commands.Function('$log', _types.Types.REAL, [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8412. return func;
  8413. }
  8414. function createAbsFun() {
  8415. var absFun = function absFun(sto, _) {
  8416. var x = sto.applyStore('x');
  8417. var result = x.value.abs();
  8418. var temp = new _storeObject.StoreObject(x.type, result);
  8419. sto.mode = _modes.Modes.RETURN;
  8420. return Promise.resolve(sto.updateStore('$', temp));
  8421. };
  8422. var block = new Commands.CommandBlock([], [new Commands.SysCall(absFun)]);
  8423. var func = new Commands.Function('$abs', new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8424. return func;
  8425. }
  8426. function createNegateFun() {
  8427. var negateFun = function negateFun(sto, _) {
  8428. var x = sto.applyStore('x');
  8429. var result = x.value.negated();
  8430. var temp = new _storeObject.StoreObject(x.type, result);
  8431. sto.mode = _modes.Modes.RETURN;
  8432. return Promise.resolve(sto.updateStore('$', temp));
  8433. };
  8434. var block = new Commands.CommandBlock([], [new Commands.SysCall(negateFun)]);
  8435. var func = new Commands.Function('$negate', new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8436. return func;
  8437. }
  8438. function createInvertFun() {
  8439. var invertFun = function invertFun(sto, _) {
  8440. var x = sto.applyStore('x');
  8441. var result = (0, _parsers.toReal)(1).dividedBy(x.value);
  8442. if (result.dp() > _config.Config.decimalPlaces) {
  8443. result = new _decimal.Decimal(result.toFixed(_config.Config.decimalPlaces));
  8444. }
  8445. var temp = new _storeObject.StoreObject(_types.Types.REAL, result);
  8446. sto.mode = _modes.Modes.RETURN;
  8447. return Promise.resolve(sto.updateStore('$', temp));
  8448. };
  8449. var block = new Commands.CommandBlock([], [new Commands.SysCall(invertFun)]);
  8450. var func = new Commands.Function('$invert', _types.Types.REAL, [new Commands.FormalParameter(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 'x', false)], block);
  8451. return func;
  8452. }
  8453. function createMaxFun() {
  8454. var maxFun = function maxFun(sto, _) {
  8455. var x = sto.applyStore('x');
  8456. var numbers = x.value.map(function (stoObj) {
  8457. return stoObj.value;
  8458. });
  8459. var result = _decimal.Decimal.max.apply(_decimal.Decimal, _toConsumableArray(numbers));
  8460. var temp = new _storeObject.StoreObject(x.type.innerType, result);
  8461. sto.mode = _modes.Modes.RETURN;
  8462. return Promise.resolve(sto.updateStore('$', temp));
  8463. };
  8464. var paramType = new _compoundType.CompoundType(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 1);
  8465. var block = new Commands.CommandBlock([], [new Commands.SysCall(maxFun)]);
  8466. var func = new Commands.Function('$max', new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), [new Commands.FormalParameter(paramType, 'x', false)], block);
  8467. return func;
  8468. }
  8469. function createMinFun() {
  8470. var minFun = function minFun(sto, _) {
  8471. var x = sto.applyStore('x');
  8472. var numbers = x.value.map(function (stoObj) {
  8473. return stoObj.value;
  8474. });
  8475. var result = _decimal.Decimal.min.apply(_decimal.Decimal, _toConsumableArray(numbers));
  8476. var temp = new _storeObject.StoreObject(x.type.innerType, result);
  8477. sto.mode = _modes.Modes.RETURN;
  8478. return Promise.resolve(sto.updateStore('$', temp));
  8479. };
  8480. var paramType = new _compoundType.CompoundType(new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), 1);
  8481. var block = new Commands.CommandBlock([], [new Commands.SysCall(minFun)]);
  8482. var func = new Commands.Function('$min', new _multiType.MultiType([_types.Types.INTEGER, _types.Types.REAL]), [new Commands.FormalParameter(paramType, 'x', false)], block);
  8483. return func;
  8484. }
  8485. /***/ }),
  8486. /***/ "./js/processor/lib/strings.js":
  8487. /*!*************************************!*\
  8488. !*** ./js/processor/lib/strings.js ***!
  8489. \*************************************/
  8490. /*! no static exports found */
  8491. /***/ (function(module, exports, __webpack_require__) {
  8492. "use strict";
  8493. Object.defineProperty(exports, "__esModule", {
  8494. value: true
  8495. });
  8496. exports.createSubstringFun = createSubstringFun;
  8497. exports.createLengthFun = createLengthFun;
  8498. exports.createUppercaseFun = createUppercaseFun;
  8499. exports.createLowercaseFun = createLowercaseFun;
  8500. exports.createrCharAtFun = createrCharAtFun;
  8501. var _storeObject = __webpack_require__(/*! ../store/storeObject */ "./js/processor/store/storeObject.js");
  8502. var _commands = __webpack_require__(/*! ./../../ast/commands */ "./js/ast/commands/index.js");
  8503. var Commands = _interopRequireWildcard(_commands);
  8504. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  8505. var _parsers = __webpack_require__(/*! ./../../typeSystem/parsers */ "./js/typeSystem/parsers.js");
  8506. var _modes = __webpack_require__(/*! ../modes */ "./js/processor/modes.js");
  8507. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  8508. /*
  8509. * substring
  8510. * length
  8511. * uppercase
  8512. * lowercase
  8513. * charAt
  8514. **/
  8515. function createSubstringFun() {
  8516. var substringFun = function substringFun(sto, _) {
  8517. var str = sto.applyStore("str");
  8518. var start = sto.applyStore("start");
  8519. var end = sto.applyStore("end");
  8520. var result = str.value.substring(start.value, end.value);
  8521. var temp = new _storeObject.StoreObject(_types.Types.STRING, result);
  8522. sto.mode = _modes.Modes.RETURN;
  8523. return Promise.resolve(sto.updateStore("$", temp));
  8524. };
  8525. var block = new Commands.CommandBlock([], [new Commands.SysCall(substringFun)]);
  8526. var func = new Commands.Function('$substring', _types.Types.STRING, [new Commands.FormalParameter(_types.Types.STRING, 'str', false), new Commands.FormalParameter(_types.Types.INTEGER, 'start', false), new Commands.FormalParameter(_types.Types.INTEGER, 'end', false)], block);
  8527. return func;
  8528. }
  8529. function createLengthFun() {
  8530. var lengthFun = function lengthFun(sto, _) {
  8531. var str = sto.applyStore("str");
  8532. var temp = new _storeObject.StoreObject(_types.Types.INTEGER, (0, _parsers.toInt)(str.value.length));
  8533. sto.mode = _modes.Modes.RETURN;
  8534. return Promise.resolve(sto.updateStore("$", temp));
  8535. };
  8536. var block = new Commands.CommandBlock([], [new Commands.SysCall(lengthFun)]);
  8537. var func = new Commands.Function('$length', _types.Types.INTEGER, [new Commands.FormalParameter(_types.Types.STRING, 'str', false)], block);
  8538. return func;
  8539. }
  8540. function createUppercaseFun() {
  8541. var uppercaseFun = function uppercaseFun(sto, _) {
  8542. var str = sto.applyStore("str");
  8543. var temp = new _storeObject.StoreObject(_types.Types.STRING, str.value.toUpperCase());
  8544. sto.mode = _modes.Modes.RETURN;
  8545. return Promise.resolve(sto.updateStore("$", temp));
  8546. };
  8547. var block = new Commands.CommandBlock([], [new Commands.SysCall(uppercaseFun)]);
  8548. var func = new Commands.Function('$uppercase', _types.Types.STRING, [new Commands.FormalParameter(_types.Types.STRING, 'str', false)], block);
  8549. return func;
  8550. }
  8551. function createLowercaseFun() {
  8552. var lowercaseFun = function lowercaseFun(sto, _) {
  8553. var str = sto.applyStore("str");
  8554. var temp = new _storeObject.StoreObject(_types.Types.STRING, str.value.toLowerCase());
  8555. sto.mode = _modes.Modes.RETURN;
  8556. return Promise.resolve(sto.updateStore("$", temp));
  8557. };
  8558. var block = new Commands.CommandBlock([], [new Commands.SysCall(lowercaseFun)]);
  8559. var func = new Commands.Function('$lowercase', _types.Types.STRING, [new Commands.FormalParameter(_types.Types.STRING, 'str', false)], block);
  8560. return func;
  8561. }
  8562. function createrCharAtFun() {
  8563. var charAtFun = function charAtFun(sto, _) {
  8564. var str = sto.applyStore("str");
  8565. var idx = sto.applyStore("index");
  8566. if (idx.value.toNumber() < 0 || idx.value.toNumber() >= str.value.length) {
  8567. return Promise.reject(new Error("invalid string position"));
  8568. }
  8569. var temp = new _storeObject.StoreObject(_types.Types.STRING, str.value.charAt(idx.value.toNumber()));
  8570. sto.mode = _modes.Modes.RETURN;
  8571. return Promise.resolve(sto.updateStore("$", temp));
  8572. };
  8573. var block = new Commands.CommandBlock([], [new Commands.SysCall(charAtFun)]);
  8574. var func = new Commands.Function('$charAt', _types.Types.STRING, [new Commands.FormalParameter(_types.Types.STRING, 'str', false), new Commands.FormalParameter(_types.Types.INTEGER, 'index', false)], block);
  8575. return func;
  8576. }
  8577. /***/ }),
  8578. /***/ "./js/processor/modes.js":
  8579. /*!*******************************!*\
  8580. !*** ./js/processor/modes.js ***!
  8581. \*******************************/
  8582. /*! no static exports found */
  8583. /***/ (function(module, exports, __webpack_require__) {
  8584. "use strict";
  8585. Object.defineProperty(exports, "__esModule", {
  8586. value: true
  8587. });
  8588. var Modes = exports.Modes = Object.freeze({
  8589. RETURN: Symbol('mode:return'),
  8590. BREAK: Symbol('mode:break'),
  8591. PAUSE: Symbol('mode:pause'),
  8592. RUN: Symbol('mode:run')
  8593. });
  8594. /***/ }),
  8595. /***/ "./js/processor/semantic/semanticAnalyser.js":
  8596. /*!***************************************************!*\
  8597. !*** ./js/processor/semantic/semanticAnalyser.js ***!
  8598. \***************************************************/
  8599. /*! no static exports found */
  8600. /***/ (function(module, exports, __webpack_require__) {
  8601. "use strict";
  8602. Object.defineProperty(exports, "__esModule", {
  8603. value: true
  8604. });
  8605. exports.SemanticAnalyser = undefined;
  8606. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8607. var _processorErrorFactory = __webpack_require__(/*! ./../error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
  8608. var _definedFunctions = __webpack_require__(/*! ./../definedFunctions */ "./js/processor/definedFunctions.js");
  8609. var _languageService = __webpack_require__(/*! ./../../services/languageService */ "./js/services/languageService.js");
  8610. var _commands = __webpack_require__(/*! ../../ast/commands */ "./js/ast/commands/index.js");
  8611. var _expressions = __webpack_require__(/*! ../../ast/expressions */ "./js/ast/expressions/index.js");
  8612. var _literal = __webpack_require__(/*! ../../ast/expressions/literal */ "./js/ast/expressions/literal.js");
  8613. var _compatibilityTable = __webpack_require__(/*! ../compatibilityTable */ "./js/processor/compatibilityTable.js");
  8614. var _types = __webpack_require__(/*! ../../typeSystem/types */ "./js/typeSystem/types.js");
  8615. var _compoundType = __webpack_require__(/*! ../../typeSystem/compoundType */ "./js/typeSystem/compoundType.js");
  8616. var _multiType = __webpack_require__(/*! ../../typeSystem/multiType */ "./js/typeSystem/multiType.js");
  8617. var _config = __webpack_require__(/*! ../../util/config */ "./js/util/config.js");
  8618. var _store = __webpack_require__(/*! ../store/store */ "./js/processor/store/store.js");
  8619. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8620. var SemanticAnalyser = exports.SemanticAnalyser = function () {
  8621. function SemanticAnalyser(ast) {
  8622. _classCallCheck(this, SemanticAnalyser);
  8623. this.ast = ast;
  8624. this.lexerClass = _languageService.LanguageService.getCurrentLexer();
  8625. var lexer = new this.lexerClass(null);
  8626. this.literalNames = lexer.literalNames;
  8627. this.symbolMap = null;
  8628. this.currentFunction = null;
  8629. }
  8630. _createClass(SemanticAnalyser, [{
  8631. key: 'pushMap',
  8632. value: function pushMap() {
  8633. if (this.symbolMap === null) {
  8634. this.symbolMap = { map: {}, next: null };
  8635. } else {
  8636. var n = { map: {}, next: this.symbolMap };
  8637. this.symbolMap = n;
  8638. }
  8639. }
  8640. }, {
  8641. key: 'popMap',
  8642. value: function popMap() {
  8643. if (this.symbolMap !== null) {
  8644. this.symbolMap = this.symbolMap.next;
  8645. }
  8646. }
  8647. }, {
  8648. key: 'insertSymbol',
  8649. value: function insertSymbol(id, typeInfo) {
  8650. this.symbolMap.map[id] = typeInfo;
  8651. }
  8652. }, {
  8653. key: 'findSymbol',
  8654. value: function findSymbol(id, symMap) {
  8655. if (!symMap.map[id]) {
  8656. if (symMap.next) {
  8657. return this.findSymbol(id, symMap.next);
  8658. }
  8659. return null;
  8660. } else {
  8661. return symMap.map[id];
  8662. }
  8663. }
  8664. }, {
  8665. key: 'getMainFunction',
  8666. value: function getMainFunction() {
  8667. return this.ast.functions.find(function (v) {
  8668. return v.isMain;
  8669. });
  8670. }
  8671. }, {
  8672. key: 'findFunction',
  8673. value: function findFunction(name) {
  8674. console.log(name);
  8675. if (name.match(/^\$.+$/)) {
  8676. var fun = _definedFunctions.LanguageDefinedFunction.getFunction(name);
  8677. if (!!!fun) {
  8678. throw _processorErrorFactory.ProcessorErrorFactory.not_implemented(name);
  8679. }
  8680. return fun;
  8681. } else {
  8682. var val = this.ast.functions.find(function (v) {
  8683. return v.name === name;
  8684. });
  8685. if (!!!val) {
  8686. return null;
  8687. }
  8688. return val;
  8689. }
  8690. }
  8691. }, {
  8692. key: 'analyseTree',
  8693. value: function analyseTree() {
  8694. var globalVars = this.ast.global;
  8695. this.pushMap();
  8696. this.assertDeclarations(globalVars);
  8697. var functions = this.ast.functions;
  8698. var mainFunc = functions.filter(function (f) {
  8699. return f.name === null;
  8700. });
  8701. if (mainFunc.length <= 0) {
  8702. throw _processorErrorFactory.ProcessorErrorFactory.main_missing();
  8703. }
  8704. for (var i = 0; i < functions.length; i++) {
  8705. var fun = functions[i];
  8706. this.assertFunction(fun);
  8707. }
  8708. return this.ast;
  8709. }
  8710. }, {
  8711. key: 'assertDeclarations',
  8712. value: function assertDeclarations(list) {
  8713. for (var i = 0; i < list.length; i++) {
  8714. this.assertDeclaration(list[i]);
  8715. }
  8716. }
  8717. }, {
  8718. key: 'assertDeclaration',
  8719. value: function assertDeclaration(declaration) {
  8720. if (declaration instanceof _commands.ArrayDeclaration) {
  8721. if (declaration.initial === null) {
  8722. var lineType = this.evaluateExpressionType(declaration.lines);
  8723. if (!lineType.isCompatible(_types.Types.INTEGER)) {
  8724. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(declaration.sourceInfo);
  8725. }
  8726. if (declaration.columns !== null) {
  8727. var columnType = this.evaluateExpressionType(declaration.columns);
  8728. if (!columnType.isCompatible(_types.Types.INTEGER)) {
  8729. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(declaration.sourceInfo);
  8730. }
  8731. }
  8732. this.insertSymbol(declaration.id, { id: declaration.id, lines: declaration.lines, columns: declaration.columns, type: declaration.type });
  8733. return;
  8734. }
  8735. this.evaluateArrayLiteral(declaration.id, declaration.lines, declaration.columns, declaration.type, declaration.initial);
  8736. this.insertSymbol(declaration.id, { id: declaration.id, lines: declaration.lines, columns: declaration.columns, type: declaration.type });
  8737. } else {
  8738. if (declaration.initial === null) {
  8739. this.insertSymbol(declaration.id, { id: declaration.id, type: declaration.type });
  8740. return;
  8741. }
  8742. var resultType = this.evaluateExpressionType(declaration.initial);
  8743. if (resultType instanceof _multiType.MultiType) {
  8744. if (!resultType.isCompatible(declaration.type)) {
  8745. var stringInfo = declaration.type.stringInfo();
  8746. var info = stringInfo[0];
  8747. throw _processorErrorFactory.ProcessorErrorFactory.incompatible_types_full(info.type, info.dim, declaration.sourceInfo);
  8748. }
  8749. this.insertSymbol(declaration.id, { id: declaration.id, type: declaration.type });
  8750. } else if (!declaration.type.isCompatible(resultType) && !_config.Config.enable_type_casting || !declaration.type.isCompatible(resultType) && _config.Config.enable_type_casting && !_store.Store.canImplicitTypeCast(declaration.type, resultType)) {
  8751. var _stringInfo = declaration.type.stringInfo();
  8752. var _info = _stringInfo[0];
  8753. throw _processorErrorFactory.ProcessorErrorFactory.incompatible_types_full(_info.type, _info.dim, declaration.sourceInfo);
  8754. } else {
  8755. this.insertSymbol(declaration.id, { id: declaration.id, type: declaration.type });
  8756. }
  8757. }
  8758. }
  8759. }, {
  8760. key: 'evaluateExpressionType',
  8761. value: function evaluateExpressionType(expression) {
  8762. if (expression instanceof _expressions.UnaryApp) {
  8763. var op = expression.op;
  8764. var resultType = this.evaluateExpressionType(expression.left);
  8765. return (0, _compatibilityTable.resultTypeAfterUnaryOp)(op, resultType);
  8766. } else if (expression instanceof _expressions.InfixApp) {
  8767. var _op = expression.op;
  8768. var resultTypeLeft = this.evaluateExpressionType(expression.left);
  8769. var resultTypeRight = this.evaluateExpressionType(expression.right);
  8770. return (0, _compatibilityTable.resultTypeAfterInfixOp)(_op, resultTypeLeft, resultTypeRight);
  8771. } else if (expression instanceof _literal.Literal) {
  8772. return this.evaluateLiteralType(expression);
  8773. } else if (expression instanceof _expressions.FunctionCall) {
  8774. if (expression.isMainCall) {
  8775. throw _processorErrorFactory.ProcessorErrorFactory.void_in_expression_full(_definedFunctions.LanguageDefinedFunction.getMainFunctionName(), expression.sourceInfo);
  8776. }
  8777. var fun = this.findFunction(expression.id);
  8778. if (fun === null) {
  8779. throw _processorErrorFactory.ProcessorErrorFactory.function_missing_full(expression.id, expression.sourceInfo);
  8780. }
  8781. if (fun.returnType.isCompatible(_types.Types.VOID)) {
  8782. throw _processorErrorFactory.ProcessorErrorFactory.void_in_expression_full(expression.id, expression.sourceInfo);
  8783. }
  8784. this.assertParameters(fun, expression.actualParameters);
  8785. return fun.returnType;
  8786. } else if (expression instanceof _expressions.ArrayAccess) {
  8787. var arrayTypeInfo = this.findSymbol(expression.id, this.symbolMap);
  8788. if (arrayTypeInfo === null) {
  8789. throw _processorErrorFactory.ProcessorErrorFactory.symbol_not_found_full(expression.id, expression.sourceInfo);
  8790. }
  8791. if (!(arrayTypeInfo.type instanceof _compoundType.CompoundType)) {
  8792. throw _processorErrorFactory.ProcessorErrorFactory.invalid_array_access_full(expression.id, expression.sourceInfo);
  8793. }
  8794. var lineType = this.evaluateExpressionType(expression.line);
  8795. if (!lineType.isCompatible(_types.Types.INTEGER)) {
  8796. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(expression.sourceInfo);
  8797. }
  8798. if (expression.column !== null) {
  8799. if (arrayTypeInfo.columns === null) {
  8800. throw _processorErrorFactory.ProcessorErrorFactory.invalid_matrix_access_full(expression.id, expression.sourceInfo);
  8801. }
  8802. var columnType = this.evaluateExpressionType(expression.column);
  8803. if (!columnType.isCompatible(_types.Types.INTEGER)) {
  8804. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(expression.sourceInfo);
  8805. }
  8806. }
  8807. var arrType = arrayTypeInfo.type;
  8808. if (expression.column !== null) {
  8809. // indexing matrix
  8810. return arrType.innerType;
  8811. } else {
  8812. if (arrayTypeInfo.columns === null) {
  8813. return arrType.innerType;
  8814. }
  8815. return new _compoundType.CompoundType(arrType.innerType, 1);
  8816. }
  8817. }
  8818. }
  8819. }, {
  8820. key: 'evaluateLiteralType',
  8821. value: function evaluateLiteralType(literal) {
  8822. if (literal instanceof _expressions.IntLiteral) {
  8823. return literal.type;
  8824. } else if (literal instanceof _expressions.RealLiteral) {
  8825. return literal.type;
  8826. } else if (literal instanceof _expressions.StringLiteral) {
  8827. return literal.type;
  8828. } else if (literal instanceof _expressions.BoolLiteral) {
  8829. return literal.type;
  8830. } else if (literal instanceof _expressions.VariableLiteral) {
  8831. var typeInfo = this.findSymbol(literal.id, this.symbolMap);
  8832. if (typeInfo === null) {
  8833. throw _processorErrorFactory.ProcessorErrorFactory.symbol_not_found_full(literal.id, literal.sourceInfo);
  8834. }
  8835. if (typeInfo.type instanceof _compoundType.CompoundType) {
  8836. return typeInfo.type;
  8837. }
  8838. return typeInfo.type;
  8839. } else {
  8840. console.warn("Evaluating type only for an array literal...");
  8841. var last = null;
  8842. if (literal.value.length === 1) {
  8843. last = this.evaluateExpressionType(literal.value[0]);
  8844. } else {
  8845. for (var i = 0; i < literal.value.length; i++) {
  8846. var e = this.evaluateExpressionType(literal.value[i]);
  8847. if (last === null) {
  8848. last = e;
  8849. } else if (!last.isCompatible(e)) {
  8850. var strInfo = last.stringInfo();
  8851. var info = strInfo[0];
  8852. var strExp = literal.toString();
  8853. throw _processorErrorFactory.ProcessorErrorFactory.incompatible_types_array_full(strExp, info.type, info.dim, literal.sourceInfo);
  8854. }
  8855. }
  8856. }
  8857. if (last instanceof _compoundType.CompoundType) {
  8858. return new _compoundType.CompoundType(last.innerType, last.dimensions + 1);
  8859. }
  8860. return new _compoundType.CompoundType(last, 1);
  8861. }
  8862. }
  8863. }, {
  8864. key: 'evaluateArrayLiteral',
  8865. value: function evaluateArrayLiteral(id, lines, columns, type, literal) {
  8866. /* if (literal instanceof ArrayLiteral) {
  8867. const dimType = this.evaluateExpressionType(lines);
  8868. if (!dimType.isCompatible(Types.INTEGER)) {
  8869. throw ProcessorErrorFactory.array_dimension_not_int_full(literal.sourceInfo);
  8870. }
  8871. if ((lines instanceof IntLiteral)) {
  8872. if (!lines.value.eq(literal.value.length)) {
  8873. if(type.dimensions > 1) {
  8874. throw ProcessorErrorFactory.matrix_line_outbounds_full(id, literal.value.length, lines.value.toNumber(), literal.sourceInfo)
  8875. } else {
  8876. throw ProcessorErrorFactory.vector_line_outbounds_full(id, literal.value.length, lines.value.toNumber(), literal.sourceInfo)
  8877. }
  8878. } else if (lines.value.isNeg()) {
  8879. throw ProcessorErrorFactory.array_dimension_not_positive_full(literal.sourceInfo);
  8880. }
  8881. }
  8882. if (columns === null) {
  8883. // it's a vector...
  8884. literal.value.reduce((last, next) => {
  8885. const eType = this.evaluateExpressionType(next);
  8886. if (!last.canAccept(eType)) {
  8887. const strInfo = last.stringInfo();
  8888. const info = strInfo[0];
  8889. const strExp = literal.toString();
  8890. throw ProcessorErrorFactory.incompatible_types_array_full(strExp,info.type, info.dim, literal.sourceInfo);
  8891. }
  8892. return last;
  8893. }, type);
  8894. return true;
  8895. } else {
  8896. const dimType = this.evaluateExpressionType(columns);
  8897. if (!dimType.isCompatible(Types.INTEGER)) {
  8898. throw ProcessorErrorFactory.array_dimension_not_int_full(literal.sourceInfo);
  8899. }
  8900. if ((columns instanceof IntLiteral)) {
  8901. const columnValue = literal.value[0].value.length;
  8902. if (!columns.value.eq(columnValue)) {
  8903. if(type.dimensions > 1) {
  8904. throw ProcessorErrorFactory.matrix_column_outbounds_full(id, literal.value.length, columns.value.toNumber(), literal.sourceInfo)
  8905. } else {
  8906. throw ProcessorErrorFactory.invalid_matrix_access_full(id, literal.sourceInfo);
  8907. }
  8908. } else if (columns.value.isNeg()) {
  8909. throw ProcessorErrorFactory.array_dimension_not_positive_full(literal.sourceInfo);
  8910. }
  8911. for (let i = 0; i < columns; i++) {
  8912. const anotherArray = literal.value[i];
  8913. this.evaluateArrayLiteral(id, columns, null, type, anotherArray)
  8914. }
  8915. }
  8916. }
  8917. } else {
  8918. const resultType = this.evaluateExpressionType(literal);
  8919. if (!(resultType instanceof CompoundType)) {
  8920. const strInfo = type.stringInfo();
  8921. const info = strInfo[0];
  8922. const strExp = literal.toString();
  8923. throw ProcessorErrorFactory.incompatible_types_array_full(strExp,info.type, info.dim, literal.sourceInfo);
  8924. }
  8925. if (!type.isCompatible(resultType)) {
  8926. const strInfo = type.stringInfo();
  8927. const info = strInfo[0];
  8928. const strExp = literal.toString();
  8929. throw ProcessorErrorFactory.incompatible_types_array_full(strExp,info.type, info.dim, literal.sourceInfo);
  8930. }
  8931. return true;
  8932. } */
  8933. return true;
  8934. }
  8935. }, {
  8936. key: 'assertFunction',
  8937. value: function assertFunction(fun) {
  8938. var _this = this;
  8939. this.pushMap();
  8940. this.currentFunction = fun;
  8941. fun.formalParameters.forEach(function (formalParam) {
  8942. if (formalParam.type instanceof _compoundType.CompoundType) {
  8943. if (formalParam.type.dimensions > 1) {
  8944. _this.insertSymbol(formalParam.id, { id: formalParam.id, lines: -1, columns: -1, type: formalParam.type });
  8945. } else {
  8946. _this.insertSymbol(formalParam.id, { id: formalParam.id, lines: -1, columns: null, type: formalParam.type });
  8947. }
  8948. } else {
  8949. _this.insertSymbol(formalParam.id, { id: formalParam.id, type: formalParam.type });
  8950. }
  8951. });
  8952. this.assertDeclarations(fun.variablesDeclarations);
  8953. var optional = fun.returnType.isCompatible(_types.Types.VOID);
  8954. var valid = this.assertReturn(fun, optional);
  8955. if (!valid) {
  8956. throw _processorErrorFactory.ProcessorErrorFactory.function_no_return(fun.name);
  8957. }
  8958. this.popMap();
  8959. }
  8960. }, {
  8961. key: 'assertReturn',
  8962. value: function assertReturn(fun, optional) {
  8963. var _this2 = this;
  8964. return fun.commands.reduce(function (last, next) {
  8965. return _this2.checkCommand(fun.returnType, next, optional) || last;
  8966. }, optional);
  8967. }
  8968. }, {
  8969. key: 'checkCommand',
  8970. value: function checkCommand(type, cmd, optional) {
  8971. if (cmd instanceof _commands.While) {
  8972. var resultType = this.evaluateExpressionType(cmd.expression);
  8973. if (!resultType.isCompatible(_types.Types.BOOLEAN)) {
  8974. throw _processorErrorFactory.ProcessorErrorFactory.loop_condition_type_full(cmd.sourceInfo);
  8975. }
  8976. this.checkCommands(type, cmd.commands, optional);
  8977. return false;
  8978. } else if (cmd instanceof _commands.For) {
  8979. this.checkCommand(type, cmd.assignment, optional);
  8980. var _resultType = this.evaluateExpressionType(cmd.condition);
  8981. if (!_resultType.isCompatible(_types.Types.BOOLEAN)) {
  8982. throw _processorErrorFactory.ProcessorErrorFactory.for_condition_type_full(cmd.sourceInfo);
  8983. }
  8984. this.checkCommand(type, cmd.increment, optional);
  8985. this.checkCommands(type, cmd.commands, optional);
  8986. return false;
  8987. } else if (cmd instanceof _commands.Switch) {
  8988. var sType = this.evaluateExpressionType(cmd.expression);
  8989. var result = optional;
  8990. var hasDefault = false;
  8991. for (var i = 0; i < cmd.cases.length; i++) {
  8992. var aCase = cmd.cases[i];
  8993. if (aCase.expression !== null) {
  8994. var caseType = this.evaluateExpressionType(aCase.expression);
  8995. if (!sType.isCompatible(caseType)) {
  8996. var strInfo = sType.stringInfo();
  8997. var info = strInfo[0];
  8998. var strExp = aCase.expression.toString();
  8999. throw _processorErrorFactory.ProcessorErrorFactory.invalid_case_type_full(strExp, info.type, info.dim, aCase.sourceInfo);
  9000. }
  9001. } else {
  9002. hasDefault = true;
  9003. }
  9004. result = result && this.checkCommands(type, aCase.commands, result);
  9005. }
  9006. return result && hasDefault;
  9007. } else if (cmd instanceof _commands.ArrayIndexAssign) {
  9008. var typeInfo = this.findSymbol(cmd.id, this.symbolMap);
  9009. if (typeInfo === null) {
  9010. throw _processorErrorFactory.ProcessorErrorFactory.symbol_not_found_full(cmd.id, cmd.sourceInfo);
  9011. }
  9012. if (!(typeInfo.type instanceof _compoundType.CompoundType)) {
  9013. throw _processorErrorFactory.ProcessorErrorFactory.invalid_array_access_full(cmd.id, cmd.sourceInfo);
  9014. }
  9015. var exp = cmd.expression;
  9016. var lineExp = cmd.line;
  9017. var lineType = this.evaluateExpressionType(lineExp);
  9018. if (!lineType.isCompatible(_types.Types.INTEGER)) {
  9019. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(cmd.sourceInfo);
  9020. }
  9021. var columnExp = cmd.column;
  9022. if (typeInfo.columns === null && columnExp !== null) {
  9023. throw _processorErrorFactory.ProcessorErrorFactory.invalid_matrix_access_full(cmd.id, cmd.sourceInfo);
  9024. } else if (columnExp !== null) {
  9025. var columnType = this.evaluateExpressionType(columnExp);
  9026. if (!columnType.isCompatible(_types.Types.INTEGER)) {
  9027. throw _processorErrorFactory.ProcessorErrorFactory.array_dimension_not_int_full(cmd.sourceInfo);
  9028. }
  9029. }
  9030. // exp can be a arrayLiteral, a single value exp or an array access
  9031. if (exp instanceof _expressions.ArrayLiteral) {
  9032. this.evaluateArrayLiteral(cmd.id, typeInfo.lines, columnExp ? typeInfo.columns : null, typeInfo.type, exp);
  9033. } else {
  9034. // cannot properly evaluate since type system is poorly constructed
  9035. }
  9036. return optional;
  9037. } else if (cmd instanceof _commands.Assign) {
  9038. var _typeInfo = this.findSymbol(cmd.id, this.symbolMap);
  9039. if (_typeInfo === null) {
  9040. throw _processorErrorFactory.ProcessorErrorFactory.symbol_not_found_full(cmd.id, cmd.sourceInfo);
  9041. }
  9042. var _exp = cmd.expression;
  9043. if (_exp instanceof _expressions.ArrayLiteral) {
  9044. if (!(_typeInfo.type instanceof _compoundType.CompoundType)) {
  9045. var stringInfo = _typeInfo.type.stringInfo();
  9046. var _info2 = stringInfo[0];
  9047. throw _processorErrorFactory.ProcessorErrorFactory.incompatible_types_full(_info2.type, _info2.dim, cmd.sourceInfo);
  9048. }
  9049. this.evaluateArrayLiteral(cmd.id, _typeInfo.lines, _typeInfo.columns, _typeInfo.type, _exp);
  9050. } else {
  9051. var _resultType2 = this.evaluateExpressionType(_exp);
  9052. if (!_resultType2.isCompatible(_typeInfo.type) && !_config.Config.enable_type_casting || !_resultType2.isCompatible(_typeInfo.type) && _config.Config.enable_type_casting && !_store.Store.canImplicitTypeCast(_typeInfo.type, _resultType2)) {
  9053. var _stringInfo2 = _typeInfo.type.stringInfo();
  9054. var _info3 = _stringInfo2[0];
  9055. throw _processorErrorFactory.ProcessorErrorFactory.incompatible_types_full(_info3.type, _info3.dim, cmd.sourceInfo);
  9056. }
  9057. }
  9058. return optional;
  9059. } else if (cmd instanceof _commands.Break) {
  9060. return optional;
  9061. } else if (cmd instanceof _commands.IfThenElse) {
  9062. var _resultType3 = this.evaluateExpressionType(cmd.condition);
  9063. if (!_resultType3.isCompatible(_types.Types.BOOLEAN)) {
  9064. throw _processorErrorFactory.ProcessorErrorFactory.if_condition_type_full(cmd.sourceInfo);
  9065. }
  9066. if (cmd.ifFalse instanceof _commands.IfThenElse) {
  9067. return this.checkCommands(type, cmd.ifTrue.commands, optional) && this.checkCommand(type, cmd.ifFalse, optional);
  9068. } else {
  9069. return this.checkCommands(type, cmd.ifTrue.commands, optional) && this.checkCommands(type, cmd.ifFalse.commands, optional);
  9070. }
  9071. } else if (cmd instanceof _expressions.FunctionCall) {
  9072. var fun = null;
  9073. if (cmd.isMainCall) {
  9074. fun = this.getMainFunction();
  9075. } else {
  9076. fun = this.findFunction(cmd.id);
  9077. }
  9078. if (fun === null) {
  9079. throw _processorErrorFactory.ProcessorErrorFactory.function_missing_full(cmd.id, cmd.sourceInfo);
  9080. }
  9081. this.assertParameters(fun, cmd.actualParameters);
  9082. return optional;
  9083. } else if (cmd instanceof _commands.Return) {
  9084. var funcName = this.currentFunction.isMain ? _definedFunctions.LanguageDefinedFunction.getMainFunctionName() : this.currentFunction.name;
  9085. if (cmd.expression === null && !type.isCompatible(_types.Types.VOID)) {
  9086. var _stringInfo3 = type.stringInfo();
  9087. var _info4 = _stringInfo3[0];
  9088. throw _processorErrorFactory.ProcessorErrorFactory.invalid_void_return_full(funcName, _info4.type, _info4.dim, cmd.sourceInfo);
  9089. } else if (cmd.expression !== null) {
  9090. var _resultType4 = this.evaluateExpressionType(cmd.expression);
  9091. if (!type.isCompatible(_resultType4)) {
  9092. var _stringInfo4 = type.stringInfo();
  9093. var _info5 = _stringInfo4[0];
  9094. throw _processorErrorFactory.ProcessorErrorFactory.invalid_return_type_full(funcName, _info5.type, _info5.dim, cmd.sourceInfo);
  9095. } else {
  9096. return true;
  9097. }
  9098. } else {
  9099. return true;
  9100. }
  9101. }
  9102. }
  9103. }, {
  9104. key: 'checkCommands',
  9105. value: function checkCommands(type, cmds, optional) {
  9106. var _this3 = this;
  9107. return cmds.reduce(function (last, next) {
  9108. return _this3.checkCommand(type, next, optional) || last;
  9109. }, optional);
  9110. }
  9111. }, {
  9112. key: 'assertParameters',
  9113. value: function assertParameters(fun, actualParametersList) {
  9114. if (fun.formalParameters.length !== actualParametersList.length) {
  9115. throw _processorErrorFactory.ProcessorErrorFactory.invalid_parameters_size_full(fun.name, actualParametersList.length, fun.formalParameters.length, null);
  9116. }
  9117. for (var i = 0; i < actualParametersList.length; i++) {
  9118. var param = actualParametersList[i];
  9119. var formalParam = fun.formalParameters[i];
  9120. var id = formalParam.id;
  9121. if (formalParam.byRef) {
  9122. if (!(param instanceof _expressions.VariableLiteral || param instanceof _expressions.ArrayAccess)) {
  9123. throw _processorErrorFactory.ProcessorErrorFactory.invalid_parameter_type_full(id, param.toString(), param.sourceInfo);
  9124. }
  9125. }
  9126. var resultType = this.evaluateExpressionType(param);
  9127. if (resultType instanceof _multiType.MultiType && formalParam.type instanceof _multiType.MultiType) {
  9128. var shared = 0;
  9129. for (var j = 0; j < resultType.types.length; j++) {
  9130. var element = resultType.types[j];
  9131. if (formalParam.type.types.indexOf(element) !== -1) {
  9132. shared++;
  9133. }
  9134. }
  9135. if (shared <= 0) {
  9136. if (_config.Config.enable_type_casting && !formalParam.byRef) {
  9137. if (resultType.isCompatible(_types.Types.INTEGER) || resultType.isCompatible(_types.Types.REAL)) {
  9138. if (formalParam.type.isCompatible(_types.Types.INTEGER) || formalParam.type.isCompatible(_types.Types.REAL)) {
  9139. continue;
  9140. }
  9141. }
  9142. }
  9143. throw _processorErrorFactory.ProcessorErrorFactory.invalid_parameter_type_full(id, param.toString(), param.sourceInfo);
  9144. }
  9145. } else if (resultType instanceof _multiType.MultiType) {
  9146. if (!resultType.isCompatible(formalParam.type)) {
  9147. if (_config.Config.enable_type_casting && !formalParam.byRef) {
  9148. if (resultType.isCompatible(_types.Types.INTEGER) || resultType.isCompatible(_types.Types.REAL)) {
  9149. if (formalParam.type.isCompatible(_types.Types.INTEGER) || formalParam.type.isCompatible(_types.Types.REAL)) {
  9150. continue;
  9151. }
  9152. }
  9153. }
  9154. throw _processorErrorFactory.ProcessorErrorFactory.invalid_parameter_type_full(id, param.toString(), param.sourceInfo);
  9155. }
  9156. } else if (!formalParam.type.isCompatible(resultType)) {
  9157. if (_config.Config.enable_type_casting && !formalParam.byRef) {
  9158. if (_store.Store.canImplicitTypeCast(formalParam.type, resultType)) {
  9159. continue;
  9160. }
  9161. }
  9162. throw _processorErrorFactory.ProcessorErrorFactory.invalid_parameter_type_full(id, param.toString(), param.sourceInfo);
  9163. }
  9164. }
  9165. }
  9166. }]);
  9167. return SemanticAnalyser;
  9168. }();
  9169. /***/ }),
  9170. /***/ "./js/processor/store/store.js":
  9171. /*!*************************************!*\
  9172. !*** ./js/processor/store/store.js ***!
  9173. \*************************************/
  9174. /*! no static exports found */
  9175. /***/ (function(module, exports, __webpack_require__) {
  9176. "use strict";
  9177. Object.defineProperty(exports, "__esModule", {
  9178. value: true
  9179. });
  9180. exports.Store = undefined;
  9181. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9182. var _modes = __webpack_require__(/*! ./../modes */ "./js/processor/modes.js");
  9183. var _types = __webpack_require__(/*! ./../../typeSystem/types */ "./js/typeSystem/types.js");
  9184. var _storeObject = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.js");
  9185. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9186. var Store = exports.Store = function () {
  9187. _createClass(Store, null, [{
  9188. key: 'canImplicitTypeCast',
  9189. value: function canImplicitTypeCast(castType, sourceType) {
  9190. if (castType.isCompatible(_types.Types.INTEGER) || castType.isCompatible(_types.Types.REAL)) {
  9191. if (sourceType.isCompatible(_types.Types.INTEGER) || sourceType.isCompatible(_types.Types.REAL)) {
  9192. return true;
  9193. }
  9194. }
  9195. return false;
  9196. }
  9197. }, {
  9198. key: 'doImplicitCasting',
  9199. value: function doImplicitCasting(castType, stoObj) {
  9200. if (!Store.canImplicitTypeCast(castType, stoObj.type)) {
  9201. throw new Error("!!!Critical error: attempted to type cast invalid types");
  9202. }
  9203. if (_types.Types.INTEGER.isCompatible(castType)) {
  9204. return new _storeObject.StoreObject(castType, stoObj.value.trunc());
  9205. } else {
  9206. return new _storeObject.StoreObject(castType, stoObj.value);
  9207. }
  9208. }
  9209. }]);
  9210. function Store(name) {
  9211. _classCallCheck(this, Store);
  9212. this.name = name;
  9213. this.store = {};
  9214. this.nextStore = null;
  9215. this.mode = _modes.Modes.RUN;
  9216. }
  9217. _createClass(Store, [{
  9218. key: 'extendStore',
  9219. value: function extendStore(nextStore) {
  9220. this.nextStore = nextStore;
  9221. }
  9222. }, {
  9223. key: 'applyStore',
  9224. value: function applyStore(id) {
  9225. if (!this.store[id]) {
  9226. if (this.nextStore !== null) {
  9227. return this.nextStore.applyStore(id);
  9228. } else {
  9229. throw new Error('Variable ' + id + ' not found.');
  9230. }
  9231. }
  9232. var val = this.store[id];
  9233. if (val.isRef) {
  9234. return val.getRefObj();
  9235. }
  9236. return this.store[id];
  9237. }
  9238. }, {
  9239. key: 'updateStore',
  9240. value: function updateStore(id, stoObj) {
  9241. if (!this.store[id]) {
  9242. if (this.nextStore !== null) {
  9243. this.nextStore.updateStore(id, stoObj);
  9244. return this;
  9245. } else {
  9246. // TODO: better error message
  9247. throw new Error('Variable ' + id + ' not found.');
  9248. }
  9249. } else {
  9250. var oldObj = this.store[id];
  9251. if (oldObj.readOnly) {
  9252. // TODO: better error message
  9253. throw new Error("Cannot change value of a read only variable: " + id);
  9254. }
  9255. if (oldObj.isRef) {
  9256. oldObj.updateRef(stoObj);
  9257. return this;
  9258. } else if (oldObj.isCompatible(stoObj)) {
  9259. stoObj.setID(id);
  9260. this.store[id] = Object.freeze(stoObj);
  9261. return this;
  9262. } else {
  9263. var oldType = oldObj.type;
  9264. var stoType = stoObj.type;
  9265. // TODO: better error message
  9266. throw new Error(oldType + ' is not compatible with type ' + stoType + ' given');
  9267. }
  9268. }
  9269. }
  9270. //In case of future use of ref, it needs to have a special function to update the storeRefObject
  9271. // and no the StoreObject refferenced by it
  9272. // updateStoreRef(id, stoObjAddress) {...}
  9273. }, {
  9274. key: 'insertStore',
  9275. value: function insertStore(id, stoObj) {
  9276. if (this.store[id]) {
  9277. // TODO: better error message
  9278. throw new Error(id + ' is already defined');
  9279. }
  9280. stoObj.setID(id);
  9281. this.store[id] = Object.freeze(stoObj);
  9282. return this;
  9283. }
  9284. }]);
  9285. return Store;
  9286. }();
  9287. /***/ }),
  9288. /***/ "./js/processor/store/storeObject.js":
  9289. /*!*******************************************!*\
  9290. !*** ./js/processor/store/storeObject.js ***!
  9291. \*******************************************/
  9292. /*! no static exports found */
  9293. /***/ (function(module, exports, __webpack_require__) {
  9294. "use strict";
  9295. Object.defineProperty(exports, "__esModule", {
  9296. value: true
  9297. });
  9298. exports.StoreObject = undefined;
  9299. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9300. var _decimal = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
  9301. var _decimal2 = _interopRequireDefault(_decimal);
  9302. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9303. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9304. var StoreObject = exports.StoreObject = function () {
  9305. function StoreObject(type, value) {
  9306. var readOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9307. _classCallCheck(this, StoreObject);
  9308. this._type = type;
  9309. this._value = value;
  9310. this._readOnly = readOnly;
  9311. this._id = null;
  9312. }
  9313. _createClass(StoreObject, [{
  9314. key: 'setID',
  9315. value: function setID(id) {
  9316. this._id = id;
  9317. }
  9318. }, {
  9319. key: 'isCompatible',
  9320. value: function isCompatible(another) {
  9321. if (another instanceof StoreObject) {
  9322. return this.type.isCompatible(another.type);
  9323. }
  9324. return false;
  9325. }
  9326. }, {
  9327. key: 'id',
  9328. get: function get() {
  9329. return this._id;
  9330. }
  9331. }, {
  9332. key: 'inStore',
  9333. get: function get() {
  9334. return this.id !== null;
  9335. }
  9336. }, {
  9337. key: 'type',
  9338. get: function get() {
  9339. return this._type;
  9340. }
  9341. }, {
  9342. key: 'value',
  9343. get: function get() {
  9344. return this._value;
  9345. }
  9346. }, {
  9347. key: 'number',
  9348. get: function get() {
  9349. if (this._value instanceof _decimal2.default) {
  9350. return this._value.toNumber();
  9351. } else {
  9352. return null;
  9353. }
  9354. }
  9355. }, {
  9356. key: 'readOnly',
  9357. get: function get() {
  9358. return this._readOnly;
  9359. },
  9360. set: function set(value) {
  9361. this._readOnly = value;
  9362. }
  9363. }]);
  9364. return StoreObject;
  9365. }();
  9366. /***/ }),
  9367. /***/ "./js/processor/store/storeObjectArray.js":
  9368. /*!************************************************!*\
  9369. !*** ./js/processor/store/storeObjectArray.js ***!
  9370. \************************************************/
  9371. /*! no static exports found */
  9372. /***/ (function(module, exports, __webpack_require__) {
  9373. "use strict";
  9374. Object.defineProperty(exports, "__esModule", {
  9375. value: true
  9376. });
  9377. exports.StoreObjectArray = undefined;
  9378. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  9379. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9380. var _storeObject = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.js");
  9381. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9382. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9383. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9384. var StoreObjectArray = exports.StoreObjectArray = function (_StoreObject) {
  9385. _inherits(StoreObjectArray, _StoreObject);
  9386. _createClass(StoreObjectArray, null, [{
  9387. key: 'WRONG_LINE_NUMBER',
  9388. get: function get() {
  9389. return 1;
  9390. }
  9391. }, {
  9392. key: 'WRONG_TYPE',
  9393. get: function get() {
  9394. return 2;
  9395. }
  9396. }, {
  9397. key: 'WRONG_COLUMN_NUMBER',
  9398. get: function get() {
  9399. return 3;
  9400. }
  9401. }]);
  9402. function StoreObjectArray(type, lines, columns) {
  9403. var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  9404. var readOnly = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  9405. _classCallCheck(this, StoreObjectArray);
  9406. var _this = _possibleConstructorReturn(this, (StoreObjectArray.__proto__ || Object.getPrototypeOf(StoreObjectArray)).call(this, type, value, readOnly));
  9407. _this._lines = lines;
  9408. _this._columns = columns;
  9409. return _this;
  9410. }
  9411. _createClass(StoreObjectArray, [{
  9412. key: 'isCompatible',
  9413. value: function isCompatible(another) {
  9414. if (another instanceof _storeObject.StoreObject) {
  9415. if (this.lines === -1 && another.lines > 0 || this.lines === another.lines) {
  9416. if (this.columns === -1 && another.columns > 0 || this.columns === another.columns) {
  9417. return _get(StoreObjectArray.prototype.__proto__ || Object.getPrototypeOf(StoreObjectArray.prototype), 'isCompatible', this).call(this, another);
  9418. }
  9419. }
  9420. }
  9421. return false;
  9422. }
  9423. }, {
  9424. key: 'lines',
  9425. get: function get() {
  9426. return this._lines;
  9427. }
  9428. }, {
  9429. key: 'columns',
  9430. get: function get() {
  9431. return this._columns;
  9432. }
  9433. }, {
  9434. key: 'isVector',
  9435. get: function get() {
  9436. return this.type.dimensions === 1;
  9437. }
  9438. }, {
  9439. key: 'isValid',
  9440. get: function get() {
  9441. var _this2 = this;
  9442. if (this.value !== null) {
  9443. if (this.isVector) {
  9444. if (this.value.length !== this.lines) {
  9445. return [StoreObjectArray.WRONG_LINE_NUMBER, this.value.length];;
  9446. }
  9447. var mustBeNull = this.value.find(function (v) {
  9448. return !_this2.type.canAccept(v.type);
  9449. });
  9450. if (!!mustBeNull) {
  9451. return [StoreObjectArray.WRONG_TYPE, this.value.indexOf(mustBeNull)];;
  9452. }
  9453. }
  9454. return [];
  9455. } else {
  9456. if (this.lines !== this.value.length) {
  9457. return [StoreObjectArray.WRONG_LINE_NUMBER, this.value.length];
  9458. }
  9459. for (var i = 0; i < this.lines; i++) {
  9460. for (var j = 0; j < this.columns; j++) {
  9461. var arr = this.value[i];
  9462. if (arr.length !== this.columns) {
  9463. return [StoreObjectArray.WRONG_COLUMN_NUMBER, arr.length];
  9464. }
  9465. var _mustBeNull = arr.find(function (v) {
  9466. return !_this2.type.canAccept(v.type);
  9467. });
  9468. if (!!_mustBeNull) {
  9469. return [StoreObjectArray.WRONG_TYPE, i, arr.indexOf(_mustBeNull)];
  9470. }
  9471. }
  9472. }
  9473. return [];
  9474. }
  9475. }
  9476. }]);
  9477. return StoreObjectArray;
  9478. }(_storeObject.StoreObject);
  9479. /***/ }),
  9480. /***/ "./js/processor/store/storeObjectArrayAddress.js":
  9481. /*!*******************************************************!*\
  9482. !*** ./js/processor/store/storeObjectArrayAddress.js ***!
  9483. \*******************************************************/
  9484. /*! no static exports found */
  9485. /***/ (function(module, exports, __webpack_require__) {
  9486. "use strict";
  9487. Object.defineProperty(exports, "__esModule", {
  9488. value: true
  9489. });
  9490. exports.StoreObjectArrayAddress = undefined;
  9491. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9492. var _storeObject = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.js");
  9493. var _storeObjectArray = __webpack_require__(/*! ./storeObjectArray */ "./js/processor/store/storeObjectArray.js");
  9494. var _compoundType = __webpack_require__(/*! ../../typeSystem/compoundType */ "./js/typeSystem/compoundType.js");
  9495. var _processorErrorFactory = __webpack_require__(/*! ../error/processorErrorFactory */ "./js/processor/error/processorErrorFactory.js");
  9496. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9497. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9498. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9499. var StoreObjectArrayAddress = exports.StoreObjectArrayAddress = function (_StoreObject) {
  9500. _inherits(StoreObjectArrayAddress, _StoreObject);
  9501. function StoreObjectArrayAddress(refID, line, column, store) {
  9502. _classCallCheck(this, StoreObjectArrayAddress);
  9503. var _this = _possibleConstructorReturn(this, (StoreObjectArrayAddress.__proto__ || Object.getPrototypeOf(StoreObjectArrayAddress)).call(this, null, null, false));
  9504. _this.refID = refID;
  9505. _this.store = store;
  9506. _this.line = line;
  9507. _this.column = column;
  9508. return _this;
  9509. }
  9510. _createClass(StoreObjectArrayAddress, [{
  9511. key: 'getArrayObject',
  9512. value: function getArrayObject() {
  9513. return this.store.applyStore(this.refID);
  9514. }
  9515. }, {
  9516. key: 'updateArrayObject',
  9517. value: function updateArrayObject(stoObj) {
  9518. var anArray = this.getArrayObject();
  9519. var newArray = Object.assign(new _storeObjectArray.StoreObjectArray(null, null, null), anArray);
  9520. if (!stoObj.type.isCompatible(this.type)) {
  9521. throw new Error('Invalid operation: cannot assign the value given to ' + this.refID);
  9522. } else if (this.type instanceof _compoundType.CompoundType && this.type.canAccept(stoObj.type)) {
  9523. throw new Error('Invalid operation: cannot assign the value given to ' + this.refID);
  9524. }
  9525. if (this.column !== null) {
  9526. newArray.value[this.line].value[this.column] = stoObj;
  9527. return newArray;
  9528. } else {
  9529. newArray.value[this.line] = stoObj;
  9530. return newArray;
  9531. }
  9532. }
  9533. }, {
  9534. key: 'isCompatible',
  9535. value: function isCompatible(another) {
  9536. if (this.type.isCompatible(another.type)) {
  9537. if (another.type instanceof _compoundType.CompoundType) {
  9538. return this.lines === another.lines && this.columns === another.columns;
  9539. } else {
  9540. this.refValue.isCompatible(another);
  9541. }
  9542. }
  9543. }
  9544. }, {
  9545. key: 'isRef',
  9546. get: function get() {
  9547. return false;
  9548. }
  9549. }, {
  9550. key: 'inStore',
  9551. get: function get() {
  9552. return true;
  9553. }
  9554. }, {
  9555. key: 'refValue',
  9556. get: function get() {
  9557. var refLine = this.store.applyStore(this.refID).value[this.line];
  9558. if (!refLine) {
  9559. if (this.getArrayObject().isVector) {
  9560. throw _processorErrorFactory.ProcessorErrorFactory.vector_line_outbounds(this.refID, this.line, this.getArrayObject().lines);
  9561. } else {
  9562. throw _processorErrorFactory.ProcessorErrorFactory.matrix_line_outbounds(this.refID, this.line, this.getArrayObject().lines);
  9563. }
  9564. }
  9565. if (this.column !== null) {
  9566. var refColumn = refLine.value[this.column];
  9567. if (!refColumn) {
  9568. if (this.getArrayObject().isVector) {
  9569. throw _processorErrorFactory.ProcessorErrorFactory.vector_not_matrix(this.refID);
  9570. } else {
  9571. throw _processorErrorFactory.ProcessorErrorFactory.matrix_column_outbounds(this.refID, this.column, this.getArrayObject().columns);
  9572. }
  9573. }
  9574. return refColumn;
  9575. }
  9576. return refLine;
  9577. }
  9578. }, {
  9579. key: 'value',
  9580. get: function get() {
  9581. return this.refValue.value;
  9582. }
  9583. }, {
  9584. key: 'type',
  9585. get: function get() {
  9586. return this.refValue.type;
  9587. }
  9588. }, {
  9589. key: 'lines',
  9590. get: function get() {
  9591. if (!(this.type instanceof _compoundType.CompoundType)) {
  9592. return null;
  9593. }
  9594. return this.refValue.value.length;
  9595. }
  9596. }, {
  9597. key: 'columns',
  9598. get: function get() {
  9599. switch (this.type.dimensions) {
  9600. case 2:
  9601. return this.refValue.value[0].value.length;
  9602. default:
  9603. return null;
  9604. }
  9605. }
  9606. }]);
  9607. return StoreObjectArrayAddress;
  9608. }(_storeObject.StoreObject);
  9609. /***/ }),
  9610. /***/ "./js/processor/store/storeObjectArrayAddressRef.js":
  9611. /*!**********************************************************!*\
  9612. !*** ./js/processor/store/storeObjectArrayAddressRef.js ***!
  9613. \**********************************************************/
  9614. /*! no static exports found */
  9615. /***/ (function(module, exports, __webpack_require__) {
  9616. "use strict";
  9617. Object.defineProperty(exports, "__esModule", {
  9618. value: true
  9619. });
  9620. exports.StoreObjectArrayAddressRef = undefined;
  9621. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9622. var _storeObject = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.js");
  9623. var _decimal = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
  9624. var _decimal2 = _interopRequireDefault(_decimal);
  9625. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9626. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9627. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9628. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9629. var StoreObjectArrayAddressRef = exports.StoreObjectArrayAddressRef = function (_StoreObject) {
  9630. _inherits(StoreObjectArrayAddressRef, _StoreObject);
  9631. function StoreObjectArrayAddressRef(address) {
  9632. _classCallCheck(this, StoreObjectArrayAddressRef);
  9633. var _this = _possibleConstructorReturn(this, (StoreObjectArrayAddressRef.__proto__ || Object.getPrototypeOf(StoreObjectArrayAddressRef)).call(this, null, null, false));
  9634. _this.address = address;
  9635. return _this;
  9636. }
  9637. _createClass(StoreObjectArrayAddressRef, [{
  9638. key: 'getRefObj',
  9639. value: function getRefObj() {
  9640. return this.address.refValue;
  9641. }
  9642. }, {
  9643. key: 'updateRef',
  9644. value: function updateRef(stoObj) {
  9645. var newArray = this.address.updateArrayObject(stoObj);
  9646. this.address.store.updateStore(this.address.refID, newArray);
  9647. }
  9648. }, {
  9649. key: 'isCompatible',
  9650. value: function isCompatible(another) {
  9651. return this.address.isCompatible(another);
  9652. }
  9653. }, {
  9654. key: 'isRef',
  9655. get: function get() {
  9656. return true;
  9657. }
  9658. }, {
  9659. key: 'type',
  9660. get: function get() {
  9661. return this.address.type;
  9662. }
  9663. }, {
  9664. key: 'value',
  9665. get: function get() {
  9666. return this.address.value;
  9667. }
  9668. }, {
  9669. key: 'number',
  9670. get: function get() {
  9671. if (this.value instanceof _decimal2.default) {
  9672. return this.value.toNumber();
  9673. } else {
  9674. return null;
  9675. }
  9676. }
  9677. }]);
  9678. return StoreObjectArrayAddressRef;
  9679. }(_storeObject.StoreObject);
  9680. /***/ }),
  9681. /***/ "./js/processor/store/storeObjectRef.js":
  9682. /*!**********************************************!*\
  9683. !*** ./js/processor/store/storeObjectRef.js ***!
  9684. \**********************************************/
  9685. /*! no static exports found */
  9686. /***/ (function(module, exports, __webpack_require__) {
  9687. "use strict";
  9688. Object.defineProperty(exports, "__esModule", {
  9689. value: true
  9690. });
  9691. exports.StoreObjectRef = undefined;
  9692. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9693. var _storeObject = __webpack_require__(/*! ./storeObject */ "./js/processor/store/storeObject.js");
  9694. var _decimal = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
  9695. var _decimal2 = _interopRequireDefault(_decimal);
  9696. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9697. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9698. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9699. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9700. var StoreObjectRef = exports.StoreObjectRef = function (_StoreObject) {
  9701. _inherits(StoreObjectRef, _StoreObject);
  9702. function StoreObjectRef(refID, store) {
  9703. _classCallCheck(this, StoreObjectRef);
  9704. var _this = _possibleConstructorReturn(this, (StoreObjectRef.__proto__ || Object.getPrototypeOf(StoreObjectRef)).call(this, null, null, false));
  9705. _this.refID = refID;
  9706. _this.store = store;
  9707. return _this;
  9708. }
  9709. _createClass(StoreObjectRef, [{
  9710. key: 'getRefObj',
  9711. value: function getRefObj() {
  9712. return this.store.applyStore(this.refID);
  9713. }
  9714. }, {
  9715. key: 'updateRef',
  9716. value: function updateRef(stoObj) {
  9717. this.store.updateStore(this.refID, stoObj);
  9718. }
  9719. }, {
  9720. key: 'isCompatible',
  9721. value: function isCompatible(another) {
  9722. return this.store.applyStore(this.refID).isCompatible(another);
  9723. }
  9724. }, {
  9725. key: 'isRef',
  9726. get: function get() {
  9727. return true;
  9728. }
  9729. }, {
  9730. key: 'type',
  9731. get: function get() {
  9732. return this.store.applyStore(this.refID).type;
  9733. }
  9734. }, {
  9735. key: 'value',
  9736. get: function get() {
  9737. return this.store.applyStore(this.refID).value;
  9738. }
  9739. }, {
  9740. key: 'number',
  9741. get: function get() {
  9742. if (this.value instanceof _decimal2.default) {
  9743. return this.value.toNumber();
  9744. } else {
  9745. return null;
  9746. }
  9747. }
  9748. }]);
  9749. return StoreObjectRef;
  9750. }(_storeObject.StoreObject);
  9751. /***/ }),
  9752. /***/ "./js/runner.js":
  9753. /*!**********************!*\
  9754. !*** ./js/runner.js ***!
  9755. \**********************/
  9756. /*! no static exports found */
  9757. /***/ (function(module, exports, __webpack_require__) {
  9758. "use strict";
  9759. Object.defineProperty(exports, "__esModule", {
  9760. value: true
  9761. });
  9762. exports.runner = runner;
  9763. var _ivprogParser = __webpack_require__(/*! ./ast/ivprogParser */ "./js/ast/ivprogParser.js");
  9764. var _ivprogProcessor = __webpack_require__(/*! ./processor/ivprogProcessor */ "./js/processor/ivprogProcessor.js");
  9765. var _domConsole = __webpack_require__(/*! ./io/domConsole */ "./js/io/domConsole.js");
  9766. var _languageService = __webpack_require__(/*! ./services/languageService */ "./js/services/languageService.js");
  9767. var _semanticAnalyser = __webpack_require__(/*! ./processor/semantic/semanticAnalyser */ "./js/processor/semantic/semanticAnalyser.js");
  9768. function runner() {
  9769. var ivprogLexer = _languageService.LanguageService.getCurrentLexer();
  9770. // const lexer = new ivprogLexer(new InputStream(input));
  9771. // const stream = new CommonTokenStream(lexer);
  9772. // stream.fill();
  9773. // let i = 1;
  9774. // let token = null;
  9775. // while ((token = stream.LT(i)).type !== ivprogLexer.EOF && token.type !== ivprogLexer.WHITESPACE) {
  9776. // console.log(`${token.type}-${token.text}`);
  9777. // console.log('\n')
  9778. // i++;
  9779. // }
  9780. // const anaSin = new IVProgParser(input, ivprogLexer);
  9781. var editor = new JsonEditor('#json-renderer', {});
  9782. var domConsole = new _domConsole.DOMConsole("#console");
  9783. // proc.interpretAST().then( sto => {
  9784. // console.log(sto.applyStore('a'));
  9785. // }).catch(e => console.log(e));
  9786. try {
  9787. $('#btn').click(function () {
  9788. var input = $('#input').val();
  9789. var analiser = new _ivprogParser.IVProgParser(input, ivprogLexer);
  9790. try {
  9791. var data = analiser.parseTree();
  9792. var semAna = new _semanticAnalyser.SemanticAnalyser(data);
  9793. var proc = new _ivprogProcessor.IVProgProcessor(semAna.analyseTree());
  9794. proc.registerInput(domConsole);
  9795. domConsole.clear();
  9796. proc.registerOutput(domConsole);
  9797. proc.interpretAST().then(function (sto) {
  9798. return editor.load(sto.store);
  9799. }).catch(function (e) {
  9800. alert(e);console.log(e);
  9801. });
  9802. } catch (error) {
  9803. alert(error);
  9804. console.log(error);
  9805. }
  9806. });
  9807. } catch (a) {
  9808. console.log(a);
  9809. }
  9810. }
  9811. /***/ }),
  9812. /***/ "./js/semantic/semantic.min.js":
  9813. /*!*************************************!*\
  9814. !*** ./js/semantic/semantic.min.js ***!
  9815. \*************************************/
  9816. /*! no static exports found */
  9817. /***/ (function(module, exports, __webpack_require__) {
  9818. "use strict";
  9819. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  9820. /*
  9821. * # Semantic UI - 2.3.3
  9822. * https://github.com/Semantic-Org/Semantic-UI
  9823. * http://www.semantic-ui.com/
  9824. *
  9825. * Copyright 2014 Contributors
  9826. * Released under the MIT license
  9827. * http://opensource.org/licenses/MIT
  9828. *
  9829. */
  9830. !function (e, t, n, i) {
  9831. e.site = e.fn.site = function (o) {
  9832. var a,
  9833. r,
  9834. s = new Date().getTime(),
  9835. l = [],
  9836. c = arguments[0],
  9837. u = "string" == typeof c,
  9838. d = [].slice.call(arguments, 1),
  9839. f = e.isPlainObject(o) ? e.extend(!0, {}, e.site.settings, o) : e.extend({}, e.site.settings),
  9840. m = f.namespace,
  9841. g = f.error,
  9842. p = "module-" + m,
  9843. h = e(n),
  9844. v = this,
  9845. b = h.data(p);return a = { initialize: function initialize() {
  9846. a.instantiate();
  9847. }, instantiate: function instantiate() {
  9848. a.verbose("Storing instance of site", a), b = a, h.data(p, a);
  9849. }, normalize: function normalize() {
  9850. a.fix.console(), a.fix.requestAnimationFrame();
  9851. }, fix: { console: function (_console) {
  9852. function console() {
  9853. return _console.apply(this, arguments);
  9854. }
  9855. console.toString = function () {
  9856. return _console.toString();
  9857. };
  9858. return console;
  9859. }(function () {
  9860. a.debug("Normalizing window.console"), console !== i && console.log !== i || (a.verbose("Console not available, normalizing events"), a.disable.console()), void 0 !== console.group && void 0 !== console.groupEnd && void 0 !== console.groupCollapsed || (a.verbose("Console group not available, normalizing events"), t.console.group = function () {}, t.console.groupEnd = function () {}, t.console.groupCollapsed = function () {}), void 0 === console.markTimeline && (a.verbose("Mark timeline not available, normalizing events"), t.console.markTimeline = function () {});
  9861. }), consoleClear: function consoleClear() {
  9862. a.debug("Disabling programmatic console clearing"), t.console.clear = function () {};
  9863. }, requestAnimationFrame: function requestAnimationFrame() {
  9864. a.debug("Normalizing requestAnimationFrame"), t.requestAnimationFrame === i && (a.debug("RequestAnimationFrame not available, normalizing event"), t.requestAnimationFrame = t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame || function (e) {
  9865. setTimeout(e, 0);
  9866. });
  9867. } }, moduleExists: function moduleExists(t) {
  9868. return e.fn[t] !== i && e.fn[t].settings !== i;
  9869. }, enabled: { modules: function modules(t) {
  9870. var n = [];return t = t || f.modules, e.each(t, function (e, t) {
  9871. a.moduleExists(t) && n.push(t);
  9872. }), n;
  9873. } }, disabled: { modules: function modules(t) {
  9874. var n = [];return t = t || f.modules, e.each(t, function (e, t) {
  9875. a.moduleExists(t) || n.push(t);
  9876. }), n;
  9877. } }, change: { setting: function setting(t, n, o, r) {
  9878. o = "string" == typeof o ? "all" === o ? f.modules : [o] : o || f.modules, r = r === i || r, e.each(o, function (i, o) {
  9879. var s,
  9880. l = !a.moduleExists(o) || e.fn[o].settings.namespace || !1;a.moduleExists(o) && (a.verbose("Changing default setting", t, n, o), e.fn[o].settings[t] = n, r && l && (s = e(":data(module-" + l + ")")).length > 0 && (a.verbose("Modifying existing settings", s), s[o]("setting", t, n)));
  9881. });
  9882. }, settings: function settings(t, n, o) {
  9883. n = "string" == typeof n ? [n] : n || f.modules, o = o === i || o, e.each(n, function (n, i) {
  9884. var r;a.moduleExists(i) && (a.verbose("Changing default setting", t, i), e.extend(!0, e.fn[i].settings, t), o && m && (r = e(":data(module-" + m + ")")).length > 0 && (a.verbose("Modifying existing settings", r), r[i]("setting", t)));
  9885. });
  9886. } }, enable: { console: function console() {
  9887. a.console(!0);
  9888. }, debug: function debug(e, t) {
  9889. e = e || f.modules, a.debug("Enabling debug for modules", e), a.change.setting("debug", !0, e, t);
  9890. }, verbose: function verbose(e, t) {
  9891. e = e || f.modules, a.debug("Enabling verbose debug for modules", e), a.change.setting("verbose", !0, e, t);
  9892. } }, disable: { console: function console() {
  9893. a.console(!1);
  9894. }, debug: function debug(e, t) {
  9895. e = e || f.modules, a.debug("Disabling debug for modules", e), a.change.setting("debug", !1, e, t);
  9896. }, verbose: function verbose(e, t) {
  9897. e = e || f.modules, a.debug("Disabling verbose debug for modules", e), a.change.setting("verbose", !1, e, t);
  9898. } }, console: function console(e) {
  9899. if (e) {
  9900. if (b.cache.console === i) return void a.error(g.console);a.debug("Restoring console function"), t.console = b.cache.console;
  9901. } else a.debug("Disabling console function"), b.cache.console = t.console, t.console = { clear: function clear() {}, error: function error() {}, group: function group() {}, groupCollapsed: function groupCollapsed() {}, groupEnd: function groupEnd() {}, info: function info() {}, log: function log() {}, markTimeline: function markTimeline() {}, warn: function warn() {} };
  9902. }, destroy: function destroy() {
  9903. a.verbose("Destroying previous site for", h), h.removeData(p);
  9904. }, cache: {}, setting: function setting(t, n) {
  9905. if (e.isPlainObject(t)) e.extend(!0, f, t);else {
  9906. if (n === i) return f[t];f[t] = n;
  9907. }
  9908. }, internal: function internal(t, n) {
  9909. if (e.isPlainObject(t)) e.extend(!0, a, t);else {
  9910. if (n === i) return a[t];a[t] = n;
  9911. }
  9912. }, debug: function debug() {
  9913. f.debug && (f.performance ? a.performance.log(arguments) : (a.debug = Function.prototype.bind.call(console.info, console, f.name + ":"), a.debug.apply(console, arguments)));
  9914. }, verbose: function verbose() {
  9915. f.verbose && f.debug && (f.performance ? a.performance.log(arguments) : (a.verbose = Function.prototype.bind.call(console.info, console, f.name + ":"), a.verbose.apply(console, arguments)));
  9916. }, error: function error() {
  9917. a.error = Function.prototype.bind.call(console.error, console, f.name + ":"), a.error.apply(console, arguments);
  9918. }, performance: { log: function log(e) {
  9919. var t, n;f.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Element: v, Name: e[0], Arguments: [].slice.call(e, 1) || "", "Execution Time": n })), clearTimeout(a.performance.timer), a.performance.timer = setTimeout(a.performance.display, 500);
  9920. }, display: function display() {
  9921. var t = f.name + ":",
  9922. n = 0;s = !1, clearTimeout(a.performance.timer), e.each(l, function (e, t) {
  9923. n += t["Execution Time"];
  9924. }), t += " " + n + "ms", (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  9925. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  9926. }), console.groupEnd()), l = [];
  9927. } }, invoke: function invoke(t, n, o) {
  9928. var s,
  9929. l,
  9930. c,
  9931. u = b;return n = n || d, o = v || o, "string" == typeof t && u !== i && (t = t.split(/[\. ]/), s = t.length - 1, e.each(t, function (n, o) {
  9932. var r = n != s ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(u[r]) && n != s) u = u[r];else {
  9933. if (u[r] !== i) return l = u[r], !1;if (!e.isPlainObject(u[o]) || n == s) return u[o] !== i ? (l = u[o], !1) : (a.error(g.method, t), !1);u = u[o];
  9934. }
  9935. })), e.isFunction(l) ? c = l.apply(o, n) : l !== i && (c = l), e.isArray(r) ? r.push(c) : r !== i ? r = [r, c] : c !== i && (r = c), l;
  9936. } }, u ? (b === i && a.initialize(), a.invoke(c)) : (b !== i && a.destroy(), a.initialize()), r !== i ? r : this;
  9937. }, e.site.settings = { name: "Site", namespace: "site", error: { console: "Console cannot be restored, most likely it was overwritten outside of module", method: "The method you called is not defined." }, debug: !1, verbose: !1, performance: !0, modules: ["accordion", "api", "checkbox", "dimmer", "dropdown", "embed", "form", "modal", "nag", "popup", "rating", "shape", "sidebar", "state", "sticky", "tab", "transition", "visit", "visibility"], siteNamespace: "site", namespaceStub: { cache: {}, config: {}, sections: {}, section: {}, utilities: {} } }, e.extend(e.expr[":"], { data: e.expr.createPseudo ? e.expr.createPseudo(function (t) {
  9938. return function (n) {
  9939. return !!e.data(n, t);
  9940. };
  9941. }) : function (t, n, i) {
  9942. return !!e.data(t, i[3]);
  9943. } });
  9944. }(jQuery, window, document), function (e, t, n, i) {
  9945. "use strict";
  9946. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.form = function (t) {
  9947. var o,
  9948. a = e(this),
  9949. r = a.selector || "",
  9950. s = new Date().getTime(),
  9951. l = [],
  9952. c = arguments[0],
  9953. u = arguments[1],
  9954. d = "string" == typeof c,
  9955. f = [].slice.call(arguments, 1);return a.each(function () {
  9956. var m,
  9957. g,
  9958. p,
  9959. h,
  9960. v,
  9961. b,
  9962. y,
  9963. x,
  9964. C,
  9965. w,
  9966. S,
  9967. k,
  9968. T,
  9969. A,
  9970. R,
  9971. P,
  9972. E = e(this),
  9973. F = this,
  9974. O = [],
  9975. D = !1;(P = { initialize: function initialize() {
  9976. P.get.settings(), d ? (R === i && P.instantiate(), P.invoke(c)) : (R !== i && R.invoke("destroy"), P.verbose("Initializing form validation", E, v), P.bindEvents(), P.set.defaults(), P.instantiate());
  9977. }, instantiate: function instantiate() {
  9978. P.verbose("Storing instance of module", P), R = P, E.data(T, P);
  9979. }, destroy: function destroy() {
  9980. P.verbose("Destroying previous module", R), P.removeEvents(), E.removeData(T);
  9981. }, refresh: function refresh() {
  9982. P.verbose("Refreshing selector cache"), m = E.find(x.field), g = E.find(x.group), p = E.find(x.message), E.find(x.prompt), h = E.find(x.submit), E.find(x.clear), E.find(x.reset);
  9983. }, submit: function submit() {
  9984. P.verbose("Submitting form", E), E.submit();
  9985. }, attachEvents: function attachEvents(t, n) {
  9986. n = n || "submit", e(t).on("click" + A, function (e) {
  9987. P[n](), e.preventDefault();
  9988. });
  9989. }, bindEvents: function bindEvents() {
  9990. P.verbose("Attaching form events"), E.on("submit" + A, P.validate.form).on("blur" + A, x.field, P.event.field.blur).on("click" + A, x.submit, P.submit).on("click" + A, x.reset, P.reset).on("click" + A, x.clear, P.clear), v.keyboardShortcuts && E.on("keydown" + A, x.field, P.event.field.keydown), m.each(function () {
  9991. var t = e(this),
  9992. n = t.prop("type"),
  9993. i = P.get.changeEvent(n, t);e(this).on(i + A, P.event.field.change);
  9994. });
  9995. }, clear: function clear() {
  9996. m.each(function () {
  9997. var t = e(this),
  9998. n = t.parent(),
  9999. i = t.closest(g),
  10000. o = i.find(x.prompt),
  10001. a = t.data(y.defaultValue) || "",
  10002. r = n.is(x.uiCheckbox),
  10003. s = n.is(x.uiDropdown);i.hasClass(C.error) && (P.verbose("Resetting error on field", i), i.removeClass(C.error), o.remove()), s ? (P.verbose("Resetting dropdown value", n, a), n.dropdown("clear")) : r ? t.prop("checked", !1) : (P.verbose("Resetting field value", t, a), t.val(""));
  10004. });
  10005. }, reset: function reset() {
  10006. m.each(function () {
  10007. var t = e(this),
  10008. n = t.parent(),
  10009. o = t.closest(g),
  10010. a = o.find(x.prompt),
  10011. r = t.data(y.defaultValue),
  10012. s = n.is(x.uiCheckbox),
  10013. l = n.is(x.uiDropdown),
  10014. c = o.hasClass(C.error);r !== i && (c && (P.verbose("Resetting error on field", o), o.removeClass(C.error), a.remove()), l ? (P.verbose("Resetting dropdown value", n, r), n.dropdown("restore defaults")) : s ? (P.verbose("Resetting checkbox value", n, r), t.prop("checked", r)) : (P.verbose("Resetting field value", t, r), t.val(r)));
  10015. });
  10016. }, determine: { isValid: function isValid() {
  10017. var t = !0;return e.each(b, function (e, n) {
  10018. P.validate.field(n, e, !0) || (t = !1);
  10019. }), t;
  10020. } }, is: { bracketedRule: function bracketedRule(e) {
  10021. return e.type && e.type.match(v.regExp.bracket);
  10022. }, shorthandFields: function shorthandFields(e) {
  10023. var t = e[Object.keys(e)[0]];return P.is.shorthandRules(t);
  10024. }, shorthandRules: function shorthandRules(t) {
  10025. return "string" == typeof t || e.isArray(t);
  10026. }, empty: function empty(e) {
  10027. return !e || 0 === e.length || (e.is('input[type="checkbox"]') ? !e.is(":checked") : P.is.blank(e));
  10028. }, blank: function blank(t) {
  10029. return "" === e.trim(t.val());
  10030. }, valid: function valid(t) {
  10031. var n = !0;return t ? (P.verbose("Checking if field is valid", t), P.validate.field(b[t], t, !1)) : (P.verbose("Checking if form is valid"), e.each(b, function (e, t) {
  10032. P.is.valid(e) || (n = !1);
  10033. }), n);
  10034. } }, removeEvents: function removeEvents() {
  10035. E.off(A), m.off(A), h.off(A), m.off(A);
  10036. }, event: { field: { keydown: function keydown(t) {
  10037. var n = e(this),
  10038. i = t.which,
  10039. o = n.is(x.input),
  10040. a = n.is(x.checkbox),
  10041. r = n.closest(x.uiDropdown).length > 0,
  10042. s = 13;i == 27 && (P.verbose("Escape key pressed blurring field"), n.blur()), t.ctrlKey || i != s || !o || r || a || (D || (n.one("keyup" + A, P.event.field.keyup), P.submit(), P.debug("Enter pressed on input submitting form")), D = !0);
  10043. }, keyup: function keyup() {
  10044. D = !1;
  10045. }, blur: function blur(t) {
  10046. var n = e(this),
  10047. i = n.closest(g),
  10048. o = P.get.validation(n);i.hasClass(C.error) ? (P.debug("Revalidating field", n, o), o && P.validate.field(o)) : "blur" == v.on && o && P.validate.field(o);
  10049. }, change: function change(t) {
  10050. var n = e(this),
  10051. i = n.closest(g),
  10052. o = P.get.validation(n);o && ("change" == v.on || i.hasClass(C.error) && v.revalidate) && (clearTimeout(P.timer), P.timer = setTimeout(function () {
  10053. P.debug("Revalidating field", n, P.get.validation(n)), P.validate.field(o);
  10054. }, v.delay));
  10055. } } }, get: { ancillaryValue: function ancillaryValue(e) {
  10056. return !(!e.type || !e.value && !P.is.bracketedRule(e)) && (e.value !== i ? e.value : e.type.match(v.regExp.bracket)[1] + "");
  10057. }, ruleName: function ruleName(e) {
  10058. return P.is.bracketedRule(e) ? e.type.replace(e.type.match(v.regExp.bracket)[0], "") : e.type;
  10059. }, changeEvent: function changeEvent(e, t) {
  10060. return "checkbox" == e || "radio" == e || "hidden" == e || t.is("select") ? "change" : P.get.inputEvent();
  10061. }, inputEvent: function inputEvent() {
  10062. return n.createElement("input").oninput !== i ? "input" : n.createElement("input").onpropertychange !== i ? "propertychange" : "keyup";
  10063. }, fieldsFromShorthand: function fieldsFromShorthand(t) {
  10064. var n = {};return e.each(t, function (t, i) {
  10065. "string" == typeof i && (i = [i]), n[t] = { rules: [] }, e.each(i, function (e, i) {
  10066. n[t].rules.push({ type: i });
  10067. });
  10068. }), n;
  10069. }, prompt: function prompt(t, n) {
  10070. var i,
  10071. o,
  10072. a = P.get.ruleName(t),
  10073. r = P.get.ancillaryValue(t),
  10074. s = P.get.field(n.identifier),
  10075. l = s.val(),
  10076. c = e.isFunction(t.prompt) ? t.prompt(l) : t.prompt || v.prompt[a] || v.text.unspecifiedRule,
  10077. u = -1 !== c.search("{value}"),
  10078. d = -1 !== c.search("{name}");return u && (c = c.replace("{value}", s.val())), d && (o = 1 == (i = s.closest(x.group).find("label").eq(0)).length ? i.text() : s.prop("placeholder") || v.text.unspecifiedField, c = c.replace("{name}", o)), c = (c = c.replace("{identifier}", n.identifier)).replace("{ruleValue}", r), t.prompt || P.verbose("Using default validation prompt for type", c, a), c;
  10079. }, settings: function settings() {
  10080. if (e.isPlainObject(t)) {
  10081. var n = Object.keys(t);n.length > 0 && t[n[0]].identifier !== i && t[n[0]].rules !== i ? (v = e.extend(!0, {}, e.fn.form.settings, u), b = e.extend({}, e.fn.form.settings.defaults, t), P.error(v.error.oldSyntax, F), P.verbose("Extending settings from legacy parameters", b, v)) : (t.fields && P.is.shorthandFields(t.fields) && (t.fields = P.get.fieldsFromShorthand(t.fields)), v = e.extend(!0, {}, e.fn.form.settings, t), b = e.extend({}, e.fn.form.settings.defaults, v.fields), P.verbose("Extending settings", b, v));
  10082. } else v = e.fn.form.settings, b = e.fn.form.settings.defaults, P.verbose("Using default form validation", b, v);k = v.namespace, y = v.metadata, x = v.selector, C = v.className, w = v.regExp, S = v.error, T = "module-" + k, A = "." + k, R = E.data(T), P.refresh();
  10083. }, field: function field(t) {
  10084. return P.verbose("Finding field with identifier", t), t = P.escape.string(t), m.filter("#" + t).length > 0 ? m.filter("#" + t) : m.filter('[name="' + t + '"]').length > 0 ? m.filter('[name="' + t + '"]') : m.filter('[name="' + t + '[]"]').length > 0 ? m.filter('[name="' + t + '[]"]') : m.filter("[data-" + y.validate + '="' + t + '"]').length > 0 ? m.filter("[data-" + y.validate + '="' + t + '"]') : e("<input/>");
  10085. }, fields: function fields(t) {
  10086. var n = e();return e.each(t, function (e, t) {
  10087. n = n.add(P.get.field(t));
  10088. }), n;
  10089. }, validation: function validation(t) {
  10090. var n, i;return !!b && (e.each(b, function (e, o) {
  10091. i = o.identifier || e, P.get.field(i)[0] == t[0] && (o.identifier = i, n = o);
  10092. }), n || !1);
  10093. }, value: function value(e) {
  10094. var t = [];return t.push(e), P.get.values.call(F, t)[e];
  10095. }, values: function values(t) {
  10096. var n = {};return (e.isArray(t) ? P.get.fields(t) : m).each(function (t, o) {
  10097. var a = e(o),
  10098. r = (a.prop("type"), a.prop("name")),
  10099. s = a.val(),
  10100. l = a.is(x.checkbox),
  10101. c = a.is(x.radio),
  10102. u = -1 !== r.indexOf("[]"),
  10103. d = !!l && a.is(":checked");r && (u ? (r = r.replace("[]", ""), n[r] || (n[r] = []), l ? d ? n[r].push(s || !0) : n[r].push(!1) : n[r].push(s)) : c ? n[r] !== i && 0 != n[r] || (n[r] = !!d && (s || !0)) : n[r] = l ? !!d && (s || !0) : s);
  10104. }), n;
  10105. } }, has: { field: function field(e) {
  10106. return P.verbose("Checking for existence of a field with identifier", e), "string" != typeof (e = P.escape.string(e)) && P.error(S.identifier, e), m.filter("#" + e).length > 0 || m.filter('[name="' + e + '"]').length > 0 || m.filter("[data-" + y.validate + '="' + e + '"]').length > 0;
  10107. } }, escape: { string: function string(e) {
  10108. return (e = String(e)).replace(w.escape, "\\$&");
  10109. } }, add: { rule: function rule(e, t) {
  10110. P.add.field(e, t);
  10111. }, field: function field(t, n) {
  10112. var i = {};P.is.shorthandRules(n) ? (n = e.isArray(n) ? n : [n], i[t] = { rules: [] }, e.each(n, function (e, n) {
  10113. i[t].rules.push({ type: n });
  10114. })) : i[t] = n, b = e.extend({}, b, i), P.debug("Adding rules", i, b);
  10115. }, fields: function fields(t) {
  10116. var n;n = t && P.is.shorthandFields(t) ? P.get.fieldsFromShorthand(t) : t, b = e.extend({}, b, n);
  10117. }, prompt: function prompt(t, n) {
  10118. var o = P.get.field(t).closest(g),
  10119. a = o.children(x.prompt),
  10120. r = 0 !== a.length;n = "string" == typeof n ? [n] : n, P.verbose("Adding field error state", t), o.addClass(C.error), v.inline && (r || (a = v.templates.prompt(n)).appendTo(o), a.html(n[0]), r ? P.verbose("Inline errors are disabled, no inline error added", t) : v.transition && e.fn.transition !== i && E.transition("is supported") ? (P.verbose("Displaying error with css transition", v.transition), a.transition(v.transition + " in", v.duration)) : (P.verbose("Displaying error with fallback javascript animation"), a.fadeIn(v.duration)));
  10121. }, errors: function errors(e) {
  10122. P.debug("Adding form error messages", e), P.set.error(), p.html(v.templates.error(e));
  10123. } }, remove: { rule: function rule(t, n) {
  10124. var o = e.isArray(n) ? n : [n];if (n == i) return P.debug("Removed all rules"), void (b[t].rules = []);b[t] != i && e.isArray(b[t].rules) && e.each(b[t].rules, function (e, n) {
  10125. -1 !== o.indexOf(n.type) && (P.debug("Removed rule", n.type), b[t].rules.splice(e, 1));
  10126. });
  10127. }, field: function field(t) {
  10128. var n = e.isArray(t) ? t : [t];e.each(n, function (e, t) {
  10129. P.remove.rule(t);
  10130. });
  10131. }, rules: function rules(t, n) {
  10132. e.isArray(t) ? e.each(fields, function (e, t) {
  10133. P.remove.rule(t, n);
  10134. }) : P.remove.rule(t, n);
  10135. }, fields: function fields(e) {
  10136. P.remove.field(e);
  10137. }, prompt: function prompt(t) {
  10138. var n = P.get.field(t).closest(g),
  10139. o = n.children(x.prompt);n.removeClass(C.error), v.inline && o.is(":visible") && (P.verbose("Removing prompt for field", t), v.transition && e.fn.transition !== i && E.transition("is supported") ? o.transition(v.transition + " out", v.duration, function () {
  10140. o.remove();
  10141. }) : o.fadeOut(v.duration, function () {
  10142. o.remove();
  10143. }));
  10144. } }, set: { success: function success() {
  10145. E.removeClass(C.error).addClass(C.success);
  10146. }, defaults: function defaults() {
  10147. m.each(function () {
  10148. var t = e(this),
  10149. n = t.filter(x.checkbox).length > 0 ? t.is(":checked") : t.val();t.data(y.defaultValue, n);
  10150. });
  10151. }, error: function error() {
  10152. E.removeClass(C.success).addClass(C.error);
  10153. }, value: function value(e, t) {
  10154. var n = {};return n[e] = t, P.set.values.call(F, n);
  10155. }, values: function values(t) {
  10156. e.isEmptyObject(t) || e.each(t, function (t, n) {
  10157. var i,
  10158. o = P.get.field(t),
  10159. a = o.parent(),
  10160. r = e.isArray(n),
  10161. s = a.is(x.uiCheckbox),
  10162. l = a.is(x.uiDropdown),
  10163. c = o.is(x.radio) && s;o.length > 0 && (r && s ? (P.verbose("Selecting multiple", n, o), a.checkbox("uncheck"), e.each(n, function (e, t) {
  10164. i = o.filter('[value="' + t + '"]'), a = i.parent(), i.length > 0 && a.checkbox("check");
  10165. })) : c ? (P.verbose("Selecting radio value", n, o), o.filter('[value="' + n + '"]').parent(x.uiCheckbox).checkbox("check")) : s ? (P.verbose("Setting checkbox value", n, a), !0 === n ? a.checkbox("check") : a.checkbox("uncheck")) : l ? (P.verbose("Setting dropdown value", n, a), a.dropdown("set selected", n)) : (P.verbose("Setting field value", n, o), o.val(n)));
  10166. });
  10167. } }, validate: { form: function form(e, t) {
  10168. var n = P.get.values();if (D) return !1;if (O = [], P.determine.isValid()) {
  10169. if (P.debug("Form has no validation errors, submitting"), P.set.success(), !0 !== t) return v.onSuccess.call(F, e, n);
  10170. } else if (P.debug("Form has errors"), P.set.error(), v.inline || P.add.errors(O), E.data("moduleApi") !== i && e.stopImmediatePropagation(), !0 !== t) return v.onFailure.call(F, O, n);
  10171. }, field: function field(t, n, o) {
  10172. o = o === i || o, "string" == typeof t && (P.verbose("Validating field", t), n = t, t = b[t]);var a = t.identifier || n,
  10173. r = P.get.field(a),
  10174. s = !!t.depends && P.get.field(t.depends),
  10175. l = !0,
  10176. c = [];return t.identifier || (P.debug("Using field name as identifier", a), t.identifier = a), r.prop("disabled") ? (P.debug("Field is disabled. Skipping", a), l = !0) : t.optional && P.is.blank(r) ? (P.debug("Field is optional and blank. Skipping", a), l = !0) : t.depends && P.is.empty(s) ? (P.debug("Field depends on another value that is not present or empty. Skipping", s), l = !0) : t.rules !== i && e.each(t.rules, function (e, n) {
  10177. P.has.field(a) && !P.validate.rule(t, n) && (P.debug("Field is invalid", a, n.type), c.push(P.get.prompt(n, t)), l = !1);
  10178. }), l ? (o && (P.remove.prompt(a, c), v.onValid.call(r)), !0) : (o && (O = O.concat(c), P.add.prompt(a, c), v.onInvalid.call(r, c)), !1);
  10179. }, rule: function rule(t, n) {
  10180. var o = P.get.field(t.identifier),
  10181. a = (n.type, o.val()),
  10182. r = P.get.ancillaryValue(n),
  10183. s = P.get.ruleName(n),
  10184. l = v.rules[s];if (e.isFunction(l)) return a = a === i || "" === a || null === a ? "" : e.trim(a + ""), l.call(o, a, r);P.error(S.noRule, s);
  10185. } }, setting: function setting(t, n) {
  10186. if (e.isPlainObject(t)) e.extend(!0, v, t);else {
  10187. if (n === i) return v[t];v[t] = n;
  10188. }
  10189. }, internal: function internal(t, n) {
  10190. if (e.isPlainObject(t)) e.extend(!0, P, t);else {
  10191. if (n === i) return P[t];P[t] = n;
  10192. }
  10193. }, debug: function debug() {
  10194. !v.silent && v.debug && (v.performance ? P.performance.log(arguments) : (P.debug = Function.prototype.bind.call(console.info, console, v.name + ":"), P.debug.apply(console, arguments)));
  10195. }, verbose: function verbose() {
  10196. !v.silent && v.verbose && v.debug && (v.performance ? P.performance.log(arguments) : (P.verbose = Function.prototype.bind.call(console.info, console, v.name + ":"), P.verbose.apply(console, arguments)));
  10197. }, error: function error() {
  10198. v.silent || (P.error = Function.prototype.bind.call(console.error, console, v.name + ":"), P.error.apply(console, arguments));
  10199. }, performance: { log: function log(e) {
  10200. var t, n;v.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: F, "Execution Time": n })), clearTimeout(P.performance.timer), P.performance.timer = setTimeout(P.performance.display, 500);
  10201. }, display: function display() {
  10202. var t = v.name + ":",
  10203. n = 0;s = !1, clearTimeout(P.performance.timer), e.each(l, function (e, t) {
  10204. n += t["Execution Time"];
  10205. }), t += " " + n + "ms", r && (t += " '" + r + "'"), a.length > 1 && (t += " (" + a.length + ")"), (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  10206. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  10207. }), console.groupEnd()), l = [];
  10208. } }, invoke: function invoke(t, n, a) {
  10209. var r,
  10210. s,
  10211. l,
  10212. c = R;return n = n || f, a = F || a, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  10213. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  10214. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  10215. }
  10216. })), e.isFunction(s) ? l = s.apply(a, n) : s !== i && (l = s), e.isArray(o) ? o.push(l) : o !== i ? o = [o, l] : l !== i && (o = l), s;
  10217. } }).initialize();
  10218. }), o !== i ? o : this;
  10219. }, e.fn.form.settings = { name: "Form", namespace: "form", debug: !1, verbose: !1, performance: !0, fields: !1, keyboardShortcuts: !0, on: "submit", inline: !1, delay: 200, revalidate: !0, transition: "scale", duration: 200, onValid: function onValid() {}, onInvalid: function onInvalid() {}, onSuccess: function onSuccess() {
  10220. return !0;
  10221. }, onFailure: function onFailure() {
  10222. return !1;
  10223. }, metadata: { defaultValue: "default", validate: "validate" }, regExp: { htmlID: /^[a-zA-Z][\w:.-]*$/g, bracket: /\[(.*)\]/i, decimal: /^\d+\.?\d*$/, email: /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i, escape: /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, flags: /^\/(.*)\/(.*)?/, integer: /^\-?\d+$/, number: /^\-?\d*(\.\d+)?$/, url: /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i }, text: { unspecifiedRule: "Please enter a valid value", unspecifiedField: "This field" }, prompt: { empty: "{name} must have a value", checked: "{name} must be checked", email: "{name} must be a valid e-mail", url: "{name} must be a valid url", regExp: "{name} is not formatted correctly", integer: "{name} must be an integer", decimal: "{name} must be a decimal number", number: "{name} must be set to a number", is: '{name} must be "{ruleValue}"', isExactly: '{name} must be exactly "{ruleValue}"', not: '{name} cannot be set to "{ruleValue}"', notExactly: '{name} cannot be set to exactly "{ruleValue}"', contain: '{name} must contain "{ruleValue}"', containExactly: '{name} must contain exactly "{ruleValue}"', doesntContain: '{name} cannot contain "{ruleValue}"', doesntContainExactly: '{name} cannot contain exactly "{ruleValue}"', minLength: "{name} must be at least {ruleValue} characters", length: "{name} must be at least {ruleValue} characters", exactLength: "{name} must be exactly {ruleValue} characters", maxLength: "{name} cannot be longer than {ruleValue} characters", match: "{name} must match {ruleValue} field", different: "{name} must have a different value than {ruleValue} field", creditCard: "{name} must be a valid credit card number", minCount: "{name} must have at least {ruleValue} choices", exactCount: "{name} must have exactly {ruleValue} choices", maxCount: "{name} must have {ruleValue} or less choices" }, selector: { checkbox: 'input[type="checkbox"], input[type="radio"]', clear: ".clear", field: "input, textarea, select", group: ".field", input: "input", message: ".error.message", prompt: ".prompt.label", radio: 'input[type="radio"]', reset: '.reset:not([type="reset"])', submit: '.submit:not([type="submit"])', uiCheckbox: ".ui.checkbox", uiDropdown: ".ui.dropdown" }, className: { error: "error", label: "ui prompt label", pressed: "down", success: "success" }, error: { identifier: "You must specify a string identifier for each field", method: "The method you called is not defined.", noRule: "There is no rule matching the one you specified", oldSyntax: "Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically." }, templates: { error: function error(t) {
  10224. var n = '<ul class="list">';return e.each(t, function (e, t) {
  10225. n += "<li>" + t + "</li>";
  10226. }), e(n += "</ul>");
  10227. }, prompt: function prompt(t) {
  10228. return e("<div/>").addClass("ui basic red pointing prompt label").html(t[0]);
  10229. } }, rules: { empty: function empty(t) {
  10230. return !(t === i || "" === t || e.isArray(t) && 0 === t.length);
  10231. }, checked: function checked() {
  10232. return e(this).filter(":checked").length > 0;
  10233. }, email: function email(t) {
  10234. return e.fn.form.settings.regExp.email.test(t);
  10235. }, url: function url(t) {
  10236. return e.fn.form.settings.regExp.url.test(t);
  10237. }, regExp: function regExp(t, n) {
  10238. if (n instanceof RegExp) return t.match(n);var i,
  10239. o = n.match(e.fn.form.settings.regExp.flags);return o && (n = o.length >= 2 ? o[1] : n, i = o.length >= 3 ? o[2] : ""), t.match(new RegExp(n, i));
  10240. }, integer: function integer(t, n) {
  10241. var o,
  10242. a,
  10243. r,
  10244. s = e.fn.form.settings.regExp.integer;return n && -1 === ["", ".."].indexOf(n) && (-1 == n.indexOf("..") ? s.test(n) && (o = a = n - 0) : (r = n.split("..", 2), s.test(r[0]) && (o = r[0] - 0), s.test(r[1]) && (a = r[1] - 0))), s.test(t) && (o === i || t >= o) && (a === i || t <= a);
  10245. }, decimal: function decimal(t) {
  10246. return e.fn.form.settings.regExp.decimal.test(t);
  10247. }, number: function number(t) {
  10248. return e.fn.form.settings.regExp.number.test(t);
  10249. }, is: function is(e, t) {
  10250. return t = "string" == typeof t ? t.toLowerCase() : t, (e = "string" == typeof e ? e.toLowerCase() : e) == t;
  10251. }, isExactly: function isExactly(e, t) {
  10252. return e == t;
  10253. }, not: function not(e, t) {
  10254. return (e = "string" == typeof e ? e.toLowerCase() : e) != (t = "string" == typeof t ? t.toLowerCase() : t);
  10255. }, notExactly: function notExactly(e, t) {
  10256. return e != t;
  10257. }, contains: function contains(t, n) {
  10258. return n = n.replace(e.fn.form.settings.regExp.escape, "\\$&"), -1 !== t.search(new RegExp(n, "i"));
  10259. }, containsExactly: function containsExactly(t, n) {
  10260. return n = n.replace(e.fn.form.settings.regExp.escape, "\\$&"), -1 !== t.search(new RegExp(n));
  10261. }, doesntContain: function doesntContain(t, n) {
  10262. return n = n.replace(e.fn.form.settings.regExp.escape, "\\$&"), -1 === t.search(new RegExp(n, "i"));
  10263. }, doesntContainExactly: function doesntContainExactly(t, n) {
  10264. return n = n.replace(e.fn.form.settings.regExp.escape, "\\$&"), -1 === t.search(new RegExp(n));
  10265. }, minLength: function minLength(e, t) {
  10266. return e !== i && e.length >= t;
  10267. }, length: function length(e, t) {
  10268. return e !== i && e.length >= t;
  10269. }, exactLength: function exactLength(e, t) {
  10270. return e !== i && e.length == t;
  10271. }, maxLength: function maxLength(e, t) {
  10272. return e !== i && e.length <= t;
  10273. }, match: function match(t, n) {
  10274. var o;e(this);return e('[data-validate="' + n + '"]').length > 0 ? o = e('[data-validate="' + n + '"]').val() : e("#" + n).length > 0 ? o = e("#" + n).val() : e('[name="' + n + '"]').length > 0 ? o = e('[name="' + n + '"]').val() : e('[name="' + n + '[]"]').length > 0 && (o = e('[name="' + n + '[]"]')), o !== i && t.toString() == o.toString();
  10275. }, different: function different(t, n) {
  10276. var o;e(this);return e('[data-validate="' + n + '"]').length > 0 ? o = e('[data-validate="' + n + '"]').val() : e("#" + n).length > 0 ? o = e("#" + n).val() : e('[name="' + n + '"]').length > 0 ? o = e('[name="' + n + '"]').val() : e('[name="' + n + '[]"]').length > 0 && (o = e('[name="' + n + '[]"]')), o !== i && t.toString() !== o.toString();
  10277. }, creditCard: function creditCard(t, n) {
  10278. var i,
  10279. o,
  10280. a = { visa: { pattern: /^4/, length: [16] }, amex: { pattern: /^3[47]/, length: [15] }, mastercard: { pattern: /^5[1-5]/, length: [16] }, discover: { pattern: /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/, length: [16] }, unionPay: { pattern: /^(62|88)/, length: [16, 17, 18, 19] }, jcb: { pattern: /^35(2[89]|[3-8][0-9])/, length: [16] }, maestro: { pattern: /^(5018|5020|5038|6304|6759|676[1-3])/, length: [12, 13, 14, 15, 16, 17, 18, 19] }, dinersClub: { pattern: /^(30[0-5]|^36)/, length: [14] }, laser: { pattern: /^(6304|670[69]|6771)/, length: [16, 17, 18, 19] }, visaElectron: { pattern: /^(4026|417500|4508|4844|491(3|7))/, length: [16] } },
  10281. r = {},
  10282. s = !1,
  10283. l = "string" == typeof n && n.split(",");if ("string" == typeof t && 0 !== t.length) {
  10284. if (t = t.replace(/[\-]/g, ""), l && (e.each(l, function (n, i) {
  10285. (o = a[i]) && (r = { length: -1 !== e.inArray(t.length, o.length), pattern: -1 !== t.search(o.pattern) }).length && r.pattern && (s = !0);
  10286. }), !s)) return !1;if ((i = { number: -1 !== e.inArray(t.length, a.unionPay.length), pattern: -1 !== t.search(a.unionPay.pattern) }).number && i.pattern) return !0;for (var c = t.length, u = 0, d = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]], f = 0; c--;) {
  10287. f += d[u][parseInt(t.charAt(c), 10)], u ^= 1;
  10288. }return f % 10 == 0 && f > 0;
  10289. }
  10290. }, minCount: function minCount(e, t) {
  10291. return 0 == t || (1 == t ? "" !== e : e.split(",").length >= t);
  10292. }, exactCount: function exactCount(e, t) {
  10293. return 0 == t ? "" === e : 1 == t ? "" !== e && -1 === e.search(",") : e.split(",").length == t;
  10294. }, maxCount: function maxCount(e, t) {
  10295. return 0 != t && (1 == t ? -1 === e.search(",") : e.split(",").length <= t);
  10296. } } };
  10297. }(jQuery, window, document), function (e, t, n, i) {
  10298. "use strict";
  10299. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.accordion = function (n) {
  10300. var o,
  10301. a = e(this),
  10302. r = new Date().getTime(),
  10303. s = [],
  10304. l = arguments[0],
  10305. c = "string" == typeof l,
  10306. u = [].slice.call(arguments, 1);t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame;return a.each(function () {
  10307. var d,
  10308. f,
  10309. m = e.isPlainObject(n) ? e.extend(!0, {}, e.fn.accordion.settings, n) : e.extend({}, e.fn.accordion.settings),
  10310. g = m.className,
  10311. p = m.namespace,
  10312. h = m.selector,
  10313. v = m.error,
  10314. b = "." + p,
  10315. y = "module-" + p,
  10316. x = a.selector || "",
  10317. C = e(this),
  10318. w = C.find(h.title),
  10319. S = C.find(h.content),
  10320. k = this,
  10321. T = C.data(y);f = { initialize: function initialize() {
  10322. f.debug("Initializing", C), f.bind.events(), m.observeChanges && f.observeChanges(), f.instantiate();
  10323. }, instantiate: function instantiate() {
  10324. T = f, C.data(y, f);
  10325. }, destroy: function destroy() {
  10326. f.debug("Destroying previous instance", C), C.off(b).removeData(y);
  10327. }, refresh: function refresh() {
  10328. w = C.find(h.title), S = C.find(h.content);
  10329. }, observeChanges: function observeChanges() {
  10330. "MutationObserver" in t && ((d = new MutationObserver(function (e) {
  10331. f.debug("DOM tree modified, updating selector cache"), f.refresh();
  10332. })).observe(k, { childList: !0, subtree: !0 }), f.debug("Setting up mutation observer", d));
  10333. }, bind: { events: function events() {
  10334. f.debug("Binding delegated events"), C.on(m.on + b, h.trigger, f.event.click);
  10335. } }, event: { click: function click() {
  10336. f.toggle.call(this);
  10337. } }, toggle: function toggle(t) {
  10338. var n = t !== i ? "number" == typeof t ? w.eq(t) : e(t).closest(h.title) : e(this).closest(h.title),
  10339. o = n.next(S),
  10340. a = o.hasClass(g.animating),
  10341. r = o.hasClass(g.active),
  10342. s = r && !a,
  10343. l = !r && a;f.debug("Toggling visibility of content", n), s || l ? m.collapsible ? f.close.call(n) : f.debug("Cannot close accordion content collapsing is disabled") : f.open.call(n);
  10344. }, open: function open(t) {
  10345. var n = t !== i ? "number" == typeof t ? w.eq(t) : e(t).closest(h.title) : e(this).closest(h.title),
  10346. o = n.next(S),
  10347. a = o.hasClass(g.animating);o.hasClass(g.active) || a ? f.debug("Accordion already open, skipping", o) : (f.debug("Opening accordion content", n), m.onOpening.call(o), m.onChanging.call(o), m.exclusive && f.closeOthers.call(n), n.addClass(g.active), o.stop(!0, !0).addClass(g.animating), m.animateChildren && (e.fn.transition !== i && C.transition("is supported") ? o.children().transition({ animation: "fade in", queue: !1, useFailSafe: !0, debug: m.debug, verbose: m.verbose, duration: m.duration }) : o.children().stop(!0, !0).animate({ opacity: 1 }, m.duration, f.resetOpacity)), o.slideDown(m.duration, m.easing, function () {
  10348. o.removeClass(g.animating).addClass(g.active), f.reset.display.call(this), m.onOpen.call(this), m.onChange.call(this);
  10349. }));
  10350. }, close: function close(t) {
  10351. var n = t !== i ? "number" == typeof t ? w.eq(t) : e(t).closest(h.title) : e(this).closest(h.title),
  10352. o = n.next(S),
  10353. a = o.hasClass(g.animating),
  10354. r = o.hasClass(g.active);!r && !(!r && a) || r && a || (f.debug("Closing accordion content", o), m.onClosing.call(o), m.onChanging.call(o), n.removeClass(g.active), o.stop(!0, !0).addClass(g.animating), m.animateChildren && (e.fn.transition !== i && C.transition("is supported") ? o.children().transition({ animation: "fade out", queue: !1, useFailSafe: !0, debug: m.debug, verbose: m.verbose, duration: m.duration }) : o.children().stop(!0, !0).animate({ opacity: 0 }, m.duration, f.resetOpacity)), o.slideUp(m.duration, m.easing, function () {
  10355. o.removeClass(g.animating).removeClass(g.active), f.reset.display.call(this), m.onClose.call(this), m.onChange.call(this);
  10356. }));
  10357. }, closeOthers: function closeOthers(t) {
  10358. var n,
  10359. o,
  10360. a,
  10361. r = t !== i ? w.eq(t) : e(this).closest(h.title),
  10362. s = r.parents(h.content).prev(h.title),
  10363. l = r.closest(h.accordion),
  10364. c = h.title + "." + g.active + ":visible",
  10365. u = h.content + "." + g.active + ":visible";m.closeNested ? a = (n = l.find(c).not(s)).next(S) : (n = l.find(c).not(s), o = l.find(u).find(c).not(s), a = (n = n.not(o)).next(S)), n.length > 0 && (f.debug("Exclusive enabled, closing other content", n), n.removeClass(g.active), a.removeClass(g.animating).stop(!0, !0), m.animateChildren && (e.fn.transition !== i && C.transition("is supported") ? a.children().transition({ animation: "fade out", useFailSafe: !0, debug: m.debug, verbose: m.verbose, duration: m.duration }) : a.children().stop(!0, !0).animate({ opacity: 0 }, m.duration, f.resetOpacity)), a.slideUp(m.duration, m.easing, function () {
  10366. e(this).removeClass(g.active), f.reset.display.call(this);
  10367. }));
  10368. }, reset: { display: function display() {
  10369. f.verbose("Removing inline display from element", this), e(this).css("display", ""), "" === e(this).attr("style") && e(this).attr("style", "").removeAttr("style");
  10370. }, opacity: function opacity() {
  10371. f.verbose("Removing inline opacity from element", this), e(this).css("opacity", ""), "" === e(this).attr("style") && e(this).attr("style", "").removeAttr("style");
  10372. } }, setting: function setting(t, n) {
  10373. if (f.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, m, t);else {
  10374. if (n === i) return m[t];e.isPlainObject(m[t]) ? e.extend(!0, m[t], n) : m[t] = n;
  10375. }
  10376. }, internal: function internal(t, n) {
  10377. if (f.debug("Changing internal", t, n), n === i) return f[t];e.isPlainObject(t) ? e.extend(!0, f, t) : f[t] = n;
  10378. }, debug: function debug() {
  10379. !m.silent && m.debug && (m.performance ? f.performance.log(arguments) : (f.debug = Function.prototype.bind.call(console.info, console, m.name + ":"), f.debug.apply(console, arguments)));
  10380. }, verbose: function verbose() {
  10381. !m.silent && m.verbose && m.debug && (m.performance ? f.performance.log(arguments) : (f.verbose = Function.prototype.bind.call(console.info, console, m.name + ":"), f.verbose.apply(console, arguments)));
  10382. }, error: function error() {
  10383. m.silent || (f.error = Function.prototype.bind.call(console.error, console, m.name + ":"), f.error.apply(console, arguments));
  10384. }, performance: { log: function log(e) {
  10385. var t, n;m.performance && (n = (t = new Date().getTime()) - (r || t), r = t, s.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: k, "Execution Time": n })), clearTimeout(f.performance.timer), f.performance.timer = setTimeout(f.performance.display, 500);
  10386. }, display: function display() {
  10387. var t = m.name + ":",
  10388. n = 0;r = !1, clearTimeout(f.performance.timer), e.each(s, function (e, t) {
  10389. n += t["Execution Time"];
  10390. }), t += " " + n + "ms", x && (t += " '" + x + "'"), (console.group !== i || console.table !== i) && s.length > 0 && (console.groupCollapsed(t), console.table ? console.table(s) : e.each(s, function (e, t) {
  10391. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  10392. }), console.groupEnd()), s = [];
  10393. } }, invoke: function invoke(t, n, a) {
  10394. var r,
  10395. s,
  10396. l,
  10397. c = T;return n = n || u, a = k || a, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  10398. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  10399. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (f.error(v.method, t), !1);c = c[o];
  10400. }
  10401. })), e.isFunction(s) ? l = s.apply(a, n) : s !== i && (l = s), e.isArray(o) ? o.push(l) : o !== i ? o = [o, l] : l !== i && (o = l), s;
  10402. } }, c ? (T === i && f.initialize(), f.invoke(l)) : (T !== i && T.invoke("destroy"), f.initialize());
  10403. }), o !== i ? o : this;
  10404. }, e.fn.accordion.settings = { name: "Accordion", namespace: "accordion", silent: !1, debug: !1, verbose: !1, performance: !0, on: "click", observeChanges: !0, exclusive: !0, collapsible: !0, closeNested: !1, animateChildren: !0, duration: 350, easing: "easeOutQuad", onOpening: function onOpening() {}, onClosing: function onClosing() {}, onChanging: function onChanging() {}, onOpen: function onOpen() {}, onClose: function onClose() {}, onChange: function onChange() {}, error: { method: "The method you called is not defined" }, className: { active: "active", animating: "animating" }, selector: { accordion: ".accordion", title: ".title", trigger: ".title", content: ".content" } }, e.extend(e.easing, { easeOutQuad: function easeOutQuad(e, t, n, i, o) {
  10405. return -i * (t /= o) * (t - 2) + n;
  10406. } });
  10407. }(jQuery, window, document), function (e, t, n, i) {
  10408. "use strict";
  10409. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.checkbox = function (o) {
  10410. var a,
  10411. r = e(this),
  10412. s = r.selector || "",
  10413. l = new Date().getTime(),
  10414. c = [],
  10415. u = arguments[0],
  10416. d = "string" == typeof u,
  10417. f = [].slice.call(arguments, 1);return r.each(function () {
  10418. var r,
  10419. m,
  10420. g = e.extend(!0, {}, e.fn.checkbox.settings, o),
  10421. p = g.className,
  10422. h = g.namespace,
  10423. v = g.selector,
  10424. b = g.error,
  10425. y = "." + h,
  10426. x = "module-" + h,
  10427. C = e(this),
  10428. w = e(this).children(v.label),
  10429. S = e(this).children(v.input),
  10430. k = S[0],
  10431. T = !1,
  10432. A = !1,
  10433. R = C.data(x),
  10434. P = this;m = { initialize: function initialize() {
  10435. m.verbose("Initializing checkbox", g), m.create.label(), m.bind.events(), m.set.tabbable(), m.hide.input(), m.observeChanges(), m.instantiate(), m.setup();
  10436. }, instantiate: function instantiate() {
  10437. m.verbose("Storing instance of module", m), R = m, C.data(x, m);
  10438. }, destroy: function destroy() {
  10439. m.verbose("Destroying module"), m.unbind.events(), m.show.input(), C.removeData(x);
  10440. }, fix: { reference: function reference() {
  10441. C.is(v.input) && (m.debug("Behavior called on <input> adjusting invoked element"), C = C.closest(v.checkbox), m.refresh());
  10442. } }, setup: function setup() {
  10443. m.set.initialLoad(), m.is.indeterminate() ? (m.debug("Initial value is indeterminate"), m.indeterminate()) : m.is.checked() ? (m.debug("Initial value is checked"), m.check()) : (m.debug("Initial value is unchecked"), m.uncheck()), m.remove.initialLoad();
  10444. }, refresh: function refresh() {
  10445. w = C.children(v.label), S = C.children(v.input), k = S[0];
  10446. }, hide: { input: function input() {
  10447. m.verbose("Modifying <input> z-index to be unselectable"), S.addClass(p.hidden);
  10448. } }, show: { input: function input() {
  10449. m.verbose("Modifying <input> z-index to be selectable"), S.removeClass(p.hidden);
  10450. } }, observeChanges: function observeChanges() {
  10451. "MutationObserver" in t && ((r = new MutationObserver(function (e) {
  10452. m.debug("DOM tree modified, updating selector cache"), m.refresh();
  10453. })).observe(P, { childList: !0, subtree: !0 }), m.debug("Setting up mutation observer", r));
  10454. }, attachEvents: function attachEvents(t, n) {
  10455. var i = e(t);n = e.isFunction(m[n]) ? m[n] : m.toggle, i.length > 0 ? (m.debug("Attaching checkbox events to element", t, n), i.on("click" + y, n)) : m.error(b.notFound);
  10456. }, event: { click: function click(t) {
  10457. var n = e(t.target);n.is(v.input) ? m.verbose("Using default check action on initialized checkbox") : n.is(v.link) ? m.debug("Clicking link inside checkbox, skipping toggle") : (m.toggle(), S.focus(), t.preventDefault());
  10458. }, keydown: function keydown(e) {
  10459. var t = e.which,
  10460. n = 13,
  10461. i = 32;t == 27 ? (m.verbose("Escape key pressed blurring field"), S.blur(), A = !0) : e.ctrlKey || t != i && t != n ? A = !1 : (m.verbose("Enter/space key pressed, toggling checkbox"), m.toggle(), A = !0);
  10462. }, keyup: function keyup(e) {
  10463. A && e.preventDefault();
  10464. } }, check: function check() {
  10465. m.should.allowCheck() && (m.debug("Checking checkbox", S), m.set.checked(), m.should.ignoreCallbacks() || (g.onChecked.call(k), g.onChange.call(k)));
  10466. }, uncheck: function uncheck() {
  10467. m.should.allowUncheck() && (m.debug("Unchecking checkbox"), m.set.unchecked(), m.should.ignoreCallbacks() || (g.onUnchecked.call(k), g.onChange.call(k)));
  10468. }, indeterminate: function indeterminate() {
  10469. m.should.allowIndeterminate() ? m.debug("Checkbox is already indeterminate") : (m.debug("Making checkbox indeterminate"), m.set.indeterminate(), m.should.ignoreCallbacks() || (g.onIndeterminate.call(k), g.onChange.call(k)));
  10470. }, determinate: function determinate() {
  10471. m.should.allowDeterminate() ? m.debug("Checkbox is already determinate") : (m.debug("Making checkbox determinate"), m.set.determinate(), m.should.ignoreCallbacks() || (g.onDeterminate.call(k), g.onChange.call(k)));
  10472. }, enable: function enable() {
  10473. m.is.enabled() ? m.debug("Checkbox is already enabled") : (m.debug("Enabling checkbox"), m.set.enabled(), g.onEnable.call(k), g.onEnabled.call(k));
  10474. }, disable: function disable() {
  10475. m.is.disabled() ? m.debug("Checkbox is already disabled") : (m.debug("Disabling checkbox"), m.set.disabled(), g.onDisable.call(k), g.onDisabled.call(k));
  10476. }, get: { radios: function radios() {
  10477. var t = m.get.name();return e('input[name="' + t + '"]').closest(v.checkbox);
  10478. }, otherRadios: function otherRadios() {
  10479. return m.get.radios().not(C);
  10480. }, name: function name() {
  10481. return S.attr("name");
  10482. } }, is: { initialLoad: function initialLoad() {
  10483. return T;
  10484. }, radio: function radio() {
  10485. return S.hasClass(p.radio) || "radio" == S.attr("type");
  10486. }, indeterminate: function indeterminate() {
  10487. return S.prop("indeterminate") !== i && S.prop("indeterminate");
  10488. }, checked: function checked() {
  10489. return S.prop("checked") !== i && S.prop("checked");
  10490. }, disabled: function disabled() {
  10491. return S.prop("disabled") !== i && S.prop("disabled");
  10492. }, enabled: function enabled() {
  10493. return !m.is.disabled();
  10494. }, determinate: function determinate() {
  10495. return !m.is.indeterminate();
  10496. }, unchecked: function unchecked() {
  10497. return !m.is.checked();
  10498. } }, should: { allowCheck: function allowCheck() {
  10499. return m.is.determinate() && m.is.checked() && !m.should.forceCallbacks() ? (m.debug("Should not allow check, checkbox is already checked"), !1) : !1 !== g.beforeChecked.apply(k) || (m.debug("Should not allow check, beforeChecked cancelled"), !1);
  10500. }, allowUncheck: function allowUncheck() {
  10501. return m.is.determinate() && m.is.unchecked() && !m.should.forceCallbacks() ? (m.debug("Should not allow uncheck, checkbox is already unchecked"), !1) : !1 !== g.beforeUnchecked.apply(k) || (m.debug("Should not allow uncheck, beforeUnchecked cancelled"), !1);
  10502. }, allowIndeterminate: function allowIndeterminate() {
  10503. return m.is.indeterminate() && !m.should.forceCallbacks() ? (m.debug("Should not allow indeterminate, checkbox is already indeterminate"), !1) : !1 !== g.beforeIndeterminate.apply(k) || (m.debug("Should not allow indeterminate, beforeIndeterminate cancelled"), !1);
  10504. }, allowDeterminate: function allowDeterminate() {
  10505. return m.is.determinate() && !m.should.forceCallbacks() ? (m.debug("Should not allow determinate, checkbox is already determinate"), !1) : !1 !== g.beforeDeterminate.apply(k) || (m.debug("Should not allow determinate, beforeDeterminate cancelled"), !1);
  10506. }, forceCallbacks: function forceCallbacks() {
  10507. return m.is.initialLoad() && g.fireOnInit;
  10508. }, ignoreCallbacks: function ignoreCallbacks() {
  10509. return T && !g.fireOnInit;
  10510. } }, can: { change: function change() {
  10511. return !(C.hasClass(p.disabled) || C.hasClass(p.readOnly) || S.prop("disabled") || S.prop("readonly"));
  10512. }, uncheck: function uncheck() {
  10513. return "boolean" == typeof g.uncheckable ? g.uncheckable : !m.is.radio();
  10514. } }, set: { initialLoad: function initialLoad() {
  10515. T = !0;
  10516. }, checked: function checked() {
  10517. m.verbose("Setting class to checked"), C.removeClass(p.indeterminate).addClass(p.checked), m.is.radio() && m.uncheckOthers(), m.is.indeterminate() || !m.is.checked() ? (m.verbose("Setting state to checked", k), S.prop("indeterminate", !1).prop("checked", !0), m.trigger.change()) : m.debug("Input is already checked, skipping input property change");
  10518. }, unchecked: function unchecked() {
  10519. m.verbose("Removing checked class"), C.removeClass(p.indeterminate).removeClass(p.checked), m.is.indeterminate() || !m.is.unchecked() ? (m.debug("Setting state to unchecked"), S.prop("indeterminate", !1).prop("checked", !1), m.trigger.change()) : m.debug("Input is already unchecked");
  10520. }, indeterminate: function indeterminate() {
  10521. m.verbose("Setting class to indeterminate"), C.addClass(p.indeterminate), m.is.indeterminate() ? m.debug("Input is already indeterminate, skipping input property change") : (m.debug("Setting state to indeterminate"), S.prop("indeterminate", !0), m.trigger.change());
  10522. }, determinate: function determinate() {
  10523. m.verbose("Removing indeterminate class"), C.removeClass(p.indeterminate), m.is.determinate() ? m.debug("Input is already determinate, skipping input property change") : (m.debug("Setting state to determinate"), S.prop("indeterminate", !1));
  10524. }, disabled: function disabled() {
  10525. m.verbose("Setting class to disabled"), C.addClass(p.disabled), m.is.disabled() ? m.debug("Input is already disabled, skipping input property change") : (m.debug("Setting state to disabled"), S.prop("disabled", "disabled"), m.trigger.change());
  10526. }, enabled: function enabled() {
  10527. m.verbose("Removing disabled class"), C.removeClass(p.disabled), m.is.enabled() ? m.debug("Input is already enabled, skipping input property change") : (m.debug("Setting state to enabled"), S.prop("disabled", !1), m.trigger.change());
  10528. }, tabbable: function tabbable() {
  10529. m.verbose("Adding tabindex to checkbox"), S.attr("tabindex") === i && S.attr("tabindex", 0);
  10530. } }, remove: { initialLoad: function initialLoad() {
  10531. T = !1;
  10532. } }, trigger: { change: function change() {
  10533. var e = n.createEvent("HTMLEvents"),
  10534. t = S[0];t && (m.verbose("Triggering native change event"), e.initEvent("change", !0, !1), t.dispatchEvent(e));
  10535. } }, create: { label: function label() {
  10536. S.prevAll(v.label).length > 0 ? (S.prev(v.label).detach().insertAfter(S), m.debug("Moving existing label", w)) : m.has.label() || (w = e("<label>").insertAfter(S), m.debug("Creating label", w));
  10537. } }, has: { label: function label() {
  10538. return w.length > 0;
  10539. } }, bind: { events: function events() {
  10540. m.verbose("Attaching checkbox events"), C.on("click" + y, m.event.click).on("keydown" + y, v.input, m.event.keydown).on("keyup" + y, v.input, m.event.keyup);
  10541. } }, unbind: { events: function events() {
  10542. m.debug("Removing events"), C.off(y);
  10543. } }, uncheckOthers: function uncheckOthers() {
  10544. var e = m.get.otherRadios();m.debug("Unchecking other radios", e), e.removeClass(p.checked);
  10545. }, toggle: function toggle() {
  10546. m.can.change() ? m.is.indeterminate() || m.is.unchecked() ? (m.debug("Currently unchecked"), m.check()) : m.is.checked() && m.can.uncheck() && (m.debug("Currently checked"), m.uncheck()) : m.is.radio() || m.debug("Checkbox is read-only or disabled, ignoring toggle");
  10547. }, setting: function setting(t, n) {
  10548. if (m.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, g, t);else {
  10549. if (n === i) return g[t];e.isPlainObject(g[t]) ? e.extend(!0, g[t], n) : g[t] = n;
  10550. }
  10551. }, internal: function internal(t, n) {
  10552. if (e.isPlainObject(t)) e.extend(!0, m, t);else {
  10553. if (n === i) return m[t];m[t] = n;
  10554. }
  10555. }, debug: function debug() {
  10556. !g.silent && g.debug && (g.performance ? m.performance.log(arguments) : (m.debug = Function.prototype.bind.call(console.info, console, g.name + ":"), m.debug.apply(console, arguments)));
  10557. }, verbose: function verbose() {
  10558. !g.silent && g.verbose && g.debug && (g.performance ? m.performance.log(arguments) : (m.verbose = Function.prototype.bind.call(console.info, console, g.name + ":"), m.verbose.apply(console, arguments)));
  10559. }, error: function error() {
  10560. g.silent || (m.error = Function.prototype.bind.call(console.error, console, g.name + ":"), m.error.apply(console, arguments));
  10561. }, performance: { log: function log(e) {
  10562. var t, n;g.performance && (n = (t = new Date().getTime()) - (l || t), l = t, c.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: P, "Execution Time": n })), clearTimeout(m.performance.timer), m.performance.timer = setTimeout(m.performance.display, 500);
  10563. }, display: function display() {
  10564. var t = g.name + ":",
  10565. n = 0;l = !1, clearTimeout(m.performance.timer), e.each(c, function (e, t) {
  10566. n += t["Execution Time"];
  10567. }), t += " " + n + "ms", s && (t += " '" + s + "'"), (console.group !== i || console.table !== i) && c.length > 0 && (console.groupCollapsed(t), console.table ? console.table(c) : e.each(c, function (e, t) {
  10568. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  10569. }), console.groupEnd()), c = [];
  10570. } }, invoke: function invoke(t, n, o) {
  10571. var r,
  10572. s,
  10573. l,
  10574. c = R;return n = n || f, o = P || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  10575. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  10576. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (m.error(b.method, t), !1);c = c[o];
  10577. }
  10578. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  10579. } }, d ? (R === i && m.initialize(), m.invoke(u)) : (R !== i && R.invoke("destroy"), m.initialize());
  10580. }), a !== i ? a : this;
  10581. }, e.fn.checkbox.settings = { name: "Checkbox", namespace: "checkbox", silent: !1, debug: !1, verbose: !0, performance: !0, uncheckable: "auto", fireOnInit: !1, onChange: function onChange() {}, beforeChecked: function beforeChecked() {}, beforeUnchecked: function beforeUnchecked() {}, beforeDeterminate: function beforeDeterminate() {}, beforeIndeterminate: function beforeIndeterminate() {}, onChecked: function onChecked() {}, onUnchecked: function onUnchecked() {}, onDeterminate: function onDeterminate() {}, onIndeterminate: function onIndeterminate() {}, onEnable: function onEnable() {}, onDisable: function onDisable() {}, onEnabled: function onEnabled() {}, onDisabled: function onDisabled() {}, className: { checked: "checked", indeterminate: "indeterminate", disabled: "disabled", hidden: "hidden", radio: "radio", readOnly: "read-only" }, error: { method: "The method you called is not defined" }, selector: { checkbox: ".ui.checkbox", label: "label, .box", input: 'input[type="checkbox"], input[type="radio"]', link: "a[href]" } };
  10582. }(jQuery, window, document), function (e, t, n, i) {
  10583. "use strict";
  10584. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.dimmer = function (t) {
  10585. var o,
  10586. a = e(this),
  10587. r = new Date().getTime(),
  10588. s = [],
  10589. l = arguments[0],
  10590. c = "string" == typeof l,
  10591. u = [].slice.call(arguments, 1);return a.each(function () {
  10592. var d,
  10593. f,
  10594. m,
  10595. g = e.isPlainObject(t) ? e.extend(!0, {}, e.fn.dimmer.settings, t) : e.extend({}, e.fn.dimmer.settings),
  10596. p = g.selector,
  10597. h = g.namespace,
  10598. v = g.className,
  10599. b = g.error,
  10600. y = "." + h,
  10601. x = "module-" + h,
  10602. C = a.selector || "",
  10603. w = "ontouchstart" in n.documentElement ? "touchstart" : "click",
  10604. S = e(this),
  10605. k = this,
  10606. T = S.data(x);(m = { preinitialize: function preinitialize() {
  10607. m.is.dimmer() ? (f = S.parent(), d = S) : (f = S, d = m.has.dimmer() ? g.dimmerName ? f.find(p.dimmer).filter("." + g.dimmerName) : f.find(p.dimmer) : m.create(), m.set.variation());
  10608. }, initialize: function initialize() {
  10609. m.debug("Initializing dimmer", g), m.bind.events(), m.set.dimmable(), m.instantiate();
  10610. }, instantiate: function instantiate() {
  10611. m.verbose("Storing instance of module", m), T = m, S.data(x, T);
  10612. }, destroy: function destroy() {
  10613. m.verbose("Destroying previous module", d), m.unbind.events(), m.remove.variation(), f.off(y);
  10614. }, bind: { events: function events() {
  10615. m.is.page() && f.get(0).addEventListener("touchmove", m.event.preventScroll, { passive: !1 }), "hover" == g.on ? f.on("mouseenter" + y, m.show).on("mouseleave" + y, m.hide) : "click" == g.on && f.on(w + y, m.toggle), m.is.page() && (m.debug("Setting as a page dimmer", f), m.set.pageDimmer()), m.is.closable() && (m.verbose("Adding dimmer close event", d), f.on(w + y, p.dimmer, m.event.click));
  10616. } }, unbind: { events: function events() {
  10617. m.is.page() && f.get(0).removeEventListener("touchmove", m.event.preventScroll, { passive: !1 }), S.removeData(x), f.off(y);
  10618. } }, event: { click: function click(t) {
  10619. m.verbose("Determining if event occured on dimmer", t), (0 === d.find(t.target).length || e(t.target).is(p.content)) && (m.hide(), t.stopImmediatePropagation());
  10620. }, preventScroll: function preventScroll(e) {
  10621. e.preventDefault();
  10622. } }, addContent: function addContent(t) {
  10623. var n = e(t);m.debug("Add content to dimmer", n), n.parent()[0] !== d[0] && n.detach().appendTo(d);
  10624. }, create: function create() {
  10625. var t = e(g.template.dimmer());return g.dimmerName && (m.debug("Creating named dimmer", g.dimmerName), t.addClass(g.dimmerName)), t.appendTo(f), t;
  10626. }, show: function show(t) {
  10627. t = e.isFunction(t) ? t : function () {}, m.debug("Showing dimmer", d, g), m.is.dimmed() && !m.is.animating() || !m.is.enabled() ? m.debug("Dimmer is already shown or disabled") : (m.animate.show(t), g.onShow.call(k), g.onChange.call(k));
  10628. }, hide: function hide(t) {
  10629. t = e.isFunction(t) ? t : function () {}, m.is.dimmed() || m.is.animating() ? (m.debug("Hiding dimmer", d), m.animate.hide(t), g.onHide.call(k), g.onChange.call(k)) : m.debug("Dimmer is not visible");
  10630. }, toggle: function toggle() {
  10631. m.verbose("Toggling dimmer visibility", d), m.is.dimmed() ? m.hide() : m.show();
  10632. }, animate: { show: function show(t) {
  10633. t = e.isFunction(t) ? t : function () {}, g.useCSS && e.fn.transition !== i && d.transition("is supported") ? ("auto" !== g.opacity && m.set.opacity(), d.transition({ displayType: "flex", animation: g.transition + " in", queue: !1, duration: m.get.duration(), useFailSafe: !0, onStart: function onStart() {
  10634. m.set.dimmed();
  10635. }, onComplete: function onComplete() {
  10636. m.set.active(), t();
  10637. } })) : (m.verbose("Showing dimmer animation with javascript"), m.set.dimmed(), "auto" == g.opacity && (g.opacity = .8), d.stop().css({ opacity: 0, width: "100%", height: "100%" }).fadeTo(m.get.duration(), g.opacity, function () {
  10638. d.removeAttr("style"), m.set.active(), t();
  10639. }));
  10640. }, hide: function hide(t) {
  10641. t = e.isFunction(t) ? t : function () {}, g.useCSS && e.fn.transition !== i && d.transition("is supported") ? (m.verbose("Hiding dimmer with css"), d.transition({ displayType: "flex", animation: g.transition + " out", queue: !1, duration: m.get.duration(), useFailSafe: !0, onStart: function onStart() {
  10642. m.remove.dimmed();
  10643. }, onComplete: function onComplete() {
  10644. m.remove.active(), t();
  10645. } })) : (m.verbose("Hiding dimmer with javascript"), m.remove.dimmed(), d.stop().fadeOut(m.get.duration(), function () {
  10646. m.remove.active(), d.removeAttr("style"), t();
  10647. }));
  10648. } }, get: { dimmer: function dimmer() {
  10649. return d;
  10650. }, duration: function duration() {
  10651. return "object" == _typeof(g.duration) ? m.is.active() ? g.duration.hide : g.duration.show : g.duration;
  10652. } }, has: { dimmer: function dimmer() {
  10653. return g.dimmerName ? S.find(p.dimmer).filter("." + g.dimmerName).length > 0 : S.find(p.dimmer).length > 0;
  10654. } }, is: { active: function active() {
  10655. return d.hasClass(v.active);
  10656. }, animating: function animating() {
  10657. return d.is(":animated") || d.hasClass(v.animating);
  10658. }, closable: function closable() {
  10659. return "auto" == g.closable ? "hover" != g.on : g.closable;
  10660. }, dimmer: function dimmer() {
  10661. return S.hasClass(v.dimmer);
  10662. }, dimmable: function dimmable() {
  10663. return S.hasClass(v.dimmable);
  10664. }, dimmed: function dimmed() {
  10665. return f.hasClass(v.dimmed);
  10666. }, disabled: function disabled() {
  10667. return f.hasClass(v.disabled);
  10668. }, enabled: function enabled() {
  10669. return !m.is.disabled();
  10670. }, page: function page() {
  10671. return f.is("body");
  10672. }, pageDimmer: function pageDimmer() {
  10673. return d.hasClass(v.pageDimmer);
  10674. } }, can: { show: function show() {
  10675. return !d.hasClass(v.disabled);
  10676. } }, set: { opacity: function opacity(e) {
  10677. var t = d.css("background-color"),
  10678. n = t.split(","),
  10679. i = n && 3 == n.length,
  10680. o = n && 4 == n.length;e = 0 === g.opacity ? 0 : g.opacity || e, i || o ? (n[3] = e + ")", t = n.join(",")) : t = "rgba(0, 0, 0, " + e + ")", m.debug("Setting opacity to", e), d.css("background-color", t);
  10681. }, active: function active() {
  10682. d.addClass(v.active);
  10683. }, dimmable: function dimmable() {
  10684. f.addClass(v.dimmable);
  10685. }, dimmed: function dimmed() {
  10686. f.addClass(v.dimmed);
  10687. }, pageDimmer: function pageDimmer() {
  10688. d.addClass(v.pageDimmer);
  10689. }, disabled: function disabled() {
  10690. d.addClass(v.disabled);
  10691. }, variation: function variation(e) {
  10692. (e = e || g.variation) && d.addClass(e);
  10693. } }, remove: { active: function active() {
  10694. d.removeClass(v.active);
  10695. }, dimmed: function dimmed() {
  10696. f.removeClass(v.dimmed);
  10697. }, disabled: function disabled() {
  10698. d.removeClass(v.disabled);
  10699. }, variation: function variation(e) {
  10700. (e = e || g.variation) && d.removeClass(e);
  10701. } }, setting: function setting(t, n) {
  10702. if (m.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, g, t);else {
  10703. if (n === i) return g[t];e.isPlainObject(g[t]) ? e.extend(!0, g[t], n) : g[t] = n;
  10704. }
  10705. }, internal: function internal(t, n) {
  10706. if (e.isPlainObject(t)) e.extend(!0, m, t);else {
  10707. if (n === i) return m[t];m[t] = n;
  10708. }
  10709. }, debug: function debug() {
  10710. !g.silent && g.debug && (g.performance ? m.performance.log(arguments) : (m.debug = Function.prototype.bind.call(console.info, console, g.name + ":"), m.debug.apply(console, arguments)));
  10711. }, verbose: function verbose() {
  10712. !g.silent && g.verbose && g.debug && (g.performance ? m.performance.log(arguments) : (m.verbose = Function.prototype.bind.call(console.info, console, g.name + ":"), m.verbose.apply(console, arguments)));
  10713. }, error: function error() {
  10714. g.silent || (m.error = Function.prototype.bind.call(console.error, console, g.name + ":"), m.error.apply(console, arguments));
  10715. }, performance: { log: function log(e) {
  10716. var t, n;g.performance && (n = (t = new Date().getTime()) - (r || t), r = t, s.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: k, "Execution Time": n })), clearTimeout(m.performance.timer), m.performance.timer = setTimeout(m.performance.display, 500);
  10717. }, display: function display() {
  10718. var t = g.name + ":",
  10719. n = 0;r = !1, clearTimeout(m.performance.timer), e.each(s, function (e, t) {
  10720. n += t["Execution Time"];
  10721. }), t += " " + n + "ms", C && (t += " '" + C + "'"), a.length > 1 && (t += " (" + a.length + ")"), (console.group !== i || console.table !== i) && s.length > 0 && (console.groupCollapsed(t), console.table ? console.table(s) : e.each(s, function (e, t) {
  10722. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  10723. }), console.groupEnd()), s = [];
  10724. } }, invoke: function invoke(t, n, a) {
  10725. var r,
  10726. s,
  10727. l,
  10728. c = T;return n = n || u, a = k || a, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  10729. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  10730. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (m.error(b.method, t), !1);c = c[o];
  10731. }
  10732. })), e.isFunction(s) ? l = s.apply(a, n) : s !== i && (l = s), e.isArray(o) ? o.push(l) : o !== i ? o = [o, l] : l !== i && (o = l), s;
  10733. } }).preinitialize(), c ? (T === i && m.initialize(), m.invoke(l)) : (T !== i && T.invoke("destroy"), m.initialize());
  10734. }), o !== i ? o : this;
  10735. }, e.fn.dimmer.settings = { name: "Dimmer", namespace: "dimmer", silent: !1, debug: !1, verbose: !1, performance: !0, dimmerName: !1, variation: !1, closable: "auto", useCSS: !0, transition: "fade", on: !1, opacity: "auto", duration: { show: 500, hide: 500 }, onChange: function onChange() {}, onShow: function onShow() {}, onHide: function onHide() {}, error: { method: "The method you called is not defined." }, className: { active: "active", animating: "animating", dimmable: "dimmable", dimmed: "dimmed", dimmer: "dimmer", disabled: "disabled", hide: "hide", pageDimmer: "page", show: "show" }, selector: { dimmer: "> .ui.dimmer", content: ".ui.dimmer > .content, .ui.dimmer > .content > .center" }, template: { dimmer: function dimmer() {
  10736. return e("<div />").attr("class", "ui dimmer");
  10737. } } };
  10738. }(jQuery, window, document), function (e, t, n, i) {
  10739. "use strict";
  10740. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.dropdown = function (o) {
  10741. var a,
  10742. r = e(this),
  10743. s = e(n),
  10744. l = r.selector || "",
  10745. c = "ontouchstart" in n.documentElement,
  10746. u = new Date().getTime(),
  10747. d = [],
  10748. f = arguments[0],
  10749. m = "string" == typeof f,
  10750. g = [].slice.call(arguments, 1);return r.each(function (p) {
  10751. var h,
  10752. v,
  10753. b,
  10754. y,
  10755. x,
  10756. C,
  10757. w,
  10758. S,
  10759. k = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.dropdown.settings, o) : e.extend({}, e.fn.dropdown.settings),
  10760. T = k.className,
  10761. A = k.message,
  10762. R = k.fields,
  10763. P = k.keys,
  10764. E = k.metadata,
  10765. F = k.namespace,
  10766. O = k.regExp,
  10767. D = k.selector,
  10768. q = k.error,
  10769. j = k.templates,
  10770. z = "." + F,
  10771. I = "module-" + F,
  10772. M = e(this),
  10773. L = e(k.context),
  10774. V = M.find(D.text),
  10775. N = M.find(D.search),
  10776. H = M.find(D.sizer),
  10777. U = M.find(D.input),
  10778. W = M.find(D.icon),
  10779. B = M.prev().find(D.text).length > 0 ? M.prev().find(D.text) : M.prev(),
  10780. Q = M.children(D.menu),
  10781. X = Q.find(D.item),
  10782. $ = !1,
  10783. Y = !1,
  10784. Z = !1,
  10785. K = this,
  10786. J = M.data(I);S = { initialize: function initialize() {
  10787. S.debug("Initializing dropdown", k), S.is.alreadySetup() ? S.setup.reference() : (S.setup.layout(), k.values && S.change.values(k.values), S.refreshData(), S.save.defaults(), S.restore.selected(), S.create.id(), S.bind.events(), S.observeChanges(), S.instantiate());
  10788. }, instantiate: function instantiate() {
  10789. S.verbose("Storing instance of dropdown", S), J = S, M.data(I, S);
  10790. }, destroy: function destroy() {
  10791. S.verbose("Destroying previous dropdown", M), S.remove.tabbable(), M.off(z).removeData(I), Q.off(z), s.off(y), S.disconnect.menuObserver(), S.disconnect.selectObserver();
  10792. }, observeChanges: function observeChanges() {
  10793. "MutationObserver" in t && (C = new MutationObserver(S.event.select.mutation), w = new MutationObserver(S.event.menu.mutation), S.debug("Setting up mutation observer", C, w), S.observe.select(), S.observe.menu());
  10794. }, disconnect: { menuObserver: function menuObserver() {
  10795. w && w.disconnect();
  10796. }, selectObserver: function selectObserver() {
  10797. C && C.disconnect();
  10798. } }, observe: { select: function select() {
  10799. S.has.input() && C.observe(M[0], { childList: !0, subtree: !0 });
  10800. }, menu: function menu() {
  10801. S.has.menu() && w.observe(Q[0], { childList: !0, subtree: !0 });
  10802. } }, create: { id: function id() {
  10803. x = (Math.random().toString(16) + "000000000").substr(2, 8), y = "." + x, S.verbose("Creating unique id for element", x);
  10804. }, userChoice: function userChoice(t) {
  10805. var n, o, a;return !!(t = t || S.get.userValues()) && (t = e.isArray(t) ? t : [t], e.each(t, function (t, r) {
  10806. !1 === S.get.item(r) && (a = k.templates.addition(S.add.variables(A.addResult, r)), o = e("<div />").html(a).attr("data-" + E.value, r).attr("data-" + E.text, r).addClass(T.addition).addClass(T.item), k.hideAdditions && o.addClass(T.hidden), n = n === i ? o : n.add(o), S.verbose("Creating user choices for value", r, o));
  10807. }), n);
  10808. }, userLabels: function userLabels(t) {
  10809. var n = S.get.userValues();n && (S.debug("Adding user labels", n), e.each(n, function (e, t) {
  10810. S.verbose("Adding custom user value"), S.add.label(t, t);
  10811. }));
  10812. }, menu: function menu() {
  10813. Q = e("<div />").addClass(T.menu).appendTo(M);
  10814. }, sizer: function sizer() {
  10815. H = e("<span />").addClass(T.sizer).insertAfter(N);
  10816. } }, search: function search(e) {
  10817. e = e !== i ? e : S.get.query(), S.verbose("Searching for query", e), S.has.minCharacters(e) ? S.filter(e) : S.hide();
  10818. }, select: { firstUnfiltered: function firstUnfiltered() {
  10819. S.verbose("Selecting first non-filtered element"), S.remove.selectedItem(), X.not(D.unselectable).not(D.addition + D.hidden).eq(0).addClass(T.selected);
  10820. }, nextAvailable: function nextAvailable(e) {
  10821. var t = (e = e.eq(0)).nextAll(D.item).not(D.unselectable).eq(0),
  10822. n = e.prevAll(D.item).not(D.unselectable).eq(0);t.length > 0 ? (S.verbose("Moving selection to", t), t.addClass(T.selected)) : (S.verbose("Moving selection to", n), n.addClass(T.selected));
  10823. } }, setup: { api: function api() {
  10824. var e = { debug: k.debug, urlData: { value: S.get.value(), query: S.get.query() }, on: !1 };S.verbose("First request, initializing API"), M.api(e);
  10825. }, layout: function layout() {
  10826. M.is("select") && (S.setup.select(), S.setup.returnedObject()), S.has.menu() || S.create.menu(), S.is.search() && !S.has.search() && (S.verbose("Adding search input"), N = e("<input />").addClass(T.search).prop("autocomplete", "off").insertBefore(V)), S.is.multiple() && S.is.searchSelection() && !S.has.sizer() && S.create.sizer(), k.allowTab && S.set.tabbable();
  10827. }, select: function select() {
  10828. var t = S.get.selectValues();S.debug("Dropdown initialized on a select", t), M.is("select") && (U = M), U.parent(D.dropdown).length > 0 ? (S.debug("UI dropdown already exists. Creating dropdown menu only"), M = U.closest(D.dropdown), S.has.menu() || S.create.menu(), Q = M.children(D.menu), S.setup.menu(t)) : (S.debug("Creating entire dropdown from select"), M = e("<div />").attr("class", U.attr("class")).addClass(T.selection).addClass(T.dropdown).html(j.dropdown(t)).insertBefore(U), U.hasClass(T.multiple) && !1 === U.prop("multiple") && (S.error(q.missingMultiple), U.prop("multiple", !0)), U.is("[multiple]") && S.set.multiple(), U.prop("disabled") && (S.debug("Disabling dropdown"), M.addClass(T.disabled)), U.removeAttr("class").detach().prependTo(M)), S.refresh();
  10829. }, menu: function menu(e) {
  10830. Q.html(j.menu(e, R)), X = Q.find(D.item);
  10831. }, reference: function reference() {
  10832. S.debug("Dropdown behavior was called on select, replacing with closest dropdown"), M = M.parent(D.dropdown), J = M.data(I), K = M.get(0), S.refresh(), S.setup.returnedObject();
  10833. }, returnedObject: function returnedObject() {
  10834. var e = r.slice(0, p),
  10835. t = r.slice(p + 1);r = e.add(M).add(t);
  10836. } }, refresh: function refresh() {
  10837. S.refreshSelectors(), S.refreshData();
  10838. }, refreshItems: function refreshItems() {
  10839. X = Q.find(D.item);
  10840. }, refreshSelectors: function refreshSelectors() {
  10841. S.verbose("Refreshing selector cache"), V = M.find(D.text), N = M.find(D.search), U = M.find(D.input), W = M.find(D.icon), B = M.prev().find(D.text).length > 0 ? M.prev().find(D.text) : M.prev(), Q = M.children(D.menu), X = Q.find(D.item);
  10842. }, refreshData: function refreshData() {
  10843. S.verbose("Refreshing cached metadata"), X.removeData(E.text).removeData(E.value);
  10844. }, clearData: function clearData() {
  10845. S.verbose("Clearing metadata"), X.removeData(E.text).removeData(E.value), M.removeData(E.defaultText).removeData(E.defaultValue).removeData(E.placeholderText);
  10846. }, toggle: function toggle() {
  10847. S.verbose("Toggling menu visibility"), S.is.active() ? S.hide() : S.show();
  10848. }, show: function show(t) {
  10849. if (t = e.isFunction(t) ? t : function () {}, !S.can.show() && S.is.remote() && (S.debug("No API results retrieved, searching before show"), S.queryRemote(S.get.query(), S.show)), S.can.show() && !S.is.active()) {
  10850. if (S.debug("Showing dropdown"), !S.has.message() || S.has.maxSelections() || S.has.allResultsFiltered() || S.remove.message(), S.is.allFiltered()) return !0;!1 !== k.onShow.call(K) && S.animate.show(function () {
  10851. S.can.click() && S.bind.intent(), S.has.menuSearch() && S.focusSearch(), S.set.visible(), t.call(K);
  10852. });
  10853. }
  10854. }, hide: function hide(t) {
  10855. t = e.isFunction(t) ? t : function () {}, S.is.active() && !S.is.animatingOutward() && (S.debug("Hiding dropdown"), !1 !== k.onHide.call(K) && S.animate.hide(function () {
  10856. S.remove.visible(), t.call(K);
  10857. }));
  10858. }, hideOthers: function hideOthers() {
  10859. S.verbose("Finding other dropdowns to hide"), r.not(M).has(D.menu + "." + T.visible).dropdown("hide");
  10860. }, hideMenu: function hideMenu() {
  10861. S.verbose("Hiding menu instantaneously"), S.remove.active(), S.remove.visible(), Q.transition("hide");
  10862. }, hideSubMenus: function hideSubMenus() {
  10863. var e = Q.children(D.item).find(D.menu);S.verbose("Hiding sub menus", e), e.transition("hide");
  10864. }, bind: { events: function events() {
  10865. c && S.bind.touchEvents(), S.bind.keyboardEvents(), S.bind.inputEvents(), S.bind.mouseEvents();
  10866. }, touchEvents: function touchEvents() {
  10867. S.debug("Touch device detected binding additional touch events"), S.is.searchSelection() || S.is.single() && M.on("touchstart" + z, S.event.test.toggle), Q.on("touchstart" + z, D.item, S.event.item.mouseenter);
  10868. }, keyboardEvents: function keyboardEvents() {
  10869. S.verbose("Binding keyboard events"), M.on("keydown" + z, S.event.keydown), S.has.search() && M.on(S.get.inputEvent() + z, D.search, S.event.input), S.is.multiple() && s.on("keydown" + y, S.event.document.keydown);
  10870. }, inputEvents: function inputEvents() {
  10871. S.verbose("Binding input change events"), M.on("change" + z, D.input, S.event.change);
  10872. }, mouseEvents: function mouseEvents() {
  10873. S.verbose("Binding mouse events"), S.is.multiple() && M.on("click" + z, D.label, S.event.label.click).on("click" + z, D.remove, S.event.remove.click), S.is.searchSelection() ? (M.on("mousedown" + z, S.event.mousedown).on("mouseup" + z, S.event.mouseup).on("mousedown" + z, D.menu, S.event.menu.mousedown).on("mouseup" + z, D.menu, S.event.menu.mouseup).on("click" + z, D.icon, S.event.icon.click).on("focus" + z, D.search, S.event.search.focus).on("click" + z, D.search, S.event.search.focus).on("blur" + z, D.search, S.event.search.blur).on("click" + z, D.text, S.event.text.focus), S.is.multiple() && M.on("click" + z, S.event.click)) : ("click" == k.on ? M.on("click" + z, D.icon, S.event.icon.click).on("click" + z, S.event.test.toggle) : "hover" == k.on ? M.on("mouseenter" + z, S.delay.show).on("mouseleave" + z, S.delay.hide) : M.on(k.on + z, S.toggle), M.on("mousedown" + z, S.event.mousedown).on("mouseup" + z, S.event.mouseup).on("focus" + z, S.event.focus), S.has.menuSearch() ? M.on("blur" + z, D.search, S.event.search.blur) : M.on("blur" + z, S.event.blur)), Q.on("mouseenter" + z, D.item, S.event.item.mouseenter).on("mouseleave" + z, D.item, S.event.item.mouseleave).on("click" + z, D.item, S.event.item.click);
  10874. }, intent: function intent() {
  10875. S.verbose("Binding hide intent event to document"), c && s.on("touchstart" + y, S.event.test.touch).on("touchmove" + y, S.event.test.touch), s.on("click" + y, S.event.test.hide);
  10876. } }, unbind: { intent: function intent() {
  10877. S.verbose("Removing hide intent event from document"), c && s.off("touchstart" + y).off("touchmove" + y), s.off("click" + y);
  10878. } }, filter: function filter(e) {
  10879. var t = e !== i ? e : S.get.query(),
  10880. n = function n() {
  10881. S.is.multiple() && S.filterActive(), (e || !e && 0 == S.get.activeItem().length) && S.select.firstUnfiltered(), S.has.allResultsFiltered() ? k.onNoResults.call(K, t) ? k.allowAdditions ? k.hideAdditions && (S.verbose("User addition with no menu, setting empty style"), S.set.empty(), S.hideMenu()) : (S.verbose("All items filtered, showing message", t), S.add.message(A.noResults)) : (S.verbose("All items filtered, hiding dropdown", t), S.hideMenu()) : (S.remove.empty(), S.remove.message()), k.allowAdditions && S.add.userSuggestion(e), S.is.searchSelection() && S.can.show() && S.is.focusedOnSearch() && S.show();
  10882. };k.useLabels && S.has.maxSelections() || (k.apiSettings ? S.can.useAPI() ? S.queryRemote(t, function () {
  10883. k.filterRemoteData && S.filterItems(t), n();
  10884. }) : S.error(q.noAPI) : (S.filterItems(t), n()));
  10885. }, queryRemote: function queryRemote(t, n) {
  10886. var i = { errorDuration: !1, cache: "local", throttle: k.throttle, urlData: { query: t }, onError: function onError() {
  10887. S.add.message(A.serverError), n();
  10888. }, onFailure: function onFailure() {
  10889. S.add.message(A.serverError), n();
  10890. }, onSuccess: function onSuccess(t) {
  10891. var i = t[R.remoteValues];e.isArray(i) && i.length > 0 ? (S.remove.message(), S.setup.menu({ values: t[R.remoteValues] })) : S.add.message(A.noResults), n();
  10892. } };M.api("get request") || S.setup.api(), i = e.extend(!0, {}, i, k.apiSettings), M.api("setting", i).api("query");
  10893. }, filterItems: function filterItems(t) {
  10894. var n = t !== i ? t : S.get.query(),
  10895. o = null,
  10896. a = S.escape.string(n),
  10897. r = new RegExp("^" + a, "igm");S.has.query() && (o = [], S.verbose("Searching for matching values", n), X.each(function () {
  10898. var t,
  10899. i,
  10900. a = e(this);if ("both" == k.match || "text" == k.match) {
  10901. if (-1 !== (t = String(S.get.choiceText(a, !1))).search(r)) return o.push(this), !0;if ("exact" === k.fullTextSearch && S.exactSearch(n, t)) return o.push(this), !0;if (!0 === k.fullTextSearch && S.fuzzySearch(n, t)) return o.push(this), !0;
  10902. }if ("both" == k.match || "value" == k.match) {
  10903. if (-1 !== (i = String(S.get.choiceValue(a, t))).search(r)) return o.push(this), !0;if ("exact" === k.fullTextSearch && S.exactSearch(n, i)) return o.push(this), !0;if (!0 === k.fullTextSearch && S.fuzzySearch(n, i)) return o.push(this), !0;
  10904. }
  10905. })), S.debug("Showing only matched items", n), S.remove.filteredItem(), o && X.not(o).addClass(T.filtered);
  10906. }, fuzzySearch: function fuzzySearch(e, t) {
  10907. var n = t.length,
  10908. i = e.length;if (e = e.toLowerCase(), t = t.toLowerCase(), i > n) return !1;if (i === n) return e === t;e: for (var o = 0, a = 0; o < i; o++) {
  10909. for (var r = e.charCodeAt(o); a < n;) {
  10910. if (t.charCodeAt(a++) === r) continue e;
  10911. }return !1;
  10912. }return !0;
  10913. }, exactSearch: function exactSearch(e, t) {
  10914. return e = e.toLowerCase(), (t = t.toLowerCase()).indexOf(e) > -1;
  10915. }, filterActive: function filterActive() {
  10916. k.useLabels && X.filter("." + T.active).addClass(T.filtered);
  10917. }, focusSearch: function focusSearch(e) {
  10918. S.has.search() && !S.is.focusedOnSearch() && (e ? (M.off("focus" + z, D.search), N.focus(), M.on("focus" + z, D.search, S.event.search.focus)) : N.focus());
  10919. }, forceSelection: function forceSelection() {
  10920. var e = X.not(T.filtered).filter("." + T.selected).eq(0),
  10921. t = X.not(T.filtered).filter("." + T.active).eq(0),
  10922. n = e.length > 0 ? e : t;if (n.length > 0 && !S.is.multiple()) return S.debug("Forcing partial selection to selected item", n), void S.event.item.click.call(n, {}, !0);k.allowAdditions ? (S.set.selected(S.get.query()), S.remove.searchTerm()) : S.remove.searchTerm();
  10923. }, change: { values: function values(t) {
  10924. k.allowAdditions || S.clear(), S.debug("Creating dropdown with specified values", t), S.setup.menu({ values: t }), e.each(t, function (e, t) {
  10925. if (1 == t.selected) return S.debug("Setting initial selection to", t.value), S.set.selected(t.value), !0;
  10926. });
  10927. } }, event: { change: function change() {
  10928. Z || (S.debug("Input changed, updating selection"), S.set.selected());
  10929. }, focus: function focus() {
  10930. k.showOnFocus && !$ && S.is.hidden() && !v && S.show();
  10931. }, blur: function blur(e) {
  10932. v = n.activeElement === this, $ || v || (S.remove.activeLabel(), S.hide());
  10933. }, mousedown: function mousedown() {
  10934. S.is.searchSelection() ? b = !0 : $ = !0;
  10935. }, mouseup: function mouseup() {
  10936. S.is.searchSelection() ? b = !1 : $ = !1;
  10937. }, click: function click(t) {
  10938. e(t.target).is(M) && (S.is.focusedOnSearch() ? S.show() : S.focusSearch());
  10939. }, search: { focus: function focus() {
  10940. $ = !0, S.is.multiple() && S.remove.activeLabel(), k.showOnFocus && S.search();
  10941. }, blur: function blur(e) {
  10942. v = n.activeElement === this, S.is.searchSelection() && !b && (Y || v || (k.forceSelection && S.forceSelection(), S.hide())), b = !1;
  10943. } }, icon: { click: function click(e) {
  10944. S.toggle();
  10945. } }, text: { focus: function focus(e) {
  10946. $ = !0, S.focusSearch();
  10947. } }, input: function input(e) {
  10948. (S.is.multiple() || S.is.searchSelection()) && S.set.filtered(), clearTimeout(S.timer), S.timer = setTimeout(S.search, k.delay.search);
  10949. }, label: { click: function click(t) {
  10950. var n = e(this),
  10951. i = M.find(D.label),
  10952. o = i.filter("." + T.active),
  10953. a = n.nextAll("." + T.active),
  10954. r = n.prevAll("." + T.active),
  10955. s = a.length > 0 ? n.nextUntil(a).add(o).add(n) : n.prevUntil(r).add(o).add(n);t.shiftKey ? (o.removeClass(T.active), s.addClass(T.active)) : t.ctrlKey ? n.toggleClass(T.active) : (o.removeClass(T.active), n.addClass(T.active)), k.onLabelSelect.apply(this, i.filter("." + T.active));
  10956. } }, remove: { click: function click() {
  10957. var t = e(this).parent();t.hasClass(T.active) ? S.remove.activeLabels() : S.remove.activeLabels(t);
  10958. } }, test: { toggle: function toggle(e) {
  10959. var t = S.is.multiple() ? S.show : S.toggle;S.is.bubbledLabelClick(e) || S.is.bubbledIconClick(e) || S.determine.eventOnElement(e, t) && e.preventDefault();
  10960. }, touch: function touch(e) {
  10961. S.determine.eventOnElement(e, function () {
  10962. "touchstart" == e.type ? S.timer = setTimeout(function () {
  10963. S.hide();
  10964. }, k.delay.touch) : "touchmove" == e.type && clearTimeout(S.timer);
  10965. }), e.stopPropagation();
  10966. }, hide: function hide(e) {
  10967. S.determine.eventInModule(e, S.hide);
  10968. } }, select: { mutation: function mutation(t) {
  10969. S.debug("<select> modified, recreating menu");var n = !1;e.each(t, function (t, i) {
  10970. if (e(i.target).is("select") || e(i.addedNodes).is("select")) return n = !0, !0;
  10971. }), n && (S.disconnect.selectObserver(), S.refresh(), S.setup.select(), S.set.selected(), S.observe.select());
  10972. } }, menu: { mutation: function mutation(t) {
  10973. var n = t[0],
  10974. i = n.addedNodes ? e(n.addedNodes[0]) : e(!1),
  10975. o = n.removedNodes ? e(n.removedNodes[0]) : e(!1),
  10976. a = i.add(o),
  10977. r = a.is(D.addition) || a.closest(D.addition).length > 0,
  10978. s = a.is(D.message) || a.closest(D.message).length > 0;r || s ? (S.debug("Updating item selector cache"), S.refreshItems()) : (S.debug("Menu modified, updating selector cache"), S.refresh());
  10979. }, mousedown: function mousedown() {
  10980. Y = !0;
  10981. }, mouseup: function mouseup() {
  10982. Y = !1;
  10983. } }, item: { mouseenter: function mouseenter(t) {
  10984. var n = e(t.target),
  10985. i = e(this),
  10986. o = i.children(D.menu),
  10987. a = i.siblings(D.item).children(D.menu),
  10988. r = o.length > 0;!(o.find(n).length > 0) && r && (clearTimeout(S.itemTimer), S.itemTimer = setTimeout(function () {
  10989. S.verbose("Showing sub-menu", o), e.each(a, function () {
  10990. S.animate.hide(!1, e(this));
  10991. }), S.animate.show(!1, o);
  10992. }, k.delay.show), t.preventDefault());
  10993. }, mouseleave: function mouseleave(t) {
  10994. var n = e(this).children(D.menu);n.length > 0 && (clearTimeout(S.itemTimer), S.itemTimer = setTimeout(function () {
  10995. S.verbose("Hiding sub-menu", n), S.animate.hide(!1, n);
  10996. }, k.delay.hide));
  10997. }, click: function click(t, i) {
  10998. var o = e(this),
  10999. a = e(t ? t.target : ""),
  11000. r = o.find(D.menu),
  11001. s = S.get.choiceText(o),
  11002. l = S.get.choiceValue(o, s),
  11003. c = r.length > 0,
  11004. u = r.find(a).length > 0;S.has.menuSearch() && e(n.activeElement).blur(), u || c && !k.allowCategorySelection || (S.is.searchSelection() && (k.allowAdditions && S.remove.userAddition(), S.remove.searchTerm(), S.is.focusedOnSearch() || 1 == i || S.focusSearch(!0)), k.useLabels || (S.remove.filteredItem(), S.set.scrollPosition(o)), S.determine.selectAction.call(this, s, l));
  11005. } }, document: { keydown: function keydown(e) {
  11006. var t = e.which;if (S.is.inObject(t, P)) {
  11007. var n = M.find(D.label),
  11008. i = n.filter("." + T.active),
  11009. o = (i.data(E.value), n.index(i)),
  11010. a = n.length,
  11011. r = i.length > 0,
  11012. s = i.length > 1,
  11013. l = 0 === o,
  11014. c = o + 1 == a,
  11015. u = S.is.searchSelection(),
  11016. d = S.is.focusedOnSearch(),
  11017. f = S.is.focused(),
  11018. m = d && 0 === S.get.caretPosition();if (u && !r && !d) return;t == P.leftArrow ? !f && !m || r ? r && (e.shiftKey ? S.verbose("Adding previous label to selection") : (S.verbose("Selecting previous label"), n.removeClass(T.active)), l && !s ? i.addClass(T.active) : i.prev(D.siblingLabel).addClass(T.active).end(), e.preventDefault()) : (S.verbose("Selecting previous label"), n.last().addClass(T.active)) : t == P.rightArrow ? (f && !r && n.first().addClass(T.active), r && (e.shiftKey ? S.verbose("Adding next label to selection") : (S.verbose("Selecting next label"), n.removeClass(T.active)), c ? u ? d ? n.removeClass(T.active) : S.focusSearch() : s ? i.next(D.siblingLabel).addClass(T.active) : i.addClass(T.active) : i.next(D.siblingLabel).addClass(T.active), e.preventDefault())) : t == P.deleteKey || t == P.backspace ? r ? (S.verbose("Removing active labels"), c && u && !d && S.focusSearch(), i.last().next(D.siblingLabel).addClass(T.active), S.remove.activeLabels(i), e.preventDefault()) : m && !r && t == P.backspace && (S.verbose("Removing last label on input backspace"), i = n.last().addClass(T.active), S.remove.activeLabels(i)) : i.removeClass(T.active);
  11019. }
  11020. } }, keydown: function keydown(e) {
  11021. var t = e.which;if (S.is.inObject(t, P)) {
  11022. var n,
  11023. i = X.not(D.unselectable).filter("." + T.selected).eq(0),
  11024. o = Q.children("." + T.active).eq(0),
  11025. a = i.length > 0 ? i : o,
  11026. r = a.length > 0 ? a.siblings(":not(." + T.filtered + ")").addBack() : Q.children(":not(." + T.filtered + ")"),
  11027. s = a.children(D.menu),
  11028. l = a.closest(D.menu),
  11029. c = l.hasClass(T.visible) || l.hasClass(T.animating) || l.parent(D.menu).length > 0,
  11030. u = s.length > 0,
  11031. d = a.length > 0,
  11032. f = a.not(D.unselectable).length > 0,
  11033. m = t == P.delimiter && k.allowAdditions && S.is.multiple();if (k.allowAdditions && k.hideAdditions && (t == P.enter || m) && f && (S.verbose("Selecting item from keyboard shortcut", a), S.event.item.click.call(a, e), S.is.searchSelection() && S.remove.searchTerm()), S.is.visible()) {
  11034. if ((t == P.enter || m) && (t == P.enter && d && u && !k.allowCategorySelection ? (S.verbose("Pressed enter on unselectable category, opening sub menu"), t = P.rightArrow) : f && (S.verbose("Selecting item from keyboard shortcut", a), S.event.item.click.call(a, e), S.is.searchSelection() && S.remove.searchTerm()), e.preventDefault()), d && (t == P.leftArrow && l[0] !== Q[0] && (S.verbose("Left key pressed, closing sub-menu"), S.animate.hide(!1, l), a.removeClass(T.selected), l.closest(D.item).addClass(T.selected), e.preventDefault()), t == P.rightArrow && u && (S.verbose("Right key pressed, opening sub-menu"), S.animate.show(!1, s), a.removeClass(T.selected), s.find(D.item).eq(0).addClass(T.selected), e.preventDefault())), t == P.upArrow) {
  11035. if (n = d && c ? a.prevAll(D.item + ":not(" + D.unselectable + ")").eq(0) : X.eq(0), r.index(n) < 0) return S.verbose("Up key pressed but reached top of current menu"), void e.preventDefault();S.verbose("Up key pressed, changing active item"), a.removeClass(T.selected), n.addClass(T.selected), S.set.scrollPosition(n), k.selectOnKeydown && S.is.single() && S.set.selectedItem(n), e.preventDefault();
  11036. }if (t == P.downArrow) {
  11037. if (0 === (n = d && c ? n = a.nextAll(D.item + ":not(" + D.unselectable + ")").eq(0) : X.eq(0)).length) return S.verbose("Down key pressed but reached bottom of current menu"), void e.preventDefault();S.verbose("Down key pressed, changing active item"), X.removeClass(T.selected), n.addClass(T.selected), S.set.scrollPosition(n), k.selectOnKeydown && S.is.single() && S.set.selectedItem(n), e.preventDefault();
  11038. }t == P.pageUp && (S.scrollPage("up"), e.preventDefault()), t == P.pageDown && (S.scrollPage("down"), e.preventDefault()), t == P.escape && (S.verbose("Escape key pressed, closing dropdown"), S.hide());
  11039. } else m && e.preventDefault(), t != P.downArrow || S.is.visible() || (S.verbose("Down key pressed, showing dropdown"), S.show(), e.preventDefault());
  11040. } else S.has.search() || S.set.selectedLetter(String.fromCharCode(t));
  11041. } }, trigger: { change: function change() {
  11042. var e = n.createEvent("HTMLEvents"),
  11043. t = U[0];t && (S.verbose("Triggering native change event"), e.initEvent("change", !0, !1), t.dispatchEvent(e));
  11044. } }, determine: { selectAction: function selectAction(t, n) {
  11045. S.verbose("Determining action", k.action), e.isFunction(S.action[k.action]) ? (S.verbose("Triggering preset action", k.action, t, n), S.action[k.action].call(K, t, n, this)) : e.isFunction(k.action) ? (S.verbose("Triggering user action", k.action, t, n), k.action.call(K, t, n, this)) : S.error(q.action, k.action);
  11046. }, eventInModule: function eventInModule(t, i) {
  11047. var o = e(t.target),
  11048. a = o.closest(n.documentElement).length > 0,
  11049. r = o.closest(M).length > 0;return i = e.isFunction(i) ? i : function () {}, a && !r ? (S.verbose("Triggering event", i), i(), !0) : (S.verbose("Event occurred in dropdown, canceling callback"), !1);
  11050. }, eventOnElement: function eventOnElement(t, i) {
  11051. var o = e(t.target),
  11052. a = o.closest(D.siblingLabel),
  11053. r = n.body.contains(t.target),
  11054. s = 0 === M.find(a).length,
  11055. l = 0 === o.closest(Q).length;return i = e.isFunction(i) ? i : function () {}, r && s && l ? (S.verbose("Triggering event", i), i(), !0) : (S.verbose("Event occurred in dropdown menu, canceling callback"), !1);
  11056. } }, action: { nothing: function nothing() {}, activate: function activate(t, n, o) {
  11057. if (n = n !== i ? n : t, S.can.activate(e(o))) {
  11058. if (S.set.selected(n, e(o)), S.is.multiple() && !S.is.allFiltered()) return;S.hideAndClear();
  11059. }
  11060. }, select: function select(t, n, o) {
  11061. if (n = n !== i ? n : t, S.can.activate(e(o))) {
  11062. if (S.set.value(n, t, e(o)), S.is.multiple() && !S.is.allFiltered()) return;S.hideAndClear();
  11063. }
  11064. }, combo: function combo(t, n, o) {
  11065. n = n !== i ? n : t, S.set.selected(n, e(o)), S.hideAndClear();
  11066. }, hide: function hide(e, t, n) {
  11067. S.set.value(t, e), S.hideAndClear();
  11068. } }, get: { id: function id() {
  11069. return x;
  11070. }, defaultText: function defaultText() {
  11071. return M.data(E.defaultText);
  11072. }, defaultValue: function defaultValue() {
  11073. return M.data(E.defaultValue);
  11074. }, placeholderText: function placeholderText() {
  11075. return "auto" != k.placeholder && "string" == typeof k.placeholder ? k.placeholder : M.data(E.placeholderText) || "";
  11076. }, text: function text() {
  11077. return V.text();
  11078. }, query: function query() {
  11079. return e.trim(N.val());
  11080. }, searchWidth: function searchWidth(e) {
  11081. return e = e !== i ? e : N.val(), H.text(e), Math.ceil(H.width() + 1);
  11082. }, selectionCount: function selectionCount() {
  11083. var t = S.get.values();return S.is.multiple() ? e.isArray(t) ? t.length : 0 : "" !== S.get.value() ? 1 : 0;
  11084. }, transition: function transition(e) {
  11085. return "auto" == k.transition ? S.is.upward(e) ? "slide up" : "slide down" : k.transition;
  11086. }, userValues: function userValues() {
  11087. var t = S.get.values();return !!t && (t = e.isArray(t) ? t : [t], e.grep(t, function (e) {
  11088. return !1 === S.get.item(e);
  11089. }));
  11090. }, uniqueArray: function uniqueArray(t) {
  11091. return e.grep(t, function (n, i) {
  11092. return e.inArray(n, t) === i;
  11093. });
  11094. }, caretPosition: function caretPosition() {
  11095. var e,
  11096. t,
  11097. i = N.get(0);return "selectionStart" in i ? i.selectionStart : n.selection ? (i.focus(), t = (e = n.selection.createRange()).text.length, e.moveStart("character", -i.value.length), e.text.length - t) : void 0;
  11098. }, value: function value() {
  11099. var t = U.length > 0 ? U.val() : M.data(E.value),
  11100. n = e.isArray(t) && 1 === t.length && "" === t[0];return t === i || n ? "" : t;
  11101. }, values: function values() {
  11102. var e = S.get.value();return "" === e ? "" : !S.has.selectInput() && S.is.multiple() ? "string" == typeof e ? e.split(k.delimiter) : "" : e;
  11103. }, remoteValues: function remoteValues() {
  11104. var t = S.get.values(),
  11105. n = !1;return t && ("string" == typeof t && (t = [t]), e.each(t, function (e, t) {
  11106. var i = S.read.remoteData(t);S.verbose("Restoring value from session data", i, t), i && (n || (n = {}), n[t] = i);
  11107. })), n;
  11108. }, choiceText: function choiceText(t, n) {
  11109. if (n = n !== i ? n : k.preserveHTML, t) return t.find(D.menu).length > 0 && (S.verbose("Retrieving text of element with sub-menu"), (t = t.clone()).find(D.menu).remove(), t.find(D.menuIcon).remove()), t.data(E.text) !== i ? t.data(E.text) : n ? e.trim(t.html()) : e.trim(t.text());
  11110. }, choiceValue: function choiceValue(t, n) {
  11111. return n = n || S.get.choiceText(t), !!t && (t.data(E.value) !== i ? String(t.data(E.value)) : "string" == typeof n ? e.trim(n.toLowerCase()) : String(n));
  11112. }, inputEvent: function inputEvent() {
  11113. var e = N[0];return !!e && (e.oninput !== i ? "input" : e.onpropertychange !== i ? "propertychange" : "keyup");
  11114. }, selectValues: function selectValues() {
  11115. var t = { values: [] };return M.find("option").each(function () {
  11116. var n = e(this),
  11117. o = n.html(),
  11118. a = n.attr("disabled"),
  11119. r = n.attr("value") !== i ? n.attr("value") : o;"auto" === k.placeholder && "" === r ? t.placeholder = o : t.values.push({ name: o, value: r, disabled: a });
  11120. }), k.placeholder && "auto" !== k.placeholder && (S.debug("Setting placeholder value to", k.placeholder), t.placeholder = k.placeholder), k.sortSelect ? (t.values.sort(function (e, t) {
  11121. return e.name > t.name ? 1 : -1;
  11122. }), S.debug("Retrieved and sorted values from select", t)) : S.debug("Retrieved values from select", t), t;
  11123. }, activeItem: function activeItem() {
  11124. return X.filter("." + T.active);
  11125. }, selectedItem: function selectedItem() {
  11126. var e = X.not(D.unselectable).filter("." + T.selected);return e.length > 0 ? e : X.eq(0);
  11127. }, itemWithAdditions: function itemWithAdditions(e) {
  11128. var t = S.get.item(e),
  11129. n = S.create.userChoice(e);return n && n.length > 0 && (t = t.length > 0 ? t.add(n) : n), t;
  11130. }, item: function item(t, n) {
  11131. var o,
  11132. a,
  11133. r = !1;return t = t !== i ? t : S.get.values() !== i ? S.get.values() : S.get.text(), o = a ? t.length > 0 : t !== i && null !== t, a = S.is.multiple() && e.isArray(t), n = "" === t || 0 === t || n || !1, o && X.each(function () {
  11134. var o = e(this),
  11135. s = S.get.choiceText(o),
  11136. l = S.get.choiceValue(o, s);if (null !== l && l !== i) if (a) -1 === e.inArray(String(l), t) && -1 === e.inArray(s, t) || (r = r ? r.add(o) : o);else if (n) {
  11137. if (S.verbose("Ambiguous dropdown value using strict type check", o, t), l === t || s === t) return r = o, !0;
  11138. } else if (String(l) == String(t) || s == t) return S.verbose("Found select item by value", l, t), r = o, !0;
  11139. }), r;
  11140. } }, check: { maxSelections: function maxSelections(e) {
  11141. return !k.maxSelections || ((e = e !== i ? e : S.get.selectionCount()) >= k.maxSelections ? (S.debug("Maximum selection count reached"), k.useLabels && (X.addClass(T.filtered), S.add.message(A.maxSelections)), !0) : (S.verbose("No longer at maximum selection count"), S.remove.message(), S.remove.filteredItem(), S.is.searchSelection() && S.filterItems(), !1));
  11142. } }, restore: { defaults: function defaults() {
  11143. S.clear(), S.restore.defaultText(), S.restore.defaultValue();
  11144. }, defaultText: function defaultText() {
  11145. var e = S.get.defaultText();e === S.get.placeholderText ? (S.debug("Restoring default placeholder text", e), S.set.placeholderText(e)) : (S.debug("Restoring default text", e), S.set.text(e));
  11146. }, placeholderText: function placeholderText() {
  11147. S.set.placeholderText();
  11148. }, defaultValue: function defaultValue() {
  11149. var e = S.get.defaultValue();e !== i && (S.debug("Restoring default value", e), "" !== e ? (S.set.value(e), S.set.selected()) : (S.remove.activeItem(), S.remove.selectedItem()));
  11150. }, labels: function labels() {
  11151. k.allowAdditions && (k.useLabels || (S.error(q.labels), k.useLabels = !0), S.debug("Restoring selected values"), S.create.userLabels()), S.check.maxSelections();
  11152. }, selected: function selected() {
  11153. S.restore.values(), S.is.multiple() ? (S.debug("Restoring previously selected values and labels"), S.restore.labels()) : S.debug("Restoring previously selected values");
  11154. }, values: function values() {
  11155. S.set.initialLoad(), k.apiSettings && k.saveRemoteData && S.get.remoteValues() ? S.restore.remoteValues() : S.set.selected(), S.remove.initialLoad();
  11156. }, remoteValues: function remoteValues() {
  11157. var t = S.get.remoteValues();S.debug("Recreating selected from session data", t), t && (S.is.single() ? e.each(t, function (e, t) {
  11158. S.set.text(t);
  11159. }) : e.each(t, function (e, t) {
  11160. S.add.label(e, t);
  11161. }));
  11162. } }, read: { remoteData: function remoteData(e) {
  11163. var n;if (t.Storage !== i) return (n = sessionStorage.getItem(e)) !== i && n;S.error(q.noStorage);
  11164. } }, save: { defaults: function defaults() {
  11165. S.save.defaultText(), S.save.placeholderText(), S.save.defaultValue();
  11166. }, defaultValue: function defaultValue() {
  11167. var e = S.get.value();S.verbose("Saving default value as", e), M.data(E.defaultValue, e);
  11168. }, defaultText: function defaultText() {
  11169. var e = S.get.text();S.verbose("Saving default text as", e), M.data(E.defaultText, e);
  11170. }, placeholderText: function placeholderText() {
  11171. var e;!1 !== k.placeholder && V.hasClass(T.placeholder) && (e = S.get.text(), S.verbose("Saving placeholder text as", e), M.data(E.placeholderText, e));
  11172. }, remoteData: function remoteData(e, n) {
  11173. t.Storage !== i ? (S.verbose("Saving remote data to session storage", n, e), sessionStorage.setItem(n, e)) : S.error(q.noStorage);
  11174. } }, clear: function clear() {
  11175. S.is.multiple() && k.useLabels ? S.remove.labels() : (S.remove.activeItem(), S.remove.selectedItem()), S.set.placeholderText(), S.clearValue();
  11176. }, clearValue: function clearValue() {
  11177. S.set.value("");
  11178. }, scrollPage: function scrollPage(e, t) {
  11179. var n,
  11180. i,
  11181. o = t || S.get.selectedItem(),
  11182. a = o.closest(D.menu),
  11183. r = a.outerHeight(),
  11184. s = a.scrollTop(),
  11185. l = X.eq(0).outerHeight(),
  11186. c = Math.floor(r / l),
  11187. u = (a.prop("scrollHeight"), "up" == e ? s - l * c : s + l * c),
  11188. d = X.not(D.unselectable);i = "up" == e ? d.index(o) - c : d.index(o) + c, (n = ("up" == e ? i >= 0 : i < d.length) ? d.eq(i) : "up" == e ? d.first() : d.last()).length > 0 && (S.debug("Scrolling page", e, n), o.removeClass(T.selected), n.addClass(T.selected), k.selectOnKeydown && S.is.single() && S.set.selectedItem(n), a.scrollTop(u));
  11189. }, set: { filtered: function filtered() {
  11190. var e = S.is.multiple(),
  11191. t = S.is.searchSelection(),
  11192. n = e && t,
  11193. i = t ? S.get.query() : "",
  11194. o = "string" == typeof i && i.length > 0,
  11195. a = S.get.searchWidth(),
  11196. r = "" !== i;e && o && (S.verbose("Adjusting input width", a, k.glyphWidth), N.css("width", a)), o || n && r ? (S.verbose("Hiding placeholder text"), V.addClass(T.filtered)) : (!e || n && !r) && (S.verbose("Showing placeholder text"), V.removeClass(T.filtered));
  11197. }, empty: function empty() {
  11198. M.addClass(T.empty);
  11199. }, loading: function loading() {
  11200. M.addClass(T.loading);
  11201. }, placeholderText: function placeholderText(e) {
  11202. e = e || S.get.placeholderText(), S.debug("Setting placeholder text", e), S.set.text(e), V.addClass(T.placeholder);
  11203. }, tabbable: function tabbable() {
  11204. S.is.searchSelection() ? (S.debug("Added tabindex to searchable dropdown"), N.val("").attr("tabindex", 0), Q.attr("tabindex", -1)) : (S.debug("Added tabindex to dropdown"), M.attr("tabindex") === i && (M.attr("tabindex", 0), Q.attr("tabindex", -1)));
  11205. }, initialLoad: function initialLoad() {
  11206. S.verbose("Setting initial load"), h = !0;
  11207. }, activeItem: function activeItem(e) {
  11208. k.allowAdditions && e.filter(D.addition).length > 0 ? e.addClass(T.filtered) : e.addClass(T.active);
  11209. }, partialSearch: function partialSearch(e) {
  11210. var t = S.get.query().length;N.val(e.substr(0, t));
  11211. }, scrollPosition: function scrollPosition(e, t) {
  11212. var n, o, a, r, s, l;n = (e = e || S.get.selectedItem()).closest(D.menu), o = e && e.length > 0, t = t !== i && t, e && n.length > 0 && o && (e.position().top, n.addClass(T.loading), a = (r = n.scrollTop()) - n.offset().top + e.offset().top, t || (l = r + n.height() < a + 5, s = a - 5 < r), S.debug("Scrolling to active item", a), (t || s || l) && n.scrollTop(a), n.removeClass(T.loading));
  11213. }, text: function text(e) {
  11214. "select" !== k.action && ("combo" == k.action ? (S.debug("Changing combo button text", e, B), k.preserveHTML ? B.html(e) : B.text(e)) : (e !== S.get.placeholderText() && V.removeClass(T.placeholder), S.debug("Changing text", e, V), V.removeClass(T.filtered), k.preserveHTML ? V.html(e) : V.text(e)));
  11215. }, selectedItem: function selectedItem(e) {
  11216. var t = S.get.choiceValue(e),
  11217. n = S.get.choiceText(e, !1),
  11218. i = S.get.choiceText(e, !0);S.debug("Setting user selection to item", e), S.remove.activeItem(), S.set.partialSearch(n), S.set.activeItem(e), S.set.selected(t, e), S.set.text(i);
  11219. }, selectedLetter: function selectedLetter(t) {
  11220. var n,
  11221. i = X.filter("." + T.selected),
  11222. o = !1;i.length > 0 && S.has.firstLetter(i, t) && (n = i.nextAll(X).eq(0), S.has.firstLetter(n, t) && (o = n)), o || X.each(function () {
  11223. if (S.has.firstLetter(e(this), t)) return o = e(this), !1;
  11224. }), o && (S.verbose("Scrolling to next value with letter", t), S.set.scrollPosition(o), i.removeClass(T.selected), o.addClass(T.selected), k.selectOnKeydown && S.is.single() && S.set.selectedItem(o));
  11225. }, direction: function direction(e) {
  11226. "auto" == k.direction ? (S.remove.upward(), S.can.openDownward(e) ? S.remove.upward(e) : S.set.upward(e), S.is.leftward(e) || S.can.openRightward(e) || S.set.leftward(e)) : "upward" == k.direction && S.set.upward(e);
  11227. }, upward: function upward(e) {
  11228. (e || M).addClass(T.upward);
  11229. }, leftward: function leftward(e) {
  11230. (e || Q).addClass(T.leftward);
  11231. }, value: function value(e, t, n) {
  11232. var o = S.escape.value(e),
  11233. a = U.length > 0,
  11234. r = S.get.values(),
  11235. s = e !== i ? String(e) : e;if (a) {
  11236. if (!k.allowReselection && s == r && (S.verbose("Skipping value update already same value", e, r), !S.is.initialLoad())) return;S.is.single() && S.has.selectInput() && S.can.extendSelect() && (S.debug("Adding user option", e), S.add.optionValue(e)), S.debug("Updating input value", o, r), Z = !0, U.val(o), !1 === k.fireOnInit && S.is.initialLoad() ? S.debug("Input native change event ignored on initial load") : S.trigger.change(), Z = !1;
  11237. } else S.verbose("Storing value in metadata", o, U), o !== r && M.data(E.value, s);!1 === k.fireOnInit && S.is.initialLoad() ? S.verbose("No callback on initial load", k.onChange) : k.onChange.call(K, e, t, n);
  11238. }, active: function active() {
  11239. M.addClass(T.active);
  11240. }, multiple: function multiple() {
  11241. M.addClass(T.multiple);
  11242. }, visible: function visible() {
  11243. M.addClass(T.visible);
  11244. }, exactly: function exactly(e, t) {
  11245. S.debug("Setting selected to exact values"), S.clear(), S.set.selected(e, t);
  11246. }, selected: function selected(t, n) {
  11247. var i = S.is.multiple();(n = k.allowAdditions ? n || S.get.itemWithAdditions(t) : n || S.get.item(t)) && (S.debug("Setting selected menu item to", n), S.is.multiple() && S.remove.searchWidth(), S.is.single() ? (S.remove.activeItem(), S.remove.selectedItem()) : k.useLabels && S.remove.selectedItem(), n.each(function () {
  11248. var t = e(this),
  11249. o = S.get.choiceText(t),
  11250. a = S.get.choiceValue(t, o),
  11251. r = t.hasClass(T.filtered),
  11252. s = t.hasClass(T.active),
  11253. l = t.hasClass(T.addition),
  11254. c = i && 1 == n.length;i ? !s || l ? (k.apiSettings && k.saveRemoteData && S.save.remoteData(o, a), k.useLabels ? (S.add.label(a, o, c), S.add.value(a, o, t), S.set.activeItem(t), S.filterActive(), S.select.nextAvailable(n)) : (S.add.value(a, o, t), S.set.text(S.add.variables(A.count)), S.set.activeItem(t))) : r || (S.debug("Selected active value, removing label"), S.remove.selected(a)) : (k.apiSettings && k.saveRemoteData && S.save.remoteData(o, a), S.set.text(o), S.set.value(a, o, t), t.addClass(T.active).addClass(T.selected));
  11255. }));
  11256. } }, add: { label: function label(t, n, i) {
  11257. var o,
  11258. a = S.is.searchSelection() ? N : V,
  11259. r = S.escape.value(t);k.ignoreCase && (r = r.toLowerCase()), o = e("<a />").addClass(T.label).attr("data-" + E.value, r).html(j.label(r, n)), o = k.onLabelCreate.call(o, r, n), S.has.label(t) ? S.debug("User selection already exists, skipping", r) : (k.label.variation && o.addClass(k.label.variation), !0 === i ? (S.debug("Animating in label", o), o.addClass(T.hidden).insertBefore(a).transition(k.label.transition, k.label.duration)) : (S.debug("Adding selection label", o), o.insertBefore(a)));
  11260. }, message: function message(t) {
  11261. var n = Q.children(D.message),
  11262. i = k.templates.message(S.add.variables(t));n.length > 0 ? n.html(i) : n = e("<div/>").html(i).addClass(T.message).appendTo(Q);
  11263. }, optionValue: function optionValue(t) {
  11264. var n = S.escape.value(t);U.find('option[value="' + S.escape.string(n) + '"]').length > 0 || (S.disconnect.selectObserver(), S.is.single() && (S.verbose("Removing previous user addition"), U.find("option." + T.addition).remove()), e("<option/>").prop("value", n).addClass(T.addition).html(t).appendTo(U), S.verbose("Adding user addition as an <option>", t), S.observe.select());
  11265. }, userSuggestion: function userSuggestion(e) {
  11266. var t,
  11267. n = Q.children(D.addition),
  11268. i = S.get.item(e),
  11269. o = i && i.not(D.addition).length,
  11270. a = n.length > 0;k.useLabels && S.has.maxSelections() || ("" === e || o ? n.remove() : (a ? (n.data(E.value, e).data(E.text, e).attr("data-" + E.value, e).attr("data-" + E.text, e).removeClass(T.filtered), k.hideAdditions || (t = k.templates.addition(S.add.variables(A.addResult, e)), n.html(t)), S.verbose("Replacing user suggestion with new value", n)) : ((n = S.create.userChoice(e)).prependTo(Q), S.verbose("Adding item choice to menu corresponding with user choice addition", n)), k.hideAdditions && !S.is.allFiltered() || n.addClass(T.selected).siblings().removeClass(T.selected), S.refreshItems()));
  11271. }, variables: function variables(e, t) {
  11272. var n,
  11273. i,
  11274. o = -1 !== e.search("{count}"),
  11275. a = -1 !== e.search("{maxCount}"),
  11276. r = -1 !== e.search("{term}");return S.verbose("Adding templated variables to message", e), o && (n = S.get.selectionCount(), e = e.replace("{count}", n)), a && (n = S.get.selectionCount(), e = e.replace("{maxCount}", k.maxSelections)), r && (i = t || S.get.query(), e = e.replace("{term}", i)), e;
  11277. }, value: function value(t, n, i) {
  11278. var o,
  11279. a = S.get.values();S.has.value(t) ? S.debug("Value already selected") : "" !== t ? (e.isArray(a) ? (o = a.concat([t]), o = S.get.uniqueArray(o)) : o = [t], S.has.selectInput() ? S.can.extendSelect() && (S.debug("Adding value to select", t, o, U), S.add.optionValue(t)) : (o = o.join(k.delimiter), S.debug("Setting hidden input to delimited value", o, U)), !1 === k.fireOnInit && S.is.initialLoad() ? S.verbose("Skipping onadd callback on initial load", k.onAdd) : k.onAdd.call(K, t, n, i), S.set.value(o, t, n, i), S.check.maxSelections()) : S.debug("Cannot select blank values from multiselect");
  11280. } }, remove: { active: function active() {
  11281. M.removeClass(T.active);
  11282. }, activeLabel: function activeLabel() {
  11283. M.find(D.label).removeClass(T.active);
  11284. }, empty: function empty() {
  11285. M.removeClass(T.empty);
  11286. }, loading: function loading() {
  11287. M.removeClass(T.loading);
  11288. }, initialLoad: function initialLoad() {
  11289. h = !1;
  11290. }, upward: function upward(e) {
  11291. (e || M).removeClass(T.upward);
  11292. }, leftward: function leftward(e) {
  11293. (e || Q).removeClass(T.leftward);
  11294. }, visible: function visible() {
  11295. M.removeClass(T.visible);
  11296. }, activeItem: function activeItem() {
  11297. X.removeClass(T.active);
  11298. }, filteredItem: function filteredItem() {
  11299. k.useLabels && S.has.maxSelections() || (k.useLabels && S.is.multiple() ? X.not("." + T.active).removeClass(T.filtered) : X.removeClass(T.filtered), S.remove.empty());
  11300. }, optionValue: function optionValue(e) {
  11301. var t = S.escape.value(e),
  11302. n = U.find('option[value="' + S.escape.string(t) + '"]');n.length > 0 && n.hasClass(T.addition) && (C && (C.disconnect(), S.verbose("Temporarily disconnecting mutation observer")), n.remove(), S.verbose("Removing user addition as an <option>", t), C && C.observe(U[0], { childList: !0, subtree: !0 }));
  11303. }, message: function message() {
  11304. Q.children(D.message).remove();
  11305. }, searchWidth: function searchWidth() {
  11306. N.css("width", "");
  11307. }, searchTerm: function searchTerm() {
  11308. S.verbose("Cleared search term"), N.val(""), S.set.filtered();
  11309. }, userAddition: function userAddition() {
  11310. X.filter(D.addition).remove();
  11311. }, selected: function selected(t, n) {
  11312. if (!(n = k.allowAdditions ? n || S.get.itemWithAdditions(t) : n || S.get.item(t))) return !1;n.each(function () {
  11313. var t = e(this),
  11314. n = S.get.choiceText(t),
  11315. i = S.get.choiceValue(t, n);S.is.multiple() ? k.useLabels ? (S.remove.value(i, n, t), S.remove.label(i)) : (S.remove.value(i, n, t), 0 === S.get.selectionCount() ? S.set.placeholderText() : S.set.text(S.add.variables(A.count))) : S.remove.value(i, n, t), t.removeClass(T.filtered).removeClass(T.active), k.useLabels && t.removeClass(T.selected);
  11316. });
  11317. }, selectedItem: function selectedItem() {
  11318. X.removeClass(T.selected);
  11319. }, value: function value(e, t, n) {
  11320. var i,
  11321. o = S.get.values();S.has.selectInput() ? (S.verbose("Input is <select> removing selected option", e), i = S.remove.arrayValue(e, o), S.remove.optionValue(e)) : (S.verbose("Removing from delimited values", e), i = (i = S.remove.arrayValue(e, o)).join(k.delimiter)), !1 === k.fireOnInit && S.is.initialLoad() ? S.verbose("No callback on initial load", k.onRemove) : k.onRemove.call(K, e, t, n), S.set.value(i, t, n), S.check.maxSelections();
  11322. }, arrayValue: function arrayValue(t, n) {
  11323. return e.isArray(n) || (n = [n]), n = e.grep(n, function (e) {
  11324. return t != e;
  11325. }), S.verbose("Removed value from delimited string", t, n), n;
  11326. }, label: function label(e, t) {
  11327. var n = M.find(D.label).filter("[data-" + E.value + '="' + S.escape.string(e) + '"]');S.verbose("Removing label", n), n.remove();
  11328. }, activeLabels: function activeLabels(e) {
  11329. e = e || M.find(D.label).filter("." + T.active), S.verbose("Removing active label selections", e), S.remove.labels(e);
  11330. }, labels: function labels(t) {
  11331. t = t || M.find(D.label), S.verbose("Removing labels", t), t.each(function () {
  11332. var t = e(this),
  11333. n = t.data(E.value),
  11334. o = n !== i ? String(n) : n,
  11335. a = S.is.userValue(o);!1 !== k.onLabelRemove.call(t, n) ? (S.remove.message(), a ? (S.remove.value(o), S.remove.label(o)) : S.remove.selected(o)) : S.debug("Label remove callback cancelled removal");
  11336. });
  11337. }, tabbable: function tabbable() {
  11338. S.is.searchSelection() ? (S.debug("Searchable dropdown initialized"), N.removeAttr("tabindex"), Q.removeAttr("tabindex")) : (S.debug("Simple selection dropdown initialized"), M.removeAttr("tabindex"), Q.removeAttr("tabindex"));
  11339. } }, has: { menuSearch: function menuSearch() {
  11340. return S.has.search() && N.closest(Q).length > 0;
  11341. }, search: function search() {
  11342. return N.length > 0;
  11343. }, sizer: function sizer() {
  11344. return H.length > 0;
  11345. }, selectInput: function selectInput() {
  11346. return U.is("select");
  11347. }, minCharacters: function minCharacters(e) {
  11348. return !k.minCharacters || (e = e !== i ? String(e) : String(S.get.query())).length >= k.minCharacters;
  11349. }, firstLetter: function firstLetter(e, t) {
  11350. var n;return !(!e || 0 === e.length || "string" != typeof t) && (n = S.get.choiceText(e, !1), (t = t.toLowerCase()) == String(n).charAt(0).toLowerCase());
  11351. }, input: function input() {
  11352. return U.length > 0;
  11353. }, items: function items() {
  11354. return X.length > 0;
  11355. }, menu: function menu() {
  11356. return Q.length > 0;
  11357. }, message: function message() {
  11358. return 0 !== Q.children(D.message).length;
  11359. }, label: function label(e) {
  11360. var t = S.escape.value(e),
  11361. n = M.find(D.label);return k.ignoreCase && (t = t.toLowerCase()), n.filter("[data-" + E.value + '="' + S.escape.string(t) + '"]').length > 0;
  11362. }, maxSelections: function maxSelections() {
  11363. return k.maxSelections && S.get.selectionCount() >= k.maxSelections;
  11364. }, allResultsFiltered: function allResultsFiltered() {
  11365. var e = X.not(D.addition);return e.filter(D.unselectable).length === e.length;
  11366. }, userSuggestion: function userSuggestion() {
  11367. return Q.children(D.addition).length > 0;
  11368. }, query: function query() {
  11369. return "" !== S.get.query();
  11370. }, value: function value(e) {
  11371. return k.ignoreCase ? S.has.valueIgnoringCase(e) : S.has.valueMatchingCase(e);
  11372. }, valueMatchingCase: function valueMatchingCase(t) {
  11373. var n = S.get.values();return !!(e.isArray(n) ? n && -1 !== e.inArray(t, n) : n == t);
  11374. }, valueIgnoringCase: function valueIgnoringCase(t) {
  11375. var n = S.get.values(),
  11376. i = !1;return e.isArray(n) || (n = [n]), e.each(n, function (e, n) {
  11377. if (String(t).toLowerCase() == String(n).toLowerCase()) return i = !0, !1;
  11378. }), i;
  11379. } }, is: { active: function active() {
  11380. return M.hasClass(T.active);
  11381. }, animatingInward: function animatingInward() {
  11382. return Q.transition("is inward");
  11383. }, animatingOutward: function animatingOutward() {
  11384. return Q.transition("is outward");
  11385. }, bubbledLabelClick: function bubbledLabelClick(t) {
  11386. return e(t.target).is("select, input") && M.closest("label").length > 0;
  11387. }, bubbledIconClick: function bubbledIconClick(t) {
  11388. return e(t.target).closest(W).length > 0;
  11389. }, alreadySetup: function alreadySetup() {
  11390. return M.is("select") && M.parent(D.dropdown).data(I) !== i && 0 === M.prev().length;
  11391. }, animating: function animating(e) {
  11392. return e ? e.transition && e.transition("is animating") : Q.transition && Q.transition("is animating");
  11393. }, leftward: function leftward(e) {
  11394. return (e || Q).hasClass(T.leftward);
  11395. }, disabled: function disabled() {
  11396. return M.hasClass(T.disabled);
  11397. }, focused: function focused() {
  11398. return n.activeElement === M[0];
  11399. }, focusedOnSearch: function focusedOnSearch() {
  11400. return n.activeElement === N[0];
  11401. }, allFiltered: function allFiltered() {
  11402. return (S.is.multiple() || S.has.search()) && !(0 == k.hideAdditions && S.has.userSuggestion()) && !S.has.message() && S.has.allResultsFiltered();
  11403. }, hidden: function hidden(e) {
  11404. return !S.is.visible(e);
  11405. }, initialLoad: function initialLoad() {
  11406. return h;
  11407. }, inObject: function inObject(t, n) {
  11408. var i = !1;return e.each(n, function (e, n) {
  11409. if (n == t) return i = !0, !0;
  11410. }), i;
  11411. }, multiple: function multiple() {
  11412. return M.hasClass(T.multiple);
  11413. }, remote: function remote() {
  11414. return k.apiSettings && S.can.useAPI();
  11415. }, single: function single() {
  11416. return !S.is.multiple();
  11417. }, selectMutation: function selectMutation(t) {
  11418. var n = !1;return e.each(t, function (t, i) {
  11419. if (i.target && e(i.target).is("select")) return n = !0, !0;
  11420. }), n;
  11421. }, search: function search() {
  11422. return M.hasClass(T.search);
  11423. }, searchSelection: function searchSelection() {
  11424. return S.has.search() && 1 === N.parent(D.dropdown).length;
  11425. }, selection: function selection() {
  11426. return M.hasClass(T.selection);
  11427. }, userValue: function userValue(t) {
  11428. return -1 !== e.inArray(t, S.get.userValues());
  11429. }, upward: function upward(e) {
  11430. return (e || M).hasClass(T.upward);
  11431. }, visible: function visible(e) {
  11432. return e ? e.hasClass(T.visible) : Q.hasClass(T.visible);
  11433. }, verticallyScrollableContext: function verticallyScrollableContext() {
  11434. var e = L.get(0) !== t && L.css("overflow-y");return "auto" == e || "scroll" == e;
  11435. }, horizontallyScrollableContext: function horizontallyScrollableContext() {
  11436. var e = L.get(0) !== t && L.css("overflow-X");return "auto" == e || "scroll" == e;
  11437. } }, can: { activate: function activate(e) {
  11438. return !!k.useLabels || !S.has.maxSelections() || !(!S.has.maxSelections() || !e.hasClass(T.active));
  11439. }, openDownward: function openDownward(e) {
  11440. var n,
  11441. i,
  11442. o = e || Q,
  11443. a = !0;return o.addClass(T.loading), i = { context: { offset: L.get(0) === t ? { top: 0, left: 0 } : L.offset(), scrollTop: L.scrollTop(), height: L.outerHeight() }, menu: { offset: o.offset(), height: o.outerHeight() } }, S.is.verticallyScrollableContext() && (i.menu.offset.top += i.context.scrollTop), (n = { above: i.context.scrollTop <= i.menu.offset.top - i.context.offset.top - i.menu.height, below: i.context.scrollTop + i.context.height >= i.menu.offset.top - i.context.offset.top + i.menu.height }).below ? (S.verbose("Dropdown can fit in context downward", n), a = !0) : n.below || n.above ? (S.verbose("Dropdown cannot fit below, opening upward", n), a = !1) : (S.verbose("Dropdown cannot fit in either direction, favoring downward", n), a = !0), o.removeClass(T.loading), a;
  11444. }, openRightward: function openRightward(e) {
  11445. var n,
  11446. i,
  11447. o = e || Q,
  11448. a = !0;return o.addClass(T.loading), i = { context: { offset: L.get(0) === t ? { top: 0, left: 0 } : L.offset(), scrollLeft: L.scrollLeft(), width: L.outerWidth() }, menu: { offset: o.offset(), width: o.outerWidth() } }, S.is.horizontallyScrollableContext() && (i.menu.offset.left += i.context.scrollLeft), (n = i.menu.offset.left - i.context.offset.left + i.menu.width >= i.context.scrollLeft + i.context.width) && (S.verbose("Dropdown cannot fit in context rightward", n), a = !1), o.removeClass(T.loading), a;
  11449. }, click: function click() {
  11450. return c || "click" == k.on;
  11451. }, extendSelect: function extendSelect() {
  11452. return k.allowAdditions || k.apiSettings;
  11453. }, show: function show() {
  11454. return !S.is.disabled() && (S.has.items() || S.has.message());
  11455. }, useAPI: function useAPI() {
  11456. return e.fn.api !== i;
  11457. } }, animate: { show: function show(t, n) {
  11458. var o,
  11459. a = n || Q,
  11460. r = n ? function () {} : function () {
  11461. S.hideSubMenus(), S.hideOthers(), S.set.active();
  11462. };t = e.isFunction(t) ? t : function () {}, S.verbose("Doing menu show animation", a), S.set.direction(n), o = S.get.transition(n), S.is.selection() && S.set.scrollPosition(S.get.selectedItem(), !0), (S.is.hidden(a) || S.is.animating(a)) && ("none" == o ? (r(), a.transition("show"), t.call(K)) : e.fn.transition !== i && M.transition("is supported") ? a.transition({ animation: o + " in", debug: k.debug, verbose: k.verbose, duration: k.duration, queue: !0, onStart: r, onComplete: function onComplete() {
  11463. t.call(K);
  11464. } }) : S.error(q.noTransition, o));
  11465. }, hide: function hide(t, n) {
  11466. var o = n || Q,
  11467. a = (n ? k.duration : k.duration, n ? function () {} : function () {
  11468. S.can.click() && S.unbind.intent(), S.remove.active();
  11469. }),
  11470. r = S.get.transition(n);t = e.isFunction(t) ? t : function () {}, (S.is.visible(o) || S.is.animating(o)) && (S.verbose("Doing menu hide animation", o), "none" == r ? (a(), o.transition("hide"), t.call(K)) : e.fn.transition !== i && M.transition("is supported") ? o.transition({ animation: r + " out", duration: k.duration, debug: k.debug, verbose: k.verbose, queue: !1, onStart: a, onComplete: function onComplete() {
  11471. t.call(K);
  11472. } }) : S.error(q.transition));
  11473. } }, hideAndClear: function hideAndClear() {
  11474. S.remove.searchTerm(), S.has.maxSelections() || (S.has.search() ? S.hide(function () {
  11475. S.remove.filteredItem();
  11476. }) : S.hide());
  11477. }, delay: { show: function show() {
  11478. S.verbose("Delaying show event to ensure user intent"), clearTimeout(S.timer), S.timer = setTimeout(S.show, k.delay.show);
  11479. }, hide: function hide() {
  11480. S.verbose("Delaying hide event to ensure user intent"), clearTimeout(S.timer), S.timer = setTimeout(S.hide, k.delay.hide);
  11481. } }, escape: { value: function value(t) {
  11482. var n = e.isArray(t),
  11483. i = "string" == typeof t,
  11484. o = !i && !n,
  11485. a = i && -1 !== t.search(O.quote),
  11486. r = [];return o || !a ? t : (S.debug("Encoding quote values for use in select", t), n ? (e.each(t, function (e, t) {
  11487. r.push(t.replace(O.quote, "&quot;"));
  11488. }), r) : t.replace(O.quote, "&quot;"));
  11489. }, string: function string(e) {
  11490. return (e = String(e)).replace(O.escape, "\\$&");
  11491. } }, setting: function setting(t, n) {
  11492. if (S.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, k, t);else {
  11493. if (n === i) return k[t];e.isPlainObject(k[t]) ? e.extend(!0, k[t], n) : k[t] = n;
  11494. }
  11495. }, internal: function internal(t, n) {
  11496. if (e.isPlainObject(t)) e.extend(!0, S, t);else {
  11497. if (n === i) return S[t];S[t] = n;
  11498. }
  11499. }, debug: function debug() {
  11500. !k.silent && k.debug && (k.performance ? S.performance.log(arguments) : (S.debug = Function.prototype.bind.call(console.info, console, k.name + ":"), S.debug.apply(console, arguments)));
  11501. }, verbose: function verbose() {
  11502. !k.silent && k.verbose && k.debug && (k.performance ? S.performance.log(arguments) : (S.verbose = Function.prototype.bind.call(console.info, console, k.name + ":"), S.verbose.apply(console, arguments)));
  11503. }, error: function error() {
  11504. k.silent || (S.error = Function.prototype.bind.call(console.error, console, k.name + ":"), S.error.apply(console, arguments));
  11505. }, performance: { log: function log(e) {
  11506. var t, n;k.performance && (n = (t = new Date().getTime()) - (u || t), u = t, d.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: K, "Execution Time": n })), clearTimeout(S.performance.timer), S.performance.timer = setTimeout(S.performance.display, 500);
  11507. }, display: function display() {
  11508. var t = k.name + ":",
  11509. n = 0;u = !1, clearTimeout(S.performance.timer), e.each(d, function (e, t) {
  11510. n += t["Execution Time"];
  11511. }), t += " " + n + "ms", l && (t += " '" + l + "'"), (console.group !== i || console.table !== i) && d.length > 0 && (console.groupCollapsed(t), console.table ? console.table(d) : e.each(d, function (e, t) {
  11512. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  11513. }), console.groupEnd()), d = [];
  11514. } }, invoke: function invoke(t, n, o) {
  11515. var r,
  11516. s,
  11517. l,
  11518. c = J;return n = n || g, o = K || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  11519. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  11520. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (S.error(q.method, t), !1);c = c[o];
  11521. }
  11522. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  11523. } }, m ? (J === i && S.initialize(), S.invoke(f)) : (J !== i && J.invoke("destroy"), S.initialize());
  11524. }), a !== i ? a : r;
  11525. }, e.fn.dropdown.settings = { silent: !1, debug: !1, verbose: !1, performance: !0, on: "click", action: "activate", values: !1, apiSettings: !1, selectOnKeydown: !0, minCharacters: 0, filterRemoteData: !1, saveRemoteData: !0, throttle: 200, context: t, direction: "auto", keepOnScreen: !0, match: "both", fullTextSearch: !1, placeholder: "auto", preserveHTML: !0, sortSelect: !1, forceSelection: !0, allowAdditions: !1, ignoreCase: !1, hideAdditions: !0, maxSelections: !1, useLabels: !0, delimiter: ",", showOnFocus: !0, allowReselection: !1, allowTab: !0, allowCategorySelection: !1, fireOnInit: !1, transition: "auto", duration: 200, glyphWidth: 1.037, label: { transition: "scale", duration: 200, variation: !1 }, delay: { hide: 300, show: 200, search: 20, touch: 50 }, onChange: function onChange(e, t, n) {}, onAdd: function onAdd(e, t, n) {}, onRemove: function onRemove(e, t, n) {}, onLabelSelect: function onLabelSelect(e) {}, onLabelCreate: function onLabelCreate(t, n) {
  11526. return e(this);
  11527. }, onLabelRemove: function onLabelRemove(e) {
  11528. return !0;
  11529. }, onNoResults: function onNoResults(e) {
  11530. return !0;
  11531. }, onShow: function onShow() {}, onHide: function onHide() {}, name: "Dropdown", namespace: "dropdown", message: { addResult: "Add <b>{term}</b>", count: "{count} selected", maxSelections: "Max {maxCount} selections", noResults: "No results found.", serverError: "There was an error contacting the server" }, error: { action: "You called a dropdown action that was not defined", alreadySetup: "Once a select has been initialized behaviors must be called on the created ui dropdown", labels: "Allowing user additions currently requires the use of labels.", missingMultiple: "<select> requires multiple property to be set to correctly preserve multiple values", method: "The method you called is not defined.", noAPI: "The API module is required to load resources remotely", noStorage: "Saving remote data requires session storage", noTransition: "This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>" }, regExp: { escape: /[-[\]{}()*+?.,\\^$|#\s]/g, quote: /"/g }, metadata: { defaultText: "defaultText", defaultValue: "defaultValue", placeholderText: "placeholder", text: "text", value: "value" }, fields: { remoteValues: "results", values: "values", disabled: "disabled", name: "name", value: "value", text: "text" }, keys: { backspace: 8, delimiter: 188, deleteKey: 46, enter: 13, escape: 27, pageUp: 33, pageDown: 34, leftArrow: 37, upArrow: 38, rightArrow: 39, downArrow: 40 }, selector: { addition: ".addition", dropdown: ".ui.dropdown", hidden: ".hidden", icon: "> .dropdown.icon", input: '> input[type="hidden"], > select', item: ".item", label: "> .label", remove: "> .label > .delete.icon", siblingLabel: ".label", menu: ".menu", message: ".message", menuIcon: ".dropdown.icon", search: "input.search, .menu > .search > input, .menu input.search", sizer: "> input.sizer", text: "> .text:not(.icon)", unselectable: ".disabled, .filtered" }, className: { active: "active", addition: "addition", animating: "animating", disabled: "disabled", empty: "empty", dropdown: "ui dropdown", filtered: "filtered", hidden: "hidden transition", item: "item", label: "ui label", loading: "loading", menu: "menu", message: "message", multiple: "multiple", placeholder: "default", sizer: "sizer", search: "search", selected: "selected", selection: "selection", upward: "upward", leftward: "left", visible: "visible" } }, e.fn.dropdown.settings.templates = { dropdown: function dropdown(t) {
  11532. var n = t.placeholder || !1,
  11533. i = (t.values, "");return i += '<i class="dropdown icon"></i>', t.placeholder ? i += '<div class="default text">' + n + "</div>" : i += '<div class="text"></div>', i += '<div class="menu">', e.each(t.values, function (e, t) {
  11534. i += t.disabled ? '<div class="disabled item" data-value="' + t.value + '">' + t.name + "</div>" : '<div class="item" data-value="' + t.value + '">' + t.name + "</div>";
  11535. }), i += "</div>";
  11536. }, menu: function menu(t, n) {
  11537. var i = t[n.values] || {},
  11538. o = "";return e.each(i, function (e, t) {
  11539. var i = t[n.text] ? 'data-text="' + t[n.text] + '"' : "",
  11540. a = t[n.disabled] ? "disabled " : "";o += '<div class="' + a + 'item" data-value="' + t[n.value] + '"' + i + ">", o += t[n.name], o += "</div>";
  11541. }), o;
  11542. }, label: function label(e, t) {
  11543. return t + '<i class="delete icon"></i>';
  11544. }, message: function message(e) {
  11545. return e;
  11546. }, addition: function addition(e) {
  11547. return e;
  11548. } };
  11549. }(jQuery, window, document), function (e, t, n, i) {
  11550. "use strict";
  11551. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.embed = function (n) {
  11552. var o,
  11553. a = e(this),
  11554. r = a.selector || "",
  11555. s = new Date().getTime(),
  11556. l = [],
  11557. c = arguments[0],
  11558. u = "string" == typeof c,
  11559. d = [].slice.call(arguments, 1);return a.each(function () {
  11560. var f,
  11561. m = e.isPlainObject(n) ? e.extend(!0, {}, e.fn.embed.settings, n) : e.extend({}, e.fn.embed.settings),
  11562. g = m.selector,
  11563. p = m.className,
  11564. h = m.sources,
  11565. v = m.error,
  11566. b = m.metadata,
  11567. y = m.namespace,
  11568. x = m.templates,
  11569. C = "." + y,
  11570. w = "module-" + y,
  11571. S = (e(t), e(this)),
  11572. k = (S.find(g.placeholder), S.find(g.icon), S.find(g.embed)),
  11573. T = this,
  11574. A = S.data(w);f = { initialize: function initialize() {
  11575. f.debug("Initializing embed"), f.determine.autoplay(), f.create(), f.bind.events(), f.instantiate();
  11576. }, instantiate: function instantiate() {
  11577. f.verbose("Storing instance of module", f), A = f, S.data(w, f);
  11578. }, destroy: function destroy() {
  11579. f.verbose("Destroying previous instance of embed"), f.reset(), S.removeData(w).off(C);
  11580. }, refresh: function refresh() {
  11581. f.verbose("Refreshing selector cache"), S.find(g.placeholder), S.find(g.icon), k = S.find(g.embed);
  11582. }, bind: { events: function events() {
  11583. f.has.placeholder() && (f.debug("Adding placeholder events"), S.on("click" + C, g.placeholder, f.createAndShow).on("click" + C, g.icon, f.createAndShow));
  11584. } }, create: function create() {
  11585. f.get.placeholder() ? f.createPlaceholder() : f.createAndShow();
  11586. }, createPlaceholder: function createPlaceholder(e) {
  11587. var t = f.get.icon(),
  11588. n = f.get.url();f.generate.embed(n);e = e || f.get.placeholder(), S.html(x.placeholder(e, t)), f.debug("Creating placeholder for embed", e, t);
  11589. }, createEmbed: function createEmbed(t) {
  11590. f.refresh(), t = t || f.get.url(), k = e("<div/>").addClass(p.embed).html(f.generate.embed(t)).appendTo(S), m.onCreate.call(T, t), f.debug("Creating embed object", k);
  11591. }, changeEmbed: function changeEmbed(e) {
  11592. k.html(f.generate.embed(e));
  11593. }, createAndShow: function createAndShow() {
  11594. f.createEmbed(), f.show();
  11595. }, change: function change(e, t, n) {
  11596. f.debug("Changing video to ", e, t, n), S.data(b.source, e).data(b.id, t), n ? S.data(b.url, n) : S.removeData(b.url), f.has.embed() ? f.changeEmbed() : f.create();
  11597. }, reset: function reset() {
  11598. f.debug("Clearing embed and showing placeholder"), f.remove.active(), f.remove.embed(), f.showPlaceholder(), m.onReset.call(T);
  11599. }, show: function show() {
  11600. f.debug("Showing embed"), f.set.active(), m.onDisplay.call(T);
  11601. }, hide: function hide() {
  11602. f.debug("Hiding embed"), f.showPlaceholder();
  11603. }, showPlaceholder: function showPlaceholder() {
  11604. f.debug("Showing placeholder image"), f.remove.active(), m.onPlaceholderDisplay.call(T);
  11605. }, get: { id: function id() {
  11606. return m.id || S.data(b.id);
  11607. }, placeholder: function placeholder() {
  11608. return m.placeholder || S.data(b.placeholder);
  11609. }, icon: function icon() {
  11610. return m.icon ? m.icon : S.data(b.icon) !== i ? S.data(b.icon) : f.determine.icon();
  11611. }, source: function source(e) {
  11612. return m.source ? m.source : S.data(b.source) !== i ? S.data(b.source) : f.determine.source();
  11613. }, type: function type() {
  11614. var e = f.get.source();return h[e] !== i && h[e].type;
  11615. }, url: function url() {
  11616. return m.url ? m.url : S.data(b.url) !== i ? S.data(b.url) : f.determine.url();
  11617. } }, determine: { autoplay: function autoplay() {
  11618. f.should.autoplay() && (m.autoplay = !0);
  11619. }, source: function source(t) {
  11620. var n = !1;return (t = t || f.get.url()) && e.each(h, function (e, i) {
  11621. if (-1 !== t.search(i.domain)) return n = e, !1;
  11622. }), n;
  11623. }, icon: function icon() {
  11624. var e = f.get.source();return h[e] !== i && h[e].icon;
  11625. }, url: function url() {
  11626. var e,
  11627. t = m.id || S.data(b.id),
  11628. n = m.source || S.data(b.source);return (e = h[n] !== i && h[n].url.replace("{id}", t)) && S.data(b.url, e), e;
  11629. } }, set: { active: function active() {
  11630. S.addClass(p.active);
  11631. } }, remove: { active: function active() {
  11632. S.removeClass(p.active);
  11633. }, embed: function embed() {
  11634. k.empty();
  11635. } }, encode: { parameters: function parameters(e) {
  11636. var t,
  11637. n = [];for (t in e) {
  11638. n.push(encodeURIComponent(t) + "=" + encodeURIComponent(e[t]));
  11639. }return n.join("&amp;");
  11640. } }, generate: { embed: function embed(e) {
  11641. f.debug("Generating embed html");var t,
  11642. n,
  11643. i = f.get.source();return (e = f.get.url(e)) ? (n = f.generate.parameters(i), t = x.iframe(e, n)) : f.error(v.noURL, S), t;
  11644. }, parameters: function parameters(t, n) {
  11645. var o = h[t] && h[t].parameters !== i ? h[t].parameters(m) : {};return (n = n || m.parameters) && (o = e.extend({}, o, n)), o = m.onEmbed(o), f.encode.parameters(o);
  11646. } }, has: { embed: function embed() {
  11647. return k.length > 0;
  11648. }, placeholder: function placeholder() {
  11649. return m.placeholder || S.data(b.placeholder);
  11650. } }, should: { autoplay: function autoplay() {
  11651. return "auto" === m.autoplay ? m.placeholder || S.data(b.placeholder) !== i : m.autoplay;
  11652. } }, is: { video: function video() {
  11653. return "video" == f.get.type();
  11654. } }, setting: function setting(t, n) {
  11655. if (f.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, m, t);else {
  11656. if (n === i) return m[t];e.isPlainObject(m[t]) ? e.extend(!0, m[t], n) : m[t] = n;
  11657. }
  11658. }, internal: function internal(t, n) {
  11659. if (e.isPlainObject(t)) e.extend(!0, f, t);else {
  11660. if (n === i) return f[t];f[t] = n;
  11661. }
  11662. }, debug: function debug() {
  11663. !m.silent && m.debug && (m.performance ? f.performance.log(arguments) : (f.debug = Function.prototype.bind.call(console.info, console, m.name + ":"), f.debug.apply(console, arguments)));
  11664. }, verbose: function verbose() {
  11665. !m.silent && m.verbose && m.debug && (m.performance ? f.performance.log(arguments) : (f.verbose = Function.prototype.bind.call(console.info, console, m.name + ":"), f.verbose.apply(console, arguments)));
  11666. }, error: function error() {
  11667. m.silent || (f.error = Function.prototype.bind.call(console.error, console, m.name + ":"), f.error.apply(console, arguments));
  11668. }, performance: { log: function log(e) {
  11669. var t, n;m.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: T, "Execution Time": n })), clearTimeout(f.performance.timer), f.performance.timer = setTimeout(f.performance.display, 500);
  11670. }, display: function display() {
  11671. var t = m.name + ":",
  11672. n = 0;s = !1, clearTimeout(f.performance.timer), e.each(l, function (e, t) {
  11673. n += t["Execution Time"];
  11674. }), t += " " + n + "ms", r && (t += " '" + r + "'"), a.length > 1 && (t += " (" + a.length + ")"), (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  11675. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  11676. }), console.groupEnd()), l = [];
  11677. } }, invoke: function invoke(t, n, a) {
  11678. var r,
  11679. s,
  11680. l,
  11681. c = A;return n = n || d, a = T || a, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  11682. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  11683. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (f.error(v.method, t), !1);c = c[o];
  11684. }
  11685. })), e.isFunction(s) ? l = s.apply(a, n) : s !== i && (l = s), e.isArray(o) ? o.push(l) : o !== i ? o = [o, l] : l !== i && (o = l), s;
  11686. } }, u ? (A === i && f.initialize(), f.invoke(c)) : (A !== i && A.invoke("destroy"), f.initialize());
  11687. }), o !== i ? o : this;
  11688. }, e.fn.embed.settings = { name: "Embed", namespace: "embed", silent: !1, debug: !1, verbose: !1, performance: !0, icon: !1, source: !1, url: !1, id: !1, autoplay: "auto", color: "#444444", hd: !0, brandedUI: !1, parameters: !1, onDisplay: function onDisplay() {}, onPlaceholderDisplay: function onPlaceholderDisplay() {}, onReset: function onReset() {}, onCreate: function onCreate(e) {}, onEmbed: function onEmbed(e) {
  11689. return e;
  11690. }, metadata: { id: "id", icon: "icon", placeholder: "placeholder", source: "source", url: "url" }, error: { noURL: "No URL specified", method: "The method you called is not defined" }, className: { active: "active", embed: "embed" }, selector: { embed: ".embed", placeholder: ".placeholder", icon: ".icon" }, sources: { youtube: { name: "youtube", type: "video", icon: "video play", domain: "youtube.com", url: "//www.youtube.com/embed/{id}", parameters: function parameters(e) {
  11691. return { autohide: !e.brandedUI, autoplay: e.autoplay, color: e.color || i, hq: e.hd, jsapi: e.api, modestbranding: !e.brandedUI };
  11692. } }, vimeo: { name: "vimeo", type: "video", icon: "video play", domain: "vimeo.com", url: "//player.vimeo.com/video/{id}", parameters: function parameters(e) {
  11693. return { api: e.api, autoplay: e.autoplay, byline: e.brandedUI, color: e.color || i, portrait: e.brandedUI, title: e.brandedUI };
  11694. } } }, templates: { iframe: function iframe(e, t) {
  11695. var n = e;return t && (n += "?" + t), '<iframe src="' + n + '" width="100%" height="100%" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
  11696. }, placeholder: function placeholder(e, t) {
  11697. var n = "";return t && (n += '<i class="' + t + ' icon"></i>'), e && (n += '<img class="placeholder" src="' + e + '">'), n;
  11698. } }, api: !1, onPause: function onPause() {}, onPlay: function onPlay() {}, onStop: function onStop() {} };
  11699. }(jQuery, window, document), function (e, t, n, i) {
  11700. "use strict";
  11701. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.modal = function (o) {
  11702. var a,
  11703. r = e(this),
  11704. s = e(t),
  11705. l = e(n),
  11706. c = e("body"),
  11707. u = r.selector || "",
  11708. d = new Date().getTime(),
  11709. f = [],
  11710. m = arguments[0],
  11711. g = "string" == typeof m,
  11712. p = [].slice.call(arguments, 1),
  11713. h = t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame || function (e) {
  11714. setTimeout(e, 0);
  11715. };return r.each(function () {
  11716. var r,
  11717. v,
  11718. b,
  11719. y,
  11720. x,
  11721. C,
  11722. w,
  11723. S,
  11724. k,
  11725. T = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.modal.settings, o) : e.extend({}, e.fn.modal.settings),
  11726. A = T.selector,
  11727. R = T.className,
  11728. P = T.namespace,
  11729. E = T.error,
  11730. F = "." + P,
  11731. O = "module-" + P,
  11732. D = e(this),
  11733. q = e(T.context),
  11734. j = D.find(A.close),
  11735. z = this,
  11736. I = D.data(O),
  11737. M = !1;k = { initialize: function initialize() {
  11738. k.verbose("Initializing dimmer", q), k.create.id(), k.create.dimmer(), k.refreshModals(), k.bind.events(), T.observeChanges && k.observeChanges(), k.instantiate();
  11739. }, instantiate: function instantiate() {
  11740. k.verbose("Storing instance of modal"), I = k, D.data(O, I);
  11741. }, create: { dimmer: function dimmer() {
  11742. var t = { debug: T.debug, variation: !T.centered && "top aligned", dimmerName: "modals" },
  11743. n = e.extend(!0, t, T.dimmerSettings);e.fn.dimmer !== i ? (k.debug("Creating dimmer"), y = q.dimmer(n), T.detachable ? (k.verbose("Modal is detachable, moving content into dimmer"), y.dimmer("add content", D)) : k.set.undetached(), x = y.dimmer("get dimmer")) : k.error(E.dimmer);
  11744. }, id: function id() {
  11745. w = (Math.random().toString(16) + "000000000").substr(2, 8), C = "." + w, k.verbose("Creating unique id for element", w);
  11746. } }, destroy: function destroy() {
  11747. k.verbose("Destroying previous modal"), D.removeData(O).off(F), s.off(C), x.off(C), j.off(F), q.dimmer("destroy");
  11748. }, observeChanges: function observeChanges() {
  11749. "MutationObserver" in t && ((S = new MutationObserver(function (e) {
  11750. k.debug("DOM tree modified, refreshing"), k.refresh();
  11751. })).observe(z, { childList: !0, subtree: !0 }), k.debug("Setting up mutation observer", S));
  11752. }, refresh: function refresh() {
  11753. k.remove.scrolling(), k.cacheSizes(), k.set.screenHeight(), k.set.type();
  11754. }, refreshModals: function refreshModals() {
  11755. v = D.siblings(A.modal), r = v.add(D);
  11756. }, attachEvents: function attachEvents(t, n) {
  11757. var i = e(t);n = e.isFunction(k[n]) ? k[n] : k.toggle, i.length > 0 ? (k.debug("Attaching modal events to element", t, n), i.off(F).on("click" + F, n)) : k.error(E.notFound, t);
  11758. }, bind: { events: function events() {
  11759. k.verbose("Attaching events"), D.on("click" + F, A.close, k.event.close).on("click" + F, A.approve, k.event.approve).on("click" + F, A.deny, k.event.deny), s.on("resize" + C, k.event.resize);
  11760. } }, get: { id: function id() {
  11761. return (Math.random().toString(16) + "000000000").substr(2, 8);
  11762. } }, event: { approve: function approve() {
  11763. M || !1 === T.onApprove.call(z, e(this)) ? k.verbose("Approve callback returned false cancelling hide") : (M = !0, k.hide(function () {
  11764. M = !1;
  11765. }));
  11766. }, deny: function deny() {
  11767. M || !1 === T.onDeny.call(z, e(this)) ? k.verbose("Deny callback returned false cancelling hide") : (M = !0, k.hide(function () {
  11768. M = !1;
  11769. }));
  11770. }, close: function close() {
  11771. k.hide();
  11772. }, click: function click(t) {
  11773. if (T.closable) {
  11774. var i = e(t.target).closest(A.modal).length > 0,
  11775. o = e.contains(n.documentElement, t.target);!i && o && k.is.active() && (k.debug("Dimmer clicked, hiding all modals"), k.remove.clickaway(), T.allowMultiple ? k.hide() : k.hideAll());
  11776. } else k.verbose("Dimmer clicked but closable setting is disabled");
  11777. }, debounce: function debounce(e, t) {
  11778. clearTimeout(k.timer), k.timer = setTimeout(e, t);
  11779. }, keyboard: function keyboard(e) {
  11780. 27 == e.which && (T.closable ? (k.debug("Escape key pressed hiding modal"), k.hide()) : k.debug("Escape key pressed, but closable is set to false"), e.preventDefault());
  11781. }, resize: function resize() {
  11782. y.dimmer("is active") && (k.is.animating() || k.is.active()) && h(k.refresh);
  11783. } }, toggle: function toggle() {
  11784. k.is.active() || k.is.animating() ? k.hide() : k.show();
  11785. }, show: function show(t) {
  11786. t = e.isFunction(t) ? t : function () {}, k.refreshModals(), k.set.dimmerSettings(), k.showModal(t);
  11787. }, hide: function hide(t) {
  11788. t = e.isFunction(t) ? t : function () {}, k.refreshModals(), k.hideModal(t);
  11789. }, showModal: function showModal(t) {
  11790. t = e.isFunction(t) ? t : function () {}, k.is.animating() || !k.is.active() ? (k.showDimmer(), k.cacheSizes(), k.set.screenHeight(), k.set.type(), k.set.clickaway(), !T.allowMultiple && k.others.active() ? k.hideOthers(k.showModal) : (T.allowMultiple && T.detachable && D.detach().appendTo(x), T.onShow.call(z), T.transition && e.fn.transition !== i && D.transition("is supported") ? (k.debug("Showing modal with css animations"), D.transition({ debug: T.debug, animation: T.transition + " in", queue: T.queue, duration: T.duration, useFailSafe: !0, onComplete: function onComplete() {
  11791. T.onVisible.apply(z), T.keyboardShortcuts && k.add.keyboardShortcuts(), k.save.focus(), k.set.active(), T.autofocus && k.set.autofocus(), t();
  11792. } })) : k.error(E.noTransition))) : k.debug("Modal is already visible");
  11793. }, hideModal: function hideModal(t, n) {
  11794. t = e.isFunction(t) ? t : function () {}, k.debug("Hiding modal"), !1 !== T.onHide.call(z, e(this)) ? (k.is.animating() || k.is.active()) && (T.transition && e.fn.transition !== i && D.transition("is supported") ? (k.remove.active(), D.transition({ debug: T.debug, animation: T.transition + " out", queue: T.queue, duration: T.duration, useFailSafe: !0, onStart: function onStart() {
  11795. k.others.active() || n || k.hideDimmer(), T.keyboardShortcuts && k.remove.keyboardShortcuts();
  11796. }, onComplete: function onComplete() {
  11797. T.onHidden.call(z), k.restore.focus(), t();
  11798. } })) : k.error(E.noTransition)) : k.verbose("Hide callback returned false cancelling hide");
  11799. }, showDimmer: function showDimmer() {
  11800. y.dimmer("is animating") || !y.dimmer("is active") ? (k.debug("Showing dimmer"), y.dimmer("show")) : k.debug("Dimmer already visible");
  11801. }, hideDimmer: function hideDimmer() {
  11802. y.dimmer("is animating") || y.dimmer("is active") ? y.dimmer("hide", function () {
  11803. k.remove.clickaway(), k.remove.screenHeight();
  11804. }) : k.debug("Dimmer is not visible cannot hide");
  11805. }, hideAll: function hideAll(t) {
  11806. var n = r.filter("." + R.active + ", ." + R.animating);t = e.isFunction(t) ? t : function () {}, n.length > 0 && (k.debug("Hiding all visible modals"), k.hideDimmer(), n.modal("hide modal", t));
  11807. }, hideOthers: function hideOthers(t) {
  11808. var n = v.filter("." + R.active + ", ." + R.animating);t = e.isFunction(t) ? t : function () {}, n.length > 0 && (k.debug("Hiding other modals", v), n.modal("hide modal", t, !0));
  11809. }, others: { active: function active() {
  11810. return v.filter("." + R.active).length > 0;
  11811. }, animating: function animating() {
  11812. return v.filter("." + R.animating).length > 0;
  11813. } }, add: { keyboardShortcuts: function keyboardShortcuts() {
  11814. k.verbose("Adding keyboard shortcuts"), l.on("keyup" + F, k.event.keyboard);
  11815. } }, save: { focus: function focus() {
  11816. e(n.activeElement).closest(D).length > 0 || (b = e(n.activeElement).blur());
  11817. } }, restore: { focus: function focus() {
  11818. b && b.length > 0 && b.focus();
  11819. } }, remove: { active: function active() {
  11820. D.removeClass(R.active);
  11821. }, clickaway: function clickaway() {
  11822. x.off("click" + C);
  11823. }, bodyStyle: function bodyStyle() {
  11824. "" === c.attr("style") && (k.verbose("Removing style attribute"), c.removeAttr("style"));
  11825. }, screenHeight: function screenHeight() {
  11826. k.debug("Removing page height"), c.css("height", "");
  11827. }, keyboardShortcuts: function keyboardShortcuts() {
  11828. k.verbose("Removing keyboard shortcuts"), l.off("keyup" + F);
  11829. }, scrolling: function scrolling() {
  11830. y.removeClass(R.scrolling), D.removeClass(R.scrolling);
  11831. } }, cacheSizes: function cacheSizes() {
  11832. D.addClass(R.loading);var o = D.prop("scrollHeight"),
  11833. a = D.outerHeight();k.cache !== i && 0 === a || (k.cache = { pageHeight: e(n).outerHeight(), height: a + T.offset, scrollHeight: o + T.offset, contextHeight: "body" == T.context ? e(t).height() : y.height() }, k.cache.topOffset = -k.cache.height / 2), D.removeClass(R.loading), k.debug("Caching modal and container sizes", k.cache);
  11834. }, can: { fit: function fit() {
  11835. var e = k.cache.contextHeight,
  11836. t = k.cache.contextHeight / 2,
  11837. n = k.cache.topOffset,
  11838. i = k.cache.scrollHeight,
  11839. o = k.cache.height,
  11840. a = T.padding;return i > o ? t + n + i + a < e : o + 2 * a < e;
  11841. } }, is: { active: function active() {
  11842. return D.hasClass(R.active);
  11843. }, animating: function animating() {
  11844. return D.transition("is supported") ? D.transition("is animating") : D.is(":visible");
  11845. }, scrolling: function scrolling() {
  11846. return y.hasClass(R.scrolling);
  11847. }, modernBrowser: function modernBrowser() {
  11848. return !(t.ActiveXObject || "ActiveXObject" in t);
  11849. } }, set: { autofocus: function autofocus() {
  11850. var e = D.find("[tabindex], :input").filter(":visible"),
  11851. t = e.filter("[autofocus]"),
  11852. n = t.length > 0 ? t.first() : e.first();n.length > 0 && n.focus();
  11853. }, clickaway: function clickaway() {
  11854. x.on("click" + C, k.event.click);
  11855. }, dimmerSettings: function dimmerSettings() {
  11856. if (e.fn.dimmer !== i) {
  11857. var t = { debug: T.debug, dimmerName: "modals", closable: "auto", variation: !T.centered && "top aligned", duration: { show: T.duration, hide: T.duration } },
  11858. n = e.extend(!0, t, T.dimmerSettings);T.inverted ? (n.variation = n.variation !== i ? n.variation + " inverted" : "inverted", x.addClass(R.inverted)) : x.removeClass(R.inverted), T.blurring ? y.addClass(R.blurring) : y.removeClass(R.blurring), q.dimmer("setting", n);
  11859. } else k.error(E.dimmer);
  11860. }, screenHeight: function screenHeight() {
  11861. k.can.fit() ? c.css("height", "") : (k.debug("Modal is taller than page content, resizing page height"), c.css("height", k.cache.height + 2 * T.padding));
  11862. }, active: function active() {
  11863. D.addClass(R.active);
  11864. }, scrolling: function scrolling() {
  11865. y.addClass(R.scrolling), D.addClass(R.scrolling);
  11866. }, type: function type() {
  11867. k.can.fit() ? (k.verbose("Modal fits on screen"), k.others.active() || k.others.animating() || k.remove.scrolling()) : (k.verbose("Modal cannot fit on screen setting to scrolling"), k.set.scrolling());
  11868. }, undetached: function undetached() {
  11869. y.addClass(R.undetached);
  11870. } }, setting: function setting(t, n) {
  11871. if (k.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, T, t);else {
  11872. if (n === i) return T[t];e.isPlainObject(T[t]) ? e.extend(!0, T[t], n) : T[t] = n;
  11873. }
  11874. }, internal: function internal(t, n) {
  11875. if (e.isPlainObject(t)) e.extend(!0, k, t);else {
  11876. if (n === i) return k[t];k[t] = n;
  11877. }
  11878. }, debug: function debug() {
  11879. !T.silent && T.debug && (T.performance ? k.performance.log(arguments) : (k.debug = Function.prototype.bind.call(console.info, console, T.name + ":"), k.debug.apply(console, arguments)));
  11880. }, verbose: function verbose() {
  11881. !T.silent && T.verbose && T.debug && (T.performance ? k.performance.log(arguments) : (k.verbose = Function.prototype.bind.call(console.info, console, T.name + ":"), k.verbose.apply(console, arguments)));
  11882. }, error: function error() {
  11883. T.silent || (k.error = Function.prototype.bind.call(console.error, console, T.name + ":"), k.error.apply(console, arguments));
  11884. }, performance: { log: function log(e) {
  11885. var t, n;T.performance && (n = (t = new Date().getTime()) - (d || t), d = t, f.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: z, "Execution Time": n })), clearTimeout(k.performance.timer), k.performance.timer = setTimeout(k.performance.display, 500);
  11886. }, display: function display() {
  11887. var t = T.name + ":",
  11888. n = 0;d = !1, clearTimeout(k.performance.timer), e.each(f, function (e, t) {
  11889. n += t["Execution Time"];
  11890. }), t += " " + n + "ms", u && (t += " '" + u + "'"), (console.group !== i || console.table !== i) && f.length > 0 && (console.groupCollapsed(t), console.table ? console.table(f) : e.each(f, function (e, t) {
  11891. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  11892. }), console.groupEnd()), f = [];
  11893. } }, invoke: function invoke(t, n, o) {
  11894. var r,
  11895. s,
  11896. l,
  11897. c = I;return n = n || p, o = z || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  11898. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  11899. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  11900. }
  11901. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  11902. } }, g ? (I === i && k.initialize(), k.invoke(m)) : (I !== i && I.invoke("destroy"), k.initialize());
  11903. }), a !== i ? a : this;
  11904. }, e.fn.modal.settings = { name: "Modal", namespace: "modal", silent: !1, debug: !1, verbose: !1, performance: !0, observeChanges: !1, allowMultiple: !1, detachable: !0, closable: !0, autofocus: !0, inverted: !1, blurring: !1, centered: !0, dimmerSettings: { closable: !1, useCSS: !0 }, keyboardShortcuts: !0, context: "body", queue: !1, duration: 500, offset: 0, transition: "scale", padding: 50, onShow: function onShow() {}, onVisible: function onVisible() {}, onHide: function onHide() {
  11905. return !0;
  11906. }, onHidden: function onHidden() {}, onApprove: function onApprove() {
  11907. return !0;
  11908. }, onDeny: function onDeny() {
  11909. return !0;
  11910. }, selector: { close: "> .close", approve: ".actions .positive, .actions .approve, .actions .ok", deny: ".actions .negative, .actions .deny, .actions .cancel", modal: ".ui.modal" }, error: { dimmer: "UI Dimmer, a required component is not included in this page", method: "The method you called is not defined.", notFound: "The element you specified could not be found" }, className: { active: "active", animating: "animating", blurring: "blurring", inverted: "inverted", loading: "loading", scrolling: "scrolling", undetached: "undetached" } };
  11911. }(jQuery, window, document), function (e, t, n, i) {
  11912. "use strict";
  11913. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.nag = function (n) {
  11914. var o,
  11915. a = e(this),
  11916. r = a.selector || "",
  11917. s = new Date().getTime(),
  11918. l = [],
  11919. c = arguments[0],
  11920. u = "string" == typeof c,
  11921. d = [].slice.call(arguments, 1);return a.each(function () {
  11922. var a,
  11923. f = e.isPlainObject(n) ? e.extend(!0, {}, e.fn.nag.settings, n) : e.extend({}, e.fn.nag.settings),
  11924. m = (f.className, f.selector),
  11925. g = f.error,
  11926. p = f.namespace,
  11927. h = "." + p,
  11928. v = p + "-module",
  11929. b = e(this),
  11930. y = (b.find(m.close), f.context ? e(f.context) : e("body")),
  11931. x = this,
  11932. C = b.data(v);t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame;a = { initialize: function initialize() {
  11933. a.verbose("Initializing element"), b.on("click" + h, m.close, a.dismiss).data(v, a), f.detachable && b.parent()[0] !== y[0] && b.detach().prependTo(y), f.displayTime > 0 && setTimeout(a.hide, f.displayTime), a.show();
  11934. }, destroy: function destroy() {
  11935. a.verbose("Destroying instance"), b.removeData(v).off(h);
  11936. }, show: function show() {
  11937. a.should.show() && !b.is(":visible") && (a.debug("Showing nag", f.animation.show), "fade" == f.animation.show ? b.fadeIn(f.duration, f.easing) : b.slideDown(f.duration, f.easing));
  11938. }, hide: function hide() {
  11939. a.debug("Showing nag", f.animation.hide), "fade" == f.animation.show ? b.fadeIn(f.duration, f.easing) : b.slideUp(f.duration, f.easing);
  11940. }, onHide: function onHide() {
  11941. a.debug("Removing nag", f.animation.hide), b.remove(), f.onHide && f.onHide();
  11942. }, dismiss: function dismiss(e) {
  11943. f.storageMethod && a.storage.set(f.key, f.value), a.hide(), e.stopImmediatePropagation(), e.preventDefault();
  11944. }, should: { show: function show() {
  11945. return f.persist ? (a.debug("Persistent nag is set, can show nag"), !0) : a.storage.get(f.key) != f.value.toString() ? (a.debug("Stored value is not set, can show nag", a.storage.get(f.key)), !0) : (a.debug("Stored value is set, cannot show nag", a.storage.get(f.key)), !1);
  11946. } }, get: { storageOptions: function storageOptions() {
  11947. var e = {};return f.expires && (e.expires = f.expires), f.domain && (e.domain = f.domain), f.path && (e.path = f.path), e;
  11948. } }, clear: function clear() {
  11949. a.storage.remove(f.key);
  11950. }, storage: { set: function set(n, o) {
  11951. var r = a.get.storageOptions();if ("localstorage" == f.storageMethod && t.localStorage !== i) t.localStorage.setItem(n, o), a.debug("Value stored using local storage", n, o);else if ("sessionstorage" == f.storageMethod && t.sessionStorage !== i) t.sessionStorage.setItem(n, o), a.debug("Value stored using session storage", n, o);else {
  11952. if (e.cookie === i) return void a.error(g.noCookieStorage);e.cookie(n, o, r), a.debug("Value stored using cookie", n, o, r);
  11953. }
  11954. }, get: function get(n, o) {
  11955. var r;return "localstorage" == f.storageMethod && t.localStorage !== i ? r = t.localStorage.getItem(n) : "sessionstorage" == f.storageMethod && t.sessionStorage !== i ? r = t.sessionStorage.getItem(n) : e.cookie !== i ? r = e.cookie(n) : a.error(g.noCookieStorage), "undefined" != r && "null" != r && r !== i && null !== r || (r = i), r;
  11956. }, remove: function remove(n) {
  11957. var o = a.get.storageOptions();"localstorage" == f.storageMethod && t.localStorage !== i ? t.localStorage.removeItem(n) : "sessionstorage" == f.storageMethod && t.sessionStorage !== i ? t.sessionStorage.removeItem(n) : e.cookie !== i ? e.removeCookie(n, o) : a.error(g.noStorage);
  11958. } }, setting: function setting(t, n) {
  11959. if (a.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, f, t);else {
  11960. if (n === i) return f[t];e.isPlainObject(f[t]) ? e.extend(!0, f[t], n) : f[t] = n;
  11961. }
  11962. }, internal: function internal(t, n) {
  11963. if (e.isPlainObject(t)) e.extend(!0, a, t);else {
  11964. if (n === i) return a[t];a[t] = n;
  11965. }
  11966. }, debug: function debug() {
  11967. !f.silent && f.debug && (f.performance ? a.performance.log(arguments) : (a.debug = Function.prototype.bind.call(console.info, console, f.name + ":"), a.debug.apply(console, arguments)));
  11968. }, verbose: function verbose() {
  11969. !f.silent && f.verbose && f.debug && (f.performance ? a.performance.log(arguments) : (a.verbose = Function.prototype.bind.call(console.info, console, f.name + ":"), a.verbose.apply(console, arguments)));
  11970. }, error: function error() {
  11971. f.silent || (a.error = Function.prototype.bind.call(console.error, console, f.name + ":"), a.error.apply(console, arguments));
  11972. }, performance: { log: function log(e) {
  11973. var t, n;f.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: x, "Execution Time": n })), clearTimeout(a.performance.timer), a.performance.timer = setTimeout(a.performance.display, 500);
  11974. }, display: function display() {
  11975. var t = f.name + ":",
  11976. n = 0;s = !1, clearTimeout(a.performance.timer), e.each(l, function (e, t) {
  11977. n += t["Execution Time"];
  11978. }), t += " " + n + "ms", r && (t += " '" + r + "'"), (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  11979. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  11980. }), console.groupEnd()), l = [];
  11981. } }, invoke: function invoke(t, n, r) {
  11982. var s,
  11983. l,
  11984. c,
  11985. u = C;return n = n || d, r = x || r, "string" == typeof t && u !== i && (t = t.split(/[\. ]/), s = t.length - 1, e.each(t, function (n, o) {
  11986. var r = n != s ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(u[r]) && n != s) u = u[r];else {
  11987. if (u[r] !== i) return l = u[r], !1;if (!e.isPlainObject(u[o]) || n == s) return u[o] !== i ? (l = u[o], !1) : (a.error(g.method, t), !1);u = u[o];
  11988. }
  11989. })), e.isFunction(l) ? c = l.apply(r, n) : l !== i && (c = l), e.isArray(o) ? o.push(c) : o !== i ? o = [o, c] : c !== i && (o = c), l;
  11990. } }, u ? (C === i && a.initialize(), a.invoke(c)) : (C !== i && C.invoke("destroy"), a.initialize());
  11991. }), o !== i ? o : this;
  11992. }, e.fn.nag.settings = { name: "Nag", silent: !1, debug: !1, verbose: !1, performance: !0, namespace: "Nag", persist: !1, displayTime: 0, animation: { show: "slide", hide: "slide" }, context: !1, detachable: !1, expires: 30, domain: !1, path: "/", storageMethod: "cookie", key: "nag", value: "dismiss", error: { noCookieStorage: "$.cookie is not included. A storage solution is required.", noStorage: "Neither $.cookie or store is defined. A storage solution is required for storing state", method: "The method you called is not defined." }, className: { bottom: "bottom", fixed: "fixed" }, selector: { close: ".close.icon" }, speed: 500, easing: "easeOutQuad", onHide: function onHide() {} }, e.extend(e.easing, { easeOutQuad: function easeOutQuad(e, t, n, i, o) {
  11993. return -i * (t /= o) * (t - 2) + n;
  11994. } });
  11995. }(jQuery, window, document), function (e, t, n, i) {
  11996. "use strict";
  11997. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.popup = function (o) {
  11998. var a,
  11999. r = e(this),
  12000. s = e(n),
  12001. l = e(t),
  12002. c = e("body"),
  12003. u = r.selector || "",
  12004. d = new Date().getTime(),
  12005. f = [],
  12006. m = arguments[0],
  12007. g = "string" == typeof m,
  12008. p = [].slice.call(arguments, 1);return r.each(function () {
  12009. var r,
  12010. h,
  12011. v,
  12012. b,
  12013. y,
  12014. x,
  12015. C = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.popup.settings, o) : e.extend({}, e.fn.popup.settings),
  12016. w = C.selector,
  12017. S = C.className,
  12018. k = C.error,
  12019. T = C.metadata,
  12020. A = C.namespace,
  12021. R = "." + C.namespace,
  12022. P = "module-" + A,
  12023. E = e(this),
  12024. F = e(C.context),
  12025. O = e(C.scrollContext),
  12026. D = e(C.boundary),
  12027. q = C.target ? e(C.target) : E,
  12028. j = 0,
  12029. z = !1,
  12030. I = !1,
  12031. M = this,
  12032. L = E.data(P);x = { initialize: function initialize() {
  12033. x.debug("Initializing", E), x.createID(), x.bind.events(), !x.exists() && C.preserve && x.create(), C.observeChanges && x.observeChanges(), x.instantiate();
  12034. }, instantiate: function instantiate() {
  12035. x.verbose("Storing instance", x), L = x, E.data(P, L);
  12036. }, observeChanges: function observeChanges() {
  12037. "MutationObserver" in t && ((v = new MutationObserver(x.event.documentChanged)).observe(n, { childList: !0, subtree: !0 }), x.debug("Setting up mutation observer", v));
  12038. }, refresh: function refresh() {
  12039. C.popup ? r = e(C.popup).eq(0) : C.inline && (r = q.nextAll(w.popup).eq(0), C.popup = r), C.popup ? (r.addClass(S.loading), h = x.get.offsetParent(), r.removeClass(S.loading), C.movePopup && x.has.popup() && x.get.offsetParent(r)[0] !== h[0] && (x.debug("Moving popup to the same offset parent as target"), r.detach().appendTo(h))) : h = C.inline ? x.get.offsetParent(q) : x.has.popup() ? x.get.offsetParent(r) : c, h.is("html") && h[0] !== c[0] && (x.debug("Setting page as offset parent"), h = c), x.get.variation() && x.set.variation();
  12040. }, reposition: function reposition() {
  12041. x.refresh(), x.set.position();
  12042. }, destroy: function destroy() {
  12043. x.debug("Destroying previous module"), v && v.disconnect(), r && !C.preserve && x.removePopup(), clearTimeout(x.hideTimer), clearTimeout(x.showTimer), x.unbind.close(), x.unbind.events(), E.removeData(P);
  12044. }, event: { start: function start(t) {
  12045. var n = e.isPlainObject(C.delay) ? C.delay.show : C.delay;clearTimeout(x.hideTimer), I || (x.showTimer = setTimeout(x.show, n));
  12046. }, end: function end() {
  12047. var t = e.isPlainObject(C.delay) ? C.delay.hide : C.delay;clearTimeout(x.showTimer), x.hideTimer = setTimeout(x.hide, t);
  12048. }, touchstart: function touchstart(e) {
  12049. I = !0, x.show();
  12050. }, resize: function resize() {
  12051. x.is.visible() && x.set.position();
  12052. }, documentChanged: function documentChanged(t) {
  12053. [].forEach.call(t, function (t) {
  12054. t.removedNodes && [].forEach.call(t.removedNodes, function (t) {
  12055. (t == M || e(t).find(M).length > 0) && (x.debug("Element removed from DOM, tearing down events"), x.destroy());
  12056. });
  12057. });
  12058. }, hideGracefully: function hideGracefully(t) {
  12059. var i = e(t.target),
  12060. o = e.contains(n.documentElement, t.target),
  12061. a = i.closest(w.popup).length > 0;t && !a && o ? (x.debug("Click occurred outside popup hiding popup"), x.hide()) : x.debug("Click was inside popup, keeping popup open");
  12062. } }, create: function create() {
  12063. var t = x.get.html(),
  12064. n = x.get.title(),
  12065. i = x.get.content();t || i || n ? (x.debug("Creating pop-up html"), t || (t = C.templates.popup({ title: n, content: i })), r = e("<div/>").addClass(S.popup).data(T.activator, E).html(t), C.inline ? (x.verbose("Inserting popup element inline", r), r.insertAfter(E)) : (x.verbose("Appending popup element to body", r), r.appendTo(F)), x.refresh(), x.set.variation(), C.hoverable && x.bind.popup(), C.onCreate.call(r, M)) : 0 !== q.next(w.popup).length ? (x.verbose("Pre-existing popup found"), C.inline = !0, C.popup = q.next(w.popup).data(T.activator, E), x.refresh(), C.hoverable && x.bind.popup()) : C.popup ? (e(C.popup).data(T.activator, E), x.verbose("Used popup specified in settings"), x.refresh(), C.hoverable && x.bind.popup()) : x.debug("No content specified skipping display", M);
  12066. }, createID: function createID() {
  12067. y = (Math.random().toString(16) + "000000000").substr(2, 8), b = "." + y, x.verbose("Creating unique id for element", y);
  12068. }, toggle: function toggle() {
  12069. x.debug("Toggling pop-up"), x.is.hidden() ? (x.debug("Popup is hidden, showing pop-up"), x.unbind.close(), x.show()) : (x.debug("Popup is visible, hiding pop-up"), x.hide());
  12070. }, show: function show(e) {
  12071. if (e = e || function () {}, x.debug("Showing pop-up", C.transition), x.is.hidden() && (!x.is.active() || !x.is.dropdown())) {
  12072. if (x.exists() || x.create(), !1 === C.onShow.call(r, M)) return void x.debug("onShow callback returned false, cancelling popup animation");C.preserve || C.popup || x.refresh(), r && x.set.position() && (x.save.conditions(), C.exclusive && x.hideAll(), x.animate.show(e));
  12073. }
  12074. }, hide: function hide(e) {
  12075. if (e = e || function () {}, x.is.visible() || x.is.animating()) {
  12076. if (!1 === C.onHide.call(r, M)) return void x.debug("onHide callback returned false, cancelling popup animation");x.remove.visible(), x.unbind.close(), x.restore.conditions(), x.animate.hide(e);
  12077. }
  12078. }, hideAll: function hideAll() {
  12079. e(w.popup).filter("." + S.popupVisible).each(function () {
  12080. e(this).data(T.activator).popup("hide");
  12081. });
  12082. }, exists: function exists() {
  12083. return !!r && (C.inline || C.popup ? x.has.popup() : r.closest(F).length >= 1);
  12084. }, removePopup: function removePopup() {
  12085. x.has.popup() && !C.popup && (x.debug("Removing popup", r), r.remove(), r = i, C.onRemove.call(r, M));
  12086. }, save: { conditions: function conditions() {
  12087. x.cache = { title: E.attr("title") }, x.cache.title && E.removeAttr("title"), x.verbose("Saving original attributes", x.cache.title);
  12088. } }, restore: { conditions: function conditions() {
  12089. return x.cache && x.cache.title && (E.attr("title", x.cache.title), x.verbose("Restoring original attributes", x.cache.title)), !0;
  12090. } }, supports: { svg: function svg() {
  12091. return "undefined" == typeof SVGGraphicsElement;
  12092. } }, animate: { show: function show(t) {
  12093. t = e.isFunction(t) ? t : function () {}, C.transition && e.fn.transition !== i && E.transition("is supported") ? (x.set.visible(), r.transition({ animation: C.transition + " in", queue: !1, debug: C.debug, verbose: C.verbose, duration: C.duration, onComplete: function onComplete() {
  12094. x.bind.close(), t.call(r, M), C.onVisible.call(r, M);
  12095. } })) : x.error(k.noTransition);
  12096. }, hide: function hide(t) {
  12097. t = e.isFunction(t) ? t : function () {}, x.debug("Hiding pop-up"), !1 !== C.onHide.call(r, M) ? C.transition && e.fn.transition !== i && E.transition("is supported") ? r.transition({ animation: C.transition + " out", queue: !1, duration: C.duration, debug: C.debug, verbose: C.verbose, onComplete: function onComplete() {
  12098. x.reset(), t.call(r, M), C.onHidden.call(r, M);
  12099. } }) : x.error(k.noTransition) : x.debug("onHide callback returned false, cancelling popup animation");
  12100. } }, change: { content: function content(e) {
  12101. r.html(e);
  12102. } }, get: { html: function html() {
  12103. return E.removeData(T.html), E.data(T.html) || C.html;
  12104. }, title: function title() {
  12105. return E.removeData(T.title), E.data(T.title) || C.title;
  12106. }, content: function content() {
  12107. return E.removeData(T.content), E.data(T.content) || C.content || E.attr("title");
  12108. }, variation: function variation() {
  12109. return E.removeData(T.variation), E.data(T.variation) || C.variation;
  12110. }, popup: function popup() {
  12111. return r;
  12112. }, popupOffset: function popupOffset() {
  12113. return r.offset();
  12114. }, calculations: function calculations() {
  12115. var e,
  12116. n = x.get.offsetParent(r),
  12117. i = q[0],
  12118. o = D[0] == t,
  12119. a = C.inline || C.popup && C.movePopup ? q.position() : q.offset(),
  12120. s = o ? { top: 0, left: 0 } : D.offset(),
  12121. c = {},
  12122. u = o ? { top: l.scrollTop(), left: l.scrollLeft() } : { top: 0, left: 0 };if (c = { target: { element: q[0], width: q.outerWidth(), height: q.outerHeight(), top: a.top, left: a.left, margin: {} }, popup: { width: r.outerWidth(), height: r.outerHeight() }, parent: { width: h.outerWidth(), height: h.outerHeight() }, screen: { top: s.top, left: s.left, scroll: { top: u.top, left: u.left }, width: D.width(), height: D.height() } }, n.get(0) !== h.get(0)) {
  12123. var d = n.offset();c.target.top -= d.top, c.target.left -= d.left, c.parent.width = n.outerWidth(), c.parent.height = n.outerHeight();
  12124. }return C.setFluidWidth && x.is.fluid() && (c.container = { width: r.parent().outerWidth() }, c.popup.width = c.container.width), c.target.margin.top = C.inline ? parseInt(t.getComputedStyle(i).getPropertyValue("margin-top"), 10) : 0, c.target.margin.left = C.inline ? x.is.rtl() ? parseInt(t.getComputedStyle(i).getPropertyValue("margin-right"), 10) : parseInt(t.getComputedStyle(i).getPropertyValue("margin-left"), 10) : 0, e = c.screen, c.boundary = { top: e.top + e.scroll.top, bottom: e.top + e.scroll.top + e.height, left: e.left + e.scroll.left, right: e.left + e.scroll.left + e.width }, c;
  12125. }, id: function id() {
  12126. return y;
  12127. }, startEvent: function startEvent() {
  12128. return "hover" == C.on ? "mouseenter" : "focus" == C.on && "focus";
  12129. }, scrollEvent: function scrollEvent() {
  12130. return "scroll";
  12131. }, endEvent: function endEvent() {
  12132. return "hover" == C.on ? "mouseleave" : "focus" == C.on && "blur";
  12133. }, distanceFromBoundary: function distanceFromBoundary(e, t) {
  12134. var n,
  12135. i,
  12136. o = {};return n = (t = t || x.get.calculations()).popup, i = t.boundary, e && (o = { top: e.top - i.top, left: e.left - i.left, right: i.right - (e.left + n.width), bottom: i.bottom - (e.top + n.height) }, x.verbose("Distance from boundaries determined", e, o)), o;
  12137. }, offsetParent: function offsetParent(t) {
  12138. var n = (t !== i ? t[0] : q[0]).parentNode,
  12139. o = e(n);if (n) for (var a = "none" === o.css("transform"), r = "static" === o.css("position"), s = o.is("body"); n && !s && r && a;) {
  12140. n = n.parentNode, a = "none" === (o = e(n)).css("transform"), r = "static" === o.css("position"), s = o.is("body");
  12141. }return o && o.length > 0 ? o : e();
  12142. }, positions: function positions() {
  12143. return { "top left": !1, "top center": !1, "top right": !1, "bottom left": !1, "bottom center": !1, "bottom right": !1, "left center": !1, "right center": !1 };
  12144. }, nextPosition: function nextPosition(e) {
  12145. var t = e.split(" "),
  12146. n = t[0],
  12147. i = t[1],
  12148. o = "top" == n || "bottom" == n,
  12149. a = !1,
  12150. r = !1,
  12151. s = !1;return z || (x.verbose("All available positions available"), z = x.get.positions()), x.debug("Recording last position tried", e), z[e] = !0, "opposite" === C.prefer && (s = (s = [{ top: "bottom", bottom: "top", left: "right", right: "left" }[n], i]).join(" "), a = !0 === z[s], x.debug("Trying opposite strategy", s)), "adjacent" === C.prefer && o && (s = (s = [n, { left: "center", center: "right", right: "left" }[i]]).join(" "), r = !0 === z[s], x.debug("Trying adjacent strategy", s)), (r || a) && (x.debug("Using backup position", s), s = { "top left": "top center", "top center": "top right", "top right": "right center", "right center": "bottom right", "bottom right": "bottom center", "bottom center": "bottom left", "bottom left": "left center", "left center": "top left" }[e]), s;
  12152. } }, set: { position: function position(e, t) {
  12153. if (0 !== q.length && 0 !== r.length) {
  12154. var n, o, a, s, l, c, u, d;if (t = t || x.get.calculations(), e = e || E.data(T.position) || C.position, n = E.data(T.offset) || C.offset, o = C.distanceAway, a = t.target, s = t.popup, l = t.parent, x.should.centerArrow(t) && (x.verbose("Adjusting offset to center arrow on small target element"), "top left" != e && "bottom left" != e || (n += a.width / 2, n -= C.arrowPixelsFromEdge), "top right" != e && "bottom right" != e || (n -= a.width / 2, n += C.arrowPixelsFromEdge)), 0 === a.width && 0 === a.height && !x.is.svg(a.element)) return x.debug("Popup target is hidden, no action taken"), !1;switch (C.inline && (x.debug("Adding margin to calculation", a.margin), "left center" == e || "right center" == e ? (n += a.margin.top, o += -a.margin.left) : "top left" == e || "top center" == e || "top right" == e ? (n += a.margin.left, o -= a.margin.top) : (n += a.margin.left, o += a.margin.top)), x.debug("Determining popup position from calculations", e, t), x.is.rtl() && (e = e.replace(/left|right/g, function (e) {
  12155. return "left" == e ? "right" : "left";
  12156. }), x.debug("RTL: Popup position updated", e)), j == C.maxSearchDepth && "string" == typeof C.lastResort && (e = C.lastResort), e) {case "top left":
  12157. c = { top: "auto", bottom: l.height - a.top + o, left: a.left + n, right: "auto" };break;case "top center":
  12158. c = { bottom: l.height - a.top + o, left: a.left + a.width / 2 - s.width / 2 + n, top: "auto", right: "auto" };break;case "top right":
  12159. c = { bottom: l.height - a.top + o, right: l.width - a.left - a.width - n, top: "auto", left: "auto" };break;case "left center":
  12160. c = { top: a.top + a.height / 2 - s.height / 2 + n, right: l.width - a.left + o, left: "auto", bottom: "auto" };break;case "right center":
  12161. c = { top: a.top + a.height / 2 - s.height / 2 + n, left: a.left + a.width + o, bottom: "auto", right: "auto" };break;case "bottom left":
  12162. c = { top: a.top + a.height + o, left: a.left + n, bottom: "auto", right: "auto" };break;case "bottom center":
  12163. c = { top: a.top + a.height + o, left: a.left + a.width / 2 - s.width / 2 + n, bottom: "auto", right: "auto" };break;case "bottom right":
  12164. c = { top: a.top + a.height + o, right: l.width - a.left - a.width - n, left: "auto", bottom: "auto" };}if (c === i && x.error(k.invalidPosition, e), x.debug("Calculated popup positioning values", c), r.css(c).removeClass(S.position).addClass(e).addClass(S.loading), u = x.get.popupOffset(), d = x.get.distanceFromBoundary(u, t), x.is.offstage(d, e)) {
  12165. if (x.debug("Position is outside viewport", e), j < C.maxSearchDepth) return j++, e = x.get.nextPosition(e), x.debug("Trying new position", e), !!r && x.set.position(e, t);if (!C.lastResort) return x.debug("Popup could not find a position to display", r), x.error(k.cannotPlace, M), x.remove.attempts(), x.remove.loading(), x.reset(), C.onUnplaceable.call(r, M), !1;x.debug("No position found, showing with last position");
  12166. }return x.debug("Position is on stage", e), x.remove.attempts(), x.remove.loading(), C.setFluidWidth && x.is.fluid() && x.set.fluidWidth(t), !0;
  12167. }x.error(k.notFound);
  12168. }, fluidWidth: function fluidWidth(e) {
  12169. e = e || x.get.calculations(), x.debug("Automatically setting element width to parent width", e.parent.width), r.css("width", e.container.width);
  12170. }, variation: function variation(e) {
  12171. (e = e || x.get.variation()) && x.has.popup() && (x.verbose("Adding variation to popup", e), r.addClass(e));
  12172. }, visible: function visible() {
  12173. E.addClass(S.visible);
  12174. } }, remove: { loading: function loading() {
  12175. r.removeClass(S.loading);
  12176. }, variation: function variation(e) {
  12177. (e = e || x.get.variation()) && (x.verbose("Removing variation", e), r.removeClass(e));
  12178. }, visible: function visible() {
  12179. E.removeClass(S.visible);
  12180. }, attempts: function attempts() {
  12181. x.verbose("Resetting all searched positions"), j = 0, z = !1;
  12182. } }, bind: { events: function events() {
  12183. x.debug("Binding popup events to module"), "click" == C.on && E.on("click" + R, x.toggle), "hover" == C.on && E.on("touchstart" + R, x.event.touchstart), x.get.startEvent() && E.on(x.get.startEvent() + R, x.event.start).on(x.get.endEvent() + R, x.event.end), C.target && x.debug("Target set to element", q), l.on("resize" + b, x.event.resize);
  12184. }, popup: function popup() {
  12185. x.verbose("Allowing hover events on popup to prevent closing"), r && x.has.popup() && r.on("mouseenter" + R, x.event.start).on("mouseleave" + R, x.event.end);
  12186. }, close: function close() {
  12187. (!0 === C.hideOnScroll || "auto" == C.hideOnScroll && "click" != C.on) && x.bind.closeOnScroll(), "hover" == C.on && I && x.bind.touchClose(), "click" == C.on && C.closable && x.bind.clickaway();
  12188. }, closeOnScroll: function closeOnScroll() {
  12189. x.verbose("Binding scroll close event to document"), O.one(x.get.scrollEvent() + b, x.event.hideGracefully);
  12190. }, touchClose: function touchClose() {
  12191. x.verbose("Binding popup touchclose event to document"), s.on("touchstart" + b, function (e) {
  12192. x.verbose("Touched away from popup"), x.event.hideGracefully.call(M, e);
  12193. });
  12194. }, clickaway: function clickaway() {
  12195. x.verbose("Binding popup close event to document"), s.on("click" + b, function (e) {
  12196. x.verbose("Clicked away from popup"), x.event.hideGracefully.call(M, e);
  12197. });
  12198. } }, unbind: { events: function events() {
  12199. l.off(b), E.off(R);
  12200. }, close: function close() {
  12201. s.off(b), O.off(b);
  12202. } }, has: { popup: function popup() {
  12203. return r && r.length > 0;
  12204. } }, should: { centerArrow: function centerArrow(e) {
  12205. return !x.is.basic() && e.target.width <= 2 * C.arrowPixelsFromEdge;
  12206. } }, is: { offstage: function offstage(t, n) {
  12207. var i = [];return e.each(t, function (e, t) {
  12208. t < -C.jitter && (x.debug("Position exceeds allowable distance from edge", e, t, n), i.push(e));
  12209. }), i.length > 0;
  12210. }, svg: function svg(e) {
  12211. return x.supports.svg() && e instanceof SVGGraphicsElement;
  12212. }, basic: function basic() {
  12213. return E.hasClass(S.basic);
  12214. }, active: function active() {
  12215. return E.hasClass(S.active);
  12216. }, animating: function animating() {
  12217. return r !== i && r.hasClass(S.animating);
  12218. }, fluid: function fluid() {
  12219. return r !== i && r.hasClass(S.fluid);
  12220. }, visible: function visible() {
  12221. return r !== i && r.hasClass(S.popupVisible);
  12222. }, dropdown: function dropdown() {
  12223. return E.hasClass(S.dropdown);
  12224. }, hidden: function hidden() {
  12225. return !x.is.visible();
  12226. }, rtl: function rtl() {
  12227. return "rtl" == E.css("direction");
  12228. } }, reset: function reset() {
  12229. x.remove.visible(), C.preserve ? e.fn.transition !== i && r.transition("remove transition") : x.removePopup();
  12230. }, setting: function setting(t, n) {
  12231. if (e.isPlainObject(t)) e.extend(!0, C, t);else {
  12232. if (n === i) return C[t];C[t] = n;
  12233. }
  12234. }, internal: function internal(t, n) {
  12235. if (e.isPlainObject(t)) e.extend(!0, x, t);else {
  12236. if (n === i) return x[t];x[t] = n;
  12237. }
  12238. }, debug: function debug() {
  12239. !C.silent && C.debug && (C.performance ? x.performance.log(arguments) : (x.debug = Function.prototype.bind.call(console.info, console, C.name + ":"), x.debug.apply(console, arguments)));
  12240. }, verbose: function verbose() {
  12241. !C.silent && C.verbose && C.debug && (C.performance ? x.performance.log(arguments) : (x.verbose = Function.prototype.bind.call(console.info, console, C.name + ":"), x.verbose.apply(console, arguments)));
  12242. }, error: function error() {
  12243. C.silent || (x.error = Function.prototype.bind.call(console.error, console, C.name + ":"), x.error.apply(console, arguments));
  12244. }, performance: { log: function log(e) {
  12245. var t, n;C.performance && (n = (t = new Date().getTime()) - (d || t), d = t, f.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: M, "Execution Time": n })), clearTimeout(x.performance.timer), x.performance.timer = setTimeout(x.performance.display, 500);
  12246. }, display: function display() {
  12247. var t = C.name + ":",
  12248. n = 0;d = !1, clearTimeout(x.performance.timer), e.each(f, function (e, t) {
  12249. n += t["Execution Time"];
  12250. }), t += " " + n + "ms", u && (t += " '" + u + "'"), (console.group !== i || console.table !== i) && f.length > 0 && (console.groupCollapsed(t), console.table ? console.table(f) : e.each(f, function (e, t) {
  12251. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  12252. }), console.groupEnd()), f = [];
  12253. } }, invoke: function invoke(t, n, o) {
  12254. var r,
  12255. s,
  12256. l,
  12257. c = L;return n = n || p, o = M || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  12258. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  12259. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  12260. }
  12261. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  12262. } }, g ? (L === i && x.initialize(), x.invoke(m)) : (L !== i && L.invoke("destroy"), x.initialize());
  12263. }), a !== i ? a : this;
  12264. }, e.fn.popup.settings = { name: "Popup", silent: !1, debug: !1, verbose: !1, performance: !0, namespace: "popup", observeChanges: !0, onCreate: function onCreate() {}, onRemove: function onRemove() {}, onShow: function onShow() {}, onVisible: function onVisible() {}, onHide: function onHide() {}, onUnplaceable: function onUnplaceable() {}, onHidden: function onHidden() {}, on: "hover", boundary: t, addTouchEvents: !0, position: "top left", variation: "", movePopup: !0, target: !1, popup: !1, inline: !1, preserve: !1, hoverable: !1, content: !1, html: !1, title: !1, closable: !0, hideOnScroll: "auto", exclusive: !1, context: "body", scrollContext: t, prefer: "opposite", lastResort: !1, arrowPixelsFromEdge: 20, delay: { show: 50, hide: 70 }, setFluidWidth: !0, duration: 200, transition: "scale", distanceAway: 0, jitter: 2, offset: 0, maxSearchDepth: 15, error: { invalidPosition: "The position you specified is not a valid position", cannotPlace: "Popup does not fit within the boundaries of the viewport", method: "The method you called is not defined.", noTransition: "This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>", notFound: "The target or popup you specified does not exist on the page" }, metadata: { activator: "activator", content: "content", html: "html", offset: "offset", position: "position", title: "title", variation: "variation" }, className: { active: "active", basic: "basic", animating: "animating", dropdown: "dropdown", fluid: "fluid", loading: "loading", popup: "ui popup", position: "top left center bottom right", visible: "visible", popupVisible: "visible" }, selector: { popup: ".ui.popup" }, templates: { escape: function escape(e) {
  12265. var t = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#x27;", "`": "&#x60;" };return (/[&<>"'`]/.test(e) ? e.replace(/[&<>"'`]/g, function (e) {
  12266. return t[e];
  12267. }) : e
  12268. );
  12269. }, popup: function popup(t) {
  12270. var n = "",
  12271. o = e.fn.popup.settings.templates.escape;return (typeof t === "undefined" ? "undefined" : _typeof(t)) !== i && (_typeof(t.title) !== i && t.title && (t.title = o(t.title), n += '<div class="header">' + t.title + "</div>"), _typeof(t.content) !== i && t.content && (t.content = o(t.content), n += '<div class="content">' + t.content + "</div>")), n;
  12272. } } };
  12273. }(jQuery, window, document), function (e, t, n, i) {
  12274. "use strict";
  12275. void 0 !== (t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")()) && t.Math == Math || ("undefined" != typeof self && self.Math == Math ? self : Function("return this")());e.fn.progress = function (t) {
  12276. var o,
  12277. a = e(this),
  12278. r = a.selector || "",
  12279. s = new Date().getTime(),
  12280. l = [],
  12281. c = arguments[0],
  12282. u = "string" == typeof c,
  12283. d = [].slice.call(arguments, 1);return a.each(function () {
  12284. var a,
  12285. f = e.isPlainObject(t) ? e.extend(!0, {}, e.fn.progress.settings, t) : e.extend({}, e.fn.progress.settings),
  12286. m = f.className,
  12287. g = f.metadata,
  12288. p = f.namespace,
  12289. h = f.selector,
  12290. v = f.error,
  12291. b = "." + p,
  12292. y = "module-" + p,
  12293. x = e(this),
  12294. C = e(this).find(h.bar),
  12295. w = e(this).find(h.progress),
  12296. S = e(this).find(h.label),
  12297. k = this,
  12298. T = x.data(y),
  12299. A = !1;a = { initialize: function initialize() {
  12300. a.debug("Initializing progress bar", f), a.set.duration(), a.set.transitionEvent(), a.read.metadata(), a.read.settings(), a.instantiate();
  12301. }, instantiate: function instantiate() {
  12302. a.verbose("Storing instance of progress", a), T = a, x.data(y, a);
  12303. }, destroy: function destroy() {
  12304. a.verbose("Destroying previous progress for", x), clearInterval(T.interval), a.remove.state(), x.removeData(y), T = i;
  12305. }, reset: function reset() {
  12306. a.remove.nextValue(), a.update.progress(0);
  12307. }, complete: function complete() {
  12308. (a.percent === i || a.percent < 100) && (a.remove.progressPoll(), a.set.percent(100));
  12309. }, read: { metadata: function metadata() {
  12310. var e = { percent: x.data(g.percent), total: x.data(g.total), value: x.data(g.value) };e.percent && (a.debug("Current percent value set from metadata", e.percent), a.set.percent(e.percent)), e.total && (a.debug("Total value set from metadata", e.total), a.set.total(e.total)), e.value && (a.debug("Current value set from metadata", e.value), a.set.value(e.value), a.set.progress(e.value));
  12311. }, settings: function settings() {
  12312. !1 !== f.total && (a.debug("Current total set in settings", f.total), a.set.total(f.total)), !1 !== f.value && (a.debug("Current value set in settings", f.value), a.set.value(f.value), a.set.progress(a.value)), !1 !== f.percent && (a.debug("Current percent set in settings", f.percent), a.set.percent(f.percent));
  12313. } }, bind: { transitionEnd: function transitionEnd(e) {
  12314. var t = a.get.transitionEnd();C.one(t + b, function (t) {
  12315. clearTimeout(a.failSafeTimer), e.call(this, t);
  12316. }), a.failSafeTimer = setTimeout(function () {
  12317. C.triggerHandler(t);
  12318. }, f.duration + f.failSafeDelay), a.verbose("Adding fail safe timer", a.timer);
  12319. } }, increment: function increment(e) {
  12320. var t, n;a.has.total() ? n = (t = a.get.value()) + (e = e || 1) : (n = (t = a.get.percent()) + (e = e || a.get.randomValue()), 100, a.debug("Incrementing percentage by", t, n)), n = a.get.normalizedValue(n), a.set.progress(n);
  12321. }, decrement: function decrement(e) {
  12322. var t, n;a.get.total() ? (n = (t = a.get.value()) - (e = e || 1), a.debug("Decrementing value by", e, t)) : (n = (t = a.get.percent()) - (e = e || a.get.randomValue()), a.debug("Decrementing percentage by", e, t)), n = a.get.normalizedValue(n), a.set.progress(n);
  12323. }, has: { progressPoll: function progressPoll() {
  12324. return a.progressPoll;
  12325. }, total: function total() {
  12326. return !1 !== a.get.total();
  12327. } }, get: { text: function text(e) {
  12328. var t = a.value || 0,
  12329. n = a.total || 0,
  12330. i = A ? a.get.displayPercent() : a.percent || 0,
  12331. o = a.total > 0 ? n - t : 100 - i;return e = (e = e || "").replace("{value}", t).replace("{total}", n).replace("{left}", o).replace("{percent}", i), a.verbose("Adding variables to progress bar text", e), e;
  12332. }, normalizedValue: function normalizedValue(e) {
  12333. if (e < 0) return a.debug("Value cannot decrement below 0"), 0;if (a.has.total()) {
  12334. if (e > a.total) return a.debug("Value cannot increment above total", a.total), a.total;
  12335. } else if (e > 100) return a.debug("Value cannot increment above 100 percent"), 100;return e;
  12336. }, updateInterval: function updateInterval() {
  12337. return "auto" == f.updateInterval ? f.duration : f.updateInterval;
  12338. }, randomValue: function randomValue() {
  12339. return a.debug("Generating random increment percentage"), Math.floor(Math.random() * f.random.max + f.random.min);
  12340. }, numericValue: function numericValue(e) {
  12341. return "string" == typeof e ? "" !== e.replace(/[^\d.]/g, "") && +e.replace(/[^\d.]/g, "") : e;
  12342. }, transitionEnd: function transitionEnd() {
  12343. var e,
  12344. t = n.createElement("element"),
  12345. o = { transition: "transitionend", OTransition: "oTransitionEnd", MozTransition: "transitionend", WebkitTransition: "webkitTransitionEnd" };for (e in o) {
  12346. if (t.style[e] !== i) return o[e];
  12347. }
  12348. }, displayPercent: function displayPercent() {
  12349. var e = C.width(),
  12350. t = x.width(),
  12351. n = e > parseInt(C.css("min-width"), 10) ? e / t * 100 : a.percent;return f.precision > 0 ? Math.round(n * (10 * f.precision)) / (10 * f.precision) : Math.round(n);
  12352. }, percent: function percent() {
  12353. return a.percent || 0;
  12354. }, value: function value() {
  12355. return a.nextValue || a.value || 0;
  12356. }, total: function total() {
  12357. return a.total || !1;
  12358. } }, create: { progressPoll: function progressPoll() {
  12359. a.progressPoll = setTimeout(function () {
  12360. a.update.toNextValue(), a.remove.progressPoll();
  12361. }, a.get.updateInterval());
  12362. } }, is: { complete: function complete() {
  12363. return a.is.success() || a.is.warning() || a.is.error();
  12364. }, success: function success() {
  12365. return x.hasClass(m.success);
  12366. }, warning: function warning() {
  12367. return x.hasClass(m.warning);
  12368. }, error: function error() {
  12369. return x.hasClass(m.error);
  12370. }, active: function active() {
  12371. return x.hasClass(m.active);
  12372. }, visible: function visible() {
  12373. return x.is(":visible");
  12374. } }, remove: { progressPoll: function progressPoll() {
  12375. a.verbose("Removing progress poll timer"), a.progressPoll && (clearTimeout(a.progressPoll), delete a.progressPoll);
  12376. }, nextValue: function nextValue() {
  12377. a.verbose("Removing progress value stored for next update"), delete a.nextValue;
  12378. }, state: function state() {
  12379. a.verbose("Removing stored state"), delete a.total, delete a.percent, delete a.value;
  12380. }, active: function active() {
  12381. a.verbose("Removing active state"), x.removeClass(m.active);
  12382. }, success: function success() {
  12383. a.verbose("Removing success state"), x.removeClass(m.success);
  12384. }, warning: function warning() {
  12385. a.verbose("Removing warning state"), x.removeClass(m.warning);
  12386. }, error: function error() {
  12387. a.verbose("Removing error state"), x.removeClass(m.error);
  12388. } }, set: { barWidth: function barWidth(e) {
  12389. e > 100 ? a.error(v.tooHigh, e) : e < 0 ? a.error(v.tooLow, e) : (C.css("width", e + "%"), x.attr("data-percent", parseInt(e, 10)));
  12390. }, duration: function duration(e) {
  12391. e = "number" == typeof (e = e || f.duration) ? e + "ms" : e, a.verbose("Setting progress bar transition duration", e), C.css({ "transition-duration": e });
  12392. }, percent: function percent(e) {
  12393. e = "string" == typeof e ? +e.replace("%", "") : e, e = f.precision > 0 ? Math.round(e * (10 * f.precision)) / (10 * f.precision) : Math.round(e), a.percent = e, a.has.total() || (a.value = f.precision > 0 ? Math.round(e / 100 * a.total * (10 * f.precision)) / (10 * f.precision) : Math.round(e / 100 * a.total * 10) / 10, f.limitValues && (a.value = a.value > 100 ? 100 : a.value < 0 ? 0 : a.value)), a.set.barWidth(e), a.set.labelInterval(), a.set.labels(), f.onChange.call(k, e, a.value, a.total);
  12394. }, labelInterval: function labelInterval() {
  12395. clearInterval(a.interval), a.bind.transitionEnd(function () {
  12396. a.verbose("Bar finished animating, removing continuous label updates"), clearInterval(a.interval), A = !1, a.set.labels();
  12397. }), A = !0, a.interval = setInterval(function () {
  12398. e.contains(n.documentElement, k) || (clearInterval(a.interval), A = !1), a.set.labels();
  12399. }, f.framerate);
  12400. }, labels: function labels() {
  12401. a.verbose("Setting both bar progress and outer label text"), a.set.barLabel(), a.set.state();
  12402. }, label: function label(e) {
  12403. (e = e || "") && (e = a.get.text(e), a.verbose("Setting label to text", e), S.text(e));
  12404. }, state: function state(e) {
  12405. 100 === (e = e !== i ? e : a.percent) ? f.autoSuccess && !(a.is.warning() || a.is.error() || a.is.success()) ? (a.set.success(), a.debug("Automatically triggering success at 100%")) : (a.verbose("Reached 100% removing active state"), a.remove.active(), a.remove.progressPoll()) : e > 0 ? (a.verbose("Adjusting active progress bar label", e), a.set.active()) : (a.remove.active(), a.set.label(f.text.active));
  12406. }, barLabel: function barLabel(e) {
  12407. e !== i ? w.text(a.get.text(e)) : "ratio" == f.label && a.total ? (a.verbose("Adding ratio to bar label"), w.text(a.get.text(f.text.ratio))) : "percent" == f.label && (a.verbose("Adding percentage to bar label"), w.text(a.get.text(f.text.percent)));
  12408. }, active: function active(e) {
  12409. e = e || f.text.active, a.debug("Setting active state"), f.showActivity && !a.is.active() && x.addClass(m.active), a.remove.warning(), a.remove.error(), a.remove.success(), (e = f.onLabelUpdate("active", e, a.value, a.total)) && a.set.label(e), a.bind.transitionEnd(function () {
  12410. f.onActive.call(k, a.value, a.total);
  12411. });
  12412. }, success: function success(e) {
  12413. e = e || f.text.success || f.text.active, a.debug("Setting success state"), x.addClass(m.success), a.remove.active(), a.remove.warning(), a.remove.error(), a.complete(), f.text.success ? (e = f.onLabelUpdate("success", e, a.value, a.total), a.set.label(e)) : (e = f.onLabelUpdate("active", e, a.value, a.total), a.set.label(e)), a.bind.transitionEnd(function () {
  12414. f.onSuccess.call(k, a.total);
  12415. });
  12416. }, warning: function warning(e) {
  12417. e = e || f.text.warning, a.debug("Setting warning state"), x.addClass(m.warning), a.remove.active(), a.remove.success(), a.remove.error(), a.complete(), (e = f.onLabelUpdate("warning", e, a.value, a.total)) && a.set.label(e), a.bind.transitionEnd(function () {
  12418. f.onWarning.call(k, a.value, a.total);
  12419. });
  12420. }, error: function error(e) {
  12421. e = e || f.text.error, a.debug("Setting error state"), x.addClass(m.error), a.remove.active(), a.remove.success(), a.remove.warning(), a.complete(), (e = f.onLabelUpdate("error", e, a.value, a.total)) && a.set.label(e), a.bind.transitionEnd(function () {
  12422. f.onError.call(k, a.value, a.total);
  12423. });
  12424. }, transitionEvent: function transitionEvent() {
  12425. a.get.transitionEnd();
  12426. }, total: function total(e) {
  12427. a.total = e;
  12428. }, value: function value(e) {
  12429. a.value = e;
  12430. }, progress: function progress(e) {
  12431. a.has.progressPoll() ? (a.debug("Updated within interval, setting next update to use new value", e), a.set.nextValue(e)) : (a.debug("First update in progress update interval, immediately updating", e), a.update.progress(e), a.create.progressPoll());
  12432. }, nextValue: function nextValue(e) {
  12433. a.nextValue = e;
  12434. } }, update: { toNextValue: function toNextValue() {
  12435. var e = a.nextValue;e && (a.debug("Update interval complete using last updated value", e), a.update.progress(e), a.remove.nextValue());
  12436. }, progress: function progress(e) {
  12437. var t;!1 === (e = a.get.numericValue(e)) && a.error(v.nonNumeric, e), e = a.get.normalizedValue(e), a.has.total() ? (a.set.value(e), t = e / a.total * 100, a.debug("Calculating percent complete from total", t), a.set.percent(t)) : (t = e, a.debug("Setting value to exact percentage value", t), a.set.percent(t));
  12438. } }, setting: function setting(t, n) {
  12439. if (a.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, f, t);else {
  12440. if (n === i) return f[t];e.isPlainObject(f[t]) ? e.extend(!0, f[t], n) : f[t] = n;
  12441. }
  12442. }, internal: function internal(t, n) {
  12443. if (e.isPlainObject(t)) e.extend(!0, a, t);else {
  12444. if (n === i) return a[t];a[t] = n;
  12445. }
  12446. }, debug: function debug() {
  12447. !f.silent && f.debug && (f.performance ? a.performance.log(arguments) : (a.debug = Function.prototype.bind.call(console.info, console, f.name + ":"), a.debug.apply(console, arguments)));
  12448. }, verbose: function verbose() {
  12449. !f.silent && f.verbose && f.debug && (f.performance ? a.performance.log(arguments) : (a.verbose = Function.prototype.bind.call(console.info, console, f.name + ":"), a.verbose.apply(console, arguments)));
  12450. }, error: function error() {
  12451. f.silent || (a.error = Function.prototype.bind.call(console.error, console, f.name + ":"), a.error.apply(console, arguments));
  12452. }, performance: { log: function log(e) {
  12453. var t, n;f.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: k, "Execution Time": n })), clearTimeout(a.performance.timer), a.performance.timer = setTimeout(a.performance.display, 500);
  12454. }, display: function display() {
  12455. var t = f.name + ":",
  12456. n = 0;s = !1, clearTimeout(a.performance.timer), e.each(l, function (e, t) {
  12457. n += t["Execution Time"];
  12458. }), t += " " + n + "ms", r && (t += " '" + r + "'"), (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  12459. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  12460. }), console.groupEnd()), l = [];
  12461. } }, invoke: function invoke(t, n, r) {
  12462. var s,
  12463. l,
  12464. c,
  12465. u = T;return n = n || d, r = k || r, "string" == typeof t && u !== i && (t = t.split(/[\. ]/), s = t.length - 1, e.each(t, function (n, o) {
  12466. var r = n != s ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(u[r]) && n != s) u = u[r];else {
  12467. if (u[r] !== i) return l = u[r], !1;if (!e.isPlainObject(u[o]) || n == s) return u[o] !== i ? (l = u[o], !1) : (a.error(v.method, t), !1);u = u[o];
  12468. }
  12469. })), e.isFunction(l) ? c = l.apply(r, n) : l !== i && (c = l), e.isArray(o) ? o.push(c) : o !== i ? o = [o, c] : c !== i && (o = c), l;
  12470. } }, u ? (T === i && a.initialize(), a.invoke(c)) : (T !== i && T.invoke("destroy"), a.initialize());
  12471. }), o !== i ? o : this;
  12472. }, e.fn.progress.settings = { name: "Progress", namespace: "progress", silent: !1, debug: !1, verbose: !1, performance: !0, random: { min: 2, max: 5 }, duration: 300, updateInterval: "auto", autoSuccess: !0, showActivity: !0, limitValues: !0, label: "percent", precision: 0, framerate: 1e3 / 30, percent: !1, total: !1, value: !1, failSafeDelay: 100, onLabelUpdate: function onLabelUpdate(e, t, n, i) {
  12473. return t;
  12474. }, onChange: function onChange(e, t, n) {}, onSuccess: function onSuccess(e) {}, onActive: function onActive(e, t) {}, onError: function onError(e, t) {}, onWarning: function onWarning(e, t) {}, error: { method: "The method you called is not defined.", nonNumeric: "Progress value is non numeric", tooHigh: "Value specified is above 100%", tooLow: "Value specified is below 0%" }, regExp: { variable: /\{\$*[A-z0-9]+\}/g }, metadata: { percent: "percent", total: "total", value: "value" }, selector: { bar: "> .bar", label: "> .label", progress: ".bar > .progress" }, text: { active: !1, error: !1, success: !1, warning: !1, percent: "{percent}%", ratio: "{value} of {total}" }, className: { active: "active", error: "error", success: "success", warning: "warning" } };
  12475. }(jQuery, window, document), function (e, t, n, i) {
  12476. "use strict";
  12477. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.rating = function (t) {
  12478. var n,
  12479. o = e(this),
  12480. a = o.selector || "",
  12481. r = new Date().getTime(),
  12482. s = [],
  12483. l = arguments[0],
  12484. c = "string" == typeof l,
  12485. u = [].slice.call(arguments, 1);return o.each(function () {
  12486. var d,
  12487. f,
  12488. m = e.isPlainObject(t) ? e.extend(!0, {}, e.fn.rating.settings, t) : e.extend({}, e.fn.rating.settings),
  12489. g = m.namespace,
  12490. p = m.className,
  12491. h = m.metadata,
  12492. v = m.selector,
  12493. b = (m.error, "." + g),
  12494. y = "module-" + g,
  12495. x = this,
  12496. C = e(this).data(y),
  12497. w = e(this),
  12498. S = w.find(v.icon);f = { initialize: function initialize() {
  12499. f.verbose("Initializing rating module", m), 0 === S.length && f.setup.layout(), m.interactive ? f.enable() : f.disable(), f.set.initialLoad(), f.set.rating(f.get.initialRating()), f.remove.initialLoad(), f.instantiate();
  12500. }, instantiate: function instantiate() {
  12501. f.verbose("Instantiating module", m), C = f, w.data(y, f);
  12502. }, destroy: function destroy() {
  12503. f.verbose("Destroying previous instance", C), f.remove.events(), w.removeData(y);
  12504. }, refresh: function refresh() {
  12505. S = w.find(v.icon);
  12506. }, setup: { layout: function layout() {
  12507. var t = f.get.maxRating(),
  12508. n = e.fn.rating.settings.templates.icon(t);f.debug("Generating icon html dynamically"), w.html(n), f.refresh();
  12509. } }, event: { mouseenter: function mouseenter() {
  12510. var t = e(this);t.nextAll().removeClass(p.selected), w.addClass(p.selected), t.addClass(p.selected).prevAll().addClass(p.selected);
  12511. }, mouseleave: function mouseleave() {
  12512. w.removeClass(p.selected), S.removeClass(p.selected);
  12513. }, click: function click() {
  12514. var t = e(this),
  12515. n = f.get.rating(),
  12516. i = S.index(t) + 1;("auto" == m.clearable ? 1 === S.length : m.clearable) && n == i ? f.clearRating() : f.set.rating(i);
  12517. } }, clearRating: function clearRating() {
  12518. f.debug("Clearing current rating"), f.set.rating(0);
  12519. }, bind: { events: function events() {
  12520. f.verbose("Binding events"), w.on("mouseenter" + b, v.icon, f.event.mouseenter).on("mouseleave" + b, v.icon, f.event.mouseleave).on("click" + b, v.icon, f.event.click);
  12521. } }, remove: { events: function events() {
  12522. f.verbose("Removing events"), w.off(b);
  12523. }, initialLoad: function initialLoad() {
  12524. d = !1;
  12525. } }, enable: function enable() {
  12526. f.debug("Setting rating to interactive mode"), f.bind.events(), w.removeClass(p.disabled);
  12527. }, disable: function disable() {
  12528. f.debug("Setting rating to read-only mode"), f.remove.events(), w.addClass(p.disabled);
  12529. }, is: { initialLoad: function initialLoad() {
  12530. return d;
  12531. } }, get: { initialRating: function initialRating() {
  12532. return w.data(h.rating) !== i ? (w.removeData(h.rating), w.data(h.rating)) : m.initialRating;
  12533. }, maxRating: function maxRating() {
  12534. return w.data(h.maxRating) !== i ? (w.removeData(h.maxRating), w.data(h.maxRating)) : m.maxRating;
  12535. }, rating: function rating() {
  12536. var e = S.filter("." + p.active).length;return f.verbose("Current rating retrieved", e), e;
  12537. } }, set: { rating: function rating(e) {
  12538. var t = e - 1 >= 0 ? e - 1 : 0,
  12539. n = S.eq(t);w.removeClass(p.selected), S.removeClass(p.selected).removeClass(p.active), e > 0 && (f.verbose("Setting current rating to", e), n.prevAll().addBack().addClass(p.active)), f.is.initialLoad() || m.onRate.call(x, e);
  12540. }, initialLoad: function initialLoad() {
  12541. d = !0;
  12542. } }, setting: function setting(t, n) {
  12543. if (f.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, m, t);else {
  12544. if (n === i) return m[t];e.isPlainObject(m[t]) ? e.extend(!0, m[t], n) : m[t] = n;
  12545. }
  12546. }, internal: function internal(t, n) {
  12547. if (e.isPlainObject(t)) e.extend(!0, f, t);else {
  12548. if (n === i) return f[t];f[t] = n;
  12549. }
  12550. }, debug: function debug() {
  12551. !m.silent && m.debug && (m.performance ? f.performance.log(arguments) : (f.debug = Function.prototype.bind.call(console.info, console, m.name + ":"), f.debug.apply(console, arguments)));
  12552. }, verbose: function verbose() {
  12553. !m.silent && m.verbose && m.debug && (m.performance ? f.performance.log(arguments) : (f.verbose = Function.prototype.bind.call(console.info, console, m.name + ":"), f.verbose.apply(console, arguments)));
  12554. }, error: function error() {
  12555. m.silent || (f.error = Function.prototype.bind.call(console.error, console, m.name + ":"), f.error.apply(console, arguments));
  12556. }, performance: { log: function log(e) {
  12557. var t, n;m.performance && (n = (t = new Date().getTime()) - (r || t), r = t, s.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: x, "Execution Time": n })), clearTimeout(f.performance.timer), f.performance.timer = setTimeout(f.performance.display, 500);
  12558. }, display: function display() {
  12559. var t = m.name + ":",
  12560. n = 0;r = !1, clearTimeout(f.performance.timer), e.each(s, function (e, t) {
  12561. n += t["Execution Time"];
  12562. }), t += " " + n + "ms", a && (t += " '" + a + "'"), o.length > 1 && (t += " (" + o.length + ")"), (console.group !== i || console.table !== i) && s.length > 0 && (console.groupCollapsed(t), console.table ? console.table(s) : e.each(s, function (e, t) {
  12563. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  12564. }), console.groupEnd()), s = [];
  12565. } }, invoke: function invoke(t, o, a) {
  12566. var r,
  12567. s,
  12568. l,
  12569. c = C;return o = o || u, a = x || a, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  12570. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  12571. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  12572. }
  12573. })), e.isFunction(s) ? l = s.apply(a, o) : s !== i && (l = s), e.isArray(n) ? n.push(l) : n !== i ? n = [n, l] : l !== i && (n = l), s;
  12574. } }, c ? (C === i && f.initialize(), f.invoke(l)) : (C !== i && C.invoke("destroy"), f.initialize());
  12575. }), n !== i ? n : this;
  12576. }, e.fn.rating.settings = { name: "Rating", namespace: "rating", slent: !1, debug: !1, verbose: !1, performance: !0, initialRating: 0, interactive: !0, maxRating: 4, clearable: "auto", fireOnInit: !1, onRate: function onRate(e) {}, error: { method: "The method you called is not defined", noMaximum: "No maximum rating specified. Cannot generate HTML automatically" }, metadata: { rating: "rating", maxRating: "maxRating" }, className: { active: "active", disabled: "disabled", selected: "selected", loading: "loading" }, selector: { icon: ".icon" }, templates: { icon: function icon(e) {
  12577. for (var t = 1, n = ""; t <= e;) {
  12578. n += '<i class="icon"></i>', t++;
  12579. }return n;
  12580. } } };
  12581. }(jQuery, window, document), function (e, t, n, i) {
  12582. "use strict";
  12583. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.search = function (o) {
  12584. var a,
  12585. r = e(this),
  12586. s = r.selector || "",
  12587. l = new Date().getTime(),
  12588. c = [],
  12589. u = arguments[0],
  12590. d = "string" == typeof u,
  12591. f = [].slice.call(arguments, 1);return e(this).each(function () {
  12592. var m,
  12593. g = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.search.settings, o) : e.extend({}, e.fn.search.settings),
  12594. p = g.className,
  12595. h = g.metadata,
  12596. v = g.regExp,
  12597. b = g.fields,
  12598. y = g.selector,
  12599. x = g.error,
  12600. C = g.namespace,
  12601. w = "." + C,
  12602. S = C + "-module",
  12603. k = e(this),
  12604. T = k.find(y.prompt),
  12605. A = k.find(y.searchButton),
  12606. R = k.find(y.results),
  12607. P = k.find(y.result),
  12608. E = (k.find(y.category), this),
  12609. F = k.data(S),
  12610. O = !1,
  12611. D = !1;m = { initialize: function initialize() {
  12612. m.verbose("Initializing module"), m.get.settings(), m.determine.searchFields(), m.bind.events(), m.set.type(), m.create.results(), m.instantiate();
  12613. }, instantiate: function instantiate() {
  12614. m.verbose("Storing instance of module", m), F = m, k.data(S, m);
  12615. }, destroy: function destroy() {
  12616. m.verbose("Destroying instance"), k.off(w).removeData(S);
  12617. }, refresh: function refresh() {
  12618. m.debug("Refreshing selector cache"), T = k.find(y.prompt), A = k.find(y.searchButton), k.find(y.category), R = k.find(y.results), P = k.find(y.result);
  12619. }, refreshResults: function refreshResults() {
  12620. R = k.find(y.results), P = k.find(y.result);
  12621. }, bind: { events: function events() {
  12622. m.verbose("Binding events to search"), g.automatic && (k.on(m.get.inputEvent() + w, y.prompt, m.event.input), T.attr("autocomplete", "off")), k.on("focus" + w, y.prompt, m.event.focus).on("blur" + w, y.prompt, m.event.blur).on("keydown" + w, y.prompt, m.handleKeyboard).on("click" + w, y.searchButton, m.query).on("mousedown" + w, y.results, m.event.result.mousedown).on("mouseup" + w, y.results, m.event.result.mouseup).on("click" + w, y.result, m.event.result.click);
  12623. } }, determine: { searchFields: function searchFields() {
  12624. o && o.searchFields !== i && (g.searchFields = o.searchFields);
  12625. } }, event: { input: function input() {
  12626. g.searchDelay ? (clearTimeout(m.timer), m.timer = setTimeout(function () {
  12627. m.is.focused() && m.query();
  12628. }, g.searchDelay)) : m.query();
  12629. }, focus: function focus() {
  12630. m.set.focus(), g.searchOnFocus && m.has.minimumCharacters() && m.query(function () {
  12631. m.can.show() && m.showResults();
  12632. });
  12633. }, blur: function blur(e) {
  12634. var t = function t() {
  12635. m.cancel.query(), m.remove.focus(), m.timer = setTimeout(m.hideResults, g.hideDelay);
  12636. };n.activeElement === this || (D = !1, m.resultsClicked ? (m.debug("Determining if user action caused search to close"), k.one("click.close" + w, y.results, function (e) {
  12637. m.is.inMessage(e) || O ? T.focus() : (O = !1, m.is.animating() || m.is.hidden() || t());
  12638. })) : (m.debug("Input blurred without user action, closing results"), t()));
  12639. }, result: { mousedown: function mousedown() {
  12640. m.resultsClicked = !0;
  12641. }, mouseup: function mouseup() {
  12642. m.resultsClicked = !1;
  12643. }, click: function click(n) {
  12644. m.debug("Search result selected");var i = e(this),
  12645. o = i.find(y.title).eq(0),
  12646. a = i.is("a[href]") ? i : i.find("a[href]").eq(0),
  12647. r = a.attr("href") || !1,
  12648. s = a.attr("target") || !1,
  12649. l = (o.html(), o.length > 0 && o.text()),
  12650. c = m.get.results(),
  12651. u = i.data(h.result) || m.get.result(l, c);if (e.isFunction(g.onSelect) && !1 === g.onSelect.call(E, u, c)) return m.debug("Custom onSelect callback cancelled default select action"), void (O = !0);m.hideResults(), l && m.set.value(l), r && (m.verbose("Opening search link found in result", a), "_blank" == s || n.ctrlKey ? t.open(r) : t.location.href = r);
  12652. } } }, handleKeyboard: function handleKeyboard(e) {
  12653. var t,
  12654. n = k.find(y.result),
  12655. i = k.find(y.category),
  12656. o = n.filter("." + p.active),
  12657. a = n.index(o),
  12658. r = n.length,
  12659. s = o.length > 0,
  12660. l = e.which,
  12661. c = 13,
  12662. u = 38,
  12663. d = 40;if (l == 27 && (m.verbose("Escape key pressed, blurring search field"), m.hideResults(), D = !0), m.is.visible()) {
  12664. if (l == c) {
  12665. if (m.verbose("Enter key pressed, selecting active result"), n.filter("." + p.active).length > 0) return m.event.result.click.call(n.filter("." + p.active), e), e.preventDefault(), !1;
  12666. } else l == u && s ? (m.verbose("Up key pressed, changing active result"), t = a - 1 < 0 ? a : a - 1, i.removeClass(p.active), n.removeClass(p.active).eq(t).addClass(p.active).closest(i).addClass(p.active), e.preventDefault()) : l == d && (m.verbose("Down key pressed, changing active result"), t = a + 1 >= r ? a : a + 1, i.removeClass(p.active), n.removeClass(p.active).eq(t).addClass(p.active).closest(i).addClass(p.active), e.preventDefault());
  12667. } else l == c && (m.verbose("Enter key pressed, executing query"), m.query(), m.set.buttonPressed(), T.one("keyup", m.remove.buttonFocus));
  12668. }, setup: { api: function api(t, n) {
  12669. var i = { debug: g.debug, on: !1, cache: g.cache, action: "search", urlData: { query: t }, onSuccess: function onSuccess(e) {
  12670. m.parse.response.call(E, e, t), n();
  12671. }, onFailure: function onFailure() {
  12672. m.displayMessage(x.serverError), n();
  12673. }, onAbort: function onAbort(e) {}, onError: m.error };e.extend(!0, i, g.apiSettings), m.verbose("Setting up API request", i), k.api(i);
  12674. } }, can: { useAPI: function useAPI() {
  12675. return e.fn.api !== i;
  12676. }, show: function show() {
  12677. return m.is.focused() && !m.is.visible() && !m.is.empty();
  12678. }, transition: function transition() {
  12679. return g.transition && e.fn.transition !== i && k.transition("is supported");
  12680. } }, is: { animating: function animating() {
  12681. return R.hasClass(p.animating);
  12682. }, hidden: function hidden() {
  12683. return R.hasClass(p.hidden);
  12684. }, inMessage: function inMessage(t) {
  12685. if (t.target) {
  12686. var i = e(t.target);return e.contains(n.documentElement, t.target) && i.closest(y.message).length > 0;
  12687. }
  12688. }, empty: function empty() {
  12689. return "" === R.html();
  12690. }, visible: function visible() {
  12691. return R.filter(":visible").length > 0;
  12692. }, focused: function focused() {
  12693. return T.filter(":focus").length > 0;
  12694. } }, get: { settings: function settings() {
  12695. e.isPlainObject(o) && o.searchFullText && (g.fullTextSearch = o.searchFullText, m.error(g.error.oldSearchSyntax, E));
  12696. }, inputEvent: function inputEvent() {
  12697. var e = T[0];return e !== i && e.oninput !== i ? "input" : e !== i && e.onpropertychange !== i ? "propertychange" : "keyup";
  12698. }, value: function value() {
  12699. return T.val();
  12700. }, results: function results() {
  12701. return k.data(h.results);
  12702. }, result: function result(t, n) {
  12703. var o = ["title", "id"],
  12704. a = !1;return t = t !== i ? t : m.get.value(), n = n !== i ? n : m.get.results(), "category" === g.type ? (m.debug("Finding result that matches", t), e.each(n, function (n, i) {
  12705. if (e.isArray(i.results) && (a = m.search.object(t, i.results, o)[0])) return !1;
  12706. })) : (m.debug("Finding result in results object", t), a = m.search.object(t, n, o)[0]), a || !1;
  12707. } }, select: { firstResult: function firstResult() {
  12708. m.verbose("Selecting first result"), P.first().addClass(p.active);
  12709. } }, set: { focus: function focus() {
  12710. k.addClass(p.focus);
  12711. }, loading: function loading() {
  12712. k.addClass(p.loading);
  12713. }, value: function value(e) {
  12714. m.verbose("Setting search input value", e), T.val(e);
  12715. }, type: function type(e) {
  12716. e = e || g.type, "category" == g.type && k.addClass(g.type);
  12717. }, buttonPressed: function buttonPressed() {
  12718. A.addClass(p.pressed);
  12719. } }, remove: { loading: function loading() {
  12720. k.removeClass(p.loading);
  12721. }, focus: function focus() {
  12722. k.removeClass(p.focus);
  12723. }, buttonPressed: function buttonPressed() {
  12724. A.removeClass(p.pressed);
  12725. } }, query: function query(t) {
  12726. t = e.isFunction(t) ? t : function () {};var n = m.get.value(),
  12727. i = m.read.cache(n);t = t || function () {}, m.has.minimumCharacters() ? (i ? (m.debug("Reading result from cache", n), m.save.results(i.results), m.addResults(i.html), m.inject.id(i.results), t()) : (m.debug("Querying for", n), e.isPlainObject(g.source) || e.isArray(g.source) ? (m.search.local(n), t()) : m.can.useAPI() ? m.search.remote(n, t) : (m.error(x.source), t())), g.onSearchQuery.call(E, n)) : m.hideResults();
  12728. }, search: { local: function local(e) {
  12729. var t,
  12730. n = m.search.object(e, g.content);m.set.loading(), m.save.results(n), m.debug("Returned full local search results", n), g.maxResults > 0 && (m.debug("Using specified max results", n), n = n.slice(0, g.maxResults)), "category" == g.type && (n = m.create.categoryResults(n)), t = m.generateResults({ results: n }), m.remove.loading(), m.addResults(t), m.inject.id(n), m.write.cache(e, { html: t, results: n });
  12731. }, remote: function remote(t, n) {
  12732. n = e.isFunction(n) ? n : function () {}, k.api("is loading") && k.api("abort"), m.setup.api(t, n), k.api("query");
  12733. }, object: function object(t, n, o) {
  12734. var a = [],
  12735. r = [],
  12736. s = [],
  12737. l = t.toString().replace(v.escape, "\\$&"),
  12738. c = new RegExp(v.beginsWith + l, "i"),
  12739. u = function u(t, n) {
  12740. var i = -1 == e.inArray(n, a),
  12741. o = -1 == e.inArray(n, s),
  12742. l = -1 == e.inArray(n, r);i && o && l && t.push(n);
  12743. };return n = n || g.source, o = o !== i ? o : g.searchFields, e.isArray(o) || (o = [o]), n === i || !1 === n ? (m.error(x.source), []) : (e.each(o, function (i, o) {
  12744. e.each(n, function (e, n) {
  12745. "string" == typeof n[o] && (-1 !== n[o].search(c) ? u(a, n) : "exact" === g.fullTextSearch && m.exactSearch(t, n[o]) ? u(r, n) : 1 == g.fullTextSearch && m.fuzzySearch(t, n[o]) && u(s, n));
  12746. });
  12747. }), e.merge(r, s), e.merge(a, r), a);
  12748. } }, exactSearch: function exactSearch(e, t) {
  12749. return e = e.toLowerCase(), (t = t.toLowerCase()).indexOf(e) > -1;
  12750. }, fuzzySearch: function fuzzySearch(e, t) {
  12751. var n = t.length,
  12752. i = e.length;if ("string" != typeof e) return !1;if (e = e.toLowerCase(), t = t.toLowerCase(), i > n) return !1;if (i === n) return e === t;e: for (var o = 0, a = 0; o < i; o++) {
  12753. for (var r = e.charCodeAt(o); a < n;) {
  12754. if (t.charCodeAt(a++) === r) continue e;
  12755. }return !1;
  12756. }return !0;
  12757. }, parse: { response: function response(e, t) {
  12758. var n = m.generateResults(e);m.verbose("Parsing server response", e), e !== i && t !== i && e[b.results] !== i && (m.addResults(n), m.inject.id(e[b.results]), m.write.cache(t, { html: n, results: e[b.results] }), m.save.results(e[b.results]));
  12759. } }, cancel: { query: function query() {
  12760. m.can.useAPI() && k.api("abort");
  12761. } }, has: { minimumCharacters: function minimumCharacters() {
  12762. return m.get.value().length >= g.minCharacters;
  12763. }, results: function results() {
  12764. return 0 !== R.length && "" != R.html();
  12765. } }, clear: { cache: function cache(e) {
  12766. var t = k.data(h.cache);e ? e && t && t[e] && (m.debug("Removing value from cache", e), delete t[e], k.data(h.cache, t)) : (m.debug("Clearing cache", e), k.removeData(h.cache));
  12767. } }, read: { cache: function cache(e) {
  12768. var t = k.data(h.cache);return !!g.cache && (m.verbose("Checking cache for generated html for query", e), "object" == (typeof t === "undefined" ? "undefined" : _typeof(t)) && t[e] !== i && t[e]);
  12769. } }, create: { categoryResults: function categoryResults(t) {
  12770. var n = {};return e.each(t, function (e, t) {
  12771. t.category && (n[t.category] === i ? (m.verbose("Creating new category of results", t.category), n[t.category] = { name: t.category, results: [t] }) : n[t.category].results.push(t));
  12772. }), n;
  12773. }, id: function id(e, t) {
  12774. var n,
  12775. o = e + 1;return t !== i ? (n = String.fromCharCode(97 + t) + o, m.verbose("Creating category result id", n)) : (n = o, m.verbose("Creating result id", n)), n;
  12776. }, results: function results() {
  12777. 0 === R.length && (R = e("<div />").addClass(p.results).appendTo(k));
  12778. } }, inject: { result: function result(e, t, n) {
  12779. m.verbose("Injecting result into results");var o = n !== i ? R.children().eq(n).children(y.results).first().children(y.result).eq(t) : R.children(y.result).eq(t);m.verbose("Injecting results metadata", o), o.data(h.result, e);
  12780. }, id: function id(t) {
  12781. m.debug("Injecting unique ids into results");var n = 0,
  12782. o = 0;return "category" === g.type ? e.each(t, function (t, a) {
  12783. o = 0, e.each(a.results, function (e, t) {
  12784. var r = a.results[e];r.id === i && (r.id = m.create.id(o, n)), m.inject.result(r, o, n), o++;
  12785. }), n++;
  12786. }) : e.each(t, function (e, n) {
  12787. var a = t[e];a.id === i && (a.id = m.create.id(o)), m.inject.result(a, o), o++;
  12788. }), t;
  12789. } }, save: { results: function results(e) {
  12790. m.verbose("Saving current search results to metadata", e), k.data(h.results, e);
  12791. } }, write: { cache: function cache(e, t) {
  12792. var n = k.data(h.cache) !== i ? k.data(h.cache) : {};g.cache && (m.verbose("Writing generated html to cache", e, t), n[e] = t, k.data(h.cache, n));
  12793. } }, addResults: function addResults(t) {
  12794. if (e.isFunction(g.onResultsAdd) && !1 === g.onResultsAdd.call(R, t)) return m.debug("onResultsAdd callback cancelled default action"), !1;t ? (R.html(t), m.refreshResults(), g.selectFirstResult && m.select.firstResult(), m.showResults()) : m.hideResults(function () {
  12795. R.empty();
  12796. });
  12797. }, showResults: function showResults(t) {
  12798. t = e.isFunction(t) ? t : function () {}, D || !m.is.visible() && m.has.results() && (m.can.transition() ? (m.debug("Showing results with css animations"), R.transition({ animation: g.transition + " in", debug: g.debug, verbose: g.verbose, duration: g.duration, onComplete: function onComplete() {
  12799. t();
  12800. }, queue: !0 })) : (m.debug("Showing results with javascript"), R.stop().fadeIn(g.duration, g.easing)), g.onResultsOpen.call(R));
  12801. }, hideResults: function hideResults(t) {
  12802. t = e.isFunction(t) ? t : function () {}, m.is.visible() && (m.can.transition() ? (m.debug("Hiding results with css animations"), R.transition({ animation: g.transition + " out", debug: g.debug, verbose: g.verbose, duration: g.duration, onComplete: function onComplete() {
  12803. t();
  12804. }, queue: !0 })) : (m.debug("Hiding results with javascript"), R.stop().fadeOut(g.duration, g.easing)), g.onResultsClose.call(R));
  12805. }, generateResults: function generateResults(t) {
  12806. m.debug("Generating html from response", t);var n = g.templates[g.type],
  12807. i = e.isPlainObject(t[b.results]) && !e.isEmptyObject(t[b.results]),
  12808. o = e.isArray(t[b.results]) && t[b.results].length > 0,
  12809. a = "";return i || o ? (g.maxResults > 0 && (i ? "standard" == g.type && m.error(x.maxResults) : t[b.results] = t[b.results].slice(0, g.maxResults)), e.isFunction(n) ? a = n(t, b) : m.error(x.noTemplate, !1)) : g.showNoResults && (a = m.displayMessage(x.noResults, "empty")), g.onResults.call(E, t), a;
  12810. }, displayMessage: function displayMessage(e, t) {
  12811. return t = t || "standard", m.debug("Displaying message", e, t), m.addResults(g.templates.message(e, t)), g.templates.message(e, t);
  12812. }, setting: function setting(t, n) {
  12813. if (e.isPlainObject(t)) e.extend(!0, g, t);else {
  12814. if (n === i) return g[t];g[t] = n;
  12815. }
  12816. }, internal: function internal(t, n) {
  12817. if (e.isPlainObject(t)) e.extend(!0, m, t);else {
  12818. if (n === i) return m[t];m[t] = n;
  12819. }
  12820. }, debug: function debug() {
  12821. !g.silent && g.debug && (g.performance ? m.performance.log(arguments) : (m.debug = Function.prototype.bind.call(console.info, console, g.name + ":"), m.debug.apply(console, arguments)));
  12822. }, verbose: function verbose() {
  12823. !g.silent && g.verbose && g.debug && (g.performance ? m.performance.log(arguments) : (m.verbose = Function.prototype.bind.call(console.info, console, g.name + ":"), m.verbose.apply(console, arguments)));
  12824. }, error: function error() {
  12825. g.silent || (m.error = Function.prototype.bind.call(console.error, console, g.name + ":"), m.error.apply(console, arguments));
  12826. }, performance: { log: function log(e) {
  12827. var t, n;g.performance && (n = (t = new Date().getTime()) - (l || t), l = t, c.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: E, "Execution Time": n })), clearTimeout(m.performance.timer), m.performance.timer = setTimeout(m.performance.display, 500);
  12828. }, display: function display() {
  12829. var t = g.name + ":",
  12830. n = 0;l = !1, clearTimeout(m.performance.timer), e.each(c, function (e, t) {
  12831. n += t["Execution Time"];
  12832. }), t += " " + n + "ms", s && (t += " '" + s + "'"), r.length > 1 && (t += " (" + r.length + ")"), (console.group !== i || console.table !== i) && c.length > 0 && (console.groupCollapsed(t), console.table ? console.table(c) : e.each(c, function (e, t) {
  12833. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  12834. }), console.groupEnd()), c = [];
  12835. } }, invoke: function invoke(t, n, o) {
  12836. var r,
  12837. s,
  12838. l,
  12839. c = F;return n = n || f, o = E || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  12840. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  12841. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  12842. }
  12843. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  12844. } }, d ? (F === i && m.initialize(), m.invoke(u)) : (F !== i && F.invoke("destroy"), m.initialize());
  12845. }), a !== i ? a : this;
  12846. }, e.fn.search.settings = { name: "Search", namespace: "search", silent: !1, debug: !1, verbose: !1, performance: !0, type: "standard", minCharacters: 1, selectFirstResult: !1, apiSettings: !1, source: !1, searchOnFocus: !0, searchFields: ["title", "description"], displayField: "", fullTextSearch: "exact", automatic: !0, hideDelay: 0, searchDelay: 200, maxResults: 7, cache: !0, showNoResults: !0, transition: "scale", duration: 200, easing: "easeOutExpo", onSelect: !1, onResultsAdd: !1, onSearchQuery: function onSearchQuery(e) {}, onResults: function onResults(e) {}, onResultsOpen: function onResultsOpen() {}, onResultsClose: function onResultsClose() {}, className: { animating: "animating", active: "active", empty: "empty", focus: "focus", hidden: "hidden", loading: "loading", results: "results", pressed: "down" }, error: { source: "Cannot search. No source used, and Semantic API module was not included", noResults: "Your search returned no results", logging: "Error in debug logging, exiting.", noEndpoint: "No search endpoint was specified", noTemplate: "A valid template name was not specified.", oldSearchSyntax: "searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.", serverError: "There was an issue querying the server.", maxResults: "Results must be an array to use maxResults setting", method: "The method you called is not defined." }, metadata: { cache: "cache", results: "results", result: "result" }, regExp: { escape: /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, beginsWith: "(?:s|^)" }, fields: { categories: "results", categoryName: "name", categoryResults: "results", description: "description", image: "image", price: "price", results: "results", title: "title", url: "url", action: "action", actionText: "text", actionURL: "url" }, selector: { prompt: ".prompt", searchButton: ".search.button", results: ".results", message: ".results > .message", category: ".category", result: ".result", title: ".title, .name" }, templates: { escape: function escape(e) {
  12847. var t = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#x27;", "`": "&#x60;" };return (/[&<>"'`]/.test(e) ? e.replace(/[&<>"'`]/g, function (e) {
  12848. return t[e];
  12849. }) : e
  12850. );
  12851. }, message: function message(e, t) {
  12852. var n = "";return e !== i && t !== i && (n += '<div class="message ' + t + '">', n += "empty" == t ? '<div class="header">No Results</div class="header"><div class="description">' + e + '</div class="description">' : ' <div class="description">' + e + "</div>", n += "</div>"), n;
  12853. }, category: function category(t, n) {
  12854. var o = "";e.fn.search.settings.templates.escape;return t[n.categoryResults] !== i && (e.each(t[n.categoryResults], function (t, a) {
  12855. a[n.results] !== i && a.results.length > 0 && (o += '<div class="category">', a[n.categoryName] !== i && (o += '<div class="name">' + a[n.categoryName] + "</div>"), o += '<div class="results">', e.each(a.results, function (e, t) {
  12856. t[n.url] ? o += '<a class="result" href="' + t[n.url] + '">' : o += '<a class="result">', t[n.image] !== i && (o += '<div class="image"> <img src="' + t[n.image] + '"></div>'), o += '<div class="content">', t[n.price] !== i && (o += '<div class="price">' + t[n.price] + "</div>"), t[n.title] !== i && (o += '<div class="title">' + t[n.title] + "</div>"), t[n.description] !== i && (o += '<div class="description">' + t[n.description] + "</div>"), o += "</div>", o += "</a>";
  12857. }), o += "</div>", o += "</div>");
  12858. }), t[n.action] && (o += '<a href="' + t[n.action][n.actionURL] + '" class="action">' + t[n.action][n.actionText] + "</a>"), o);
  12859. }, standard: function standard(t, n) {
  12860. var o = "";return t[n.results] !== i && (e.each(t[n.results], function (e, t) {
  12861. t[n.url] ? o += '<a class="result" href="' + t[n.url] + '">' : o += '<a class="result">', t[n.image] !== i && (o += '<div class="image"> <img src="' + t[n.image] + '"></div>'), o += '<div class="content">', t[n.price] !== i && (o += '<div class="price">' + t[n.price] + "</div>"), t[n.title] !== i && (o += '<div class="title">' + t[n.title] + "</div>"), t[n.description] !== i && (o += '<div class="description">' + t[n.description] + "</div>"), o += "</div>", o += "</a>";
  12862. }), t[n.action] && (o += '<a href="' + t[n.action][n.actionURL] + '" class="action">' + t[n.action][n.actionText] + "</a>"), o);
  12863. } } };
  12864. }(jQuery, window, document), function (e, t, n, i) {
  12865. "use strict";
  12866. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.shape = function (o) {
  12867. var a,
  12868. r = e(this),
  12869. s = (e("body"), new Date().getTime()),
  12870. l = [],
  12871. c = arguments[0],
  12872. u = "string" == typeof c,
  12873. d = [].slice.call(arguments, 1),
  12874. f = t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame || function (e) {
  12875. setTimeout(e, 0);
  12876. };return r.each(function () {
  12877. var t,
  12878. m,
  12879. g,
  12880. p = r.selector || "",
  12881. h = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.shape.settings, o) : e.extend({}, e.fn.shape.settings),
  12882. v = h.namespace,
  12883. b = h.selector,
  12884. y = h.error,
  12885. x = h.className,
  12886. C = "." + v,
  12887. w = "module-" + v,
  12888. S = e(this),
  12889. k = S.find(b.sides),
  12890. T = S.find(b.side),
  12891. A = !1,
  12892. R = this,
  12893. P = S.data(w);g = { initialize: function initialize() {
  12894. g.verbose("Initializing module for", R), g.set.defaultSide(), g.instantiate();
  12895. }, instantiate: function instantiate() {
  12896. g.verbose("Storing instance of module", g), P = g, S.data(w, P);
  12897. }, destroy: function destroy() {
  12898. g.verbose("Destroying previous module for", R), S.removeData(w).off(C);
  12899. }, refresh: function refresh() {
  12900. g.verbose("Refreshing selector cache for", R), S = e(R), k = e(this).find(b.shape), T = e(this).find(b.side);
  12901. }, repaint: function repaint() {
  12902. g.verbose("Forcing repaint event");(k[0] || n.createElement("div")).offsetWidth;
  12903. }, animate: function animate(e, n) {
  12904. g.verbose("Animating box with properties", e), n = n || function (e) {
  12905. g.verbose("Executing animation callback"), e !== i && e.stopPropagation(), g.reset(), g.set.active();
  12906. }, h.beforeChange.call(m[0]), g.get.transitionEvent() ? (g.verbose("Starting CSS animation"), S.addClass(x.animating), k.css(e).one(g.get.transitionEvent(), n), g.set.duration(h.duration), f(function () {
  12907. S.addClass(x.animating), t.addClass(x.hidden);
  12908. })) : n();
  12909. }, queue: function queue(e) {
  12910. g.debug("Queueing animation of", e), k.one(g.get.transitionEvent(), function () {
  12911. g.debug("Executing queued animation"), setTimeout(function () {
  12912. S.shape(e);
  12913. }, 0);
  12914. });
  12915. }, reset: function reset() {
  12916. g.verbose("Animating states reset"), S.removeClass(x.animating).attr("style", "").removeAttr("style"), k.attr("style", "").removeAttr("style"), T.attr("style", "").removeAttr("style").removeClass(x.hidden), m.removeClass(x.animating).attr("style", "").removeAttr("style");
  12917. }, is: { complete: function complete() {
  12918. return T.filter("." + x.active)[0] == m[0];
  12919. }, animating: function animating() {
  12920. return S.hasClass(x.animating);
  12921. } }, set: { defaultSide: function defaultSide() {
  12922. t = S.find("." + h.className.active), m = t.next(b.side).length > 0 ? t.next(b.side) : S.find(b.side).first(), A = !1, g.verbose("Active side set to", t), g.verbose("Next side set to", m);
  12923. }, duration: function duration(e) {
  12924. e = "number" == typeof (e = e || h.duration) ? e + "ms" : e, g.verbose("Setting animation duration", e), (h.duration || 0 === h.duration) && k.add(T).css({ "-webkit-transition-duration": e, "-moz-transition-duration": e, "-ms-transition-duration": e, "-o-transition-duration": e, "transition-duration": e });
  12925. }, currentStageSize: function currentStageSize() {
  12926. var e = S.find("." + h.className.active),
  12927. t = e.outerWidth(!0),
  12928. n = e.outerHeight(!0);S.css({ width: t, height: n });
  12929. }, stageSize: function stageSize() {
  12930. var e = S.clone().addClass(x.loading),
  12931. t = e.find("." + h.className.active),
  12932. n = A ? e.find(b.side).eq(A) : t.next(b.side).length > 0 ? t.next(b.side) : e.find(b.side).first(),
  12933. i = "next" == h.width ? n.outerWidth(!0) : "initial" == h.width ? S.width() : h.width,
  12934. o = "next" == h.height ? n.outerHeight(!0) : "initial" == h.height ? S.height() : h.height;t.removeClass(x.active), n.addClass(x.active), e.insertAfter(S), e.remove(), "auto" != h.width && (S.css("width", i + h.jitter), g.verbose("Specifying width during animation", i)), "auto" != h.height && (S.css("height", o + h.jitter), g.verbose("Specifying height during animation", o));
  12935. }, nextSide: function nextSide(e) {
  12936. A = e, m = T.filter(e), A = T.index(m), 0 === m.length && (g.set.defaultSide(), g.error(y.side)), g.verbose("Next side manually set to", m);
  12937. }, active: function active() {
  12938. g.verbose("Setting new side to active", m), T.removeClass(x.active), m.addClass(x.active), h.onChange.call(m[0]), g.set.defaultSide();
  12939. } }, flip: { up: function up() {
  12940. if (!g.is.complete() || g.is.animating() || h.allowRepeats) {
  12941. if (g.is.animating()) g.queue("flip up");else {
  12942. g.debug("Flipping up", m);var e = g.get.transform.up();g.set.stageSize(), g.stage.above(), g.animate(e);
  12943. }
  12944. } else g.debug("Side already visible", m);
  12945. }, down: function down() {
  12946. if (!g.is.complete() || g.is.animating() || h.allowRepeats) {
  12947. if (g.is.animating()) g.queue("flip down");else {
  12948. g.debug("Flipping down", m);var e = g.get.transform.down();g.set.stageSize(), g.stage.below(), g.animate(e);
  12949. }
  12950. } else g.debug("Side already visible", m);
  12951. }, left: function left() {
  12952. if (!g.is.complete() || g.is.animating() || h.allowRepeats) {
  12953. if (g.is.animating()) g.queue("flip left");else {
  12954. g.debug("Flipping left", m);var e = g.get.transform.left();g.set.stageSize(), g.stage.left(), g.animate(e);
  12955. }
  12956. } else g.debug("Side already visible", m);
  12957. }, right: function right() {
  12958. if (!g.is.complete() || g.is.animating() || h.allowRepeats) {
  12959. if (g.is.animating()) g.queue("flip right");else {
  12960. g.debug("Flipping right", m);var e = g.get.transform.right();g.set.stageSize(), g.stage.right(), g.animate(e);
  12961. }
  12962. } else g.debug("Side already visible", m);
  12963. }, over: function over() {
  12964. !g.is.complete() || g.is.animating() || h.allowRepeats ? g.is.animating() ? g.queue("flip over") : (g.debug("Flipping over", m), g.set.stageSize(), g.stage.behind(), g.animate(g.get.transform.over())) : g.debug("Side already visible", m);
  12965. }, back: function back() {
  12966. !g.is.complete() || g.is.animating() || h.allowRepeats ? g.is.animating() ? g.queue("flip back") : (g.debug("Flipping back", m), g.set.stageSize(), g.stage.behind(), g.animate(g.get.transform.back())) : g.debug("Side already visible", m);
  12967. } }, get: { transform: { up: function up() {
  12968. return { transform: "translateY(" + -(t.outerHeight(!0) - m.outerHeight(!0)) / 2 + "px) translateZ(" + -t.outerHeight(!0) / 2 + "px) rotateX(-90deg)" };
  12969. }, down: function down() {
  12970. return { transform: "translateY(" + -(t.outerHeight(!0) - m.outerHeight(!0)) / 2 + "px) translateZ(" + -t.outerHeight(!0) / 2 + "px) rotateX(90deg)" };
  12971. }, left: function left() {
  12972. return { transform: "translateX(" + -(t.outerWidth(!0) - m.outerWidth(!0)) / 2 + "px) translateZ(" + -t.outerWidth(!0) / 2 + "px) rotateY(90deg)" };
  12973. }, right: function right() {
  12974. return { transform: "translateX(" + -(t.outerWidth(!0) - m.outerWidth(!0)) / 2 + "px) translateZ(" + -t.outerWidth(!0) / 2 + "px) rotateY(-90deg)" };
  12975. }, over: function over() {
  12976. return { transform: "translateX(" + -(t.outerWidth(!0) - m.outerWidth(!0)) / 2 + "px) rotateY(180deg)" };
  12977. }, back: function back() {
  12978. return { transform: "translateX(" + -(t.outerWidth(!0) - m.outerWidth(!0)) / 2 + "px) rotateY(-180deg)" };
  12979. } }, transitionEvent: function transitionEvent() {
  12980. var e,
  12981. t = n.createElement("element"),
  12982. o = { transition: "transitionend", OTransition: "oTransitionEnd", MozTransition: "transitionend", WebkitTransition: "webkitTransitionEnd" };for (e in o) {
  12983. if (t.style[e] !== i) return o[e];
  12984. }
  12985. }, nextSide: function nextSide() {
  12986. return t.next(b.side).length > 0 ? t.next(b.side) : S.find(b.side).first();
  12987. } }, stage: { above: function above() {
  12988. var e = { origin: (t.outerHeight(!0) - m.outerHeight(!0)) / 2, depth: { active: m.outerHeight(!0) / 2, next: t.outerHeight(!0) / 2 } };g.verbose("Setting the initial animation position as above", m, e), k.css({ transform: "translateZ(-" + e.depth.active + "px)" }), t.css({ transform: "rotateY(0deg) translateZ(" + e.depth.active + "px)" }), m.addClass(x.animating).css({ top: e.origin + "px", transform: "rotateX(90deg) translateZ(" + e.depth.next + "px)" });
  12989. }, below: function below() {
  12990. var e = { origin: (t.outerHeight(!0) - m.outerHeight(!0)) / 2, depth: { active: m.outerHeight(!0) / 2, next: t.outerHeight(!0) / 2 } };g.verbose("Setting the initial animation position as below", m, e), k.css({ transform: "translateZ(-" + e.depth.active + "px)" }), t.css({ transform: "rotateY(0deg) translateZ(" + e.depth.active + "px)" }), m.addClass(x.animating).css({ top: e.origin + "px", transform: "rotateX(-90deg) translateZ(" + e.depth.next + "px)" });
  12991. }, left: function left() {
  12992. var e = t.outerWidth(!0),
  12993. n = m.outerWidth(!0),
  12994. i = { origin: (e - n) / 2, depth: { active: n / 2, next: e / 2 } };g.verbose("Setting the initial animation position as left", m, i), k.css({ transform: "translateZ(-" + i.depth.active + "px)" }), t.css({ transform: "rotateY(0deg) translateZ(" + i.depth.active + "px)" }), m.addClass(x.animating).css({ left: i.origin + "px", transform: "rotateY(-90deg) translateZ(" + i.depth.next + "px)" });
  12995. }, right: function right() {
  12996. var e = t.outerWidth(!0),
  12997. n = m.outerWidth(!0),
  12998. i = { origin: (e - n) / 2, depth: { active: n / 2, next: e / 2 } };g.verbose("Setting the initial animation position as left", m, i), k.css({ transform: "translateZ(-" + i.depth.active + "px)" }), t.css({ transform: "rotateY(0deg) translateZ(" + i.depth.active + "px)" }), m.addClass(x.animating).css({ left: i.origin + "px", transform: "rotateY(90deg) translateZ(" + i.depth.next + "px)" });
  12999. }, behind: function behind() {
  13000. var e = t.outerWidth(!0),
  13001. n = m.outerWidth(!0),
  13002. i = { origin: (e - n) / 2, depth: { active: n / 2, next: e / 2 } };g.verbose("Setting the initial animation position as behind", m, i), t.css({ transform: "rotateY(0deg)" }), m.addClass(x.animating).css({ left: i.origin + "px", transform: "rotateY(-180deg)" });
  13003. } }, setting: function setting(t, n) {
  13004. if (g.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, h, t);else {
  13005. if (n === i) return h[t];e.isPlainObject(h[t]) ? e.extend(!0, h[t], n) : h[t] = n;
  13006. }
  13007. }, internal: function internal(t, n) {
  13008. if (e.isPlainObject(t)) e.extend(!0, g, t);else {
  13009. if (n === i) return g[t];g[t] = n;
  13010. }
  13011. }, debug: function debug() {
  13012. !h.silent && h.debug && (h.performance ? g.performance.log(arguments) : (g.debug = Function.prototype.bind.call(console.info, console, h.name + ":"), g.debug.apply(console, arguments)));
  13013. }, verbose: function verbose() {
  13014. !h.silent && h.verbose && h.debug && (h.performance ? g.performance.log(arguments) : (g.verbose = Function.prototype.bind.call(console.info, console, h.name + ":"), g.verbose.apply(console, arguments)));
  13015. }, error: function error() {
  13016. h.silent || (g.error = Function.prototype.bind.call(console.error, console, h.name + ":"), g.error.apply(console, arguments));
  13017. }, performance: { log: function log(e) {
  13018. var t, n;h.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: R, "Execution Time": n })), clearTimeout(g.performance.timer), g.performance.timer = setTimeout(g.performance.display, 500);
  13019. }, display: function display() {
  13020. var t = h.name + ":",
  13021. n = 0;s = !1, clearTimeout(g.performance.timer), e.each(l, function (e, t) {
  13022. n += t["Execution Time"];
  13023. }), t += " " + n + "ms", p && (t += " '" + p + "'"), r.length > 1 && (t += " (" + r.length + ")"), (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  13024. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  13025. }), console.groupEnd()), l = [];
  13026. } }, invoke: function invoke(t, n, o) {
  13027. var r,
  13028. s,
  13029. l,
  13030. c = P;return n = n || d, o = R || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  13031. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  13032. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  13033. }
  13034. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  13035. } }, u ? (P === i && g.initialize(), g.invoke(c)) : (P !== i && P.invoke("destroy"), g.initialize());
  13036. }), a !== i ? a : this;
  13037. }, e.fn.shape.settings = { name: "Shape", silent: !1, debug: !1, verbose: !1, jitter: 0, performance: !0, namespace: "shape", width: "initial", height: "initial", beforeChange: function beforeChange() {}, onChange: function onChange() {}, allowRepeats: !1, duration: !1, error: { side: "You tried to switch to a side that does not exist.", method: "The method you called is not defined" }, className: { animating: "animating", hidden: "hidden", loading: "loading", active: "active" }, selector: { sides: ".sides", side: ".side" } };
  13038. }(jQuery, window, document), function (e, t, n, i) {
  13039. "use strict";
  13040. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.sidebar = function (o) {
  13041. var a,
  13042. r = e(this),
  13043. s = e(t),
  13044. l = e(n),
  13045. c = e("html"),
  13046. u = e("head"),
  13047. d = r.selector || "",
  13048. f = new Date().getTime(),
  13049. m = [],
  13050. g = arguments[0],
  13051. p = "string" == typeof g,
  13052. h = [].slice.call(arguments, 1),
  13053. v = t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame || function (e) {
  13054. setTimeout(e, 0);
  13055. };return r.each(function () {
  13056. var r,
  13057. b,
  13058. y,
  13059. x,
  13060. C,
  13061. w,
  13062. S = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.sidebar.settings, o) : e.extend({}, e.fn.sidebar.settings),
  13063. k = S.selector,
  13064. T = S.className,
  13065. A = S.namespace,
  13066. R = S.regExp,
  13067. P = S.error,
  13068. E = "." + A,
  13069. F = "module-" + A,
  13070. O = e(this),
  13071. D = e(S.context),
  13072. q = O.children(k.sidebar),
  13073. j = (D.children(k.fixed), D.children(k.pusher)),
  13074. z = this,
  13075. I = O.data(F);w = { initialize: function initialize() {
  13076. w.debug("Initializing sidebar", o), w.create.id(), C = w.get.transitionEvent(), S.delaySetup ? v(w.setup.layout) : w.setup.layout(), v(function () {
  13077. w.setup.cache();
  13078. }), w.instantiate();
  13079. }, instantiate: function instantiate() {
  13080. w.verbose("Storing instance of module", w), I = w, O.data(F, w);
  13081. }, create: { id: function id() {
  13082. y = (Math.random().toString(16) + "000000000").substr(2, 8), b = "." + y, w.verbose("Creating unique id for element", y);
  13083. } }, destroy: function destroy() {
  13084. w.verbose("Destroying previous module for", O), O.off(E).removeData(F), w.is.ios() && w.remove.ios(), D.off(b), s.off(b), l.off(b);
  13085. }, event: { clickaway: function clickaway(e) {
  13086. var t = j.find(e.target).length > 0 || j.is(e.target),
  13087. n = D.is(e.target);t && (w.verbose("User clicked on dimmed page"), w.hide()), n && (w.verbose("User clicked on dimmable context (scaled out page)"), w.hide());
  13088. }, touch: function touch(e) {}, containScroll: function containScroll(e) {
  13089. z.scrollTop <= 0 && (z.scrollTop = 1), z.scrollTop + z.offsetHeight >= z.scrollHeight && (z.scrollTop = z.scrollHeight - z.offsetHeight - 1);
  13090. }, scroll: function scroll(t) {
  13091. 0 === e(t.target).closest(k.sidebar).length && t.preventDefault();
  13092. } }, bind: { clickaway: function clickaway() {
  13093. w.verbose("Adding clickaway events to context", D), S.closable && D.on("click" + b, w.event.clickaway).on("touchend" + b, w.event.clickaway);
  13094. }, scrollLock: function scrollLock() {
  13095. S.scrollLock && (w.debug("Disabling page scroll"), s.on("DOMMouseScroll" + b, w.event.scroll)), w.verbose("Adding events to contain sidebar scroll"), l.on("touchmove" + b, w.event.touch), O.on("scroll" + E, w.event.containScroll);
  13096. } }, unbind: { clickaway: function clickaway() {
  13097. w.verbose("Removing clickaway events from context", D), D.off(b);
  13098. }, scrollLock: function scrollLock() {
  13099. w.verbose("Removing scroll lock from page"), l.off(b), s.off(b), O.off("scroll" + E);
  13100. } }, add: { inlineCSS: function inlineCSS() {
  13101. var t,
  13102. n = w.cache.width || O.outerWidth(),
  13103. i = w.cache.height || O.outerHeight(),
  13104. o = w.is.rtl(),
  13105. a = w.get.direction(),
  13106. s = { left: n, right: -n, top: i, bottom: -i };o && (w.verbose("RTL detected, flipping widths"), s.left = -n, s.right = n), t = "<style>", "left" === a || "right" === a ? (w.debug("Adding CSS rules for animation distance", n), t += " .ui.visible." + a + ".sidebar ~ .fixed, .ui.visible." + a + ".sidebar ~ .pusher { -webkit-transform: translate3d(" + s[a] + "px, 0, 0); transform: translate3d(" + s[a] + "px, 0, 0); }") : "top" !== a && "bottom" != a || (t += " .ui.visible." + a + ".sidebar ~ .fixed, .ui.visible." + a + ".sidebar ~ .pusher { -webkit-transform: translate3d(0, " + s[a] + "px, 0); transform: translate3d(0, " + s[a] + "px, 0); }"), w.is.ie() && ("left" === a || "right" === a ? (w.debug("Adding CSS rules for animation distance", n), t += " body.pushable > .ui.visible." + a + ".sidebar ~ .pusher:after { -webkit-transform: translate3d(" + s[a] + "px, 0, 0); transform: translate3d(" + s[a] + "px, 0, 0); }") : "top" !== a && "bottom" != a || (t += " body.pushable > .ui.visible." + a + ".sidebar ~ .pusher:after { -webkit-transform: translate3d(0, " + s[a] + "px, 0); transform: translate3d(0, " + s[a] + "px, 0); }"), t += " body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after, body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after { -webkit-transform: translate3d(0px, 0, 0); transform: translate3d(0px, 0, 0); }"), r = e(t += "</style>").appendTo(u), w.debug("Adding sizing css to head", r);
  13107. } }, refresh: function refresh() {
  13108. w.verbose("Refreshing selector cache"), D = e(S.context), q = D.children(k.sidebar), j = D.children(k.pusher), D.children(k.fixed), w.clear.cache();
  13109. }, refreshSidebars: function refreshSidebars() {
  13110. w.verbose("Refreshing other sidebars"), q = D.children(k.sidebar);
  13111. }, repaint: function repaint() {
  13112. w.verbose("Forcing repaint event"), z.style.display = "none";z.offsetHeight;z.scrollTop = z.scrollTop, z.style.display = "";
  13113. }, setup: { cache: function cache() {
  13114. w.cache = { width: O.outerWidth(), height: O.outerHeight(), rtl: "rtl" == O.css("direction") };
  13115. }, layout: function layout() {
  13116. 0 === D.children(k.pusher).length && (w.debug("Adding wrapper element for sidebar"), w.error(P.pusher), j = e('<div class="pusher" />'), D.children().not(k.omitted).not(q).wrapAll(j), w.refresh()), 0 !== O.nextAll(k.pusher).length && O.nextAll(k.pusher)[0] === j[0] || (w.debug("Moved sidebar to correct parent element"), w.error(P.movedSidebar, z), O.detach().prependTo(D), w.refresh()), w.clear.cache(), w.set.pushable(), w.set.direction();
  13117. } }, attachEvents: function attachEvents(t, n) {
  13118. var i = e(t);n = e.isFunction(w[n]) ? w[n] : w.toggle, i.length > 0 ? (w.debug("Attaching sidebar events to element", t, n), i.on("click" + E, n)) : w.error(P.notFound, t);
  13119. }, show: function show(t) {
  13120. if (t = e.isFunction(t) ? t : function () {}, w.is.hidden()) {
  13121. if (w.refreshSidebars(), S.overlay && (w.error(P.overlay), S.transition = "overlay"), w.refresh(), w.othersActive()) if (w.debug("Other sidebars currently visible"), S.exclusive) {
  13122. if ("overlay" != S.transition) return void w.hideOthers(w.show);w.hideOthers();
  13123. } else S.transition = "overlay";w.pushPage(function () {
  13124. t.call(z), S.onShow.call(z);
  13125. }), S.onChange.call(z), S.onVisible.call(z);
  13126. } else w.debug("Sidebar is already visible");
  13127. }, hide: function hide(t) {
  13128. t = e.isFunction(t) ? t : function () {}, (w.is.visible() || w.is.animating()) && (w.debug("Hiding sidebar", t), w.refreshSidebars(), w.pullPage(function () {
  13129. t.call(z), S.onHidden.call(z);
  13130. }), S.onChange.call(z), S.onHide.call(z));
  13131. }, othersAnimating: function othersAnimating() {
  13132. return q.not(O).filter("." + T.animating).length > 0;
  13133. }, othersVisible: function othersVisible() {
  13134. return q.not(O).filter("." + T.visible).length > 0;
  13135. }, othersActive: function othersActive() {
  13136. return w.othersVisible() || w.othersAnimating();
  13137. }, hideOthers: function hideOthers(e) {
  13138. var t = q.not(O).filter("." + T.visible),
  13139. n = t.length,
  13140. i = 0;e = e || function () {}, t.sidebar("hide", function () {
  13141. ++i == n && e();
  13142. });
  13143. }, toggle: function toggle() {
  13144. w.verbose("Determining toggled direction"), w.is.hidden() ? w.show() : w.hide();
  13145. }, pushPage: function pushPage(t) {
  13146. var n,
  13147. i,
  13148. _o,
  13149. a = w.get.transition(),
  13150. r = "overlay" === a || w.othersActive() ? O : j;t = e.isFunction(t) ? t : function () {}, "scale down" == S.transition && w.scrollToTop(), w.set.transition(a), w.repaint(), n = function n() {
  13151. w.bind.clickaway(), w.add.inlineCSS(), w.set.animating(), w.set.visible();
  13152. }, i = function i() {
  13153. w.set.dimmed();
  13154. }, _o = function o(e) {
  13155. e.target == r[0] && (r.off(C + b, _o), w.remove.animating(), w.bind.scrollLock(), t.call(z));
  13156. }, r.off(C + b), r.on(C + b, _o), v(n), S.dimPage && !w.othersVisible() && v(i);
  13157. }, pullPage: function pullPage(t) {
  13158. var n,
  13159. _i,
  13160. o = w.get.transition(),
  13161. a = "overlay" == o || w.othersActive() ? O : j;t = e.isFunction(t) ? t : function () {}, w.verbose("Removing context push state", w.get.direction()), w.unbind.clickaway(), w.unbind.scrollLock(), n = function n() {
  13162. w.set.transition(o), w.set.animating(), w.remove.visible(), S.dimPage && !w.othersVisible() && j.removeClass(T.dimmed);
  13163. }, _i = function i(e) {
  13164. e.target == a[0] && (a.off(C + b, _i), w.remove.animating(), w.remove.transition(), w.remove.inlineCSS(), ("scale down" == o || S.returnScroll && w.is.mobile()) && w.scrollBack(), t.call(z));
  13165. }, a.off(C + b), a.on(C + b, _i), v(n);
  13166. }, scrollToTop: function scrollToTop() {
  13167. w.verbose("Scrolling to top of page to avoid animation issues"), x = e(t).scrollTop(), O.scrollTop(0), t.scrollTo(0, 0);
  13168. }, scrollBack: function scrollBack() {
  13169. w.verbose("Scrolling back to original page position"), t.scrollTo(0, x);
  13170. }, clear: { cache: function cache() {
  13171. w.verbose("Clearing cached dimensions"), w.cache = {};
  13172. } }, set: { ios: function ios() {
  13173. c.addClass(T.ios);
  13174. }, pushed: function pushed() {
  13175. D.addClass(T.pushed);
  13176. }, pushable: function pushable() {
  13177. D.addClass(T.pushable);
  13178. }, dimmed: function dimmed() {
  13179. j.addClass(T.dimmed);
  13180. }, active: function active() {
  13181. O.addClass(T.active);
  13182. }, animating: function animating() {
  13183. O.addClass(T.animating);
  13184. }, transition: function transition(e) {
  13185. e = e || w.get.transition(), O.addClass(e);
  13186. }, direction: function direction(e) {
  13187. e = e || w.get.direction(), O.addClass(T[e]);
  13188. }, visible: function visible() {
  13189. O.addClass(T.visible);
  13190. }, overlay: function overlay() {
  13191. O.addClass(T.overlay);
  13192. } }, remove: { inlineCSS: function inlineCSS() {
  13193. w.debug("Removing inline css styles", r), r && r.length > 0 && r.remove();
  13194. }, ios: function ios() {
  13195. c.removeClass(T.ios);
  13196. }, pushed: function pushed() {
  13197. D.removeClass(T.pushed);
  13198. }, pushable: function pushable() {
  13199. D.removeClass(T.pushable);
  13200. }, active: function active() {
  13201. O.removeClass(T.active);
  13202. }, animating: function animating() {
  13203. O.removeClass(T.animating);
  13204. }, transition: function transition(e) {
  13205. e = e || w.get.transition(), O.removeClass(e);
  13206. }, direction: function direction(e) {
  13207. e = e || w.get.direction(), O.removeClass(T[e]);
  13208. }, visible: function visible() {
  13209. O.removeClass(T.visible);
  13210. }, overlay: function overlay() {
  13211. O.removeClass(T.overlay);
  13212. } }, get: { direction: function direction() {
  13213. return O.hasClass(T.top) ? T.top : O.hasClass(T.right) ? T.right : O.hasClass(T.bottom) ? T.bottom : T.left;
  13214. }, transition: function transition() {
  13215. var e,
  13216. t = w.get.direction();return e = w.is.mobile() ? "auto" == S.mobileTransition ? S.defaultTransition.mobile[t] : S.mobileTransition : "auto" == S.transition ? S.defaultTransition.computer[t] : S.transition, w.verbose("Determined transition", e), e;
  13217. }, transitionEvent: function transitionEvent() {
  13218. var e,
  13219. t = n.createElement("element"),
  13220. o = { transition: "transitionend", OTransition: "oTransitionEnd", MozTransition: "transitionend", WebkitTransition: "webkitTransitionEnd" };for (e in o) {
  13221. if (t.style[e] !== i) return o[e];
  13222. }
  13223. } }, is: { ie: function ie() {
  13224. return !t.ActiveXObject && "ActiveXObject" in t || "ActiveXObject" in t;
  13225. }, ios: function ios() {
  13226. var e = navigator.userAgent,
  13227. t = e.match(R.ios),
  13228. n = e.match(R.mobileChrome);return !(!t || n) && (w.verbose("Browser was found to be iOS", e), !0);
  13229. }, mobile: function mobile() {
  13230. var e = navigator.userAgent;return e.match(R.mobile) ? (w.verbose("Browser was found to be mobile", e), !0) : (w.verbose("Browser is not mobile, using regular transition", e), !1);
  13231. }, hidden: function hidden() {
  13232. return !w.is.visible();
  13233. }, visible: function visible() {
  13234. return O.hasClass(T.visible);
  13235. }, open: function open() {
  13236. return w.is.visible();
  13237. }, closed: function closed() {
  13238. return w.is.hidden();
  13239. }, vertical: function vertical() {
  13240. return O.hasClass(T.top);
  13241. }, animating: function animating() {
  13242. return D.hasClass(T.animating);
  13243. }, rtl: function rtl() {
  13244. return w.cache.rtl === i && (w.cache.rtl = "rtl" == O.css("direction")), w.cache.rtl;
  13245. } }, setting: function setting(t, n) {
  13246. if (w.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, S, t);else {
  13247. if (n === i) return S[t];e.isPlainObject(S[t]) ? e.extend(!0, S[t], n) : S[t] = n;
  13248. }
  13249. }, internal: function internal(t, n) {
  13250. if (e.isPlainObject(t)) e.extend(!0, w, t);else {
  13251. if (n === i) return w[t];w[t] = n;
  13252. }
  13253. }, debug: function debug() {
  13254. !S.silent && S.debug && (S.performance ? w.performance.log(arguments) : (w.debug = Function.prototype.bind.call(console.info, console, S.name + ":"), w.debug.apply(console, arguments)));
  13255. }, verbose: function verbose() {
  13256. !S.silent && S.verbose && S.debug && (S.performance ? w.performance.log(arguments) : (w.verbose = Function.prototype.bind.call(console.info, console, S.name + ":"), w.verbose.apply(console, arguments)));
  13257. }, error: function error() {
  13258. S.silent || (w.error = Function.prototype.bind.call(console.error, console, S.name + ":"), w.error.apply(console, arguments));
  13259. }, performance: { log: function log(e) {
  13260. var t, n;S.performance && (n = (t = new Date().getTime()) - (f || t), f = t, m.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: z, "Execution Time": n })), clearTimeout(w.performance.timer), w.performance.timer = setTimeout(w.performance.display, 500);
  13261. }, display: function display() {
  13262. var t = S.name + ":",
  13263. n = 0;f = !1, clearTimeout(w.performance.timer), e.each(m, function (e, t) {
  13264. n += t["Execution Time"];
  13265. }), t += " " + n + "ms", d && (t += " '" + d + "'"), (console.group !== i || console.table !== i) && m.length > 0 && (console.groupCollapsed(t), console.table ? console.table(m) : e.each(m, function (e, t) {
  13266. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  13267. }), console.groupEnd()), m = [];
  13268. } }, invoke: function invoke(t, n, o) {
  13269. var r,
  13270. s,
  13271. l,
  13272. c = I;return n = n || h, o = z || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  13273. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  13274. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (w.error(P.method, t), !1);c = c[o];
  13275. }
  13276. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  13277. } }, p ? (I === i && w.initialize(), w.invoke(g)) : (I !== i && w.invoke("destroy"), w.initialize());
  13278. }), a !== i ? a : this;
  13279. }, e.fn.sidebar.settings = { name: "Sidebar", namespace: "sidebar", silent: !1, debug: !1, verbose: !1, performance: !0, transition: "auto", mobileTransition: "auto", defaultTransition: { computer: { left: "uncover", right: "uncover", top: "overlay", bottom: "overlay" }, mobile: { left: "uncover", right: "uncover", top: "overlay", bottom: "overlay" } }, context: "body", exclusive: !1, closable: !0, dimPage: !0, scrollLock: !1, returnScroll: !1, delaySetup: !1, duration: 500, onChange: function onChange() {}, onShow: function onShow() {}, onHide: function onHide() {}, onHidden: function onHidden() {}, onVisible: function onVisible() {}, className: { active: "active", animating: "animating", dimmed: "dimmed", ios: "ios", pushable: "pushable", pushed: "pushed", right: "right", top: "top", left: "left", bottom: "bottom", visible: "visible" }, selector: { fixed: ".fixed", omitted: "script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed", pusher: ".pusher", sidebar: ".ui.sidebar" }, regExp: { ios: /(iPad|iPhone|iPod)/g, mobileChrome: /(CriOS)/g, mobile: /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g }, error: { method: "The method you called is not defined.", pusher: "Had to add pusher element. For optimal performance make sure body content is inside a pusher element", movedSidebar: "Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag", overlay: "The overlay setting is no longer supported, use animation: overlay", notFound: "There were no elements that matched the specified selector" } };
  13280. }(jQuery, window, document), function (e, t, n, i) {
  13281. "use strict";
  13282. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.sticky = function (o) {
  13283. var a,
  13284. r = e(this),
  13285. s = r.selector || "",
  13286. l = new Date().getTime(),
  13287. c = [],
  13288. u = arguments[0],
  13289. d = "string" == typeof u,
  13290. f = [].slice.call(arguments, 1);return r.each(function () {
  13291. var r,
  13292. m,
  13293. g,
  13294. p,
  13295. h,
  13296. v = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.sticky.settings, o) : e.extend({}, e.fn.sticky.settings),
  13297. b = v.className,
  13298. y = v.namespace,
  13299. x = v.error,
  13300. C = "." + y,
  13301. w = "module-" + y,
  13302. S = e(this),
  13303. k = e(t),
  13304. T = e(v.scrollContext),
  13305. A = (S.selector, S.data(w)),
  13306. R = t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame || function (e) {
  13307. setTimeout(e, 0);
  13308. },
  13309. P = this;h = { initialize: function initialize() {
  13310. h.determineContainer(), h.determineContext(), h.verbose("Initializing sticky", v, r), h.save.positions(), h.checkErrors(), h.bind.events(), v.observeChanges && h.observeChanges(), h.instantiate();
  13311. }, instantiate: function instantiate() {
  13312. h.verbose("Storing instance of module", h), A = h, S.data(w, h);
  13313. }, destroy: function destroy() {
  13314. h.verbose("Destroying previous instance"), h.reset(), g && g.disconnect(), p && p.disconnect(), k.off("load" + C, h.event.load).off("resize" + C, h.event.resize), T.off("scrollchange" + C, h.event.scrollchange), S.removeData(w);
  13315. }, observeChanges: function observeChanges() {
  13316. "MutationObserver" in t && (g = new MutationObserver(h.event.documentChanged), p = new MutationObserver(h.event.changed), g.observe(n, { childList: !0, subtree: !0 }), p.observe(P, { childList: !0, subtree: !0 }), p.observe(m[0], { childList: !0, subtree: !0 }), h.debug("Setting up mutation observer", p));
  13317. }, determineContainer: function determineContainer() {
  13318. r = v.container ? e(v.container) : S.offsetParent();
  13319. }, determineContext: function determineContext() {
  13320. 0 !== (m = v.context ? e(v.context) : r).length || h.error(x.invalidContext, v.context, S);
  13321. }, checkErrors: function checkErrors() {
  13322. if (h.is.hidden() && h.error(x.visible, S), h.cache.element.height > h.cache.context.height) return h.reset(), void h.error(x.elementSize, S);
  13323. }, bind: { events: function events() {
  13324. k.on("load" + C, h.event.load).on("resize" + C, h.event.resize), T.off("scroll" + C).on("scroll" + C, h.event.scroll).on("scrollchange" + C, h.event.scrollchange);
  13325. } }, event: { changed: function changed(e) {
  13326. clearTimeout(h.timer), h.timer = setTimeout(function () {
  13327. h.verbose("DOM tree modified, updating sticky menu", e), h.refresh();
  13328. }, 100);
  13329. }, documentChanged: function documentChanged(t) {
  13330. [].forEach.call(t, function (t) {
  13331. t.removedNodes && [].forEach.call(t.removedNodes, function (t) {
  13332. (t == P || e(t).find(P).length > 0) && (h.debug("Element removed from DOM, tearing down events"), h.destroy());
  13333. });
  13334. });
  13335. }, load: function load() {
  13336. h.verbose("Page contents finished loading"), R(h.refresh);
  13337. }, resize: function resize() {
  13338. h.verbose("Window resized"), R(h.refresh);
  13339. }, scroll: function scroll() {
  13340. R(function () {
  13341. T.triggerHandler("scrollchange" + C, T.scrollTop());
  13342. });
  13343. }, scrollchange: function scrollchange(e, t) {
  13344. h.stick(t), v.onScroll.call(P);
  13345. } }, refresh: function refresh(e) {
  13346. h.reset(), v.context || h.determineContext(), e && h.determineContainer(), h.save.positions(), h.stick(), v.onReposition.call(P);
  13347. }, supports: { sticky: function sticky() {
  13348. var t = e("<div/>");t[0];return t.addClass(b.supported), t.css("position").match("sticky");
  13349. } }, save: { lastScroll: function lastScroll(e) {
  13350. h.lastScroll = e;
  13351. }, elementScroll: function elementScroll(e) {
  13352. h.elementScroll = e;
  13353. }, positions: function positions() {
  13354. var e = { height: T.height() },
  13355. t = { margin: { top: parseInt(S.css("margin-top"), 10), bottom: parseInt(S.css("margin-bottom"), 10) }, offset: S.offset(), width: S.outerWidth(), height: S.outerHeight() },
  13356. n = { offset: m.offset(), height: m.outerHeight() };r.outerHeight();h.is.standardScroll() || (h.debug("Non-standard scroll. Removing scroll offset from element offset"), e.top = T.scrollTop(), e.left = T.scrollLeft(), t.offset.top += e.top, n.offset.top += e.top, t.offset.left += e.left, n.offset.left += e.left), h.cache = { fits: t.height + v.offset <= e.height, sameHeight: t.height == n.height, scrollContext: { height: e.height }, element: { margin: t.margin, top: t.offset.top - t.margin.top, left: t.offset.left, width: t.width, height: t.height, bottom: t.offset.top + t.height }, context: { top: n.offset.top, height: n.height, bottom: n.offset.top + n.height } }, h.set.containerSize(), h.stick(), h.debug("Caching element positions", h.cache);
  13357. } }, get: { direction: function direction(e) {
  13358. var t = "down";return e = e || T.scrollTop(), h.lastScroll !== i && (h.lastScroll < e ? t = "down" : h.lastScroll > e && (t = "up")), t;
  13359. }, scrollChange: function scrollChange(e) {
  13360. return e = e || T.scrollTop(), h.lastScroll ? e - h.lastScroll : 0;
  13361. }, currentElementScroll: function currentElementScroll() {
  13362. return h.elementScroll ? h.elementScroll : h.is.top() ? Math.abs(parseInt(S.css("top"), 10)) || 0 : Math.abs(parseInt(S.css("bottom"), 10)) || 0;
  13363. }, elementScroll: function elementScroll(e) {
  13364. e = e || T.scrollTop();var t = h.cache.element,
  13365. n = h.cache.scrollContext,
  13366. i = h.get.scrollChange(e),
  13367. o = t.height - n.height + v.offset,
  13368. a = h.get.currentElementScroll(),
  13369. r = a + i;return a = h.cache.fits || r < 0 ? 0 : r > o ? o : r;
  13370. } }, remove: { lastScroll: function lastScroll() {
  13371. delete h.lastScroll;
  13372. }, elementScroll: function elementScroll(e) {
  13373. delete h.elementScroll;
  13374. }, minimumSize: function minimumSize() {
  13375. r.css("min-height", "");
  13376. }, offset: function offset() {
  13377. S.css("margin-top", "");
  13378. } }, set: { offset: function offset() {
  13379. h.verbose("Setting offset on element", v.offset), S.css("margin-top", v.offset);
  13380. }, containerSize: function containerSize() {
  13381. var e = r.get(0).tagName;"HTML" === e || "body" == e ? h.determineContainer() : Math.abs(r.outerHeight() - h.cache.context.height) > v.jitter && (h.debug("Context has padding, specifying exact height for container", h.cache.context.height), r.css({ height: h.cache.context.height }));
  13382. }, minimumSize: function minimumSize() {
  13383. var e = h.cache.element;r.css("min-height", e.height);
  13384. }, scroll: function scroll(e) {
  13385. h.debug("Setting scroll on element", e), h.elementScroll != e && (h.is.top() && S.css("bottom", "").css("top", -e), h.is.bottom() && S.css("top", "").css("bottom", e));
  13386. }, size: function size() {
  13387. 0 !== h.cache.element.height && 0 !== h.cache.element.width && (P.style.setProperty("width", h.cache.element.width + "px", "important"), P.style.setProperty("height", h.cache.element.height + "px", "important"));
  13388. } }, is: { standardScroll: function standardScroll() {
  13389. return T[0] == t;
  13390. }, top: function top() {
  13391. return S.hasClass(b.top);
  13392. }, bottom: function bottom() {
  13393. return S.hasClass(b.bottom);
  13394. }, initialPosition: function initialPosition() {
  13395. return !h.is.fixed() && !h.is.bound();
  13396. }, hidden: function hidden() {
  13397. return !S.is(":visible");
  13398. }, bound: function bound() {
  13399. return S.hasClass(b.bound);
  13400. }, fixed: function fixed() {
  13401. return S.hasClass(b.fixed);
  13402. } }, stick: function stick(e) {
  13403. var t = e || T.scrollTop(),
  13404. n = h.cache,
  13405. i = n.fits,
  13406. o = n.sameHeight,
  13407. a = n.element,
  13408. r = n.scrollContext,
  13409. s = n.context,
  13410. l = h.is.bottom() && v.pushing ? v.bottomOffset : v.offset,
  13411. c = (e = { top: t + l, bottom: t + l + r.height }, h.get.direction(e.top), i ? 0 : h.get.elementScroll(e.top)),
  13412. u = !i;0 !== a.height && !o && (h.is.initialPosition() ? e.top >= s.bottom ? (h.debug("Initial element position is bottom of container"), h.bindBottom()) : e.top > a.top && (a.height + e.top - c >= s.bottom ? (h.debug("Initial element position is bottom of container"), h.bindBottom()) : (h.debug("Initial element position is fixed"), h.fixTop())) : h.is.fixed() ? h.is.top() ? e.top <= a.top ? (h.debug("Fixed element reached top of container"), h.setInitialPosition()) : a.height + e.top - c >= s.bottom ? (h.debug("Fixed element reached bottom of container"), h.bindBottom()) : u && (h.set.scroll(c), h.save.lastScroll(e.top), h.save.elementScroll(c)) : h.is.bottom() && (e.bottom - a.height <= a.top ? (h.debug("Bottom fixed rail has reached top of container"), h.setInitialPosition()) : e.bottom >= s.bottom ? (h.debug("Bottom fixed rail has reached bottom of container"), h.bindBottom()) : u && (h.set.scroll(c), h.save.lastScroll(e.top), h.save.elementScroll(c))) : h.is.bottom() && (e.top <= a.top ? (h.debug("Jumped from bottom fixed to top fixed, most likely used home/end button"), h.setInitialPosition()) : v.pushing ? h.is.bound() && e.bottom <= s.bottom && (h.debug("Fixing bottom attached element to bottom of browser."), h.fixBottom()) : h.is.bound() && e.top <= s.bottom - a.height && (h.debug("Fixing bottom attached element to top of browser."), h.fixTop())));
  13413. }, bindTop: function bindTop() {
  13414. h.debug("Binding element to top of parent container"), h.remove.offset(), S.css({ left: "", top: "", marginBottom: "" }).removeClass(b.fixed).removeClass(b.bottom).addClass(b.bound).addClass(b.top), v.onTop.call(P), v.onUnstick.call(P);
  13415. }, bindBottom: function bindBottom() {
  13416. h.debug("Binding element to bottom of parent container"), h.remove.offset(), S.css({ left: "", top: "" }).removeClass(b.fixed).removeClass(b.top).addClass(b.bound).addClass(b.bottom), v.onBottom.call(P), v.onUnstick.call(P);
  13417. }, setInitialPosition: function setInitialPosition() {
  13418. h.debug("Returning to initial position"), h.unfix(), h.unbind();
  13419. }, fixTop: function fixTop() {
  13420. h.debug("Fixing element to top of page"), v.setSize && h.set.size(), h.set.minimumSize(), h.set.offset(), S.css({ left: h.cache.element.left, bottom: "", marginBottom: "" }).removeClass(b.bound).removeClass(b.bottom).addClass(b.fixed).addClass(b.top), v.onStick.call(P);
  13421. }, fixBottom: function fixBottom() {
  13422. h.debug("Sticking element to bottom of page"), v.setSize && h.set.size(), h.set.minimumSize(), h.set.offset(), S.css({ left: h.cache.element.left, bottom: "", marginBottom: "" }).removeClass(b.bound).removeClass(b.top).addClass(b.fixed).addClass(b.bottom), v.onStick.call(P);
  13423. }, unbind: function unbind() {
  13424. h.is.bound() && (h.debug("Removing container bound position on element"), h.remove.offset(), S.removeClass(b.bound).removeClass(b.top).removeClass(b.bottom));
  13425. }, unfix: function unfix() {
  13426. h.is.fixed() && (h.debug("Removing fixed position on element"), h.remove.minimumSize(), h.remove.offset(), S.removeClass(b.fixed).removeClass(b.top).removeClass(b.bottom), v.onUnstick.call(P));
  13427. }, reset: function reset() {
  13428. h.debug("Resetting elements position"), h.unbind(), h.unfix(), h.resetCSS(), h.remove.offset(), h.remove.lastScroll();
  13429. }, resetCSS: function resetCSS() {
  13430. S.css({ width: "", height: "" }), r.css({ height: "" });
  13431. }, setting: function setting(t, n) {
  13432. if (e.isPlainObject(t)) e.extend(!0, v, t);else {
  13433. if (n === i) return v[t];v[t] = n;
  13434. }
  13435. }, internal: function internal(t, n) {
  13436. if (e.isPlainObject(t)) e.extend(!0, h, t);else {
  13437. if (n === i) return h[t];h[t] = n;
  13438. }
  13439. }, debug: function debug() {
  13440. !v.silent && v.debug && (v.performance ? h.performance.log(arguments) : (h.debug = Function.prototype.bind.call(console.info, console, v.name + ":"), h.debug.apply(console, arguments)));
  13441. }, verbose: function verbose() {
  13442. !v.silent && v.verbose && v.debug && (v.performance ? h.performance.log(arguments) : (h.verbose = Function.prototype.bind.call(console.info, console, v.name + ":"), h.verbose.apply(console, arguments)));
  13443. }, error: function error() {
  13444. v.silent || (h.error = Function.prototype.bind.call(console.error, console, v.name + ":"), h.error.apply(console, arguments));
  13445. }, performance: { log: function log(e) {
  13446. var t, n;v.performance && (n = (t = new Date().getTime()) - (l || t), l = t, c.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: P, "Execution Time": n })), clearTimeout(h.performance.timer), h.performance.timer = setTimeout(h.performance.display, 0);
  13447. }, display: function display() {
  13448. var t = v.name + ":",
  13449. n = 0;l = !1, clearTimeout(h.performance.timer), e.each(c, function (e, t) {
  13450. n += t["Execution Time"];
  13451. }), t += " " + n + "ms", s && (t += " '" + s + "'"), (console.group !== i || console.table !== i) && c.length > 0 && (console.groupCollapsed(t), console.table ? console.table(c) : e.each(c, function (e, t) {
  13452. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  13453. }), console.groupEnd()), c = [];
  13454. } }, invoke: function invoke(t, n, o) {
  13455. var r,
  13456. s,
  13457. l,
  13458. c = A;return n = n || f, o = P || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  13459. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  13460. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  13461. }
  13462. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  13463. } }, d ? (A === i && h.initialize(), h.invoke(u)) : (A !== i && A.invoke("destroy"), h.initialize());
  13464. }), a !== i ? a : this;
  13465. }, e.fn.sticky.settings = { name: "Sticky", namespace: "sticky", silent: !1, debug: !1, verbose: !0, performance: !0, pushing: !1, context: !1, container: !1, scrollContext: t, offset: 0, bottomOffset: 0, jitter: 5, setSize: !0, observeChanges: !1, onReposition: function onReposition() {}, onScroll: function onScroll() {}, onStick: function onStick() {}, onUnstick: function onUnstick() {}, onTop: function onTop() {}, onBottom: function onBottom() {}, error: { container: "Sticky element must be inside a relative container", visible: "Element is hidden, you must call refresh after element becomes visible. Use silent setting to surpress this warning in production.", method: "The method you called is not defined.", invalidContext: "Context specified does not exist", elementSize: "Sticky element is larger than its container, cannot create sticky." }, className: { bound: "bound", fixed: "fixed", supported: "native", top: "top", bottom: "bottom" } };
  13466. }(jQuery, window, document), function (e, t, n, i) {
  13467. "use strict";
  13468. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.tab = function (o) {
  13469. var a,
  13470. r = e.isFunction(this) ? e(t) : e(this),
  13471. s = r.selector || "",
  13472. l = new Date().getTime(),
  13473. c = [],
  13474. u = arguments[0],
  13475. d = "string" == typeof u,
  13476. f = [].slice.call(arguments, 1),
  13477. m = !1;return r.each(function () {
  13478. var g,
  13479. p,
  13480. h,
  13481. v,
  13482. b,
  13483. y,
  13484. x = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.tab.settings, o) : e.extend({}, e.fn.tab.settings),
  13485. C = x.className,
  13486. w = x.metadata,
  13487. S = x.selector,
  13488. k = x.error,
  13489. T = "." + x.namespace,
  13490. A = "module-" + x.namespace,
  13491. R = e(this),
  13492. P = {},
  13493. E = !0,
  13494. F = 0,
  13495. O = this,
  13496. D = R.data(A);b = { initialize: function initialize() {
  13497. b.debug("Initializing tab menu item", R), b.fix.callbacks(), b.determineTabs(), b.debug("Determining tabs", x.context, p), x.auto && b.set.auto(), b.bind.events(), x.history && !m && (b.initializeHistory(), m = !0), b.instantiate();
  13498. }, instantiate: function instantiate() {
  13499. b.verbose("Storing instance of module", b), D = b, R.data(A, b);
  13500. }, destroy: function destroy() {
  13501. b.debug("Destroying tabs", R), R.removeData(A).off(T);
  13502. }, bind: { events: function events() {
  13503. e.isWindow(O) || (b.debug("Attaching tab activation events to element", R), R.on("click" + T, b.event.click));
  13504. } }, determineTabs: function determineTabs() {
  13505. var t;"parent" === x.context ? (R.closest(S.ui).length > 0 ? (t = R.closest(S.ui), b.verbose("Using closest UI element as parent", t)) : t = R, g = t.parent(), b.verbose("Determined parent element for creating context", g)) : x.context ? (g = e(x.context), b.verbose("Using selector for tab context", x.context, g)) : g = e("body"), x.childrenOnly ? (p = g.children(S.tabs), b.debug("Searching tab context children for tabs", g, p)) : (p = g.find(S.tabs), b.debug("Searching tab context for tabs", g, p));
  13506. }, fix: { callbacks: function callbacks() {
  13507. e.isPlainObject(o) && (o.onTabLoad || o.onTabInit) && (o.onTabLoad && (o.onLoad = o.onTabLoad, delete o.onTabLoad, b.error(k.legacyLoad, o.onLoad)), o.onTabInit && (o.onFirstLoad = o.onTabInit, delete o.onTabInit, b.error(k.legacyInit, o.onFirstLoad)), x = e.extend(!0, {}, e.fn.tab.settings, o));
  13508. } }, initializeHistory: function initializeHistory() {
  13509. if (b.debug("Initializing page state"), e.address === i) return b.error(k.state), !1;if ("state" == x.historyType) {
  13510. if (b.debug("Using HTML5 to manage state"), !1 === x.path) return b.error(k.path), !1;e.address.history(!0).state(x.path);
  13511. }e.address.bind("change", b.event.history.change);
  13512. }, event: { click: function click(t) {
  13513. var n = e(this).data(w.tab);n !== i ? (x.history ? (b.verbose("Updating page state", t), e.address.value(n)) : (b.verbose("Changing tab", t), b.changeTab(n)), t.preventDefault()) : b.debug("No tab specified");
  13514. }, history: { change: function change(t) {
  13515. var n = t.pathNames.join("/") || b.get.initialPath(),
  13516. o = x.templates.determineTitle(n) || !1;b.performance.display(), b.debug("History change event", n, t), y = t, n !== i && b.changeTab(n), o && e.address.title(o);
  13517. } } }, refresh: function refresh() {
  13518. h && (b.debug("Refreshing tab", h), b.changeTab(h));
  13519. }, cache: { read: function read(e) {
  13520. return e !== i && P[e];
  13521. }, add: function add(e, t) {
  13522. e = e || h, b.debug("Adding cached content for", e), P[e] = t;
  13523. }, remove: function remove(e) {
  13524. e = e || h, b.debug("Removing cached content for", e), delete P[e];
  13525. } }, set: { auto: function auto() {
  13526. var t = "string" == typeof x.path ? x.path.replace(/\/$/, "") + "/{$tab}" : "/{$tab}";b.verbose("Setting up automatic tab retrieval from server", t), e.isPlainObject(x.apiSettings) ? x.apiSettings.url = t : x.apiSettings = { url: t };
  13527. }, loading: function loading(e) {
  13528. var t = b.get.tabElement(e);t.hasClass(C.loading) || (b.verbose("Setting loading state for", t), t.addClass(C.loading).siblings(p).removeClass(C.active + " " + C.loading), t.length > 0 && x.onRequest.call(t[0], e));
  13529. }, state: function state(t) {
  13530. e.address.value(t);
  13531. } }, changeTab: function changeTab(n) {
  13532. var i = t.history && t.history.pushState && x.ignoreFirstLoad && E,
  13533. o = x.auto || e.isPlainObject(x.apiSettings),
  13534. a = o && !i ? b.utilities.pathToArray(n) : b.get.defaultPathArray(n);n = b.utilities.arrayToPath(a), e.each(a, function (t, r) {
  13535. var s,
  13536. l,
  13537. c,
  13538. u,
  13539. d = a.slice(0, t + 1),
  13540. f = b.utilities.arrayToPath(d),
  13541. m = b.is.tab(f),
  13542. p = t + 1 == a.length,
  13543. S = b.get.tabElement(f);if (b.verbose("Looking for tab", r), m) {
  13544. if (b.verbose("Tab was found", r), h = f, v = b.utilities.filterArray(a, d), p ? u = !0 : (l = a.slice(0, t + 2), c = b.utilities.arrayToPath(l), (u = !b.is.tab(c)) && b.verbose("Tab parameters found", l)), u && o) return i ? (b.debug("Ignoring remote content on first tab load", f), E = !1, b.cache.add(n, S.html()), b.activate.all(f), x.onFirstLoad.call(S[0], f, v, y), x.onLoad.call(S[0], f, v, y)) : (b.activate.navigation(f), b.fetch.content(f, n)), !1;b.debug("Opened local tab", f), b.activate.all(f), b.cache.read(f) || (b.cache.add(f, !0), b.debug("First time tab loaded calling tab init"), x.onFirstLoad.call(S[0], f, v, y)), x.onLoad.call(S[0], f, v, y);
  13545. } else {
  13546. if (-1 != n.search("/") || "" === n) return b.error(k.missingTab, R, g, f), !1;if (f = (s = e("#" + n + ', a[name="' + n + '"]')).closest("[data-tab]").data(w.tab), S = b.get.tabElement(f), s && s.length > 0 && f) return b.debug("Anchor link used, opening parent tab", S, s), S.hasClass(C.active) || setTimeout(function () {
  13547. b.scrollTo(s);
  13548. }, 0), b.activate.all(f), b.cache.read(f) || (b.cache.add(f, !0), b.debug("First time tab loaded calling tab init"), x.onFirstLoad.call(S[0], f, v, y)), x.onLoad.call(S[0], f, v, y), !1;
  13549. }
  13550. });
  13551. }, scrollTo: function scrollTo(t) {
  13552. var i = !!(t && t.length > 0) && t.offset().top;!1 !== i && (b.debug("Forcing scroll to an in-page link in a hidden tab", i, t), e(n).scrollTop(i));
  13553. }, update: { content: function content(t, n, o) {
  13554. var a = b.get.tabElement(t),
  13555. r = a[0];o = o !== i ? o : x.evaluateScripts, "string" == typeof x.cacheType && "dom" == x.cacheType.toLowerCase() && "string" != typeof n ? a.empty().append(e(n).clone(!0)) : o ? (b.debug("Updating HTML and evaluating inline scripts", t, n), a.html(n)) : (b.debug("Updating HTML", t, n), r.innerHTML = n);
  13556. } }, fetch: { content: function content(t, n) {
  13557. var o,
  13558. a,
  13559. r = b.get.tabElement(t),
  13560. s = { dataType: "html", encodeParameters: !1, on: "now", cache: x.alwaysRefresh, headers: { "X-Remote": !0 }, onSuccess: function onSuccess(e) {
  13561. "response" == x.cacheType && b.cache.add(n, e), b.update.content(t, e), t == h ? (b.debug("Content loaded", t), b.activate.tab(t)) : b.debug("Content loaded in background", t), x.onFirstLoad.call(r[0], t, v, y), x.onLoad.call(r[0], t, v, y), x.loadOnce ? b.cache.add(n, !0) : "string" == typeof x.cacheType && "dom" == x.cacheType.toLowerCase() && r.children().length > 0 ? setTimeout(function () {
  13562. var e = r.children().clone(!0);e = e.not("script"), b.cache.add(n, e);
  13563. }, 0) : b.cache.add(n, r.html());
  13564. }, urlData: { tab: n } },
  13565. l = r.api("get request") || !1,
  13566. c = l && "pending" === l.state();n = n || t, a = b.cache.read(n), x.cache && a ? (b.activate.tab(t), b.debug("Adding cached content", n), x.loadOnce || ("once" == x.evaluateScripts ? b.update.content(t, a, !1) : b.update.content(t, a)), x.onLoad.call(r[0], t, v, y)) : c ? (b.set.loading(t), b.debug("Content is already loading", n)) : e.api !== i ? (o = e.extend(!0, {}, x.apiSettings, s), b.debug("Retrieving remote content", n, o), b.set.loading(t), r.api(o)) : b.error(k.api);
  13567. } }, activate: { all: function all(e) {
  13568. b.activate.tab(e), b.activate.navigation(e);
  13569. }, tab: function tab(e) {
  13570. var t = b.get.tabElement(e),
  13571. n = "siblings" == x.deactivate ? t.siblings(p) : p.not(t),
  13572. i = t.hasClass(C.active);b.verbose("Showing tab content for", t), i || (t.addClass(C.active), n.removeClass(C.active + " " + C.loading), t.length > 0 && x.onVisible.call(t[0], e));
  13573. }, navigation: function navigation(e) {
  13574. var t = b.get.navElement(e),
  13575. n = "siblings" == x.deactivate ? t.siblings(r) : r.not(t),
  13576. i = t.hasClass(C.active);b.verbose("Activating tab navigation for", t, e), i || (t.addClass(C.active), n.removeClass(C.active + " " + C.loading));
  13577. } }, deactivate: { all: function all() {
  13578. b.deactivate.navigation(), b.deactivate.tabs();
  13579. }, navigation: function navigation() {
  13580. r.removeClass(C.active);
  13581. }, tabs: function tabs() {
  13582. p.removeClass(C.active + " " + C.loading);
  13583. } }, is: { tab: function tab(e) {
  13584. return e !== i && b.get.tabElement(e).length > 0;
  13585. } }, get: { initialPath: function initialPath() {
  13586. return r.eq(0).data(w.tab) || p.eq(0).data(w.tab);
  13587. }, path: function path() {
  13588. return e.address.value();
  13589. }, defaultPathArray: function defaultPathArray(e) {
  13590. return b.utilities.pathToArray(b.get.defaultPath(e));
  13591. }, defaultPath: function defaultPath(e) {
  13592. var t = r.filter("[data-" + w.tab + '^="' + e + '/"]').eq(0).data(w.tab) || !1;if (t) {
  13593. if (b.debug("Found default tab", t), F < x.maxDepth) return F++, b.get.defaultPath(t);b.error(k.recursion);
  13594. } else b.debug("No default tabs found for", e, p);return F = 0, e;
  13595. }, navElement: function navElement(e) {
  13596. return e = e || h, r.filter("[data-" + w.tab + '="' + e + '"]');
  13597. }, tabElement: function tabElement(e) {
  13598. var t, n, i, o;return e = e || h, i = b.utilities.pathToArray(e), o = b.utilities.last(i), t = p.filter("[data-" + w.tab + '="' + e + '"]'), n = p.filter("[data-" + w.tab + '="' + o + '"]'), t.length > 0 ? t : n;
  13599. }, tab: function tab() {
  13600. return h;
  13601. } }, utilities: { filterArray: function filterArray(t, n) {
  13602. return e.grep(t, function (t) {
  13603. return -1 == e.inArray(t, n);
  13604. });
  13605. }, last: function last(t) {
  13606. return !!e.isArray(t) && t[t.length - 1];
  13607. }, pathToArray: function pathToArray(e) {
  13608. return e === i && (e = h), "string" == typeof e ? e.split("/") : [e];
  13609. }, arrayToPath: function arrayToPath(t) {
  13610. return !!e.isArray(t) && t.join("/");
  13611. } }, setting: function setting(t, n) {
  13612. if (b.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, x, t);else {
  13613. if (n === i) return x[t];e.isPlainObject(x[t]) ? e.extend(!0, x[t], n) : x[t] = n;
  13614. }
  13615. }, internal: function internal(t, n) {
  13616. if (e.isPlainObject(t)) e.extend(!0, b, t);else {
  13617. if (n === i) return b[t];b[t] = n;
  13618. }
  13619. }, debug: function debug() {
  13620. !x.silent && x.debug && (x.performance ? b.performance.log(arguments) : (b.debug = Function.prototype.bind.call(console.info, console, x.name + ":"), b.debug.apply(console, arguments)));
  13621. }, verbose: function verbose() {
  13622. !x.silent && x.verbose && x.debug && (x.performance ? b.performance.log(arguments) : (b.verbose = Function.prototype.bind.call(console.info, console, x.name + ":"), b.verbose.apply(console, arguments)));
  13623. }, error: function error() {
  13624. x.silent || (b.error = Function.prototype.bind.call(console.error, console, x.name + ":"), b.error.apply(console, arguments));
  13625. }, performance: { log: function log(e) {
  13626. var t, n;x.performance && (n = (t = new Date().getTime()) - (l || t), l = t, c.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: O, "Execution Time": n })), clearTimeout(b.performance.timer), b.performance.timer = setTimeout(b.performance.display, 500);
  13627. }, display: function display() {
  13628. var t = x.name + ":",
  13629. n = 0;l = !1, clearTimeout(b.performance.timer), e.each(c, function (e, t) {
  13630. n += t["Execution Time"];
  13631. }), t += " " + n + "ms", s && (t += " '" + s + "'"), (console.group !== i || console.table !== i) && c.length > 0 && (console.groupCollapsed(t), console.table ? console.table(c) : e.each(c, function (e, t) {
  13632. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  13633. }), console.groupEnd()), c = [];
  13634. } }, invoke: function invoke(t, n, o) {
  13635. var r,
  13636. s,
  13637. l,
  13638. c = D;return n = n || f, o = O || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  13639. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  13640. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (b.error(k.method, t), !1);c = c[o];
  13641. }
  13642. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  13643. } }, d ? (D === i && b.initialize(), b.invoke(u)) : (D !== i && D.invoke("destroy"), b.initialize());
  13644. }), a !== i ? a : this;
  13645. }, e.tab = function () {
  13646. e(t).tab.apply(this, arguments);
  13647. }, e.fn.tab.settings = { name: "Tab", namespace: "tab", silent: !1, debug: !1, verbose: !1, performance: !0, auto: !1, history: !1, historyType: "hash", path: !1, context: !1, childrenOnly: !1, maxDepth: 25, deactivate: "siblings", alwaysRefresh: !1, cache: !0, loadOnce: !1, cacheType: "response", ignoreFirstLoad: !1, apiSettings: !1, evaluateScripts: "once", onFirstLoad: function onFirstLoad(e, t, n) {}, onLoad: function onLoad(e, t, n) {}, onVisible: function onVisible(e, t, n) {}, onRequest: function onRequest(e, t, n) {}, templates: { determineTitle: function determineTitle(e) {} }, error: { api: "You attempted to load content without API module", method: "The method you called is not defined", missingTab: "Activated tab cannot be found. Tabs are case-sensitive.", noContent: "The tab you specified is missing a content url.", path: "History enabled, but no path was specified", recursion: "Max recursive depth reached", legacyInit: "onTabInit has been renamed to onFirstLoad in 2.0, please adjust your code.", legacyLoad: "onTabLoad has been renamed to onLoad in 2.0. Please adjust your code", state: "History requires Asual's Address library <https://github.com/asual/jquery-address>" }, metadata: { tab: "tab", loaded: "loaded", promise: "promise" }, className: { loading: "loading", active: "active" }, selector: { tabs: ".ui.tab", ui: ".ui" } };
  13648. }(jQuery, window, document), function (e, t, n, i) {
  13649. "use strict";
  13650. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.transition = function () {
  13651. var o,
  13652. a = e(this),
  13653. r = a.selector || "",
  13654. s = new Date().getTime(),
  13655. l = [],
  13656. c = arguments,
  13657. u = c[0],
  13658. d = [].slice.call(arguments, 1),
  13659. f = "string" == typeof u;t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame;return a.each(function (t) {
  13660. var m,
  13661. g,
  13662. p,
  13663. h,
  13664. v,
  13665. b,
  13666. y,
  13667. x,
  13668. C,
  13669. w = e(this),
  13670. S = this;(C = { initialize: function initialize() {
  13671. m = C.get.settings.apply(S, c), h = m.className, p = m.error, v = m.metadata, x = "." + m.namespace, y = "module-" + m.namespace, g = w.data(y) || C, b = C.get.animationEndEvent(), f && (f = C.invoke(u)), !1 === f && (C.verbose("Converted arguments into settings object", m), m.interval ? C.delay(m.animate) : C.animate(), C.instantiate());
  13672. }, instantiate: function instantiate() {
  13673. C.verbose("Storing instance of module", C), g = C, w.data(y, g);
  13674. }, destroy: function destroy() {
  13675. C.verbose("Destroying previous module for", S), w.removeData(y);
  13676. }, refresh: function refresh() {
  13677. C.verbose("Refreshing display type on next animation"), delete C.displayType;
  13678. }, forceRepaint: function forceRepaint() {
  13679. C.verbose("Forcing element repaint");var e = w.parent(),
  13680. t = w.next();0 === t.length ? w.detach().appendTo(e) : w.detach().insertBefore(t);
  13681. }, repaint: function repaint() {
  13682. C.verbose("Repainting element");S.offsetWidth;
  13683. }, delay: function delay(e) {
  13684. var n,
  13685. o = C.get.animationDirection();o || (o = C.can.transition() ? C.get.direction() : "static"), e = e !== i ? e : m.interval, n = "auto" == m.reverse && o == h.outward || 1 == m.reverse ? (a.length - t) * m.interval : t * m.interval, C.debug("Delaying animation by", n), setTimeout(C.animate, n);
  13686. }, animate: function animate(e) {
  13687. if (m = e || m, !C.is.supported()) return C.error(p.support), !1;if (C.debug("Preparing animation", m.animation), C.is.animating()) {
  13688. if (m.queue) return !m.allowRepeats && C.has.direction() && C.is.occurring() && !0 !== C.queuing ? C.debug("Animation is currently occurring, preventing queueing same animation", m.animation) : C.queue(m.animation), !1;if (!m.allowRepeats && C.is.occurring()) return C.debug("Animation is already occurring, will not execute repeated animation", m.animation), !1;C.debug("New animation started, completing previous early", m.animation), g.complete();
  13689. }C.can.animate() ? C.set.animating(m.animation) : C.error(p.noAnimation, m.animation, S);
  13690. }, reset: function reset() {
  13691. C.debug("Resetting animation to beginning conditions"), C.remove.animationCallbacks(), C.restore.conditions(), C.remove.animating();
  13692. }, queue: function queue(e) {
  13693. C.debug("Queueing animation of", e), C.queuing = !0, w.one(b + ".queue" + x, function () {
  13694. C.queuing = !1, C.repaint(), C.animate.apply(this, m);
  13695. });
  13696. }, complete: function complete(e) {
  13697. C.debug("Animation complete", m.animation), C.remove.completeCallback(), C.remove.failSafe(), C.is.looping() || (C.is.outward() ? (C.verbose("Animation is outward, hiding element"), C.restore.conditions(), C.hide()) : C.is.inward() ? (C.verbose("Animation is outward, showing element"), C.restore.conditions(), C.show()) : (C.verbose("Static animation completed"), C.restore.conditions(), m.onComplete.call(S)));
  13698. }, force: { visible: function visible() {
  13699. var e = w.attr("style"),
  13700. t = C.get.userStyle(),
  13701. n = C.get.displayType(),
  13702. o = t + "display: " + n + " !important;",
  13703. a = w.css("display"),
  13704. r = e === i || "" === e;a !== n ? (C.verbose("Overriding default display to show element", n), w.attr("style", o)) : r && w.removeAttr("style");
  13705. }, hidden: function hidden() {
  13706. var e = w.attr("style"),
  13707. t = w.css("display"),
  13708. n = e === i || "" === e;"none" === t || C.is.hidden() ? n && w.removeAttr("style") : (C.verbose("Overriding default display to hide element"), w.css("display", "none"));
  13709. } }, has: { direction: function direction(t) {
  13710. var n = !1;return "string" == typeof (t = t || m.animation) && (t = t.split(" "), e.each(t, function (e, t) {
  13711. t !== h.inward && t !== h.outward || (n = !0);
  13712. })), n;
  13713. }, inlineDisplay: function inlineDisplay() {
  13714. var t = w.attr("style") || "";return e.isArray(t.match(/display.*?;/, ""));
  13715. } }, set: { animating: function animating(e) {
  13716. var t;C.remove.completeCallback(), e = e || m.animation, t = C.get.animationClass(e), C.save.animation(t), C.force.visible(), C.remove.hidden(), C.remove.direction(), C.start.animation(t);
  13717. }, duration: function duration(e, t) {
  13718. ((t = "number" == typeof (t = t || m.duration) ? t + "ms" : t) || 0 === t) && (C.verbose("Setting animation duration", t), w.css({ "animation-duration": t }));
  13719. }, direction: function direction(e) {
  13720. (e = e || C.get.direction()) == h.inward ? C.set.inward() : C.set.outward();
  13721. }, looping: function looping() {
  13722. C.debug("Transition set to loop"), w.addClass(h.looping);
  13723. }, hidden: function hidden() {
  13724. w.addClass(h.transition).addClass(h.hidden);
  13725. }, inward: function inward() {
  13726. C.debug("Setting direction to inward"), w.removeClass(h.outward).addClass(h.inward);
  13727. }, outward: function outward() {
  13728. C.debug("Setting direction to outward"), w.removeClass(h.inward).addClass(h.outward);
  13729. }, visible: function visible() {
  13730. w.addClass(h.transition).addClass(h.visible);
  13731. } }, start: { animation: function animation(e) {
  13732. e = e || C.get.animationClass(), C.debug("Starting tween", e), w.addClass(e).one(b + ".complete" + x, C.complete), m.useFailSafe && C.add.failSafe(), C.set.duration(m.duration), m.onStart.call(S);
  13733. } }, save: { animation: function animation(e) {
  13734. C.cache || (C.cache = {}), C.cache.animation = e;
  13735. }, displayType: function displayType(e) {
  13736. "none" !== e && w.data(v.displayType, e);
  13737. }, transitionExists: function transitionExists(t, n) {
  13738. e.fn.transition.exists[t] = n, C.verbose("Saving existence of transition", t, n);
  13739. } }, restore: { conditions: function conditions() {
  13740. var e = C.get.currentAnimation();e && (w.removeClass(e), C.verbose("Removing animation class", C.cache)), C.remove.duration();
  13741. } }, add: { failSafe: function failSafe() {
  13742. var e = C.get.duration();C.timer = setTimeout(function () {
  13743. w.triggerHandler(b);
  13744. }, e + m.failSafeDelay), C.verbose("Adding fail safe timer", C.timer);
  13745. } }, remove: { animating: function animating() {
  13746. w.removeClass(h.animating);
  13747. }, animationCallbacks: function animationCallbacks() {
  13748. C.remove.queueCallback(), C.remove.completeCallback();
  13749. }, queueCallback: function queueCallback() {
  13750. w.off(".queue" + x);
  13751. }, completeCallback: function completeCallback() {
  13752. w.off(".complete" + x);
  13753. }, display: function display() {
  13754. w.css("display", "");
  13755. }, direction: function direction() {
  13756. w.removeClass(h.inward).removeClass(h.outward);
  13757. }, duration: function duration() {
  13758. w.css("animation-duration", "");
  13759. }, failSafe: function failSafe() {
  13760. C.verbose("Removing fail safe timer", C.timer), C.timer && clearTimeout(C.timer);
  13761. }, hidden: function hidden() {
  13762. w.removeClass(h.hidden);
  13763. }, visible: function visible() {
  13764. w.removeClass(h.visible);
  13765. }, looping: function looping() {
  13766. C.debug("Transitions are no longer looping"), C.is.looping() && (C.reset(), w.removeClass(h.looping));
  13767. }, transition: function transition() {
  13768. w.removeClass(h.visible).removeClass(h.hidden);
  13769. } }, get: { settings: function settings(t, n, i) {
  13770. return "object" == (typeof t === "undefined" ? "undefined" : _typeof(t)) ? e.extend(!0, {}, e.fn.transition.settings, t) : "function" == typeof i ? e.extend({}, e.fn.transition.settings, { animation: t, onComplete: i, duration: n }) : "string" == typeof n || "number" == typeof n ? e.extend({}, e.fn.transition.settings, { animation: t, duration: n }) : "object" == (typeof n === "undefined" ? "undefined" : _typeof(n)) ? e.extend({}, e.fn.transition.settings, n, { animation: t }) : "function" == typeof n ? e.extend({}, e.fn.transition.settings, { animation: t, onComplete: n }) : e.extend({}, e.fn.transition.settings, { animation: t });
  13771. }, animationClass: function animationClass(e) {
  13772. var t = e || m.animation,
  13773. n = C.can.transition() && !C.has.direction() ? C.get.direction() + " " : "";return h.animating + " " + h.transition + " " + n + t;
  13774. }, currentAnimation: function currentAnimation() {
  13775. return !(!C.cache || C.cache.animation === i) && C.cache.animation;
  13776. }, currentDirection: function currentDirection() {
  13777. return C.is.inward() ? h.inward : h.outward;
  13778. }, direction: function direction() {
  13779. return C.is.hidden() || !C.is.visible() ? h.inward : h.outward;
  13780. }, animationDirection: function animationDirection(t) {
  13781. var n;return "string" == typeof (t = t || m.animation) && (t = t.split(" "), e.each(t, function (e, t) {
  13782. t === h.inward ? n = h.inward : t === h.outward && (n = h.outward);
  13783. })), n || !1;
  13784. }, duration: function duration(e) {
  13785. return !1 === (e = e || m.duration) && (e = w.css("animation-duration") || 0), "string" == typeof e ? e.indexOf("ms") > -1 ? parseFloat(e) : 1e3 * parseFloat(e) : e;
  13786. }, displayType: function displayType(e) {
  13787. return e = e === i || e, m.displayType ? m.displayType : (e && w.data(v.displayType) === i && C.can.transition(!0), w.data(v.displayType));
  13788. }, userStyle: function userStyle(e) {
  13789. return (e = e || w.attr("style") || "").replace(/display.*?;/, "");
  13790. }, transitionExists: function transitionExists(t) {
  13791. return e.fn.transition.exists[t];
  13792. }, animationStartEvent: function animationStartEvent() {
  13793. var e,
  13794. t = n.createElement("div"),
  13795. o = { animation: "animationstart", OAnimation: "oAnimationStart", MozAnimation: "mozAnimationStart", WebkitAnimation: "webkitAnimationStart" };for (e in o) {
  13796. if (t.style[e] !== i) return o[e];
  13797. }return !1;
  13798. }, animationEndEvent: function animationEndEvent() {
  13799. var e,
  13800. t = n.createElement("div"),
  13801. o = { animation: "animationend", OAnimation: "oAnimationEnd", MozAnimation: "mozAnimationEnd", WebkitAnimation: "webkitAnimationEnd" };for (e in o) {
  13802. if (t.style[e] !== i) return o[e];
  13803. }return !1;
  13804. } }, can: { transition: function transition(t) {
  13805. var n,
  13806. o,
  13807. a,
  13808. r,
  13809. s,
  13810. l,
  13811. c = m.animation,
  13812. u = C.get.transitionExists(c),
  13813. d = C.get.displayType(!1);if (u === i || t) {
  13814. if (C.verbose("Determining whether animation exists"), n = w.attr("class"), o = w.prop("tagName"), r = (a = e("<" + o + " />").addClass(n).insertAfter(w)).addClass(c).removeClass(h.inward).removeClass(h.outward).addClass(h.animating).addClass(h.transition).css("animationName"), s = a.addClass(h.inward).css("animationName"), d || (d = a.attr("class", n).removeAttr("style").removeClass(h.hidden).removeClass(h.visible).show().css("display"), C.verbose("Determining final display state", d), C.save.displayType(d)), a.remove(), r != s) C.debug("Direction exists for animation", c), l = !0;else {
  13815. if ("none" == r || !r) return void C.debug("No animation defined in css", c);C.debug("Static animation found", c, d), l = !1;
  13816. }C.save.transitionExists(c, l);
  13817. }return u !== i ? u : l;
  13818. }, animate: function animate() {
  13819. return C.can.transition() !== i;
  13820. } }, is: { animating: function animating() {
  13821. return w.hasClass(h.animating);
  13822. }, inward: function inward() {
  13823. return w.hasClass(h.inward);
  13824. }, outward: function outward() {
  13825. return w.hasClass(h.outward);
  13826. }, looping: function looping() {
  13827. return w.hasClass(h.looping);
  13828. }, occurring: function occurring(e) {
  13829. return e = "." + (e = e || m.animation).replace(" ", "."), w.filter(e).length > 0;
  13830. }, visible: function visible() {
  13831. return w.is(":visible");
  13832. }, hidden: function hidden() {
  13833. return "hidden" === w.css("visibility");
  13834. }, supported: function supported() {
  13835. return !1 !== b;
  13836. } }, hide: function hide() {
  13837. C.verbose("Hiding element"), C.is.animating() && C.reset(), S.blur(), C.remove.display(), C.remove.visible(), C.set.hidden(), C.force.hidden(), m.onHide.call(S), m.onComplete.call(S);
  13838. }, show: function show(e) {
  13839. C.verbose("Showing element", e), C.remove.hidden(), C.set.visible(), C.force.visible(), m.onShow.call(S), m.onComplete.call(S);
  13840. }, toggle: function toggle() {
  13841. C.is.visible() ? C.hide() : C.show();
  13842. }, stop: function stop() {
  13843. C.debug("Stopping current animation"), w.triggerHandler(b);
  13844. }, stopAll: function stopAll() {
  13845. C.debug("Stopping all animation"), C.remove.queueCallback(), w.triggerHandler(b);
  13846. }, clear: { queue: function queue() {
  13847. C.debug("Clearing animation queue"), C.remove.queueCallback();
  13848. } }, enable: function enable() {
  13849. C.verbose("Starting animation"), w.removeClass(h.disabled);
  13850. }, disable: function disable() {
  13851. C.debug("Stopping animation"), w.addClass(h.disabled);
  13852. }, setting: function setting(t, n) {
  13853. if (C.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, m, t);else {
  13854. if (n === i) return m[t];e.isPlainObject(m[t]) ? e.extend(!0, m[t], n) : m[t] = n;
  13855. }
  13856. }, internal: function internal(t, n) {
  13857. if (e.isPlainObject(t)) e.extend(!0, C, t);else {
  13858. if (n === i) return C[t];C[t] = n;
  13859. }
  13860. }, debug: function debug() {
  13861. !m.silent && m.debug && (m.performance ? C.performance.log(arguments) : (C.debug = Function.prototype.bind.call(console.info, console, m.name + ":"), C.debug.apply(console, arguments)));
  13862. }, verbose: function verbose() {
  13863. !m.silent && m.verbose && m.debug && (m.performance ? C.performance.log(arguments) : (C.verbose = Function.prototype.bind.call(console.info, console, m.name + ":"), C.verbose.apply(console, arguments)));
  13864. }, error: function error() {
  13865. m.silent || (C.error = Function.prototype.bind.call(console.error, console, m.name + ":"), C.error.apply(console, arguments));
  13866. }, performance: { log: function log(e) {
  13867. var t, n;m.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: S, "Execution Time": n })), clearTimeout(C.performance.timer), C.performance.timer = setTimeout(C.performance.display, 500);
  13868. }, display: function display() {
  13869. var t = m.name + ":",
  13870. n = 0;s = !1, clearTimeout(C.performance.timer), e.each(l, function (e, t) {
  13871. n += t["Execution Time"];
  13872. }), t += " " + n + "ms", r && (t += " '" + r + "'"), a.length > 1 && (t += " (" + a.length + ")"), (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  13873. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  13874. }), console.groupEnd()), l = [];
  13875. } }, invoke: function invoke(t, n, a) {
  13876. var r,
  13877. s,
  13878. l,
  13879. c = g;return n = n || d, a = S || a, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  13880. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  13881. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i && (s = c[o], !1);c = c[o];
  13882. }
  13883. })), e.isFunction(s) ? l = s.apply(a, n) : s !== i && (l = s), e.isArray(o) ? o.push(l) : o !== i ? o = [o, l] : l !== i && (o = l), s !== i && s;
  13884. } }).initialize();
  13885. }), o !== i ? o : this;
  13886. }, e.fn.transition.exists = {}, e.fn.transition.settings = { name: "Transition", silent: !1, debug: !1, verbose: !1, performance: !0, namespace: "transition", interval: 0, reverse: "auto", onStart: function onStart() {}, onComplete: function onComplete() {}, onShow: function onShow() {}, onHide: function onHide() {}, useFailSafe: !0, failSafeDelay: 100, allowRepeats: !1, displayType: !1, animation: "fade", duration: !1, queue: !0, metadata: { displayType: "display" }, className: { animating: "animating", disabled: "disabled", hidden: "hidden", inward: "in", loading: "loading", looping: "looping", outward: "out", transition: "transition", visible: "visible" }, error: { noAnimation: "Element is no longer attached to DOM. Unable to animate. Use silent setting to surpress this warning in production.", repeated: "That animation is already occurring, cancelling repeated animation", method: "The method you called is not defined", support: "This browser does not support CSS animations" } };
  13887. }(jQuery, window, document), function (e, t, n, i) {
  13888. "use strict";
  13889. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")();e.api = e.fn.api = function (n) {
  13890. var o,
  13891. a = e.isFunction(this) ? e(t) : e(this),
  13892. r = a.selector || "",
  13893. s = new Date().getTime(),
  13894. l = [],
  13895. c = arguments[0],
  13896. u = "string" == typeof c,
  13897. d = [].slice.call(arguments, 1);return a.each(function () {
  13898. var a,
  13899. f,
  13900. m,
  13901. g,
  13902. p,
  13903. h,
  13904. v = e.isPlainObject(n) ? e.extend(!0, {}, e.fn.api.settings, n) : e.extend({}, e.fn.api.settings),
  13905. b = v.namespace,
  13906. y = v.metadata,
  13907. x = v.selector,
  13908. C = v.error,
  13909. w = v.className,
  13910. S = "." + b,
  13911. k = "module-" + b,
  13912. T = e(this),
  13913. A = T.closest(x.form),
  13914. R = v.stateContext ? e(v.stateContext) : T,
  13915. P = this,
  13916. E = R[0],
  13917. F = T.data(k);h = { initialize: function initialize() {
  13918. u || h.bind.events(), h.instantiate();
  13919. }, instantiate: function instantiate() {
  13920. h.verbose("Storing instance of module", h), F = h, T.data(k, F);
  13921. }, destroy: function destroy() {
  13922. h.verbose("Destroying previous module for", P), T.removeData(k).off(S);
  13923. }, bind: { events: function events() {
  13924. var e = h.get.event();e ? (h.verbose("Attaching API events to element", e), T.on(e + S, h.event.trigger)) : "now" == v.on && (h.debug("Querying API endpoint immediately"), h.query());
  13925. } }, decode: { json: function json(e) {
  13926. if (e !== i && "string" == typeof e) try {
  13927. e = JSON.parse(e);
  13928. } catch (e) {}return e;
  13929. } }, read: { cachedResponse: function cachedResponse(e) {
  13930. var n;if (t.Storage !== i) return n = sessionStorage.getItem(e), h.debug("Using cached response", e, n), n = h.decode.json(n);h.error(C.noStorage);
  13931. } }, write: { cachedResponse: function cachedResponse(n, o) {
  13932. o && "" === o ? h.debug("Response empty, not caching", o) : t.Storage !== i ? (e.isPlainObject(o) && (o = JSON.stringify(o)), sessionStorage.setItem(n, o), h.verbose("Storing cached response for url", n, o)) : h.error(C.noStorage);
  13933. } }, query: function query() {
  13934. if (h.is.disabled()) h.debug("Element is disabled API request aborted");else {
  13935. if (h.is.loading()) {
  13936. if (!v.interruptRequests) return void h.debug("Cancelling request, previous request is still pending");h.debug("Interrupting previous request"), h.abort();
  13937. }if (v.defaultData && e.extend(!0, v.urlData, h.get.defaultData()), v.serializeForm && (v.data = h.add.formData(v.data)), !1 === (f = h.get.settings())) return h.cancelled = !0, void h.error(C.beforeSend);if (h.cancelled = !1, (m = h.get.templatedURL()) || h.is.mocked()) {
  13938. if ((m = h.add.urlData(m)) || h.is.mocked()) {
  13939. if (f.url = v.base + m, a = e.extend(!0, {}, v, { type: v.method || v.type, data: g, url: v.base + m, beforeSend: v.beforeXHR, success: function success() {}, failure: function failure() {}, complete: function complete() {} }), h.debug("Querying URL", a.url), h.verbose("Using AJAX settings", a), "local" === v.cache && h.read.cachedResponse(m)) return h.debug("Response returned from local cache"), h.request = h.create.request(), void h.request.resolveWith(E, [h.read.cachedResponse(m)]);v.throttle ? v.throttleFirstRequest || h.timer ? (h.debug("Throttling request", v.throttle), clearTimeout(h.timer), h.timer = setTimeout(function () {
  13940. h.timer && delete h.timer, h.debug("Sending throttled request", g, a.method), h.send.request();
  13941. }, v.throttle)) : (h.debug("Sending request", g, a.method), h.send.request(), h.timer = setTimeout(function () {}, v.throttle)) : (h.debug("Sending request", g, a.method), h.send.request());
  13942. }
  13943. } else h.error(C.missingURL);
  13944. }
  13945. }, should: { removeError: function removeError() {
  13946. return !0 === v.hideError || "auto" === v.hideError && !h.is.form();
  13947. } }, is: { disabled: function disabled() {
  13948. return T.filter(x.disabled).length > 0;
  13949. }, expectingJSON: function expectingJSON() {
  13950. return "json" === v.dataType || "jsonp" === v.dataType;
  13951. }, form: function form() {
  13952. return T.is("form") || R.is("form");
  13953. }, mocked: function mocked() {
  13954. return v.mockResponse || v.mockResponseAsync || v.response || v.responseAsync;
  13955. }, input: function input() {
  13956. return T.is("input");
  13957. }, loading: function loading() {
  13958. return !!h.request && "pending" == h.request.state();
  13959. }, abortedRequest: function abortedRequest(e) {
  13960. return e && e.readyState !== i && 0 === e.readyState ? (h.verbose("XHR request determined to be aborted"), !0) : (h.verbose("XHR request was not aborted"), !1);
  13961. }, validResponse: function validResponse(t) {
  13962. return h.is.expectingJSON() && e.isFunction(v.successTest) ? (h.debug("Checking JSON returned success", v.successTest, t), v.successTest(t) ? (h.debug("Response passed success test", t), !0) : (h.debug("Response failed success test", t), !1)) : (h.verbose("Response is not JSON, skipping validation", v.successTest, t), !0);
  13963. } }, was: { cancelled: function cancelled() {
  13964. return h.cancelled || !1;
  13965. }, succesful: function succesful() {
  13966. return h.request && "resolved" == h.request.state();
  13967. }, failure: function failure() {
  13968. return h.request && "rejected" == h.request.state();
  13969. }, complete: function complete() {
  13970. return h.request && ("resolved" == h.request.state() || "rejected" == h.request.state());
  13971. } }, add: { urlData: function urlData(t, n) {
  13972. var o, a;return t && (o = t.match(v.regExp.required), a = t.match(v.regExp.optional), n = n || v.urlData, o && (h.debug("Looking for required URL variables", o), e.each(o, function (o, a) {
  13973. var r = -1 !== a.indexOf("$") ? a.substr(2, a.length - 3) : a.substr(1, a.length - 2),
  13974. s = e.isPlainObject(n) && n[r] !== i ? n[r] : T.data(r) !== i ? T.data(r) : R.data(r) !== i ? R.data(r) : n[r];if (s === i) return h.error(C.requiredParameter, r, t), t = !1, !1;h.verbose("Found required variable", r, s), s = v.encodeParameters ? h.get.urlEncodedValue(s) : s, t = t.replace(a, s);
  13975. })), a && (h.debug("Looking for optional URL variables", o), e.each(a, function (o, a) {
  13976. var r = -1 !== a.indexOf("$") ? a.substr(3, a.length - 4) : a.substr(2, a.length - 3),
  13977. s = e.isPlainObject(n) && n[r] !== i ? n[r] : T.data(r) !== i ? T.data(r) : R.data(r) !== i ? R.data(r) : n[r];s !== i ? (h.verbose("Optional variable Found", r, s), t = t.replace(a, s)) : (h.verbose("Optional variable not found", r), t = -1 !== t.indexOf("/" + a) ? t.replace("/" + a, "") : t.replace(a, ""));
  13978. }))), t;
  13979. }, formData: function formData(t) {
  13980. var n = e.fn.serializeObject !== i,
  13981. o = n ? A.serializeObject() : A.serialize();return t = t || v.data, e.isPlainObject(t) ? n ? (h.debug("Extending existing data with form data", t, o), t = e.extend(!0, {}, t, o)) : (h.error(C.missingSerialize), h.debug("Cant extend data. Replacing data with form data", t, o), t = o) : (h.debug("Adding form data", o), t = o), t;
  13982. } }, send: { request: function request() {
  13983. h.set.loading(), h.request = h.create.request(), h.is.mocked() ? h.mockedXHR = h.create.mockedXHR() : h.xhr = h.create.xhr(), v.onRequest.call(E, h.request, h.xhr);
  13984. } }, event: { trigger: function trigger(e) {
  13985. h.query(), "submit" != e.type && "click" != e.type || e.preventDefault();
  13986. }, xhr: { always: function always() {}, done: function done(t, n, i) {
  13987. var o = this,
  13988. a = new Date().getTime() - p,
  13989. r = v.loadingDuration - a,
  13990. s = !!e.isFunction(v.onResponse) && (h.is.expectingJSON() ? v.onResponse.call(o, e.extend(!0, {}, t)) : v.onResponse.call(o, t));r = r > 0 ? r : 0, s && (h.debug("Modified API response in onResponse callback", v.onResponse, s, t), t = s), r > 0 && h.debug("Response completed early delaying state change by", r), setTimeout(function () {
  13991. h.is.validResponse(t) ? h.request.resolveWith(o, [t, i]) : h.request.rejectWith(o, [i, "invalid"]);
  13992. }, r);
  13993. }, fail: function fail(e, t, n) {
  13994. var i = this,
  13995. o = new Date().getTime() - p,
  13996. a = v.loadingDuration - o;(a = a > 0 ? a : 0) > 0 && h.debug("Response completed early delaying state change by", a), setTimeout(function () {
  13997. h.is.abortedRequest(e) ? h.request.rejectWith(i, [e, "aborted", n]) : h.request.rejectWith(i, [e, "error", t, n]);
  13998. }, a);
  13999. } }, request: { done: function done(e, t) {
  14000. h.debug("Successful API Response", e), "local" === v.cache && m && (h.write.cachedResponse(m, e), h.debug("Saving server response locally", h.cache)), v.onSuccess.call(E, e, T, t);
  14001. }, complete: function complete(e, t) {
  14002. var n, i;h.was.succesful() ? (i = e, n = t) : (n = e, i = h.get.responseFromXHR(n)), h.remove.loading(), v.onComplete.call(E, i, T, n);
  14003. }, fail: function fail(e, t, n) {
  14004. var o = h.get.responseFromXHR(e),
  14005. r = h.get.errorFromRequest(o, t, n);if ("aborted" == t) return h.debug("XHR Aborted (Most likely caused by page navigation or CORS Policy)", t, n), v.onAbort.call(E, t, T, e), !0;"invalid" == t ? h.debug("JSON did not pass success test. A server-side error has most likely occurred", o) : "error" == t && e !== i && (h.debug("XHR produced a server error", t, n), 200 != e.status && n !== i && "" !== n && h.error(C.statusMessage + n, a.url), v.onError.call(E, r, T, e)), v.errorDuration && "aborted" !== t && (h.debug("Adding error state"), h.set.error(), h.should.removeError() && setTimeout(h.remove.error, v.errorDuration)), h.debug("API Request failed", r, e), v.onFailure.call(E, o, T, e);
  14006. } } }, create: { request: function request() {
  14007. return e.Deferred().always(h.event.request.complete).done(h.event.request.done).fail(h.event.request.fail);
  14008. }, mockedXHR: function mockedXHR() {
  14009. var t,
  14010. n,
  14011. i,
  14012. o = v.mockResponse || v.response,
  14013. a = v.mockResponseAsync || v.responseAsync;return i = e.Deferred().always(h.event.xhr.complete).done(h.event.xhr.done).fail(h.event.xhr.fail), o ? (e.isFunction(o) ? (h.debug("Using specified synchronous callback", o), n = o.call(E, f)) : (h.debug("Using settings specified response", o), n = o), i.resolveWith(E, [n, !1, { responseText: n }])) : e.isFunction(a) && (t = function t(e) {
  14014. h.debug("Async callback returned response", e), e ? i.resolveWith(E, [e, !1, { responseText: e }]) : i.rejectWith(E, [{ responseText: e }, !1, !1]);
  14015. }, h.debug("Using specified async response callback", a), a.call(E, f, t)), i;
  14016. }, xhr: function xhr() {
  14017. var t;return t = e.ajax(a).always(h.event.xhr.always).done(h.event.xhr.done).fail(h.event.xhr.fail), h.verbose("Created server request", t, a), t;
  14018. } }, set: { error: function error() {
  14019. h.verbose("Adding error state to element", R), R.addClass(w.error);
  14020. }, loading: function loading() {
  14021. h.verbose("Adding loading state to element", R), R.addClass(w.loading), p = new Date().getTime();
  14022. } }, remove: { error: function error() {
  14023. h.verbose("Removing error state from element", R), R.removeClass(w.error);
  14024. }, loading: function loading() {
  14025. h.verbose("Removing loading state from element", R), R.removeClass(w.loading);
  14026. } }, get: { responseFromXHR: function responseFromXHR(t) {
  14027. return !!e.isPlainObject(t) && (h.is.expectingJSON() ? h.decode.json(t.responseText) : t.responseText);
  14028. }, errorFromRequest: function errorFromRequest(t, n, o) {
  14029. return e.isPlainObject(t) && t.error !== i ? t.error : v.error[n] !== i ? v.error[n] : o;
  14030. }, request: function request() {
  14031. return h.request || !1;
  14032. }, xhr: function xhr() {
  14033. return h.xhr || !1;
  14034. }, settings: function settings() {
  14035. var t;return (t = v.beforeSend.call(E, v)) && (t.success !== i && (h.debug("Legacy success callback detected", t), h.error(C.legacyParameters, t.success), t.onSuccess = t.success), t.failure !== i && (h.debug("Legacy failure callback detected", t), h.error(C.legacyParameters, t.failure), t.onFailure = t.failure), t.complete !== i && (h.debug("Legacy complete callback detected", t), h.error(C.legacyParameters, t.complete), t.onComplete = t.complete)), t === i && h.error(C.noReturnedValue), !1 === t ? t : t !== i ? e.extend(!0, {}, t) : e.extend(!0, {}, v);
  14036. }, urlEncodedValue: function urlEncodedValue(e) {
  14037. var n = t.decodeURIComponent(e),
  14038. i = t.encodeURIComponent(e);return n !== e ? (h.debug("URL value is already encoded, avoiding double encoding", e), e) : (h.verbose("Encoding value using encodeURIComponent", e, i), i);
  14039. }, defaultData: function defaultData() {
  14040. var t = {};return e.isWindow(P) || (h.is.input() ? t.value = T.val() : h.is.form() || (t.text = T.text())), t;
  14041. }, event: function event() {
  14042. return e.isWindow(P) || "now" == v.on ? (h.debug("API called without element, no events attached"), !1) : "auto" == v.on ? T.is("input") ? P.oninput !== i ? "input" : P.onpropertychange !== i ? "propertychange" : "keyup" : T.is("form") ? "submit" : "click" : v.on;
  14043. }, templatedURL: function templatedURL(e) {
  14044. if (e = e || T.data(y.action) || v.action || !1, m = T.data(y.url) || v.url || !1) return h.debug("Using specified url", m), m;if (e) {
  14045. if (h.debug("Looking up url for action", e, v.api), v.api[e] === i && !h.is.mocked()) return void h.error(C.missingAction, v.action, v.api);m = v.api[e];
  14046. } else h.is.form() && (m = T.attr("action") || R.attr("action") || !1, h.debug("No url or action specified, defaulting to form action", m));return m;
  14047. } }, abort: function abort() {
  14048. var e = h.get.xhr();e && "resolved" !== e.state() && (h.debug("Cancelling API request"), e.abort());
  14049. }, reset: function reset() {
  14050. h.remove.error(), h.remove.loading();
  14051. }, setting: function setting(t, n) {
  14052. if (h.debug("Changing setting", t, n), e.isPlainObject(t)) e.extend(!0, v, t);else {
  14053. if (n === i) return v[t];e.isPlainObject(v[t]) ? e.extend(!0, v[t], n) : v[t] = n;
  14054. }
  14055. }, internal: function internal(t, n) {
  14056. if (e.isPlainObject(t)) e.extend(!0, h, t);else {
  14057. if (n === i) return h[t];h[t] = n;
  14058. }
  14059. }, debug: function debug() {
  14060. !v.silent && v.debug && (v.performance ? h.performance.log(arguments) : (h.debug = Function.prototype.bind.call(console.info, console, v.name + ":"), h.debug.apply(console, arguments)));
  14061. }, verbose: function verbose() {
  14062. !v.silent && v.verbose && v.debug && (v.performance ? h.performance.log(arguments) : (h.verbose = Function.prototype.bind.call(console.info, console, v.name + ":"), h.verbose.apply(console, arguments)));
  14063. }, error: function error() {
  14064. v.silent || (h.error = Function.prototype.bind.call(console.error, console, v.name + ":"), h.error.apply(console, arguments));
  14065. }, performance: { log: function log(e) {
  14066. var t, n;v.performance && (n = (t = new Date().getTime()) - (s || t), s = t, l.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", "Execution Time": n })), clearTimeout(h.performance.timer), h.performance.timer = setTimeout(h.performance.display, 500);
  14067. }, display: function display() {
  14068. var t = v.name + ":",
  14069. n = 0;s = !1, clearTimeout(h.performance.timer), e.each(l, function (e, t) {
  14070. n += t["Execution Time"];
  14071. }), t += " " + n + "ms", r && (t += " '" + r + "'"), (console.group !== i || console.table !== i) && l.length > 0 && (console.groupCollapsed(t), console.table ? console.table(l) : e.each(l, function (e, t) {
  14072. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  14073. }), console.groupEnd()), l = [];
  14074. } }, invoke: function invoke(t, n, a) {
  14075. var r,
  14076. s,
  14077. l,
  14078. c = F;return n = n || d, a = P || a, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  14079. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  14080. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (h.error(C.method, t), !1);c = c[o];
  14081. }
  14082. })), e.isFunction(s) ? l = s.apply(a, n) : s !== i && (l = s), e.isArray(o) ? o.push(l) : o !== i ? o = [o, l] : l !== i && (o = l), s;
  14083. } }, u ? (F === i && h.initialize(), h.invoke(c)) : (F !== i && F.invoke("destroy"), h.initialize());
  14084. }), o !== i ? o : this;
  14085. }, e.api.settings = { name: "API", namespace: "api", debug: !1, verbose: !1, performance: !0, api: {}, cache: !0, interruptRequests: !0, on: "auto", stateContext: !1, loadingDuration: 0, hideError: "auto", errorDuration: 2e3, encodeParameters: !0, action: !1, url: !1, base: "", urlData: {}, defaultData: !0, serializeForm: !1, throttle: 0, throttleFirstRequest: !0, method: "get", data: {}, dataType: "json", mockResponse: !1, mockResponseAsync: !1, response: !1, responseAsync: !1, beforeSend: function beforeSend(e) {
  14086. return e;
  14087. }, beforeXHR: function beforeXHR(e) {}, onRequest: function onRequest(e, t) {}, onResponse: !1, onSuccess: function onSuccess(e, t) {}, onComplete: function onComplete(e, t) {}, onFailure: function onFailure(e, t) {}, onError: function onError(e, t) {}, onAbort: function onAbort(e, t) {}, successTest: !1, error: { beforeSend: "The before send function has aborted the request", error: "There was an error with your request", exitConditions: "API Request Aborted. Exit conditions met", JSONParse: "JSON could not be parsed during error handling", legacyParameters: "You are using legacy API success callback names", method: "The method you called is not defined", missingAction: "API action used but no url was defined", missingSerialize: "jquery-serialize-object is required to add form data to an existing data object", missingURL: "No URL specified for api event", noReturnedValue: "The beforeSend callback must return a settings object, beforeSend ignored.", noStorage: "Caching responses locally requires session storage", parseError: "There was an error parsing your request", requiredParameter: "Missing a required URL parameter: ", statusMessage: "Server gave an error: ", timeout: "Your request timed out" }, regExp: { required: /\{\$*[A-z0-9]+\}/g, optional: /\{\/\$*[A-z0-9]+\}/g }, className: { loading: "loading", error: "error" }, selector: { disabled: ".disabled", form: "form" }, metadata: { action: "action", url: "url" } };
  14088. }(jQuery, window, document), function (e, t, n, i) {
  14089. "use strict";
  14090. t = void 0 !== t && t.Math == Math ? t : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(), e.fn.visibility = function (o) {
  14091. var a,
  14092. r = e(this),
  14093. s = r.selector || "",
  14094. l = new Date().getTime(),
  14095. c = [],
  14096. u = arguments[0],
  14097. d = "string" == typeof u,
  14098. f = [].slice.call(arguments, 1),
  14099. m = r.length,
  14100. g = 0;return r.each(function () {
  14101. var r,
  14102. p,
  14103. h,
  14104. v,
  14105. b = e.isPlainObject(o) ? e.extend(!0, {}, e.fn.visibility.settings, o) : e.extend({}, e.fn.visibility.settings),
  14106. y = b.className,
  14107. x = b.namespace,
  14108. C = b.error,
  14109. w = b.metadata,
  14110. S = "." + x,
  14111. k = "module-" + x,
  14112. T = e(t),
  14113. A = e(this),
  14114. R = e(b.context),
  14115. P = (A.selector, A.data(k)),
  14116. E = t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || t.msRequestAnimationFrame || function (e) {
  14117. setTimeout(e, 0);
  14118. },
  14119. F = this,
  14120. O = !1;v = { initialize: function initialize() {
  14121. v.debug("Initializing", b), v.setup.cache(), v.should.trackChanges() && ("image" == b.type && v.setup.image(), "fixed" == b.type && v.setup.fixed(), b.observeChanges && v.observeChanges(), v.bind.events()), v.save.position(), v.is.visible() || v.error(C.visible, A), b.initialCheck && v.checkVisibility(), v.instantiate();
  14122. }, instantiate: function instantiate() {
  14123. v.debug("Storing instance", v), A.data(k, v), P = v;
  14124. }, destroy: function destroy() {
  14125. v.verbose("Destroying previous module"), h && h.disconnect(), p && p.disconnect(), T.off("load" + S, v.event.load).off("resize" + S, v.event.resize), R.off("scroll" + S, v.event.scroll).off("scrollchange" + S, v.event.scrollchange), "fixed" == b.type && (v.resetFixed(), v.remove.placeholder()), A.off(S).removeData(k);
  14126. }, observeChanges: function observeChanges() {
  14127. "MutationObserver" in t && (p = new MutationObserver(v.event.contextChanged), h = new MutationObserver(v.event.changed), p.observe(n, { childList: !0, subtree: !0 }), h.observe(F, { childList: !0, subtree: !0 }), v.debug("Setting up mutation observer", h));
  14128. }, bind: { events: function events() {
  14129. v.verbose("Binding visibility events to scroll and resize"), b.refreshOnLoad && T.on("load" + S, v.event.load), T.on("resize" + S, v.event.resize), R.off("scroll" + S).on("scroll" + S, v.event.scroll).on("scrollchange" + S, v.event.scrollchange);
  14130. } }, event: { changed: function changed(e) {
  14131. v.verbose("DOM tree modified, updating visibility calculations"), v.timer = setTimeout(function () {
  14132. v.verbose("DOM tree modified, updating sticky menu"), v.refresh();
  14133. }, 100);
  14134. }, contextChanged: function contextChanged(t) {
  14135. [].forEach.call(t, function (t) {
  14136. t.removedNodes && [].forEach.call(t.removedNodes, function (t) {
  14137. (t == F || e(t).find(F).length > 0) && (v.debug("Element removed from DOM, tearing down events"), v.destroy());
  14138. });
  14139. });
  14140. }, resize: function resize() {
  14141. v.debug("Window resized"), b.refreshOnResize && E(v.refresh);
  14142. }, load: function load() {
  14143. v.debug("Page finished loading"), E(v.refresh);
  14144. }, scroll: function scroll() {
  14145. b.throttle ? (clearTimeout(v.timer), v.timer = setTimeout(function () {
  14146. R.triggerHandler("scrollchange" + S, [R.scrollTop()]);
  14147. }, b.throttle)) : E(function () {
  14148. R.triggerHandler("scrollchange" + S, [R.scrollTop()]);
  14149. });
  14150. }, scrollchange: function scrollchange(e, t) {
  14151. v.checkVisibility(t);
  14152. } }, precache: function precache(t, i) {
  14153. t instanceof Array || (t = [t]);for (var o = t.length, a = 0, r = [], s = n.createElement("img"), l = function l() {
  14154. ++a >= t.length && e.isFunction(i) && i();
  14155. }; o--;) {
  14156. (s = n.createElement("img")).onload = l, s.onerror = l, s.src = t[o], r.push(s);
  14157. }
  14158. }, enableCallbacks: function enableCallbacks() {
  14159. v.debug("Allowing callbacks to occur"), O = !1;
  14160. }, disableCallbacks: function disableCallbacks() {
  14161. v.debug("Disabling all callbacks temporarily"), O = !0;
  14162. }, should: { trackChanges: function trackChanges() {
  14163. return d ? (v.debug("One time query, no need to bind events"), !1) : (v.debug("Callbacks being attached"), !0);
  14164. } }, setup: { cache: function cache() {
  14165. v.cache = { occurred: {}, screen: {}, element: {} };
  14166. }, image: function image() {
  14167. var e = A.data(w.src);e && (v.verbose("Lazy loading image", e), b.once = !0, b.observeChanges = !1, b.onOnScreen = function () {
  14168. v.debug("Image on screen", F), v.precache(e, function () {
  14169. v.set.image(e, function () {
  14170. ++g == m && b.onAllLoaded.call(this), b.onLoad.call(this);
  14171. });
  14172. });
  14173. });
  14174. }, fixed: function fixed() {
  14175. v.debug("Setting up fixed"), b.once = !1, b.observeChanges = !1, b.initialCheck = !0, b.refreshOnLoad = !0, o.transition || (b.transition = !1), v.create.placeholder(), v.debug("Added placeholder", r), b.onTopPassed = function () {
  14176. v.debug("Element passed, adding fixed position", A), v.show.placeholder(), v.set.fixed(), b.transition && e.fn.transition !== i && A.transition(b.transition, b.duration);
  14177. }, b.onTopPassedReverse = function () {
  14178. v.debug("Element returned to position, removing fixed", A), v.hide.placeholder(), v.remove.fixed();
  14179. };
  14180. } }, create: { placeholder: function placeholder() {
  14181. v.verbose("Creating fixed position placeholder"), r = A.clone(!1).css("display", "none").addClass(y.placeholder).insertAfter(A);
  14182. } }, show: { placeholder: function placeholder() {
  14183. v.verbose("Showing placeholder"), r.css("display", "block").css("visibility", "hidden");
  14184. } }, hide: { placeholder: function placeholder() {
  14185. v.verbose("Hiding placeholder"), r.css("display", "none").css("visibility", "");
  14186. } }, set: { fixed: function fixed() {
  14187. v.verbose("Setting element to fixed position"), A.addClass(y.fixed).css({ position: "fixed", top: b.offset + "px", left: "auto", zIndex: b.zIndex }), b.onFixed.call(F);
  14188. }, image: function image(t, n) {
  14189. if (A.attr("src", t), b.transition) {
  14190. if (e.fn.transition !== i) {
  14191. if (A.hasClass(y.visible)) return void v.debug("Transition already occurred on this image, skipping animation");A.transition(b.transition, b.duration, n);
  14192. } else A.fadeIn(b.duration, n);
  14193. } else A.show();
  14194. } }, is: { onScreen: function onScreen() {
  14195. return v.get.elementCalculations().onScreen;
  14196. }, offScreen: function offScreen() {
  14197. return v.get.elementCalculations().offScreen;
  14198. }, visible: function visible() {
  14199. return !(!v.cache || !v.cache.element) && !(0 === v.cache.element.width && 0 === v.cache.element.offset.top);
  14200. }, verticallyScrollableContext: function verticallyScrollableContext() {
  14201. var e = R.get(0) !== t && R.css("overflow-y");return "auto" == e || "scroll" == e;
  14202. }, horizontallyScrollableContext: function horizontallyScrollableContext() {
  14203. var e = R.get(0) !== t && R.css("overflow-x");return "auto" == e || "scroll" == e;
  14204. } }, refresh: function refresh() {
  14205. v.debug("Refreshing constants (width/height)"), "fixed" == b.type && v.resetFixed(), v.reset(), v.save.position(), b.checkOnRefresh && v.checkVisibility(), b.onRefresh.call(F);
  14206. }, resetFixed: function resetFixed() {
  14207. v.remove.fixed(), v.remove.occurred();
  14208. }, reset: function reset() {
  14209. v.verbose("Resetting all cached values"), e.isPlainObject(v.cache) && (v.cache.screen = {}, v.cache.element = {});
  14210. }, checkVisibility: function checkVisibility(e) {
  14211. v.verbose("Checking visibility of element", v.cache.element), !O && v.is.visible() && (v.save.scroll(e), v.save.calculations(), v.passed(), v.passingReverse(), v.topVisibleReverse(), v.bottomVisibleReverse(), v.topPassedReverse(), v.bottomPassedReverse(), v.onScreen(), v.offScreen(), v.passing(), v.topVisible(), v.bottomVisible(), v.topPassed(), v.bottomPassed(), b.onUpdate && b.onUpdate.call(F, v.get.elementCalculations()));
  14212. }, passed: function passed(t, n) {
  14213. var o = v.get.elementCalculations();if (t && n) b.onPassed[t] = n;else {
  14214. if (t !== i) return v.get.pixelsPassed(t) > o.pixelsPassed;o.passing && e.each(b.onPassed, function (e, t) {
  14215. o.bottomVisible || o.pixelsPassed > v.get.pixelsPassed(e) ? v.execute(t, e) : b.once || v.remove.occurred(t);
  14216. });
  14217. }
  14218. }, onScreen: function onScreen(e) {
  14219. var t = v.get.elementCalculations(),
  14220. n = e || b.onOnScreen,
  14221. o = "onScreen";if (e && (v.debug("Adding callback for onScreen", e), b.onOnScreen = e), t.onScreen ? v.execute(n, o) : b.once || v.remove.occurred(o), e !== i) return t.onOnScreen;
  14222. }, offScreen: function offScreen(e) {
  14223. var t = v.get.elementCalculations(),
  14224. n = e || b.onOffScreen,
  14225. o = "offScreen";if (e && (v.debug("Adding callback for offScreen", e), b.onOffScreen = e), t.offScreen ? v.execute(n, o) : b.once || v.remove.occurred(o), e !== i) return t.onOffScreen;
  14226. }, passing: function passing(e) {
  14227. var t = v.get.elementCalculations(),
  14228. n = e || b.onPassing,
  14229. o = "passing";if (e && (v.debug("Adding callback for passing", e), b.onPassing = e), t.passing ? v.execute(n, o) : b.once || v.remove.occurred(o), e !== i) return t.passing;
  14230. }, topVisible: function topVisible(e) {
  14231. var t = v.get.elementCalculations(),
  14232. n = e || b.onTopVisible,
  14233. o = "topVisible";if (e && (v.debug("Adding callback for top visible", e), b.onTopVisible = e), t.topVisible ? v.execute(n, o) : b.once || v.remove.occurred(o), e === i) return t.topVisible;
  14234. }, bottomVisible: function bottomVisible(e) {
  14235. var t = v.get.elementCalculations(),
  14236. n = e || b.onBottomVisible,
  14237. o = "bottomVisible";if (e && (v.debug("Adding callback for bottom visible", e), b.onBottomVisible = e), t.bottomVisible ? v.execute(n, o) : b.once || v.remove.occurred(o), e === i) return t.bottomVisible;
  14238. }, topPassed: function topPassed(e) {
  14239. var t = v.get.elementCalculations(),
  14240. n = e || b.onTopPassed,
  14241. o = "topPassed";if (e && (v.debug("Adding callback for top passed", e), b.onTopPassed = e), t.topPassed ? v.execute(n, o) : b.once || v.remove.occurred(o), e === i) return t.topPassed;
  14242. }, bottomPassed: function bottomPassed(e) {
  14243. var t = v.get.elementCalculations(),
  14244. n = e || b.onBottomPassed,
  14245. o = "bottomPassed";if (e && (v.debug("Adding callback for bottom passed", e), b.onBottomPassed = e), t.bottomPassed ? v.execute(n, o) : b.once || v.remove.occurred(o), e === i) return t.bottomPassed;
  14246. }, passingReverse: function passingReverse(e) {
  14247. var t = v.get.elementCalculations(),
  14248. n = e || b.onPassingReverse,
  14249. o = "passingReverse";if (e && (v.debug("Adding callback for passing reverse", e), b.onPassingReverse = e), t.passing ? b.once || v.remove.occurred(o) : v.get.occurred("passing") && v.execute(n, o), e !== i) return !t.passing;
  14250. }, topVisibleReverse: function topVisibleReverse(e) {
  14251. var t = v.get.elementCalculations(),
  14252. n = e || b.onTopVisibleReverse,
  14253. o = "topVisibleReverse";if (e && (v.debug("Adding callback for top visible reverse", e), b.onTopVisibleReverse = e), t.topVisible ? b.once || v.remove.occurred(o) : v.get.occurred("topVisible") && v.execute(n, o), e === i) return !t.topVisible;
  14254. }, bottomVisibleReverse: function bottomVisibleReverse(e) {
  14255. var t = v.get.elementCalculations(),
  14256. n = e || b.onBottomVisibleReverse,
  14257. o = "bottomVisibleReverse";if (e && (v.debug("Adding callback for bottom visible reverse", e), b.onBottomVisibleReverse = e), t.bottomVisible ? b.once || v.remove.occurred(o) : v.get.occurred("bottomVisible") && v.execute(n, o), e === i) return !t.bottomVisible;
  14258. }, topPassedReverse: function topPassedReverse(e) {
  14259. var t = v.get.elementCalculations(),
  14260. n = e || b.onTopPassedReverse,
  14261. o = "topPassedReverse";if (e && (v.debug("Adding callback for top passed reverse", e), b.onTopPassedReverse = e), t.topPassed ? b.once || v.remove.occurred(o) : v.get.occurred("topPassed") && v.execute(n, o), e === i) return !t.onTopPassed;
  14262. }, bottomPassedReverse: function bottomPassedReverse(e) {
  14263. var t = v.get.elementCalculations(),
  14264. n = e || b.onBottomPassedReverse,
  14265. o = "bottomPassedReverse";if (e && (v.debug("Adding callback for bottom passed reverse", e), b.onBottomPassedReverse = e), t.bottomPassed ? b.once || v.remove.occurred(o) : v.get.occurred("bottomPassed") && v.execute(n, o), e === i) return !t.bottomPassed;
  14266. }, execute: function execute(e, t) {
  14267. var n = v.get.elementCalculations(),
  14268. i = v.get.screenCalculations();(e = e || !1) && (b.continuous ? (v.debug("Callback being called continuously", t, n), e.call(F, n, i)) : v.get.occurred(t) || (v.debug("Conditions met", t, n), e.call(F, n, i))), v.save.occurred(t);
  14269. }, remove: { fixed: function fixed() {
  14270. v.debug("Removing fixed position"), A.removeClass(y.fixed).css({ position: "", top: "", left: "", zIndex: "" }), b.onUnfixed.call(F);
  14271. }, placeholder: function placeholder() {
  14272. v.debug("Removing placeholder content"), r && r.remove();
  14273. }, occurred: function occurred(e) {
  14274. if (e) {
  14275. var t = v.cache.occurred;t[e] !== i && !0 === t[e] && (v.debug("Callback can now be called again", e), v.cache.occurred[e] = !1);
  14276. } else v.cache.occurred = {};
  14277. } }, save: { calculations: function calculations() {
  14278. v.verbose("Saving all calculations necessary to determine positioning"), v.save.direction(), v.save.screenCalculations(), v.save.elementCalculations();
  14279. }, occurred: function occurred(e) {
  14280. e && (v.cache.occurred[e] !== i && !0 === v.cache.occurred[e] || (v.verbose("Saving callback occurred", e), v.cache.occurred[e] = !0));
  14281. }, scroll: function scroll(e) {
  14282. e = e + b.offset || R.scrollTop() + b.offset, v.cache.scroll = e;
  14283. }, direction: function direction() {
  14284. var e,
  14285. t = v.get.scroll(),
  14286. n = v.get.lastScroll();return e = t > n && n ? "down" : t < n && n ? "up" : "static", v.cache.direction = e, v.cache.direction;
  14287. }, elementPosition: function elementPosition() {
  14288. var e = v.cache.element,
  14289. t = v.get.screenSize();return v.verbose("Saving element position"), e.fits = e.height < t.height, e.offset = A.offset(), e.width = A.outerWidth(), e.height = A.outerHeight(), v.is.verticallyScrollableContext() && (e.offset.top += R.scrollTop() - R.offset().top), v.is.horizontallyScrollableContext() && (e.offset.left += R.scrollLeft - R.offset().left), v.cache.element = e, e;
  14290. }, elementCalculations: function elementCalculations() {
  14291. var e = v.get.screenCalculations(),
  14292. t = v.get.elementPosition();return b.includeMargin ? (t.margin = {}, t.margin.top = parseInt(A.css("margin-top"), 10), t.margin.bottom = parseInt(A.css("margin-bottom"), 10), t.top = t.offset.top - t.margin.top, t.bottom = t.offset.top + t.height + t.margin.bottom) : (t.top = t.offset.top, t.bottom = t.offset.top + t.height), t.topPassed = e.top >= t.top, t.bottomPassed = e.top >= t.bottom, t.topVisible = e.bottom >= t.top && !t.topPassed, t.bottomVisible = e.bottom >= t.bottom && !t.bottomPassed, t.pixelsPassed = 0, t.percentagePassed = 0, t.onScreen = (t.topVisible || t.passing) && !t.bottomPassed, t.passing = t.topPassed && !t.bottomPassed, t.offScreen = !t.onScreen, t.passing && (t.pixelsPassed = e.top - t.top, t.percentagePassed = (e.top - t.top) / t.height), v.cache.element = t, v.verbose("Updated element calculations", t), t;
  14293. }, screenCalculations: function screenCalculations() {
  14294. var e = v.get.scroll();return v.save.direction(), v.cache.screen.top = e, v.cache.screen.bottom = e + v.cache.screen.height, v.cache.screen;
  14295. }, screenSize: function screenSize() {
  14296. v.verbose("Saving window position"), v.cache.screen = { height: R.height() };
  14297. }, position: function position() {
  14298. v.save.screenSize(), v.save.elementPosition();
  14299. } }, get: { pixelsPassed: function pixelsPassed(e) {
  14300. var t = v.get.elementCalculations();return e.search("%") > -1 ? t.height * (parseInt(e, 10) / 100) : parseInt(e, 10);
  14301. }, occurred: function occurred(e) {
  14302. return v.cache.occurred !== i && v.cache.occurred[e] || !1;
  14303. }, direction: function direction() {
  14304. return v.cache.direction === i && v.save.direction(), v.cache.direction;
  14305. }, elementPosition: function elementPosition() {
  14306. return v.cache.element === i && v.save.elementPosition(), v.cache.element;
  14307. }, elementCalculations: function elementCalculations() {
  14308. return v.cache.element === i && v.save.elementCalculations(), v.cache.element;
  14309. }, screenCalculations: function screenCalculations() {
  14310. return v.cache.screen === i && v.save.screenCalculations(), v.cache.screen;
  14311. }, screenSize: function screenSize() {
  14312. return v.cache.screen === i && v.save.screenSize(), v.cache.screen;
  14313. }, scroll: function scroll() {
  14314. return v.cache.scroll === i && v.save.scroll(), v.cache.scroll;
  14315. }, lastScroll: function lastScroll() {
  14316. return v.cache.screen === i ? (v.debug("First scroll event, no last scroll could be found"), !1) : v.cache.screen.top;
  14317. } }, setting: function setting(t, n) {
  14318. if (e.isPlainObject(t)) e.extend(!0, b, t);else {
  14319. if (n === i) return b[t];b[t] = n;
  14320. }
  14321. }, internal: function internal(t, n) {
  14322. if (e.isPlainObject(t)) e.extend(!0, v, t);else {
  14323. if (n === i) return v[t];v[t] = n;
  14324. }
  14325. }, debug: function debug() {
  14326. !b.silent && b.debug && (b.performance ? v.performance.log(arguments) : (v.debug = Function.prototype.bind.call(console.info, console, b.name + ":"), v.debug.apply(console, arguments)));
  14327. }, verbose: function verbose() {
  14328. !b.silent && b.verbose && b.debug && (b.performance ? v.performance.log(arguments) : (v.verbose = Function.prototype.bind.call(console.info, console, b.name + ":"), v.verbose.apply(console, arguments)));
  14329. }, error: function error() {
  14330. b.silent || (v.error = Function.prototype.bind.call(console.error, console, b.name + ":"), v.error.apply(console, arguments));
  14331. }, performance: { log: function log(e) {
  14332. var t, n;b.performance && (n = (t = new Date().getTime()) - (l || t), l = t, c.push({ Name: e[0], Arguments: [].slice.call(e, 1) || "", Element: F, "Execution Time": n })), clearTimeout(v.performance.timer), v.performance.timer = setTimeout(v.performance.display, 500);
  14333. }, display: function display() {
  14334. var t = b.name + ":",
  14335. n = 0;l = !1, clearTimeout(v.performance.timer), e.each(c, function (e, t) {
  14336. n += t["Execution Time"];
  14337. }), t += " " + n + "ms", s && (t += " '" + s + "'"), (console.group !== i || console.table !== i) && c.length > 0 && (console.groupCollapsed(t), console.table ? console.table(c) : e.each(c, function (e, t) {
  14338. console.log(t.Name + ": " + t["Execution Time"] + "ms");
  14339. }), console.groupEnd()), c = [];
  14340. } }, invoke: function invoke(t, n, o) {
  14341. var r,
  14342. s,
  14343. l,
  14344. c = P;return n = n || f, o = F || o, "string" == typeof t && c !== i && (t = t.split(/[\. ]/), r = t.length - 1, e.each(t, function (n, o) {
  14345. var a = n != r ? o + t[n + 1].charAt(0).toUpperCase() + t[n + 1].slice(1) : t;if (e.isPlainObject(c[a]) && n != r) c = c[a];else {
  14346. if (c[a] !== i) return s = c[a], !1;if (!e.isPlainObject(c[o]) || n == r) return c[o] !== i ? (s = c[o], !1) : (v.error(C.method, t), !1);c = c[o];
  14347. }
  14348. })), e.isFunction(s) ? l = s.apply(o, n) : s !== i && (l = s), e.isArray(a) ? a.push(l) : a !== i ? a = [a, l] : l !== i && (a = l), s;
  14349. } }, d ? (P === i && v.initialize(), P.save.scroll(), P.save.calculations(), v.invoke(u)) : (P !== i && P.invoke("destroy"), v.initialize());
  14350. }), a !== i ? a : this;
  14351. }, e.fn.visibility.settings = { name: "Visibility", namespace: "visibility", debug: !1, verbose: !1, performance: !0, observeChanges: !0, initialCheck: !0, refreshOnLoad: !0, refreshOnResize: !0, checkOnRefresh: !0, once: !0, continuous: !1, offset: 0, includeMargin: !1, context: t, throttle: !1, type: !1, zIndex: "10", transition: "fade in", duration: 1e3, onPassed: {}, onOnScreen: !1, onOffScreen: !1, onPassing: !1, onTopVisible: !1, onBottomVisible: !1, onTopPassed: !1, onBottomPassed: !1, onPassingReverse: !1, onTopVisibleReverse: !1, onBottomVisibleReverse: !1, onTopPassedReverse: !1, onBottomPassedReverse: !1, onLoad: function onLoad() {}, onAllLoaded: function onAllLoaded() {}, onFixed: function onFixed() {}, onUnfixed: function onUnfixed() {}, onUpdate: !1, onRefresh: function onRefresh() {}, metadata: { src: "src" }, className: { fixed: "fixed", placeholder: "placeholder", visible: "visible" }, error: { method: "The method you called is not defined.", visible: "Element is hidden, you must call refresh after element becomes visible" } };
  14352. }(jQuery, window, document);
  14353. /***/ }),
  14354. /***/ "./js/services/i18nHelper.js":
  14355. /*!***********************************!*\
  14356. !*** ./js/services/i18nHelper.js ***!
  14357. \***********************************/
  14358. /*! no static exports found */
  14359. /***/ (function(module, exports, __webpack_require__) {
  14360. "use strict";
  14361. Object.defineProperty(exports, "__esModule", {
  14362. value: true
  14363. });
  14364. exports.i18nHelper = undefined;
  14365. var _lineI18n = __webpack_require__(/*! line-i18n */ "./node_modules/line-i18n/dist/index.js");
  14366. var _lineI18n2 = _interopRequireDefault(_lineI18n);
  14367. var _localizedStringsService = __webpack_require__(/*! ./localizedStringsService */ "./js/services/localizedStringsService.js");
  14368. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14369. var StringTypes = _lineI18n2.default.StringTypes;
  14370. var i18nHelper = exports.i18nHelper = Object.freeze({
  14371. i18n: function i18n(identifier) {
  14372. var opts = identifier.split(':');
  14373. var type = opts[0].toLowerCase();
  14374. var id = opts[1];
  14375. if (StringTypes.ERROR === type) {
  14376. return _localizedStringsService.LocalizedStrings.getError(id);
  14377. } else if (StringTypes.MESSAGE === type) {
  14378. return _localizedStringsService.LocalizedStrings.getMessage(id);
  14379. } else if (StringTypes.UI === type) {
  14380. return _localizedStringsService.LocalizedStrings.getUI(id);
  14381. } else {
  14382. console.warn("A string has been passed to the i18n helper function that was not in the form type:id -> " + identifier);
  14383. return _localizedStringsService.LocalizedStrings.getString(identifier, type);
  14384. }
  14385. }
  14386. });
  14387. /***/ }),
  14388. /***/ "./js/services/languageService.js":
  14389. /*!****************************************!*\
  14390. !*** ./js/services/languageService.js ***!
  14391. \****************************************/
  14392. /*! no static exports found */
  14393. /***/ (function(module, exports, __webpack_require__) {
  14394. "use strict";
  14395. Object.defineProperty(exports, "__esModule", {
  14396. value: true
  14397. });
  14398. exports.LanguageService = undefined;
  14399. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14400. var _grammar = __webpack_require__(/*! ./../../grammar/ */ "./grammar/index.js");
  14401. var _grammar2 = _interopRequireDefault(_grammar);
  14402. var _lineI18n = __webpack_require__(/*! line-i18n */ "./node_modules/line-i18n/dist/index.js");
  14403. var _lineI18n2 = _interopRequireDefault(_lineI18n);
  14404. var _config = __webpack_require__(/*! ./../util/config */ "./js/util/config.js");
  14405. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14406. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14407. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  14408. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14409. var LanguageServiceExtended = function (_line_i18n$LanguageSe) {
  14410. _inherits(LanguageServiceExtended, _line_i18n$LanguageSe);
  14411. function LanguageServiceExtended() {
  14412. _classCallCheck(this, LanguageServiceExtended);
  14413. return _possibleConstructorReturn(this, (LanguageServiceExtended.__proto__ || Object.getPrototypeOf(LanguageServiceExtended)).call(this, typeof iLMparameters === 'undefined' ? _config.Config.default_lang : iLMparameters.lang));
  14414. }
  14415. _createClass(LanguageServiceExtended, [{
  14416. key: 'getCurrentLexer',
  14417. value: function getCurrentLexer() {
  14418. var langInfo = _grammar2.default[this.getLang()];
  14419. if (langInfo === null || langInfo === undefined) {
  14420. return _grammar2.default[this.getDefaultLang()].lexer;
  14421. } else {
  14422. return langInfo.lexer;
  14423. }
  14424. }
  14425. }, {
  14426. key: 'getCurrentLangFuncs',
  14427. value: function getCurrentLangFuncs() {
  14428. var langInfo = _grammar2.default[this.getLang()];
  14429. if (langInfo === null || langInfo === undefined) {
  14430. return _grammar2.default[this.getDefaultLang()].langFuncs;
  14431. } else {
  14432. return langInfo.langFuncs;
  14433. }
  14434. }
  14435. }, {
  14436. key: 'getCurrentLangLibs',
  14437. value: function getCurrentLangLibs() {
  14438. var langInfo = _grammar2.default[this.getLang()];
  14439. if (langInfo === null || langInfo === undefined) {
  14440. return _grammar2.default[this.getDefaultLang()].langLibs;
  14441. }
  14442. return langInfo.langLibs;
  14443. }
  14444. }]);
  14445. return LanguageServiceExtended;
  14446. }(_lineI18n2.default.LanguageServiceNoLS);
  14447. var LanguageService = exports.LanguageService = new LanguageServiceExtended();
  14448. /***/ }),
  14449. /***/ "./js/services/localizedStringsService.js":
  14450. /*!************************************************!*\
  14451. !*** ./js/services/localizedStringsService.js ***!
  14452. \************************************************/
  14453. /*! no static exports found */
  14454. /***/ (function(module, exports, __webpack_require__) {
  14455. "use strict";
  14456. Object.defineProperty(exports, "__esModule", {
  14457. value: true
  14458. });
  14459. exports.LocalizedStrings = undefined;
  14460. var _languageService = __webpack_require__(/*! ./languageService */ "./js/services/languageService.js");
  14461. var _lineI18n = __webpack_require__(/*! line-i18n */ "./node_modules/line-i18n/dist/index.js");
  14462. var _lineI18n2 = _interopRequireDefault(_lineI18n);
  14463. var _i18n = __webpack_require__(/*! ./../../i18n */ "./i18n/index.js");
  14464. var _i18n2 = _interopRequireDefault(_i18n);
  14465. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14466. var LocalizedStrings = exports.LocalizedStrings = Object.freeze(new _lineI18n2.default.LocalizedStrings(_languageService.LanguageService, _i18n2.default, true));
  14467. /***/ }),
  14468. /***/ "./js/typeSystem/baseTypes.js":
  14469. /*!************************************!*\
  14470. !*** ./js/typeSystem/baseTypes.js ***!
  14471. \************************************/
  14472. /*! no static exports found */
  14473. /***/ (function(module, exports, __webpack_require__) {
  14474. "use strict";
  14475. Object.defineProperty(exports, "__esModule", {
  14476. value: true
  14477. });
  14478. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14479. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14480. var BaseType = function () {
  14481. function BaseType(name, ord) {
  14482. _classCallCheck(this, BaseType);
  14483. this.name = name;
  14484. this.ord = ord;
  14485. }
  14486. _createClass(BaseType, [{
  14487. key: "isCompatible",
  14488. value: function isCompatible(another) {
  14489. if (another instanceof BaseType) {
  14490. return this.name === another.name && this.ord === another.ord;
  14491. }
  14492. return false;
  14493. }
  14494. }, {
  14495. key: "value",
  14496. get: function get() {
  14497. return this.name;
  14498. }
  14499. }]);
  14500. return BaseType;
  14501. }();
  14502. // Base types names are the same as i18n ui type keys
  14503. var BaseTypes = exports.BaseTypes = Object.freeze({
  14504. INTEGER: new BaseType("integer", 0),
  14505. REAL: new BaseType("real", 1),
  14506. STRING: new BaseType("text", 2),
  14507. BOOLEAN: new BaseType("boolean", 3),
  14508. VOID: new BaseType("void", 4),
  14509. UNDEFINED: new BaseType("undefined", 5)
  14510. });
  14511. /***/ }),
  14512. /***/ "./js/typeSystem/compoundType.js":
  14513. /*!***************************************!*\
  14514. !*** ./js/typeSystem/compoundType.js ***!
  14515. \***************************************/
  14516. /*! no static exports found */
  14517. /***/ (function(module, exports, __webpack_require__) {
  14518. "use strict";
  14519. Object.defineProperty(exports, "__esModule", {
  14520. value: true
  14521. });
  14522. exports.CompoundType = undefined;
  14523. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14524. var _type = __webpack_require__(/*! ./type */ "./js/typeSystem/type.js");
  14525. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14526. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  14527. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14528. var CompoundType = exports.CompoundType = function (_Type) {
  14529. _inherits(CompoundType, _Type);
  14530. function CompoundType(type, dimensions) {
  14531. _classCallCheck(this, CompoundType);
  14532. var _this = _possibleConstructorReturn(this, (CompoundType.__proto__ || Object.getPrototypeOf(CompoundType)).call(this, null));
  14533. _this.innerType = type;
  14534. _this.dimensions = dimensions;
  14535. return _this;
  14536. }
  14537. _createClass(CompoundType, [{
  14538. key: "isCompatible",
  14539. value: function isCompatible(another) {
  14540. if (another instanceof CompoundType) {
  14541. if (this.dimensions !== another.dimensions) {
  14542. return false;
  14543. }
  14544. return this.innerType.isCompatible(another.innerType);
  14545. }
  14546. return false;
  14547. }
  14548. }, {
  14549. key: "stringInfo",
  14550. value: function stringInfo() {
  14551. var _this2 = this;
  14552. var list = this.innerType.stringInfo();
  14553. list.forEach(function (v) {
  14554. v.dim = _this2.dimensions;
  14555. });
  14556. return list;
  14557. }
  14558. }, {
  14559. key: "canAccept",
  14560. value: function canAccept(another) {
  14561. if (another instanceof CompoundType) {
  14562. return this.dimensions > another.dimensions && this.innerType.isCompatible(another.innerType);
  14563. } else {
  14564. return this.innerType.isCompatible(another);
  14565. }
  14566. }
  14567. }]);
  14568. return CompoundType;
  14569. }(_type.Type);
  14570. /***/ }),
  14571. /***/ "./js/typeSystem/multiType.js":
  14572. /*!************************************!*\
  14573. !*** ./js/typeSystem/multiType.js ***!
  14574. \************************************/
  14575. /*! no static exports found */
  14576. /***/ (function(module, exports, __webpack_require__) {
  14577. "use strict";
  14578. Object.defineProperty(exports, "__esModule", {
  14579. value: true
  14580. });
  14581. exports.MultiType = undefined;
  14582. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14583. var _type = __webpack_require__(/*! ./type */ "./js/typeSystem/type.js");
  14584. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14585. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  14586. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14587. var MultiType = exports.MultiType = function (_Type) {
  14588. _inherits(MultiType, _Type);
  14589. function MultiType(types) {
  14590. _classCallCheck(this, MultiType);
  14591. var _this = _possibleConstructorReturn(this, (MultiType.__proto__ || Object.getPrototypeOf(MultiType)).call(this, null));
  14592. _this.types = types;
  14593. return _this;
  14594. }
  14595. _createClass(MultiType, [{
  14596. key: "stringInfo",
  14597. value: function stringInfo() {
  14598. var list = [];
  14599. for (var i = 0; i < this.types.length; i++) {
  14600. var t = this.types[i];
  14601. list = list.concat(t.stringInfo());
  14602. }
  14603. return list;
  14604. }
  14605. }, {
  14606. key: "isCompatible",
  14607. value: function isCompatible(another) {
  14608. if (another instanceof _type.Type) {
  14609. for (var i = 0; i < this.types.length; i++) {
  14610. var t = this.types[i];
  14611. if (another.isCompatible(t)) {
  14612. return true;
  14613. }
  14614. }
  14615. }
  14616. return false;
  14617. }
  14618. }, {
  14619. key: "value",
  14620. get: function get() {
  14621. return null;
  14622. }
  14623. }, {
  14624. key: "ord",
  14625. get: function get() {
  14626. return null;
  14627. }
  14628. }]);
  14629. return MultiType;
  14630. }(_type.Type);
  14631. /***/ }),
  14632. /***/ "./js/typeSystem/parsers.js":
  14633. /*!**********************************!*\
  14634. !*** ./js/typeSystem/parsers.js ***!
  14635. \**********************************/
  14636. /*! no static exports found */
  14637. /***/ (function(module, exports, __webpack_require__) {
  14638. "use strict";
  14639. Object.defineProperty(exports, "__esModule", {
  14640. value: true
  14641. });
  14642. exports.toInt = toInt;
  14643. exports.toString = toString;
  14644. exports.toReal = toReal;
  14645. exports.toBool = toBool;
  14646. exports.convertToString = convertToString;
  14647. var _languageService = __webpack_require__(/*! ../services/languageService */ "./js/services/languageService.js");
  14648. var _types = __webpack_require__(/*! ./types */ "./js/typeSystem/types.js");
  14649. var _decimal = __webpack_require__(/*! decimal.js */ "./node_modules/decimal.js/decimal.js");
  14650. var _decimal2 = _interopRequireDefault(_decimal);
  14651. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14652. function toInt(str) {
  14653. return new _decimal2.default(str);
  14654. }
  14655. function toString(str) {
  14656. var value = str.replace(/^"/, '');
  14657. value = value.replace(/"$/, '');
  14658. value = value.replace(/\\b/g, "\b");
  14659. value = value.replace(/\\t/g, "\t");
  14660. value = value.replace(/\\n/g, "\n");
  14661. value = value.replace(/\\r/g, "\r");
  14662. value = value.replace(/\\\"/g, "\"");
  14663. value = value.replace(/\\\'/g, "\'");
  14664. value = value.replace(/\\\\/g, "\\");
  14665. return value;
  14666. }
  14667. function toReal(value) {
  14668. return new _decimal2.default(value);
  14669. }
  14670. function toBool(str) {
  14671. var val = "'" + str + "'";
  14672. var lexer = _languageService.LanguageService.getCurrentLexer();
  14673. var instance = new lexer(null);
  14674. if (instance.literalNames[lexer.RK_TRUE] === val) {
  14675. return true;
  14676. } else if (instance.literalNames[lexer.RK_FALSE] === val) {
  14677. return false;
  14678. } else {
  14679. // TODO: better error message
  14680. throw new Error(str + "not a valid boolean");
  14681. }
  14682. }
  14683. function convertBoolToString(bool) {
  14684. var lexer = _languageService.LanguageService.getCurrentLexer();
  14685. var instance = new lexer(null);
  14686. if (bool) {
  14687. return instance.literalNames[lexer.RK_TRUE];
  14688. } else {
  14689. return instance.literalNames[lexer.RK_FALSE];
  14690. }
  14691. }
  14692. function convertToString(value, type) {
  14693. switch (type.ord) {
  14694. case _types.Types.INTEGER.ord:
  14695. return value.toString();
  14696. case _types.Types.REAL.ord:
  14697. {
  14698. if (value.dp() <= 0) {
  14699. return value.toFixed(1);
  14700. } else {
  14701. return value.toNumber();
  14702. }
  14703. }
  14704. case _types.Types.BOOLEAN.ord:
  14705. return convertBoolToString(value);
  14706. default:
  14707. return value;
  14708. }
  14709. }
  14710. /***/ }),
  14711. /***/ "./js/typeSystem/type.js":
  14712. /*!*******************************!*\
  14713. !*** ./js/typeSystem/type.js ***!
  14714. \*******************************/
  14715. /*! no static exports found */
  14716. /***/ (function(module, exports, __webpack_require__) {
  14717. "use strict";
  14718. Object.defineProperty(exports, "__esModule", {
  14719. value: true
  14720. });
  14721. exports.Type = undefined;
  14722. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14723. var _config = __webpack_require__(/*! ../util/config */ "./js/util/config.js");
  14724. var _baseTypes = __webpack_require__(/*! ./baseTypes */ "./js/typeSystem/baseTypes.js");
  14725. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14726. var Type = exports.Type = function () {
  14727. function Type(baseType) {
  14728. _classCallCheck(this, Type);
  14729. this.baseType = baseType;
  14730. }
  14731. _createClass(Type, [{
  14732. key: "stringInfo",
  14733. value: function stringInfo() {
  14734. return [{ type: this.baseType.name, dim: 0 }];
  14735. }
  14736. }, {
  14737. key: "isCompatible",
  14738. value: function isCompatible(another) {
  14739. if (another instanceof Type) {
  14740. return this.baseType.isCompatible(another.baseType);
  14741. }
  14742. return false;
  14743. }
  14744. }, {
  14745. key: "value",
  14746. get: function get() {
  14747. return this.baseType.value;
  14748. }
  14749. }, {
  14750. key: "ord",
  14751. get: function get() {
  14752. return this.baseType.ord;
  14753. }
  14754. }]);
  14755. return Type;
  14756. }();
  14757. /***/ }),
  14758. /***/ "./js/typeSystem/types.js":
  14759. /*!********************************!*\
  14760. !*** ./js/typeSystem/types.js ***!
  14761. \********************************/
  14762. /*! no static exports found */
  14763. /***/ (function(module, exports, __webpack_require__) {
  14764. "use strict";
  14765. Object.defineProperty(exports, "__esModule", {
  14766. value: true
  14767. });
  14768. exports.Types = undefined;
  14769. var _baseTypes = __webpack_require__(/*! ./baseTypes */ "./js/typeSystem/baseTypes.js");
  14770. var _type = __webpack_require__(/*! ./type */ "./js/typeSystem/type.js");
  14771. var _multiType = __webpack_require__(/*! ./multiType */ "./js/typeSystem/multiType.js");
  14772. var INTEGER = new _type.Type(_baseTypes.BaseTypes.INTEGER);
  14773. var REAL = new _type.Type(_baseTypes.BaseTypes.REAL);
  14774. var STRING = new _type.Type(_baseTypes.BaseTypes.STRING);
  14775. var BOOLEAN = new _type.Type(_baseTypes.BaseTypes.BOOLEAN);
  14776. var VOID = new _type.Type(_baseTypes.BaseTypes.VOID);
  14777. var UNDEFINED = new _type.Type(_baseTypes.BaseTypes.UNDEFINED);
  14778. var ALL = new _multiType.MultiType([INTEGER, REAL, STRING, BOOLEAN]);
  14779. var Types = exports.Types = Object.freeze({
  14780. INTEGER: INTEGER,
  14781. REAL: REAL,
  14782. STRING: STRING,
  14783. BOOLEAN: BOOLEAN,
  14784. VOID: VOID,
  14785. UNDEFINED: UNDEFINED,
  14786. ALL: ALL
  14787. });
  14788. /***/ }),
  14789. /***/ "./js/util/config.js":
  14790. /*!***************************!*\
  14791. !*** ./js/util/config.js ***!
  14792. \***************************/
  14793. /*! no static exports found */
  14794. /***/ (function(module, exports, __webpack_require__) {
  14795. "use strict";
  14796. Object.defineProperty(exports, "__esModule", {
  14797. value: true
  14798. });
  14799. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14800. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14801. var ConfigObject = function () {
  14802. function ConfigObject() {
  14803. _classCallCheck(this, ConfigObject);
  14804. this.loopTimeout = 5000;
  14805. this.decimalPlaces = 5;
  14806. this.intConvertRoundMode = 2;
  14807. this.default_lang = 'pt';
  14808. this.enable_type_casting = true;
  14809. }
  14810. _createClass(ConfigObject, [{
  14811. key: 'setConfig',
  14812. value: function setConfig(opts) {
  14813. for (var key in opts) {
  14814. if (this.hasOwnProperty(key)) {
  14815. this[key] = opts[key];
  14816. }
  14817. }
  14818. }
  14819. }]);
  14820. return ConfigObject;
  14821. }();
  14822. var config = new ConfigObject();
  14823. var Config = exports.Config = config;
  14824. /***/ }),
  14825. /***/ "./js/util/inputTest.js":
  14826. /*!******************************!*\
  14827. !*** ./js/util/inputTest.js ***!
  14828. \******************************/
  14829. /*! no static exports found */
  14830. /***/ (function(module, exports, __webpack_require__) {
  14831. "use strict";
  14832. Object.defineProperty(exports, "__esModule", {
  14833. value: true
  14834. });
  14835. exports.InputTest = undefined;
  14836. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14837. var _input = __webpack_require__(/*! ./../io/input */ "./js/io/input.js");
  14838. var _localizedStringsService = __webpack_require__(/*! ../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  14839. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14840. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  14841. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14842. var InputTest = exports.InputTest = function (_Input) {
  14843. _inherits(InputTest, _Input);
  14844. function InputTest(inputList) {
  14845. _classCallCheck(this, InputTest);
  14846. var _this = _possibleConstructorReturn(this, (InputTest.__proto__ || Object.getPrototypeOf(InputTest)).call(this));
  14847. _this.index = 0;
  14848. _this.inputList = inputList;
  14849. return _this;
  14850. }
  14851. _createClass(InputTest, [{
  14852. key: 'requestInput',
  14853. value: function requestInput(callback) {
  14854. if (this.index < this.inputList.length) {
  14855. callback(this.inputList[this.index]);
  14856. this.index++;
  14857. } else {
  14858. throw new Error(_localizedStringsService.LocalizedStrings.getError("exceeded_input_request"));
  14859. }
  14860. }
  14861. }]);
  14862. return InputTest;
  14863. }(_input.Input);
  14864. /***/ }),
  14865. /***/ "./js/util/outputTest.js":
  14866. /*!*******************************!*\
  14867. !*** ./js/util/outputTest.js ***!
  14868. \*******************************/
  14869. /*! no static exports found */
  14870. /***/ (function(module, exports, __webpack_require__) {
  14871. "use strict";
  14872. Object.defineProperty(exports, "__esModule", {
  14873. value: true
  14874. });
  14875. exports.OutputTest = undefined;
  14876. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14877. var _output = __webpack_require__(/*! ./../io/output */ "./js/io/output.js");
  14878. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14879. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  14880. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14881. var OutputTest = exports.OutputTest = function (_Output) {
  14882. _inherits(OutputTest, _Output);
  14883. function OutputTest() {
  14884. _classCallCheck(this, OutputTest);
  14885. var _this = _possibleConstructorReturn(this, (OutputTest.__proto__ || Object.getPrototypeOf(OutputTest)).call(this));
  14886. _this.list = [];
  14887. return _this;
  14888. }
  14889. _createClass(OutputTest, [{
  14890. key: 'sendOutput',
  14891. value: function sendOutput(text) {
  14892. this.list.push(text);
  14893. }
  14894. }]);
  14895. return OutputTest;
  14896. }(_output.Output);
  14897. /***/ }),
  14898. /***/ "./js/visualUI/algorithm.js":
  14899. /*!**********************************!*\
  14900. !*** ./js/visualUI/algorithm.js ***!
  14901. \**********************************/
  14902. /*! no static exports found */
  14903. /***/ (function(module, exports, __webpack_require__) {
  14904. "use strict";
  14905. Object.defineProperty(exports, "__esModule", {
  14906. value: true
  14907. });
  14908. exports.renderAlgorithm = renderAlgorithm;
  14909. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  14910. var _jquery2 = _interopRequireDefault(_jquery);
  14911. var _types = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
  14912. var _ivprog_elements = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  14913. var Models = _interopRequireWildcard(_ivprog_elements);
  14914. var _localizedStringsService = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  14915. var _globals = __webpack_require__(/*! ./globals */ "./js/visualUI/globals.js");
  14916. var GlobalsManagement = _interopRequireWildcard(_globals);
  14917. var _variables = __webpack_require__(/*! ./variables */ "./js/visualUI/variables.js");
  14918. var VariablesManagement = _interopRequireWildcard(_variables);
  14919. var _commands = __webpack_require__(/*! ./commands */ "./js/visualUI/commands.js");
  14920. var CommandsManagement = _interopRequireWildcard(_commands);
  14921. var _code_generator = __webpack_require__(/*! ./code_generator */ "./js/visualUI/code_generator.js");
  14922. var CodeManagement = _interopRequireWildcard(_code_generator);
  14923. var _variable_value_menu = __webpack_require__(/*! ./commands/variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  14924. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  14925. var _functions = __webpack_require__(/*! ./functions */ "./js/visualUI/functions.js");
  14926. var FunctionsManagement = _interopRequireWildcard(_functions);
  14927. var _domConsole = __webpack_require__(/*! ./../io/domConsole */ "./js/io/domConsole.js");
  14928. var _ivprogParser = __webpack_require__(/*! ./../ast/ivprogParser */ "./js/ast/ivprogParser.js");
  14929. var _ivprogProcessor = __webpack_require__(/*! ./../processor/ivprogProcessor */ "./js/processor/ivprogProcessor.js");
  14930. var _languageService = __webpack_require__(/*! ../services/languageService */ "./js/services/languageService.js");
  14931. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  14932. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14933. window.block_render = false;
  14934. function renderAlgorithm() {
  14935. if (window.block_render) {
  14936. return;
  14937. }
  14938. if (window.draging) {
  14939. return;
  14940. }
  14941. window.block_render = true;
  14942. console.log('rendering algorithm');
  14943. (0, _jquery2.default)('.all_functions').children().off();
  14944. (0, _jquery2.default)('.all_functions').empty();
  14945. (0, _jquery2.default)('.list_globals').children().off();
  14946. (0, _jquery2.default)('.list_globals').empty();
  14947. for (var i = 0; i < window.program_obj.functions.length; i++) {
  14948. FunctionsManagement.renderFunction(window.program_obj.functions[i]);
  14949. }
  14950. for (var i = 0; i < window.program_obj.globals.length; i++) {
  14951. GlobalsManagement.renderGlobal(window.program_obj.globals[i]);
  14952. }
  14953. setTimeout(function () {
  14954. window.block_render = false;
  14955. }, 500);
  14956. }
  14957. /***/ }),
  14958. /***/ "./js/visualUI/code_generator.js":
  14959. /*!***************************************!*\
  14960. !*** ./js/visualUI/code_generator.js ***!
  14961. \***************************************/
  14962. /*! no static exports found */
  14963. /***/ (function(module, exports, __webpack_require__) {
  14964. "use strict";
  14965. Object.defineProperty(exports, "__esModule", {
  14966. value: true
  14967. });
  14968. exports.generate = generate;
  14969. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  14970. var _jquery2 = _interopRequireDefault(_jquery);
  14971. var _types = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
  14972. var _ivprog_elements = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  14973. var Models = _interopRequireWildcard(_ivprog_elements);
  14974. var _localizedStringsService = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  14975. var _globals = __webpack_require__(/*! ./globals */ "./js/visualUI/globals.js");
  14976. var GlobalsManagement = _interopRequireWildcard(_globals);
  14977. var _variables = __webpack_require__(/*! ./variables */ "./js/visualUI/variables.js");
  14978. var VariablesManagement = _interopRequireWildcard(_variables);
  14979. var _commands = __webpack_require__(/*! ./commands */ "./js/visualUI/commands.js");
  14980. var CommandsManagement = _interopRequireWildcard(_commands);
  14981. var _utils = __webpack_require__(/*! ./utils */ "./js/visualUI/utils.js");
  14982. var Utils = _interopRequireWildcard(_utils);
  14983. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  14984. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14985. function generate() {
  14986. (0, _jquery2.default)('.ivprog_visual_panel').find('.error_icon').remove();
  14987. var code = _localizedStringsService.LocalizedStrings.getUI('program') + ' { ';
  14988. code += globalsCode();
  14989. code += '\n';
  14990. var has_error = false;
  14991. for (var i = 0; i < window.program_obj.functions.length; i++) {
  14992. var n_code = functionsCode(window.program_obj.functions[i]);
  14993. if (n_code == null) {
  14994. has_error = true;
  14995. }
  14996. code += n_code;
  14997. code += '\n';
  14998. }
  14999. code += '\n}';
  15000. if (has_error) {
  15001. return null;
  15002. } else {
  15003. return code;
  15004. }
  15005. }
  15006. function functionsCode(function_obj) {
  15007. var ret = '\n\t' + _localizedStringsService.LocalizedStrings.getUI('function') + ' ';
  15008. var has_error = false;
  15009. switch (function_obj.return_type) {
  15010. case _types.Types.INTEGER:
  15011. ret += _localizedStringsService.LocalizedStrings.getUI('integer');
  15012. break;
  15013. case _types.Types.REAL:
  15014. ret += _localizedStringsService.LocalizedStrings.getUI('real');
  15015. break;
  15016. case _types.Types.TEXT:
  15017. ret += _localizedStringsService.LocalizedStrings.getUI('text');
  15018. break;
  15019. case _types.Types.BOOLEAN:
  15020. ret += _localizedStringsService.LocalizedStrings.getUI('boolean');
  15021. break;
  15022. case _types.Types.VOID:
  15023. ret += _localizedStringsService.LocalizedStrings.getUI('void');
  15024. break;
  15025. }
  15026. ret += ' ';
  15027. if (function_obj.return_dimensions == 1) {
  15028. ret += '[] ';
  15029. } else if (function_obj.return_dimensions == 2) {
  15030. ret += '[][] ';
  15031. }
  15032. ret += function_obj.name + ' ( ';
  15033. for (var j = 0; j < function_obj.parameters_list.length; j++) {
  15034. ret += parametersCode(function_obj.parameters_list[j]);
  15035. if (j + 1 < function_obj.parameters_list.length) {
  15036. ret += ',';
  15037. }
  15038. }
  15039. ret += ' ) {';
  15040. for (var j = 0; j < function_obj.variables_list.length; j++) {
  15041. ret += variablesCode(function_obj.variables_list[j]);
  15042. }
  15043. for (var j = 0; j < function_obj.commands.length; j++) {
  15044. try {
  15045. ret += commandsCode(function_obj.commands[j]);
  15046. } catch (err) {
  15047. has_error = true;
  15048. console.error(err.message);
  15049. var todos = (0, _jquery2.default)('body').find('.command_container');
  15050. for (var i = 0; i < todos.length; i++) {
  15051. if ((0, _jquery2.default)(todos[i]).data('command') == function_obj.commands[j]) {
  15052. (0, _jquery2.default)(todos[i]).prepend(' <i class="ui icon red exclamation triangle error_icon"></i> ');
  15053. break;
  15054. }
  15055. }
  15056. }
  15057. }
  15058. ret += '\n\t}';
  15059. if (has_error) {
  15060. return null;
  15061. } else {
  15062. return ret;
  15063. }
  15064. }
  15065. function commandsCode(command_obj) {
  15066. var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
  15067. switch (command_obj.type) {
  15068. case Models.COMMAND_TYPES.break:
  15069. return breaksCode(command_obj, indentation);
  15070. case Models.COMMAND_TYPES.comment:
  15071. return commentsCode(command_obj, indentation);
  15072. case Models.COMMAND_TYPES.reader:
  15073. return readersCode(command_obj, indentation);
  15074. case Models.COMMAND_TYPES.writer:
  15075. return writersCode(command_obj, indentation);
  15076. case Models.COMMAND_TYPES.functioncall:
  15077. return functioncallsCode(command_obj, indentation);
  15078. case Models.COMMAND_TYPES.attribution:
  15079. return attributionsCode(command_obj, indentation);
  15080. case Models.COMMAND_TYPES.whiletrue:
  15081. return whiletruesCode(command_obj, indentation);
  15082. case Models.COMMAND_TYPES.dowhiletrue:
  15083. return doWhilesCode(command_obj, indentation);
  15084. case Models.COMMAND_TYPES.iftrue:
  15085. return iftruesCode(command_obj, indentation);
  15086. case Models.COMMAND_TYPES.repeatNtimes:
  15087. return repeatNtimesCode(command_obj, indentation);
  15088. case Models.COMMAND_TYPES.switch:
  15089. return switchsCode(command_obj, indentation);
  15090. case Models.COMMAND_TYPES.return:
  15091. return returnsCode(command_obj, indentation);
  15092. }
  15093. }
  15094. function returnsCode(command_obj, indentation) {
  15095. var ret = '\n';
  15096. for (var i = 0; i < indentation; i++) {
  15097. ret += '\t';
  15098. }
  15099. ret += _localizedStringsService.LocalizedStrings.getUI('text_return');
  15100. if (command_obj.variable_value_menu) {
  15101. try {
  15102. ret += ' ' + variableValueMenuCode(command_obj.variable_value_menu, true);
  15103. } catch (err) {}
  15104. }
  15105. return ret;
  15106. }
  15107. function breaksCode(command_obj, indentation) {
  15108. var ret = '\n';
  15109. for (var i = 0; i < indentation; i++) {
  15110. ret += '\t';
  15111. }
  15112. ret += _localizedStringsService.LocalizedStrings.getUI('text_break');
  15113. return ret;
  15114. }
  15115. function switchsCode(command_obj, indentation) {
  15116. var ret = '\n';
  15117. for (var i = 0; i < indentation; i++) {
  15118. ret += '\t';
  15119. }
  15120. ret += _localizedStringsService.LocalizedStrings.getUI('text_code_switch') + ' ( ';
  15121. ret += variableValueMenuCode(command_obj.variable);
  15122. ret += ' ) { ';
  15123. if (command_obj.cases) {
  15124. for (var i = 0; i < command_obj.cases.length; i++) {
  15125. ret += switchcasesCode(command_obj.cases[i], indentation + 1);
  15126. }
  15127. }
  15128. ret += '\n';
  15129. for (var i = 0; i < indentation; i++) {
  15130. ret += '\t';
  15131. }
  15132. ret += '} ';
  15133. return ret;
  15134. }
  15135. function switchcasesCode(switchcase, indentation) {
  15136. var ret = '\n';
  15137. for (var i = 0; i < indentation; i++) {
  15138. ret += '\t';
  15139. }
  15140. ret += _localizedStringsService.LocalizedStrings.getUI('text_code_case') + ' ';
  15141. ret += variableValueMenuCode(switchcase.variable_value_menu);
  15142. ret += ' :';
  15143. if (switchcase.commands_block) {
  15144. for (var i = 0; i < switchcase.commands_block.length; i++) {
  15145. ret += commandsCode(switchcase.commands_block[i], indentation + 1);
  15146. }
  15147. }
  15148. return ret;
  15149. }
  15150. function repeatNtimesCode(command_obj, indentation) {
  15151. var ret = '\n';
  15152. for (var i = 0; i < indentation; i++) {
  15153. ret += '\t';
  15154. }
  15155. ret += _localizedStringsService.LocalizedStrings.getUI('text_for') + ' ( ';
  15156. if (command_obj.var_attribution) {
  15157. ret += variableValueMenuCode(command_obj.var_attribution);
  15158. ret += ' = ';
  15159. ret += variableValueMenuCode(command_obj.expression1);
  15160. }
  15161. ret += ' ; ';
  15162. if (command_obj.expression2) {
  15163. switch (command_obj.expression2.expression.type) {
  15164. case Models.EXPRESSION_TYPES.exp_logic:
  15165. ret += logicExpressionCode(command_obj.expression2.expression);
  15166. break;
  15167. case Models.EXPRESSION_TYPES.exp_arithmetic:
  15168. ret += arithmeticExpressionCode(command_obj.expression2.expression);
  15169. break;
  15170. }
  15171. }
  15172. ret += ' ; ';
  15173. if (command_obj.var_incrementation) {
  15174. ret += variableValueMenuCode(command_obj.var_incrementation);
  15175. ret += ' = ';
  15176. ret += variableValueMenuCode(command_obj.expression3.itens[0]);
  15177. switch (command_obj.expression3.itens[1]) {
  15178. case Models.ARITHMETIC_TYPES.plus:
  15179. ret += ' + ';
  15180. break;
  15181. case Models.ARITHMETIC_TYPES.minus:
  15182. ret += ' - ';
  15183. break;
  15184. case Models.ARITHMETIC_TYPES.multiplication:
  15185. ret += ' * ';
  15186. break;
  15187. case Models.ARITHMETIC_TYPES.division:
  15188. ret += ' / ';
  15189. break;
  15190. case Models.ARITHMETIC_TYPES.module:
  15191. ret += ' % ';
  15192. break;
  15193. }
  15194. ret += variableValueMenuCode(command_obj.expression3.itens[2]);
  15195. }
  15196. ret += ' ) { ';
  15197. if (command_obj.commands_block) {
  15198. for (var i = 0; i < command_obj.commands_block.length; i++) {
  15199. ret += commandsCode(command_obj.commands_block[i], indentation + 1);
  15200. }
  15201. }
  15202. ret += '\n';
  15203. for (var i = 0; i < indentation; i++) {
  15204. ret += '\t';
  15205. }
  15206. ret += '}';
  15207. return ret;
  15208. }
  15209. function iftruesCode(command_obj, indentation) {
  15210. var ret = '\n';
  15211. for (var i = 0; i < indentation; i++) {
  15212. ret += '\t';
  15213. }
  15214. ret += _localizedStringsService.LocalizedStrings.getUI('text_if');
  15215. if (!command_obj.expression.expression) {
  15216. Utils.renderErrorMessage(command_obj.expression.dom_object, _localizedStringsService.LocalizedStrings.getUI('inform_valid_expression'));
  15217. }
  15218. switch (command_obj.expression.expression.type) {
  15219. case Models.EXPRESSION_TYPES.exp_logic:
  15220. ret += logicExpressionCode(command_obj.expression.expression);
  15221. break;
  15222. case Models.EXPRESSION_TYPES.exp_arithmetic:
  15223. ret += arithmeticExpressionCode(command_obj.expression.expression);
  15224. break;
  15225. }
  15226. ret += ' { ';
  15227. if (command_obj.commands_block) {
  15228. for (var i = 0; i < command_obj.commands_block.length; i++) {
  15229. ret += commandsCode(command_obj.commands_block[i], indentation + 1);
  15230. }
  15231. }
  15232. ret += '\n';
  15233. for (var i = 0; i < indentation; i++) {
  15234. ret += '\t';
  15235. }
  15236. ret += '} ' + _localizedStringsService.LocalizedStrings.getUI('text_else') + ' {';
  15237. if (command_obj.commands_else) {
  15238. for (var i = 0; i < command_obj.commands_else.length; i++) {
  15239. ret += commandsCode(command_obj.commands_else[i], indentation + 1);
  15240. }
  15241. }
  15242. ret += '\n';
  15243. for (var i = 0; i < indentation; i++) {
  15244. ret += '\t';
  15245. }
  15246. ret += '}';
  15247. return ret;
  15248. }
  15249. function doWhilesCode(command_obj, indentation) {
  15250. var ret = '\n';
  15251. for (var i = 0; i < indentation; i++) {
  15252. ret += '\t';
  15253. }
  15254. ret += _localizedStringsService.LocalizedStrings.getUI('text_code_do') + ' { ';
  15255. if (command_obj.commands_block) {
  15256. for (var i = 0; i < command_obj.commands_block.length; i++) {
  15257. ret += commandsCode(command_obj.commands_block[i], indentation + 1);
  15258. }
  15259. }
  15260. ret += '\n';
  15261. for (var i = 0; i < indentation; i++) {
  15262. ret += '\t';
  15263. }
  15264. ret += '} ' + _localizedStringsService.LocalizedStrings.getUI('text_code_while');
  15265. if (!command_obj.expression.expression) {
  15266. Utils.renderErrorMessage(command_obj.expression.dom_object, _localizedStringsService.LocalizedStrings.getUI('inform_valid_expression'));
  15267. }
  15268. switch (command_obj.expression.expression.type) {
  15269. case Models.EXPRESSION_TYPES.exp_logic:
  15270. ret += logicExpressionCode(command_obj.expression.expression);
  15271. break;
  15272. case Models.EXPRESSION_TYPES.exp_arithmetic:
  15273. ret += arithmeticExpressionCode(command_obj.expression.expression);
  15274. break;
  15275. }
  15276. return ret;
  15277. }
  15278. function whiletruesCode(command_obj, indentation) {
  15279. var ret = '\n';
  15280. for (var i = 0; i < indentation; i++) {
  15281. ret += '\t';
  15282. }
  15283. ret += _localizedStringsService.LocalizedStrings.getUI('text_code_while');
  15284. if (!command_obj.expression.expression) {
  15285. Utils.renderErrorMessage(command_obj.expression.dom_object, _localizedStringsService.LocalizedStrings.getUI('inform_valid_expression'));
  15286. }
  15287. switch (command_obj.expression.expression.type) {
  15288. case Models.EXPRESSION_TYPES.exp_logic:
  15289. ret += logicExpressionCode(command_obj.expression.expression);
  15290. break;
  15291. case Models.EXPRESSION_TYPES.exp_arithmetic:
  15292. ret += arithmeticExpressionCode(command_obj.expression.expression);
  15293. break;
  15294. }
  15295. ret += ' { ';
  15296. if (command_obj.commands_block) {
  15297. for (var i = 0; i < command_obj.commands_block.length; i++) {
  15298. ret += commandsCode(command_obj.commands_block[i], indentation + 1);
  15299. }
  15300. }
  15301. ret += '\n';
  15302. for (var i = 0; i < indentation; i++) {
  15303. ret += '\t';
  15304. }
  15305. ret += '}';
  15306. return ret;
  15307. }
  15308. function logicExpressionCode(expression) {
  15309. var ret = ' ( ';
  15310. if (expression.first_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  15311. ret += logicExpressionCode(expression.first_operand);
  15312. } else if (expression.first_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  15313. ret += arithmeticExpressionCode(expression.first_operand);
  15314. } else {
  15315. ret += variableValueMenuCode(expression.first_operand);
  15316. }
  15317. if (expression.operator) {
  15318. switch (expression.operator) {
  15319. case Models.LOGIC_COMPARISON.equals_to:
  15320. ret += ' == ';
  15321. break;
  15322. case Models.LOGIC_COMPARISON.not_equals_to:
  15323. ret += ' != ';
  15324. break;
  15325. case Models.LOGIC_COMPARISON.and:
  15326. ret += ' && ';
  15327. break;
  15328. case Models.LOGIC_COMPARISON.or:
  15329. ret += ' || ';
  15330. break;
  15331. }
  15332. if (expression.second_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  15333. ret += logicExpressionCode(expression.second_operand);
  15334. } else if (expression.second_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  15335. ret += arithmeticExpressionCode(expression.second_operand);
  15336. } else {
  15337. ret += variableValueMenuCode(expression.second_operand);
  15338. }
  15339. }
  15340. ret += ' ) ';
  15341. return ret;
  15342. }
  15343. function arithmeticExpressionCode(expression) {
  15344. var ret = ' ( ';
  15345. if (expression.first_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  15346. ret += logicExpressionCode(expression.first_operand);
  15347. } else if (expression.first_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  15348. ret += arithmeticExpressionCode(expression.first_operand);
  15349. } else {
  15350. ret += variableValueMenuCode(expression.first_operand);
  15351. }
  15352. switch (expression.operator) {
  15353. case Models.ARITHMETIC_COMPARISON.greater_than:
  15354. ret += ' > ';
  15355. break;
  15356. case Models.ARITHMETIC_COMPARISON.less_than:
  15357. ret += ' < ';
  15358. break;
  15359. case Models.ARITHMETIC_COMPARISON.equals_to:
  15360. ret += ' == ';
  15361. break;
  15362. case Models.ARITHMETIC_COMPARISON.not_equals_to:
  15363. ret += ' != ';
  15364. break;
  15365. case Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to:
  15366. ret += ' >= ';
  15367. break;
  15368. case Models.ARITHMETIC_COMPARISON.less_than_or_equals_to:
  15369. ret += ' <= ';
  15370. break;
  15371. }
  15372. if (expression.second_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  15373. ret += logicExpressionCode(expression.second_operand);
  15374. } else if (expression.second_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  15375. ret += arithmeticExpressionCode(expression.second_operand);
  15376. } else {
  15377. ret += variableValueMenuCode(expression.second_operand);
  15378. }
  15379. ret += ' ) ';
  15380. return ret;
  15381. }
  15382. function attributionsCode(command_obj, indentation) {
  15383. var ret = '\n';
  15384. for (var i = 0; i < indentation; i++) {
  15385. ret += '\t';
  15386. }
  15387. ret += variableValueMenuCode(command_obj.variable) + ' = ';
  15388. for (var i = 0; i < command_obj.expression.length; i++) {
  15389. ret += elementExpressionCode(command_obj.expression[i]);
  15390. }
  15391. return ret;
  15392. }
  15393. function elementExpressionCode(expression_obj) {
  15394. var ret = '';
  15395. for (var i = 0; i < expression_obj.itens.length; i++) {
  15396. if (expression_obj.itens[i].type) {
  15397. ret += variableValueMenuCode(expression_obj.itens[i]);
  15398. } else if (expression_obj.itens[i].type_exp) {
  15399. if (expression_obj.itens[i].type_exp == Models.EXPRESSION_ELEMENTS.par_exp_par) {
  15400. ret += ' ( ';
  15401. }
  15402. ret += elementExpressionCode(expression_obj.itens[i]);
  15403. if (expression_obj.itens[i].type_exp == Models.EXPRESSION_ELEMENTS.par_exp_par) {
  15404. ret += ' ) ';
  15405. }
  15406. } else {
  15407. switch (expression_obj.itens[i]) {
  15408. case Models.ARITHMETIC_TYPES.plus:
  15409. ret += ' + ';
  15410. break;
  15411. case Models.ARITHMETIC_TYPES.minus:
  15412. ret += ' - ';
  15413. break;
  15414. case Models.ARITHMETIC_TYPES.multiplication:
  15415. ret += ' * ';
  15416. break;
  15417. case Models.ARITHMETIC_TYPES.division:
  15418. ret += ' / ';
  15419. break;
  15420. case Models.ARITHMETIC_TYPES.module:
  15421. ret += ' % ';
  15422. break;
  15423. }
  15424. }
  15425. }
  15426. return ret;
  15427. }
  15428. function functioncallsCode(command_obj, indentation) {
  15429. var ret = '\n';
  15430. for (var i = 0; i < indentation; i++) {
  15431. ret += '\t';
  15432. }
  15433. ret += variableValueMenuCode(command_obj.function_called);
  15434. return ret;
  15435. }
  15436. function readersCode(command_obj, indentation) {
  15437. var ret = '\n';
  15438. for (var i = 0; i < indentation; i++) {
  15439. ret += '\t';
  15440. }
  15441. ret += _localizedStringsService.LocalizedStrings.getUI('text_command_read') + ' ( ';
  15442. ret += variableValueMenuCode(command_obj.variable_value_menu);
  15443. ret += ' ) ';
  15444. return ret;
  15445. }
  15446. function variableValueMenuCode(variable_obj) {
  15447. var is_return = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  15448. var ret = '';
  15449. try {
  15450. if (variable_obj.function_called) {
  15451. if (variable_obj.function_called.name) {
  15452. ret += variable_obj.function_called.name + ' ( ';
  15453. } else {
  15454. ret += _localizedStringsService.LocalizedStrings.getUI(variable_obj.function_called.category) + '.' + _localizedStringsService.LocalizedStrings.getUI(variable_obj.function_called.identifier) + ' ( ';
  15455. }
  15456. if (variable_obj.parameters_list) {
  15457. for (var i = 0; i < variable_obj.parameters_list.length; i++) {
  15458. ret += variableValueMenuCode(variable_obj.parameters_list[i]);
  15459. if (i + 1 < variable_obj.parameters_list.length) {
  15460. ret += ', ';
  15461. }
  15462. }
  15463. }
  15464. ret += ' )';
  15465. } else if (variable_obj.content.type) {
  15466. ret += variable_obj.content.name;
  15467. if (variable_obj.content.dimensions == 1 && variable_obj.dimensions != 1) {
  15468. ret += ' [ ' + variableValueMenuCode(variable_obj.column) + ' ] ';
  15469. }
  15470. if (variable_obj.content.dimensions == 2 && variable_obj.dimensions != 2) {
  15471. ret += ' [ ' + variableValueMenuCode(variable_obj.row) + ' ] ';
  15472. ret += ' [ ' + variableValueMenuCode(variable_obj.column) + ' ] ';
  15473. }
  15474. } else {
  15475. if (isNaN(variable_obj.content)) {
  15476. ret += '"' + variable_obj.content + '"';
  15477. } else {
  15478. ret += variable_obj.content;
  15479. }
  15480. }
  15481. } catch (err) {
  15482. if (!is_return) {
  15483. Utils.renderErrorMessage(variable_obj.dom_object, _localizedStringsService.LocalizedStrings.getUI('inform_valid_content'));
  15484. throw err;
  15485. }
  15486. }
  15487. return ret;
  15488. }
  15489. function writersCode(command_obj, indentation) {
  15490. var ret = '\n';
  15491. for (var i = 0; i < indentation; i++) {
  15492. ret += '\t';
  15493. }
  15494. ret += _localizedStringsService.LocalizedStrings.getUI('text_command_write') + ' ( ';
  15495. for (var i = 0; i < command_obj.content.length; i++) {
  15496. ret += variableValueMenuCode(command_obj.content[i]);
  15497. if (i + 1 < command_obj.content.length) {
  15498. ret += ' + ';
  15499. }
  15500. }
  15501. ret += ' ) ';
  15502. return ret;
  15503. }
  15504. function commentsCode(command_obj, indentation) {
  15505. var ret = '\n';
  15506. for (var i = 0; i < indentation; i++) {
  15507. ret += '\t';
  15508. }
  15509. ret += '// ';
  15510. ret += command_obj.comment_text.content;
  15511. return ret;
  15512. }
  15513. function parametersCode(parameter_obj) {
  15514. var ret = '';
  15515. switch (parameter_obj.type) {
  15516. case _types.Types.INTEGER:
  15517. ret += ' ' + _localizedStringsService.LocalizedStrings.getUI('integer') + ' ';
  15518. break;
  15519. case _types.Types.REAL:
  15520. ret += ' ' + _localizedStringsService.LocalizedStrings.getUI('real') + ' ';
  15521. break;
  15522. case _types.Types.TEXT:
  15523. ret += ' ' + _localizedStringsService.LocalizedStrings.getUI('text') + ' ';
  15524. break;
  15525. case _types.Types.BOOLEAN:
  15526. ret += ' ' + _localizedStringsService.LocalizedStrings.getUI('boolean') + ' ';
  15527. break;
  15528. }
  15529. ret += parameter_obj.name + '';
  15530. if (parameter_obj.dimensions == 1) {
  15531. ret += ' []';
  15532. } else if (parameter_obj.dimensions == 2) {
  15533. ret += ' [][]';
  15534. }
  15535. return ret;
  15536. }
  15537. function variablesCode(variable_obj) {
  15538. var ret = '';
  15539. var temp = variable_obj;
  15540. ret += '\n\t\t';
  15541. if (temp.is_constant) {
  15542. ret += 'const ';
  15543. }
  15544. switch (temp.type) {
  15545. case _types.Types.INTEGER:
  15546. ret += _localizedStringsService.LocalizedStrings.getUI('integer') + ' ';
  15547. break;
  15548. case _types.Types.REAL:
  15549. ret += _localizedStringsService.LocalizedStrings.getUI('real') + ' ';
  15550. break;
  15551. case _types.Types.TEXT:
  15552. ret += _localizedStringsService.LocalizedStrings.getUI('text') + ' ';
  15553. break;
  15554. case _types.Types.BOOLEAN:
  15555. ret += _localizedStringsService.LocalizedStrings.getUI('boolean') + ' ';
  15556. break;
  15557. }
  15558. ret += temp.name + ' ';
  15559. if (temp.dimensions == 1) {
  15560. ret += '[' + temp.columns + '] ';
  15561. switch (temp.type) {
  15562. case _types.Types.INTEGER:
  15563. ret += '= {' + temp.value + '}';
  15564. break;
  15565. case _types.Types.REAL:
  15566. ret += '= {' + temp.value.toFixed(2) + '}';
  15567. break;
  15568. case _types.Types.TEXT:
  15569. ret += '= {';
  15570. for (var j = 0; j < temp.value.length; j++) {
  15571. ret += '"' + temp.value[j] + '"';
  15572. if (j + 1 < temp.value.length) {
  15573. ret += ',';
  15574. }
  15575. }
  15576. ret += '}';
  15577. break;
  15578. case _types.Types.BOOLEAN:
  15579. ret += '= {';
  15580. for (var j = 0; j < temp.value.length; j++) {
  15581. if (temp.value[j]) {
  15582. ret += _localizedStringsService.LocalizedStrings.getUI("true");
  15583. } else {
  15584. ret += _localizedStringsService.LocalizedStrings.getUI("false");
  15585. }
  15586. if (j + 1 < temp.value.length) {
  15587. ret += ',';
  15588. }
  15589. }
  15590. ret += '}';
  15591. break;
  15592. }
  15593. } else if (temp.dimensions == 2) {
  15594. ret += '[' + temp.rows + '][' + temp.columns + '] ';
  15595. switch (temp.type) {
  15596. case _types.Types.INTEGER:
  15597. ret += '= {';
  15598. for (var j = 0; j < temp.rows; j++) {
  15599. ret += '{' + temp.value[j] + '}';
  15600. if (j + 1 < temp.rows) {
  15601. ret += ',';
  15602. }
  15603. }
  15604. ret += '}';
  15605. break;
  15606. case _types.Types.REAL:
  15607. ret += '= {';
  15608. for (var j = 0; j < temp.rows; j++) {
  15609. ret += '{' + temp.value[j].toFixed(2) + '}';
  15610. if (j + 1 < temp.rows) {
  15611. ret += ',';
  15612. }
  15613. }
  15614. ret += '}';
  15615. break;
  15616. case _types.Types.TEXT:
  15617. ret += '= {';
  15618. for (var j = 0; j < temp.rows; j++) {
  15619. ret += '{';
  15620. for (var k = 0; k < temp.columns; k++) {
  15621. ret += '"' + temp.value[j][k] + '"';
  15622. if (k + 1 < temp.columns) {
  15623. ret += ',';
  15624. }
  15625. }
  15626. ret += '}';
  15627. if (j + 1 < temp.rows) {
  15628. ret += ',';
  15629. }
  15630. }
  15631. ret += '}';
  15632. break;
  15633. case _types.Types.BOOLEAN:
  15634. ret += '= {';
  15635. for (var j = 0; j < temp.rows; j++) {
  15636. ret += '{';
  15637. for (var k = 0; k < temp.columns; k++) {
  15638. if (temp.value[j][k]) {
  15639. ret += _localizedStringsService.LocalizedStrings.getUI("true");
  15640. } else {
  15641. ret += _localizedStringsService.LocalizedStrings.getUI("false");
  15642. }
  15643. if (k + 1 < temp.columns) {
  15644. ret += ',';
  15645. }
  15646. }
  15647. ret += '}';
  15648. if (j + 1 < temp.rows) {
  15649. ret += ',';
  15650. }
  15651. }
  15652. ret += '}';
  15653. break;
  15654. }
  15655. } else {
  15656. switch (temp.type) {
  15657. case _types.Types.INTEGER:
  15658. ret += '= ' + temp.value;
  15659. break;
  15660. case _types.Types.REAL:
  15661. ret += '= ' + temp.value.toFixed(2);
  15662. break;
  15663. case _types.Types.TEXT:
  15664. ret += '= "' + temp.value + '"';
  15665. break;
  15666. case _types.Types.BOOLEAN:
  15667. ret += '= ';
  15668. if (temp.value) {
  15669. ret += _localizedStringsService.LocalizedStrings.getUI("true");
  15670. } else {
  15671. ret += _localizedStringsService.LocalizedStrings.getUI("false");
  15672. }
  15673. break;
  15674. }
  15675. }
  15676. return ret;
  15677. }
  15678. function globalsCode() {
  15679. var ret = '';
  15680. if (window.program_obj.globals) {
  15681. for (var i = 0; i < window.program_obj.globals.length; i++) {
  15682. var temp = window.program_obj.globals[i];
  15683. ret += '\n\t';
  15684. if (temp.is_constant) {
  15685. ret += 'const ';
  15686. }
  15687. switch (temp.type) {
  15688. case _types.Types.INTEGER:
  15689. ret += _localizedStringsService.LocalizedStrings.getUI('integer');
  15690. break;
  15691. case _types.Types.REAL:
  15692. ret += _localizedStringsService.LocalizedStrings.getUI('real');
  15693. break;
  15694. case _types.Types.TEXT:
  15695. ret += _localizedStringsService.LocalizedStrings.getUI('text');
  15696. break;
  15697. case _types.Types.BOOLEAN:
  15698. ret += _localizedStringsService.LocalizedStrings.getUI('boolean');
  15699. break;
  15700. }
  15701. ret += ' ' + temp.name + ' ';
  15702. if (temp.dimensions == 1) {
  15703. ret += '[' + temp.columns + '] ';
  15704. switch (temp.type) {
  15705. case _types.Types.INTEGER:
  15706. ret += '= {' + temp.value + '}';
  15707. break;
  15708. case _types.Types.REAL:
  15709. ret += '= {';
  15710. for (var j = 0; j < temp.value.length; j++) {
  15711. ret += temp.value[j].toFixed(2);
  15712. if (j + 1 < temp.value.length) {
  15713. ret += ',';
  15714. }
  15715. }
  15716. ret += '}';
  15717. break;
  15718. case _types.Types.TEXT:
  15719. ret += '= {';
  15720. for (var j = 0; j < temp.value.length; j++) {
  15721. ret += '"' + temp.value[j] + '"';
  15722. if (j + 1 < temp.value.length) {
  15723. ret += ',';
  15724. }
  15725. }
  15726. ret += '}';
  15727. break;
  15728. case _types.Types.BOOLEAN:
  15729. ret += '= {';
  15730. for (var j = 0; j < temp.value.length; j++) {
  15731. if (temp.value[j]) {
  15732. ret += _localizedStringsService.LocalizedStrings.getUI("true");
  15733. } else {
  15734. ret += _localizedStringsService.LocalizedStrings.getUI("false");
  15735. }
  15736. if (j + 1 < temp.value.length) {
  15737. ret += ',';
  15738. }
  15739. }
  15740. ret += '}';
  15741. break;
  15742. }
  15743. } else if (temp.dimensions == 2) {
  15744. ret += '[' + temp.rows + '][' + temp.columns + '] ';
  15745. switch (temp.type) {
  15746. case _types.Types.INTEGER:
  15747. ret += '= {';
  15748. for (var j = 0; j < temp.rows; j++) {
  15749. ret += '{' + temp.value[j] + '}';
  15750. if (j + 1 < temp.rows) {
  15751. ret += ',';
  15752. }
  15753. }
  15754. ret += '}';
  15755. break;
  15756. case _types.Types.REAL:
  15757. ret += '= {';
  15758. for (var j = 0; j < temp.rows; j++) {
  15759. ret += '{';
  15760. for (var k = 0; k < temp.columns; k++) {
  15761. ret += temp.value[j][k].toFixed(2);
  15762. if (k + 1 < temp.columns) {
  15763. ret += ',';
  15764. }
  15765. }
  15766. ret += '}';
  15767. if (j + 1 < temp.rows) {
  15768. ret += ',';
  15769. }
  15770. }
  15771. ret += '}';
  15772. break;
  15773. case _types.Types.TEXT:
  15774. ret += '= {';
  15775. for (var j = 0; j < temp.rows; j++) {
  15776. ret += '{';
  15777. for (var k = 0; k < temp.columns; k++) {
  15778. ret += '"' + temp.value[j][k] + '"';
  15779. if (k + 1 < temp.columns) {
  15780. ret += ',';
  15781. }
  15782. }
  15783. ret += '}';
  15784. if (j + 1 < temp.rows) {
  15785. ret += ',';
  15786. }
  15787. }
  15788. ret += '}';
  15789. break;
  15790. case _types.Types.BOOLEAN:
  15791. ret += '= {';
  15792. for (var j = 0; j < temp.rows; j++) {
  15793. ret += '{';
  15794. for (var k = 0; k < temp.columns; k++) {
  15795. if (temp.value[j][k]) {
  15796. ret += _localizedStringsService.LocalizedStrings.getUI("true");
  15797. } else {
  15798. ret += _localizedStringsService.LocalizedStrings.getUI("false");
  15799. }
  15800. if (k + 1 < temp.columns) {
  15801. ret += ',';
  15802. }
  15803. }
  15804. ret += '}';
  15805. if (j + 1 < temp.rows) {
  15806. ret += ',';
  15807. }
  15808. }
  15809. ret += '}';
  15810. break;
  15811. }
  15812. } else {
  15813. switch (temp.type) {
  15814. case _types.Types.INTEGER:
  15815. ret += '= ' + temp.value;
  15816. break;
  15817. case _types.Types.REAL:
  15818. ret += '= ' + temp.value.toFixed(2);
  15819. break;
  15820. case _types.Types.TEXT:
  15821. ret += '= "' + temp.value + '"';
  15822. break;
  15823. case _types.Types.BOOLEAN:
  15824. ret += '= ';
  15825. if (temp.value) {
  15826. ret += _localizedStringsService.LocalizedStrings.getUI("true");;
  15827. } else {
  15828. ret += _localizedStringsService.LocalizedStrings.getUI("false");;
  15829. }
  15830. break;
  15831. }
  15832. }
  15833. }
  15834. }
  15835. return ret;
  15836. }
  15837. /***/ }),
  15838. /***/ "./js/visualUI/commands.js":
  15839. /*!*********************************!*\
  15840. !*** ./js/visualUI/commands.js ***!
  15841. \*********************************/
  15842. /*! no static exports found */
  15843. /***/ (function(module, exports, __webpack_require__) {
  15844. "use strict";
  15845. Object.defineProperty(exports, "__esModule", {
  15846. value: true
  15847. });
  15848. exports.removeCommand = removeCommand;
  15849. exports.createFloatingCommand = createFloatingCommand;
  15850. exports.renderCommand = renderCommand;
  15851. exports.genericCreateCommand = genericCreateCommand;
  15852. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  15853. var _jquery2 = _interopRequireDefault(_jquery);
  15854. var _types = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
  15855. var _ivprog_elements = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  15856. var Models = _interopRequireWildcard(_ivprog_elements);
  15857. var _localizedStringsService = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  15858. var _globals = __webpack_require__(/*! ./globals */ "./js/visualUI/globals.js");
  15859. var GlobalsManagement = _interopRequireWildcard(_globals);
  15860. var _variables = __webpack_require__(/*! ./variables */ "./js/visualUI/variables.js");
  15861. var VariablesManagement = _interopRequireWildcard(_variables);
  15862. var _comment = __webpack_require__(/*! ./commands/comment */ "./js/visualUI/commands/comment.js");
  15863. var CommentsManagement = _interopRequireWildcard(_comment);
  15864. var _reader = __webpack_require__(/*! ./commands/reader */ "./js/visualUI/commands/reader.js");
  15865. var ReadersManagement = _interopRequireWildcard(_reader);
  15866. var _writer = __webpack_require__(/*! ./commands/writer */ "./js/visualUI/commands/writer.js");
  15867. var WritersManagement = _interopRequireWildcard(_writer);
  15868. var _attribution = __webpack_require__(/*! ./commands/attribution */ "./js/visualUI/commands/attribution.js");
  15869. var AttributionsManagement = _interopRequireWildcard(_attribution);
  15870. var _iftrue = __webpack_require__(/*! ./commands/iftrue */ "./js/visualUI/commands/iftrue.js");
  15871. var IftruesManagement = _interopRequireWildcard(_iftrue);
  15872. var _repeatNtimes = __webpack_require__(/*! ./commands/repeatNtimes */ "./js/visualUI/commands/repeatNtimes.js");
  15873. var RepeatNtimesManagement = _interopRequireWildcard(_repeatNtimes);
  15874. var _whiletrue = __webpack_require__(/*! ./commands/whiletrue */ "./js/visualUI/commands/whiletrue.js");
  15875. var WhiletruesManagement = _interopRequireWildcard(_whiletrue);
  15876. var _dowhiletrue = __webpack_require__(/*! ./commands/dowhiletrue */ "./js/visualUI/commands/dowhiletrue.js");
  15877. var DowhiletruesManagement = _interopRequireWildcard(_dowhiletrue);
  15878. var _switch = __webpack_require__(/*! ./commands/switch */ "./js/visualUI/commands/switch.js");
  15879. var SwitchesManagement = _interopRequireWildcard(_switch);
  15880. var _functioncall = __webpack_require__(/*! ./commands/functioncall */ "./js/visualUI/commands/functioncall.js");
  15881. var FunctioncallsManagement = _interopRequireWildcard(_functioncall);
  15882. var _variable_value_menu = __webpack_require__(/*! ./commands/variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  15883. var VariableValueMenuManagement = _interopRequireWildcard(_variable_value_menu);
  15884. var _break = __webpack_require__(/*! ./commands/break */ "./js/visualUI/commands/break.js");
  15885. var BreaksManagement = _interopRequireWildcard(_break);
  15886. var _return = __webpack_require__(/*! ./commands/return */ "./js/visualUI/commands/return.js");
  15887. var ReturnsManagement = _interopRequireWildcard(_return);
  15888. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  15889. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15890. var has_element_created_draged = false;
  15891. var which_element_is_draged = null;
  15892. function removeCommand(command, function_obj, dom_obj) {
  15893. if (function_obj.commands.indexOf(command) > -1) {
  15894. function_obj.commands.splice(function_obj.commands.indexOf(command), 1);
  15895. return true;
  15896. }
  15897. // Utilize dois parantNode, pois o primeiro é o div de comandos
  15898. try {
  15899. if (dom_obj.parent().parent().data('command').commands_block.indexOf(command) > -1) {
  15900. dom_obj.parent().parent().data('command').commands_block.splice(dom_obj.parent().parent().data('command').commands_block.indexOf(command), 1);
  15901. return true;
  15902. }
  15903. } catch (err) {}
  15904. try {
  15905. if (dom_obj.parent().parent().data('command').type == Models.COMMAND_TYPES.iftrue) {
  15906. if (dom_obj.parent().parent().data('command').commands_else.indexOf(command) > -1) {
  15907. dom_obj.parent().parent().data('command').commands_else.splice(dom_obj.parent().parent().data('command').commands_else.indexOf(command), 1);
  15908. return true;
  15909. }
  15910. }
  15911. } catch (err) {}
  15912. if (dom_obj.parent().data('switchcase')) {
  15913. console.log("o que encontrei: ");
  15914. console.log(dom_obj.parent().data('switchcase'));
  15915. dom_obj.parent().data('switchcase').commands_block.splice(dom_obj.parent().data('switchcase').commands_block.indexOf(command), 1);
  15916. return true;
  15917. }
  15918. return false;
  15919. }
  15920. function createFloatingCommand(function_obj, function_container, command_type, mouse_event) {
  15921. var floatingObject;
  15922. switch (command_type) {
  15923. case Models.COMMAND_TYPES.break:
  15924. floatingObject = BreaksManagement.createFloatingCommand();
  15925. break;
  15926. case Models.COMMAND_TYPES.comment:
  15927. floatingObject = CommentsManagement.createFloatingCommand();
  15928. break;
  15929. case Models.COMMAND_TYPES.reader:
  15930. floatingObject = ReadersManagement.createFloatingCommand();
  15931. break;
  15932. case Models.COMMAND_TYPES.writer:
  15933. floatingObject = WritersManagement.createFloatingCommand();
  15934. break;
  15935. case Models.COMMAND_TYPES.attribution:
  15936. floatingObject = AttributionsManagement.createFloatingCommand();
  15937. break;
  15938. case Models.COMMAND_TYPES.iftrue:
  15939. floatingObject = IftruesManagement.createFloatingCommand();
  15940. break;
  15941. case Models.COMMAND_TYPES.repeatNtimes:
  15942. floatingObject = RepeatNtimesManagement.createFloatingCommand();
  15943. break;
  15944. case Models.COMMAND_TYPES.whiletrue:
  15945. floatingObject = WhiletruesManagement.createFloatingCommand();
  15946. break;
  15947. case Models.COMMAND_TYPES.dowhiletrue:
  15948. floatingObject = DowhiletruesManagement.createFloatingCommand();
  15949. break;
  15950. case Models.COMMAND_TYPES.switch:
  15951. floatingObject = SwitchesManagement.createFloatingCommand();
  15952. break;
  15953. case Models.COMMAND_TYPES.functioncall:
  15954. floatingObject = FunctioncallsManagement.createFloatingCommand();
  15955. break;
  15956. case Models.COMMAND_TYPES.return:
  15957. floatingObject = ReturnsManagement.createFloatingCommand();
  15958. break;
  15959. }
  15960. floatingObject.draggable({
  15961. drag: function drag(evt) {
  15962. borderMouseDragCommand(function_obj, function_container, evt);
  15963. },
  15964. stop: function stop(evt) {
  15965. function_container.find('.over_command_drag').each(function (index) {
  15966. (0, _jquery2.default)(this).removeClass('over_command_drag');
  15967. });
  15968. }
  15969. }).appendTo("body");
  15970. floatingObject.mouseup(function (evt) {
  15971. manageCommand(function_obj, function_container, evt, command_type);
  15972. });
  15973. floatingObject.css("position", "absolute");
  15974. mouse_event.type = "mousedown.draggable";
  15975. mouse_event.target = floatingObject[0];
  15976. floatingObject.css("left", mouse_event.pageX - 15);
  15977. floatingObject.css("top", mouse_event.pageY - 15);
  15978. floatingObject.trigger(mouse_event);
  15979. }
  15980. function borderMouseDragCommand(function_obj, function_container, evt) {
  15981. function_container.find('.over_command_drag').each(function (index) {
  15982. (0, _jquery2.default)(this).removeClass('over_command_drag');
  15983. });
  15984. var prev = null;
  15985. function_container.find('.commands_list_div').each(function (index) {
  15986. prev = (0, _jquery2.default)(this);
  15987. if (prev) {
  15988. var objLeft = prev.offset().left;
  15989. var objTop = prev.offset().top;
  15990. var objRight = objLeft + prev.width();
  15991. var objBottom = objTop + prev.height();
  15992. if (evt.pageX > objLeft && evt.pageX < objRight && evt.pageY > objTop && evt.pageY < objBottom) {
  15993. prev.addClass("over_command_drag");
  15994. }
  15995. }
  15996. });
  15997. function_container.find('.command_container').each(function (index) {
  15998. var obj = (0, _jquery2.default)(this);
  15999. var objLeft = obj.offset().left;
  16000. var objTop = obj.offset().top;
  16001. var objRight = objLeft + obj.width();
  16002. var objBottom = objTop + obj.height();
  16003. if (evt.pageX > objLeft && evt.pageX < objRight && evt.pageY > objTop && evt.pageY < objBottom) {
  16004. if (prev) {
  16005. prev.removeClass('over_command_drag');
  16006. }
  16007. obj.addClass("over_command_drag");
  16008. return;
  16009. }
  16010. });
  16011. }
  16012. // before_after_inside: 1 -> before, 2 -> after, 3 -> inside
  16013. function renderCommand(command, element_reference, before_after_inside, function_obj) {
  16014. var createdElement;
  16015. switch (command.type) {
  16016. case Models.COMMAND_TYPES.comment:
  16017. createdElement = CommentsManagement.renderCommand(command, function_obj);
  16018. break;
  16019. case Models.COMMAND_TYPES.break:
  16020. createdElement = BreaksManagement.renderCommand(command, function_obj);
  16021. break;
  16022. case Models.COMMAND_TYPES.reader:
  16023. createdElement = ReadersManagement.renderCommand(command, function_obj);
  16024. break;
  16025. case Models.COMMAND_TYPES.writer:
  16026. createdElement = WritersManagement.renderCommand(command, function_obj);
  16027. break;
  16028. case Models.COMMAND_TYPES.attribution:
  16029. createdElement = AttributionsManagement.renderCommand(command, function_obj);
  16030. break;
  16031. case Models.COMMAND_TYPES.functioncall:
  16032. createdElement = FunctioncallsManagement.renderCommand(command, function_obj);
  16033. break;
  16034. case Models.COMMAND_TYPES.iftrue:
  16035. createdElement = IftruesManagement.renderCommand(command, function_obj);
  16036. break;
  16037. case Models.COMMAND_TYPES.repeatNtimes:
  16038. createdElement = RepeatNtimesManagement.renderCommand(command, function_obj);
  16039. break;
  16040. case Models.COMMAND_TYPES.whiletrue:
  16041. createdElement = WhiletruesManagement.renderCommand(command, function_obj);
  16042. break;
  16043. case Models.COMMAND_TYPES.dowhiletrue:
  16044. createdElement = DowhiletruesManagement.renderCommand(command, function_obj);
  16045. break;
  16046. case Models.COMMAND_TYPES.switch:
  16047. createdElement = SwitchesManagement.renderCommand(command, function_obj);
  16048. break;
  16049. case Models.COMMAND_TYPES.return:
  16050. createdElement = ReturnsManagement.renderCommand(command, function_obj);
  16051. break;
  16052. }
  16053. switch (before_after_inside) {
  16054. case 1:
  16055. createdElement.insertBefore(element_reference);
  16056. break;
  16057. case 2:
  16058. createdElement.insertAfter(element_reference);
  16059. break;
  16060. case 3:
  16061. element_reference.append(createdElement);
  16062. break;
  16063. }
  16064. }
  16065. function genericCreateCommand(command_type) {
  16066. switch (command_type) {
  16067. case Models.COMMAND_TYPES.break:
  16068. return new Models.Break();
  16069. case Models.COMMAND_TYPES.comment:
  16070. return new Models.Comment(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_value, _localizedStringsService.LocalizedStrings.getUI('text_comment'), null, null, false));
  16071. case Models.COMMAND_TYPES.reader:
  16072. return new Models.Reader(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_variable, null, null, null, false));
  16073. case Models.COMMAND_TYPES.writer:
  16074. return new Models.Writer([new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  16075. case Models.COMMAND_TYPES.attribution:
  16076. return new Models.Attribution(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_variable, null, null, null, false), []);
  16077. case Models.COMMAND_TYPES.functioncall:
  16078. return new Models.FunctionCall(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_function, null, null, null, false), null);
  16079. case Models.COMMAND_TYPES.iftrue:
  16080. return new Models.IfTrue(new Models.ConditionalExpression(null), null, null);
  16081. case Models.COMMAND_TYPES.repeatNtimes:
  16082. return new Models.RepeatNTimes(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_variable, null, null, null, false), new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_variable, null, null, null, false), null, new Models.ConditionalExpression(null), null, null);
  16083. case Models.COMMAND_TYPES.whiletrue:
  16084. return new Models.WhileTrue(new Models.ConditionalExpression(null), null);
  16085. case Models.COMMAND_TYPES.dowhiletrue:
  16086. return new Models.DoWhileTrue(new Models.ConditionalExpression(null), null);
  16087. case Models.COMMAND_TYPES.switch:
  16088. var sc = [new Models.SwitchCase(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true))];
  16089. return new Models.Switch(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.variable_and_function, null, null, null, true), sc);
  16090. case Models.COMMAND_TYPES.return:
  16091. return new Models.Return(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  16092. }
  16093. }
  16094. function dragTrash(event) {
  16095. var trash = (0, _jquery2.default)('<i class="ui icon trash alternate outline"></i>');
  16096. (0, _jquery2.default)('body').append(trash);
  16097. trash.css('position', 'absolute');
  16098. trash.css('top', event.clientY);
  16099. trash.css('left', event.clientX - 20);
  16100. trash.css('font-size', '3em');
  16101. trash.css('display', 'none');
  16102. trash.fadeIn(200, function () {
  16103. trash.fadeOut(200, function () {
  16104. trash.remove();
  16105. });
  16106. });
  16107. }
  16108. function manageCommand(function_obj, function_container, event, command_type) {
  16109. (0, _jquery2.default)(".created_element").each(function (index) {
  16110. (0, _jquery2.default)(this).remove();
  16111. });
  16112. var el = (0, _jquery2.default)(document.elementFromPoint(event.clientX, event.clientY));
  16113. console.log('soltou no: ');
  16114. console.log(el);
  16115. console.log(el.data('fun'));
  16116. // Primeiro verificar se ele soltou no espaço da função correta:
  16117. var hier = el.parentsUntil(".all_functions");
  16118. var esta_correto = false;
  16119. var esta_na_div_correta = false;
  16120. if (el.hasClass("commands_list_div")) {
  16121. esta_na_div_correta = true;
  16122. }
  16123. for (var i = 0; i < hier.length; i++) {
  16124. var temp = (0, _jquery2.default)(hier[i]);
  16125. if (temp.hasClass("commands_list_div")) {
  16126. esta_na_div_correta = true;
  16127. }
  16128. if (temp.data('fun') == function_obj) {
  16129. esta_correto = true;
  16130. break;
  16131. }
  16132. }
  16133. if (!esta_correto) {
  16134. has_element_created_draged = false;
  16135. which_element_is_draged = null;
  16136. dragTrash(event);
  16137. return;
  16138. } else {
  16139. if (!esta_na_div_correta) {
  16140. has_element_created_draged = false;
  16141. which_element_is_draged = null;
  16142. dragTrash(event);
  16143. return;
  16144. }
  16145. }
  16146. // Agora é descobrir qual o escopo para adicionar o comando:
  16147. // Se o elemento clicado possuir o atributo "fun", então, é direto na div dos comandos:
  16148. if (typeof el.data('fun') !== 'undefined') {
  16149. // Se a lista de comandos estiver vazia, então é o primeiro.
  16150. // Portanto, ele deve soltar o elemento obrigatoriamente no objeto vazio
  16151. if (el.data('fun').commands == null || el.data('fun').commands.length == 0) {
  16152. // pode adicionar
  16153. el.data('fun').commands = [];
  16154. var new_cmd = genericCreateCommand(command_type);
  16155. el.data('fun').commands.push(new_cmd);
  16156. renderCommand(new_cmd, (0, _jquery2.default)(function_container).find('.commands_list_div'), 3, function_obj);
  16157. } else {
  16158. // Entra nesse else, caso já existam outros comandos no bloco:
  16159. findNearbyCommandToAddInFunctionScope(el, event, (0, _jquery2.default)(function_container).find('.commands_list_div'), function_obj, command_type);
  16160. }
  16161. } else {
  16162. console.log("soltou em um comando");
  16163. // descobrir em qual comando ele soltou:
  16164. var hier_find = el.parentsUntil(".commands_list_div");
  16165. var hierarquia_bottom_up = [];
  16166. if (typeof el.data('command') !== 'undefined') {
  16167. hierarquia_bottom_up.push(el.data('command'));
  16168. }
  16169. for (var i = 0; i < hier_find.length; i++) {
  16170. if (typeof (0, _jquery2.default)(hier_find[i]).data('command') !== 'undefined') {
  16171. hierarquia_bottom_up.push((0, _jquery2.default)(hier_find[i]).data('command'));
  16172. }
  16173. }
  16174. console.log("comando em que soltou: ");
  16175. console.log(hierarquia_bottom_up[0]);
  16176. console.log("hierarquia de baixo para cima na árvore, de onde ele soltou: ");
  16177. for (var i = 0; i < hierarquia_bottom_up.length; i++) {
  16178. console.log(hierarquia_bottom_up[i]);
  16179. }
  16180. // Se for do tipo break, verificar se está no contexto correto:
  16181. // Caso não esteja no contexto, apenas retorna sem dar continuidade:
  16182. var is_correct_context = false;
  16183. if (command_type == Models.COMMAND_TYPES.break) {
  16184. for (var i = 0; i < hierarquia_bottom_up.length; i++) {
  16185. if (hierarquia_bottom_up[i].type == Models.COMMAND_TYPES.repeatNtimes || hierarquia_bottom_up[i].type == Models.COMMAND_TYPES.whiletrue || hierarquia_bottom_up[i].type == Models.COMMAND_TYPES.dowhiletrue || hierarquia_bottom_up[i].type == Models.COMMAND_TYPES.switch) {
  16186. is_correct_context = true;
  16187. break;
  16188. }
  16189. }
  16190. if (!is_correct_context) {
  16191. console.error("Context not allowed to insert BREAK COMMAND!");
  16192. return;
  16193. }
  16194. }
  16195. // se a hierarquia possuir apenas um elemento, então está na raiz dos comandos:
  16196. if (hierarquia_bottom_up.length == 1) {
  16197. console.log('QQ1');
  16198. var sub_elemento = false;
  16199. for (var i = 0; i < hier_find.length; i++) {
  16200. if (typeof (0, _jquery2.default)(hier_find[i]).data('command') !== 'undefined') {
  16201. console.log('QQ2');
  16202. findBeforeOrAfterCommandToAdd(hier_find[i], event, function_obj, command_type);
  16203. sub_elemento = true;
  16204. break;
  16205. }
  16206. }
  16207. if (!sub_elemento) {
  16208. console.log('QQ3');
  16209. findBeforeOrAfterCommandToAdd(el[0], event, function_obj, command_type);
  16210. }
  16211. } else {
  16212. console.log('QQ4');
  16213. // caso exista mais de um elemento na hierarquia:
  16214. if (typeof (0, _jquery2.default)(el).data('command') !== 'undefined') {
  16215. console.log('QQ5');
  16216. console.log("PPP1");
  16217. insertCommandInBlockHierar(el[0], event, function_obj, command_type, hier_find, hierarquia_bottom_up);
  16218. } else {
  16219. console.log('QQ6');
  16220. var sub_elemento = false;
  16221. for (var i = 0; i < hier_find.length; i++) {
  16222. if (typeof (0, _jquery2.default)(hier_find[i]).data('command') !== 'undefined') {
  16223. console.log('QQ7');
  16224. insertCommandInBlockHierar(hier_find[i], event, function_obj, command_type, hier_find, hierarquia_bottom_up);
  16225. sub_elemento = true;
  16226. break;
  16227. }
  16228. }
  16229. }
  16230. }
  16231. }
  16232. has_element_created_draged = false;
  16233. which_element_is_draged = null;
  16234. renderAlgorithm();
  16235. }
  16236. function insertCommandInBlockHierar(el, event, function_obj, command_type, hier_dom, hier_obj) {
  16237. var el_jq = (0, _jquery2.default)(el);
  16238. var command_parent = el_jq.data('command');
  16239. if (el_jq.data('command').type == Models.COMMAND_TYPES.repeatNtimes || el_jq.data('command').type == Models.COMMAND_TYPES.whiletrue || el_jq.data('command').type == Models.COMMAND_TYPES.dowhiletrue || el_jq.data('command').type == Models.COMMAND_TYPES.switch) {
  16240. console.log('QQ17');
  16241. if (el_jq.data('command').type == Models.COMMAND_TYPES.repeatNtimes || el_jq.data('command').type == Models.COMMAND_TYPES.whiletrue || el_jq.data('command').type == Models.COMMAND_TYPES.dowhiletrue) {
  16242. console.log('QQ18');
  16243. // Se não tiver outro comando ainda no bloco, só adiciona:
  16244. if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
  16245. command_parent.commands_block = [];
  16246. var recentComand = genericCreateCommand(command_type);
  16247. command_parent.commands_block.push(recentComand);
  16248. renderCommand(recentComand, el_jq.find('.block_commands'), 3, function_obj);
  16249. } else {
  16250. // Se já tem algum comando no bloco:
  16251. findNearbyCommandToAddInBlockScope(el, event, el, function_obj, command_type, command_parent);
  16252. }
  16253. } else {
  16254. // QUANDO FOR BLOCO DO TIPO IF OU SWITCH/CASE:
  16255. addCommandToSwitchCase(event, function_obj, command_type);
  16256. }
  16257. } else {
  16258. console.log('QQ19');
  16259. // entra neste bloco, se soltou o comando sobre outro comando dentro de um subbloco:
  16260. findBeforeOrAfterCommandToAddInsertBlock(el, event, function_obj, command_type);
  16261. }
  16262. }
  16263. function findNearbyCommandToAddInBlockScope(el, event, node_list_commands, function_obj, command_type, command_parent) {
  16264. var all_sub = (0, _jquery2.default)(node_list_commands).find('div.command_container');
  16265. var menor_distancia = 999999999;
  16266. var elemento_menor_distancia = null;
  16267. var antes = true;
  16268. var t_bot;
  16269. var t_top;
  16270. // Descobrindo o elemento mais próximo:
  16271. for (var i = 0; i < all_sub.length; i++) {
  16272. t_top = all_sub[i].getBoundingClientRect().top;
  16273. t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
  16274. if (t_top - event.clientY < menor_distancia) {
  16275. menor_distancia = event.clientY - t_top;
  16276. elemento_menor_distancia = all_sub[i];
  16277. }
  16278. }
  16279. var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height;
  16280. // Está mais próximo da borda de baixo, ou seja.. inserir por último:
  16281. if (borda_inferior - event.clientY < menor_distancia) {
  16282. var recentComand = genericCreateCommand(command_type);
  16283. command_parent.commands_block.push(recentComand);
  16284. //
  16285. renderCommand(recentComand, node_list_commands, 3, function_obj);
  16286. } else {
  16287. var recentComand = genericCreateCommand(command_type);
  16288. var index = command_parent.commands_block.indexOf((0, _jquery2.default)(elemento_menor_distancia).data('command'));
  16289. if (index > -1) {
  16290. command_parent.commands_block.splice(index, 0, recentComand);
  16291. }
  16292. renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
  16293. }
  16294. }
  16295. function findBeforeOrAfterCommandToAddInsertBlock(el, event, function_obj, command_type) {
  16296. var el_jq = (0, _jquery2.default)(el);
  16297. var command_parent = (0, _jquery2.default)(el.parentNode.parentNode).data('command');
  16298. var command_target = el_jq.data('command');
  16299. var temp_parent = (0, _jquery2.default)(el.parentNode.parentNode);
  16300. var is_in_else = false;
  16301. if (!command_parent) {
  16302. command_parent = el_jq.data('command');
  16303. temp_parent = el_jq;
  16304. var hier = el_jq.parentsUntil(".command_container");
  16305. for (var i = 0; i < hier.length; i++) {
  16306. var temp = (0, _jquery2.default)(hier[i]);
  16307. if (typeof temp.data('else') != 'undefined') {
  16308. is_in_else = true;
  16309. }
  16310. if (typeof temp.data('command') != 'undefined') {
  16311. command_parent = temp.data('command');
  16312. temp_parent = temp;
  16313. }
  16314. }
  16315. }
  16316. var hier = el_jq.parentsUntil(".command_container");
  16317. for (var i = 0; i < hier.length; i++) {
  16318. var temp = (0, _jquery2.default)(hier[i]);
  16319. if (typeof temp.data('else') != 'undefined') {
  16320. is_in_else = true;
  16321. }
  16322. }
  16323. if (command_parent == command_target) {
  16324. var hier = el_jq.parentsUntil(".command_container");
  16325. for (var i = 0; i < hier.length; i++) {
  16326. var temp = (0, _jquery2.default)(hier[i]);
  16327. if (typeof temp.data('else') !== 'undefined') {
  16328. is_in_else = true;
  16329. break;
  16330. }
  16331. }
  16332. }
  16333. if (command_parent.type != Models.COMMAND_TYPES.iftrue && command_parent.type != Models.COMMAND_TYPES.switch) {
  16334. var hier = temp_parent.parentsUntil(".all_cases_div");
  16335. console.log("vou procurar!!");
  16336. for (var i = 0; i < hier.length; i++) {
  16337. console.log("estou vasculhando...");
  16338. var temp = (0, _jquery2.default)(hier[i]);
  16339. if (typeof temp.data('switchcase') !== 'undefined') {
  16340. console.log("encontrei");
  16341. command_parent = temp.data('switchcase');
  16342. is_in_else = false;
  16343. break;
  16344. }
  16345. }
  16346. }
  16347. console.log('debugging:');
  16348. console.log('el_jq');
  16349. console.log(el_jq);
  16350. console.log('command_parent');
  16351. console.log(command_parent);
  16352. console.log('command_target');
  16353. console.log(command_target);
  16354. var menor_distancia = 999999999;
  16355. var antes = true;
  16356. var t_bot;
  16357. var t_top;
  16358. t_top = el.getBoundingClientRect().top;
  16359. t_bot = el.getBoundingClientRect().top + el.getBoundingClientRect().height;
  16360. var d_top = event.clientY - t_top; // distancia topo
  16361. var d_bot = t_bot - event.clientY; // distancia baixo
  16362. // Está mais próximo da borda de baixo, ou seja.. inserir por último:
  16363. if (d_top < d_bot) {
  16364. var recentComand = genericCreateCommand(command_type);
  16365. console.log('MMM1');
  16366. if (is_in_else) {
  16367. console.log('MMM2');
  16368. if (command_parent == command_target) {
  16369. console.log('MMM3');
  16370. if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
  16371. command_parent.commands_else = [];
  16372. var recentComand = genericCreateCommand(command_type);
  16373. command_parent.commands_else.push(recentComand);
  16374. renderCommand(recentComand, el_jq, 3, function_obj);
  16375. } else {
  16376. // Se já tem algum comando no bloco:
  16377. findInBlockCorrectPlace(el_jq, event, function_obj, command_type, true);
  16378. }
  16379. return;
  16380. }
  16381. console.log('MMM7');
  16382. var index = command_parent.commands_else.indexOf(command_target);
  16383. if (index > -1) {
  16384. command_parent.commands_else.splice(index, 0, recentComand);
  16385. }
  16386. renderCommand(recentComand, el, 1, function_obj);
  16387. } else {
  16388. console.log('MMM4');
  16389. if (command_parent == command_target) {
  16390. console.log('Nxxxx5');
  16391. if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
  16392. command_parent.commands_block = [];
  16393. console.log('SSS4');
  16394. var recentComand = genericCreateCommand(command_type);
  16395. command_parent.commands_block.push(recentComand);
  16396. renderCommand(recentComand, el_jq, 3, function_obj);
  16397. } else {
  16398. console.log('SSS5');
  16399. findInBlockCorrectPlace(el_jq, event, function_obj, command_type);
  16400. }
  16401. return;
  16402. }
  16403. console.log('MMM6');
  16404. var index = command_parent.commands_block.indexOf(command_target);
  16405. if (index > -1) {
  16406. command_parent.commands_block.splice(index, 0, recentComand);
  16407. }
  16408. renderCommand(recentComand, el, 1, function_obj);
  16409. }
  16410. } else {
  16411. console.log('XXX1');
  16412. var recentComand = genericCreateCommand(command_type);
  16413. if (is_in_else) {
  16414. if (command_parent == command_target) {
  16415. console.log('MMM3');
  16416. if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
  16417. command_parent.commands_else = [];
  16418. console.log('SSS1');
  16419. var recentComand = genericCreateCommand(command_type);
  16420. command_parent.commands_else.push(recentComand);
  16421. renderCommand(recentComand, el_jq, 3, function_obj);
  16422. } else {
  16423. // Se já tem algum comando no bloco:
  16424. console.log('SSS2');
  16425. findInBlockCorrectPlace(el_jq, event, function_obj, command_type, true);
  16426. }
  16427. return;
  16428. }
  16429. console.log('XXX2');
  16430. var index = command_parent.commands_else.indexOf(command_target);
  16431. if (index > -1) {
  16432. command_parent.commands_else.splice(index + 1, 0, recentComand);
  16433. }
  16434. renderCommand(recentComand, el, 2, function_obj);
  16435. } else {
  16436. if (command_parent == command_target) {
  16437. console.log('Nxxxx78');
  16438. if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
  16439. command_parent.commands_block = [];
  16440. var recentComand = genericCreateCommand(command_type);
  16441. command_parent.commands_block.push(recentComand);
  16442. console.log('SSS6');
  16443. renderCommand(recentComand, el_jq, 3, function_obj);
  16444. } else {
  16445. console.log('SSS7');
  16446. findInBlockCorrectPlace(el_jq, event, function_obj, command_type);
  16447. }
  16448. return;
  16449. }
  16450. console.log('XXX3');
  16451. var index = command_parent.commands_block.indexOf(command_target);
  16452. if (index > -1) {
  16453. command_parent.commands_block.splice(index + 1, 0, recentComand);
  16454. }
  16455. renderCommand(recentComand, el, 2, function_obj);
  16456. }
  16457. }
  16458. }
  16459. function insertCommandInBlock(el, event, function_obj, command_type) {
  16460. var el_jq = (0, _jquery2.default)(el);
  16461. var command_parent = el_jq.data('command');
  16462. if (el_jq.data('command').type == Models.COMMAND_TYPES.repeatNtimes || el_jq.data('command').type == Models.COMMAND_TYPES.whiletrue || el_jq.data('command').type == Models.COMMAND_TYPES.dowhiletrue) {
  16463. // Se não tiver outro comando ainda no bloco, só adiciona:
  16464. if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
  16465. command_parent.commands_block = [];
  16466. var recentComand = genericCreateCommand(command_type);
  16467. command_parent.commands_block.push(recentComand);
  16468. renderCommand(recentComand, el_jq.find('.block_commands'), 3, function_obj);
  16469. } else {
  16470. // Se já tem algum comando no bloco:
  16471. findInBlockCorrectPlace(el, event, function_obj, command_type);
  16472. }
  16473. } else if (el_jq.data('command').type == Models.COMMAND_TYPES.iftrue) {
  16474. console.log('QQ9');
  16475. // no if ou no else?
  16476. var correct_div = (0, _jquery2.default)(document.elementFromPoint(event.pageX, event.pageY));
  16477. var is_in_if = true;
  16478. if (correct_div.data('if')) {
  16479. is_in_if = true;
  16480. } else if (correct_div.data('else')) {
  16481. is_in_if = false;
  16482. } else {
  16483. var hier = correct_div.parentsUntil(".command_container");
  16484. for (var i = 0; i < hier.length; i++) {
  16485. var temp = (0, _jquery2.default)(hier[i]);
  16486. if (typeof temp.data('if') !== 'undefined') {
  16487. is_in_if = true;
  16488. break;
  16489. }
  16490. if (typeof temp.data('else') !== 'undefined') {
  16491. is_in_if = false;
  16492. break;
  16493. }
  16494. }
  16495. }
  16496. if (is_in_if) {
  16497. if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
  16498. command_parent.commands_block = [];
  16499. var recentComand = genericCreateCommand(command_type);
  16500. command_parent.commands_block.push(recentComand);
  16501. renderCommand(recentComand, el_jq.find('.commands_if'), 3, function_obj);
  16502. } else {
  16503. // Se já tem algum comando no bloco:
  16504. findInBlockCorrectPlace(el_jq.find('.commands_if'), event, function_obj, command_type);
  16505. }
  16506. } else {
  16507. if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
  16508. command_parent.commands_else = [];
  16509. var recentComand = genericCreateCommand(command_type);
  16510. command_parent.commands_else.push(recentComand);
  16511. renderCommand(recentComand, el_jq.find('.commands_else'), 3, function_obj);
  16512. } else {
  16513. // Se já tem algum comando no bloco:
  16514. findInBlockCorrectPlace(el_jq.find('.commands_else'), event, function_obj, command_type, true);
  16515. }
  16516. }
  16517. } else {
  16518. // é do tipo switch
  16519. console.log("está tentando inserir em um switch que está na raiz!");
  16520. addCommandToSwitchCase(event, function_obj, command_type);
  16521. }
  16522. }
  16523. function addCommandToSwitchCase(event, function_obj, command_type) {
  16524. var el = (0, _jquery2.default)(document.elementFromPoint(event.clientX, event.clientY));
  16525. var which_case = el.data('switchcase');
  16526. var case_div = el;
  16527. if (!which_case) {
  16528. var hier_find = el.parentsUntil(".all_cases_div");
  16529. for (var i = 0; i < hier_find.length; i++) {
  16530. if (typeof (0, _jquery2.default)(hier_find[i]).data('switchcase') !== 'undefined') {
  16531. which_case = (0, _jquery2.default)(hier_find[i]).data('switchcase');
  16532. case_div = (0, _jquery2.default)(hier_find[i]);
  16533. break;
  16534. }
  16535. }
  16536. }
  16537. if (which_case.commands_block == null || which_case.commands_block.length < 1) {
  16538. which_case.commands_block = [];
  16539. var recentComand = genericCreateCommand(command_type);
  16540. which_case.commands_block.push(recentComand);
  16541. renderCommand(recentComand, case_div.find('.case_commands_block'), 3, function_obj);
  16542. } else {
  16543. findInBlockCorrectPlaceInSwitchCase(which_case, case_div, event, function_obj, command_type);
  16544. }
  16545. }
  16546. function findInBlockCorrectPlaceInSwitchCase(which_case, case_div, event, function_obj, command_type) {
  16547. var all_sub = case_div.find('div.command_container');
  16548. var menor_distancia = 999999999;
  16549. var elemento_menor_distancia = null;
  16550. var antes = true;
  16551. var t_bot;
  16552. var t_top;
  16553. // Descobrindo o elemento mais próximo:
  16554. for (var i = 0; i < all_sub.length; i++) {
  16555. t_top = all_sub[i].getBoundingClientRect().top;
  16556. t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
  16557. if (t_top - event.clientY < menor_distancia) {
  16558. menor_distancia = event.clientY - t_top;
  16559. elemento_menor_distancia = all_sub[i];
  16560. }
  16561. }
  16562. var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height;
  16563. // Está mais próximo da borda de baixo, ou seja.. inserir por último:
  16564. if (borda_inferior - event.clientY < menor_distancia) {
  16565. var recentComand = genericCreateCommand(command_type);
  16566. which_case.commands_block.push(recentComand);
  16567. renderCommand(recentComand, (0, _jquery2.default)(case_div.find('.case_commands_block')[0]), 3, function_obj);
  16568. } else {
  16569. var recentComand = genericCreateCommand(command_type);
  16570. var index = which_case.commands_block.indexOf((0, _jquery2.default)(elemento_menor_distancia).data('command'));
  16571. if (index > -1) {
  16572. which_case.commands_block.splice(index, 0, recentComand);
  16573. renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
  16574. }
  16575. }
  16576. }
  16577. function findInBlockCorrectPlace(el, event, function_obj, command_type) {
  16578. var is_in_else = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  16579. var el_jq = (0, _jquery2.default)(el);
  16580. var all_sub = el_jq.find('div.command_container');
  16581. var menor_distancia = 999999999;
  16582. var elemento_menor_distancia = null;
  16583. var antes = true;
  16584. var t_bot;
  16585. var t_top;
  16586. // Descobrindo o elemento mais próximo:
  16587. for (var i = 0; i < all_sub.length; i++) {
  16588. t_top = all_sub[i].getBoundingClientRect().top;
  16589. t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
  16590. if (t_top - event.clientY < menor_distancia) {
  16591. menor_distancia = event.clientY - t_top;
  16592. elemento_menor_distancia = all_sub[i];
  16593. }
  16594. }
  16595. var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height;
  16596. console.log("menor_distancia: ");
  16597. console.log(elemento_menor_distancia);
  16598. // Está mais próximo da borda de baixo, ou seja.. inserir por último:
  16599. if (borda_inferior - event.clientY < menor_distancia) {
  16600. console.log('QQ11');
  16601. var recentComand = genericCreateCommand(command_type);
  16602. var command_parent = el_jq.data('command');
  16603. if (is_in_else) {
  16604. console.log('QQ15');
  16605. command_parent.commands_else.push(recentComand);
  16606. console.log('el_jq');
  16607. console.log(el_jq);
  16608. console.log("$(el_jq.find('.commands_else')[0]):: ");
  16609. console.log((0, _jquery2.default)(el_jq.find('.commands_else')[0]));
  16610. renderCommand(recentComand, el_jq, 3, function_obj);
  16611. } else {
  16612. console.log('QQ16');
  16613. command_parent.commands_block.push(recentComand);
  16614. renderCommand(recentComand, (0, _jquery2.default)(el_jq.find('.block_commands')[0]), 3, function_obj);
  16615. }
  16616. } else {
  16617. console.log('QQ12');
  16618. var recentComand = genericCreateCommand(command_type);
  16619. var command_parent = el_jq.data('command');
  16620. if (is_in_else) {
  16621. var index = command_parent.commands_else.indexOf((0, _jquery2.default)(elemento_menor_distancia).data('command'));
  16622. if (index > -1) {
  16623. command_parent.commands_else.splice(index, 0, recentComand);
  16624. renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
  16625. }
  16626. } else {
  16627. var index = command_parent.commands_block.indexOf((0, _jquery2.default)(elemento_menor_distancia).data('command'));
  16628. if (index > -1) {
  16629. command_parent.commands_block.splice(index, 0, recentComand);
  16630. renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
  16631. }
  16632. }
  16633. }
  16634. }
  16635. function findBeforeOrAfterCommandToAdd(el, event, function_obj, command_type) {
  16636. switch ((0, _jquery2.default)(el).data('command').type) {
  16637. case Models.COMMAND_TYPES.iftrue:
  16638. case Models.COMMAND_TYPES.switch:
  16639. case Models.COMMAND_TYPES.repeatNtimes:
  16640. case Models.COMMAND_TYPES.whiletrue:
  16641. case Models.COMMAND_TYPES.dowhiletrue:
  16642. insertCommandInBlock(el, event, function_obj, command_type);
  16643. return;
  16644. }
  16645. var menor_distancia = 999999999;
  16646. var antes = true;
  16647. var t_bot;
  16648. var t_top;
  16649. t_top = el.getBoundingClientRect().top;
  16650. t_bot = el.getBoundingClientRect().top + el.getBoundingClientRect().height;
  16651. var d_top = event.clientY - t_top; // distancia topo
  16652. var d_bot = t_bot - event.clientY; // distancia baixo
  16653. // Está mais próximo da borda de baixo, ou seja.. inserir por último:
  16654. if (d_top < d_bot) {
  16655. var recentComand = genericCreateCommand(command_type);
  16656. var index = function_obj.commands.indexOf((0, _jquery2.default)(el).data('command'));
  16657. if (index > -1) {
  16658. function_obj.commands.splice(index, 0, recentComand);
  16659. }
  16660. renderCommand(recentComand, el, 1, function_obj);
  16661. } else {
  16662. var recentComand = genericCreateCommand(command_type);
  16663. var index = function_obj.commands.indexOf((0, _jquery2.default)(el).data('command'));
  16664. if (index > -1) {
  16665. function_obj.commands.splice(index + 1, 0, recentComand);
  16666. }
  16667. renderCommand(recentComand, el, 2, function_obj);
  16668. }
  16669. }
  16670. function findNearbyCommandToAddInFunctionScope(el, event, node_list_commands, function_obj, command_type) {
  16671. var all_sub = (0, _jquery2.default)(node_list_commands).find('div.command_container');
  16672. var menor_distancia = 999999999;
  16673. var elemento_menor_distancia = null;
  16674. var antes = true;
  16675. var t_bot;
  16676. var t_top;
  16677. // Descobrindo o elemento mais próximo:
  16678. for (var i = 0; i < all_sub.length; i++) {
  16679. t_top = all_sub[i].getBoundingClientRect().top;
  16680. t_bot = all_sub[i].getBoundingClientRect().top + all_sub[i].getBoundingClientRect().height;
  16681. if (t_top - event.clientY < menor_distancia) {
  16682. menor_distancia = event.clientY - t_top;
  16683. elemento_menor_distancia = all_sub[i];
  16684. }
  16685. }
  16686. var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height;
  16687. // Está mais próximo da borda de baixo, ou seja.. inserir por último:
  16688. if (borda_inferior - event.clientY < menor_distancia) {
  16689. var recentComand = genericCreateCommand(command_type);
  16690. function_obj.commands.push(recentComand);
  16691. //
  16692. renderCommand(recentComand, node_list_commands, 3, function_obj);
  16693. } else {
  16694. var recentComand = genericCreateCommand(command_type);
  16695. var index = function_obj.commands.indexOf((0, _jquery2.default)(elemento_menor_distancia).data('command'));
  16696. if (index > -1) {
  16697. function_obj.commands.splice(index, 0, recentComand);
  16698. }
  16699. renderCommand(recentComand, elemento_menor_distancia, 1, function_obj);
  16700. }
  16701. }
  16702. /***/ }),
  16703. /***/ "./js/visualUI/commands/attribution.js":
  16704. /*!*********************************************!*\
  16705. !*** ./js/visualUI/commands/attribution.js ***!
  16706. \*********************************************/
  16707. /*! no static exports found */
  16708. /***/ (function(module, exports, __webpack_require__) {
  16709. "use strict";
  16710. Object.defineProperty(exports, "__esModule", {
  16711. value: true
  16712. });
  16713. exports.createFloatingCommand = createFloatingCommand;
  16714. exports.renderCommand = renderCommand;
  16715. exports.manageExpressionElements = manageExpressionElements;
  16716. exports.renderMenuOperations = renderMenuOperations;
  16717. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  16718. var _jquery2 = _interopRequireDefault(_jquery);
  16719. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  16720. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  16721. var Models = _interopRequireWildcard(_ivprog_elements);
  16722. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  16723. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  16724. var GlobalsManagement = _interopRequireWildcard(_globals);
  16725. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  16726. var VariablesManagement = _interopRequireWildcard(_variables);
  16727. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  16728. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  16729. var VariableValueMenuManagement = _interopRequireWildcard(_variable_value_menu);
  16730. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  16731. var CommandsManagement = _interopRequireWildcard(_commands);
  16732. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  16733. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16734. function createFloatingCommand() {
  16735. return (0, _jquery2.default)('<div class="ui attribution created_element"> <i class="ui icon small arrow left"></i> <span> x = 1 + 1 </span></div>');
  16736. }
  16737. function renderCommand(command, function_obj) {
  16738. var el = (0, _jquery2.default)('<div class="ui attribution command_container"><i class="ui icon small arrow left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_attributed"></div> <span class="text_attr_receives span_command_spec">' + _localizedStringsService.LocalizedStrings.getUI('text_receives') + '</span> ' + '<div class="expression_elements"></div> </div>');
  16739. el.data('command', command);
  16740. VariableValueMenu.renderMenu(command, command.variable, el.find('.var_attributed'), function_obj);
  16741. if (!command.expression || command.expression.length < 1) {
  16742. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.none, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  16743. command.expression.push(exp);
  16744. }
  16745. addHandlers(command, function_obj, el);
  16746. renderExpressionElements(command, function_obj, el);
  16747. return el;
  16748. }
  16749. function manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, selectedItem, expression_element) {
  16750. var index_to_move = expression_element.itens.indexOf(ref_object);
  16751. switch (selectedItem.data('exp')) {
  16752. case Models.EXPRESSION_ELEMENTS.exp_op_exp:
  16753. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp, [expression_element.itens[index_to_move], Models.ARITHMETIC_TYPES.plus, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  16754. expression_element.itens[index_to_move] = exp;
  16755. break;
  16756. case Models.EXPRESSION_ELEMENTS.op_exp:
  16757. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.plus, expression_element.itens[index_to_move]]);
  16758. expression_element.itens[index_to_move] = exp;
  16759. break;
  16760. case Models.EXPRESSION_ELEMENTS.par_exp_par:
  16761. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.par_exp_par, [expression_element.itens[index_to_move]]);
  16762. expression_element.itens[index_to_move] = exp;
  16763. break;
  16764. }
  16765. renderExpressionElements(command, function_obj, dom_object);
  16766. }
  16767. function renderExpressionElements(command, function_obj, el) {
  16768. var expression_div = el.find('.expression_elements');
  16769. var command_container;
  16770. if (el.hasClass("command_container") == false) {
  16771. var hier = el.parentsUntil(".command_container");
  16772. for (var i = 0; i < hier.length; i++) {
  16773. if ((0, _jquery2.default)(hier[i]).hasClass("command_container")) {
  16774. command_container = (0, _jquery2.default)(hier[i]);
  16775. break;
  16776. }
  16777. if ((0, _jquery2.default)(hier[i]).hasClass("expression_elements")) {
  16778. expression_div = (0, _jquery2.default)(hier[i]);
  16779. break;
  16780. }
  16781. }
  16782. }
  16783. if (command_container) {
  16784. expression_div = command_container.find('.expression_elements');
  16785. }
  16786. expression_div.text('');
  16787. for (var i = 0; i < command.expression.length; i++) {
  16788. var temp = (0, _jquery2.default)('<div class="expression_element"></div>');
  16789. temp.data('ref_element', command.expression[i]);
  16790. temp.data('ref_index', i);
  16791. expression_div.append(temp);
  16792. renderElement(command, function_obj, temp, command.expression[i]);
  16793. }
  16794. }
  16795. function renderOperator(command, function_obj, temp_op, expression_element, index_op) {
  16796. var context_menu = '<div class="ui dropdown"><div class="text">';
  16797. switch (expression_element.itens[index_op]) {
  16798. case Models.ARITHMETIC_TYPES.plus:
  16799. context_menu += '+';
  16800. break;
  16801. case Models.ARITHMETIC_TYPES.minus:
  16802. context_menu += '-';
  16803. break;
  16804. case Models.ARITHMETIC_TYPES.multiplication:
  16805. context_menu += '*';
  16806. break;
  16807. case Models.ARITHMETIC_TYPES.division:
  16808. context_menu += '/';
  16809. break;
  16810. case Models.ARITHMETIC_TYPES.module:
  16811. context_menu += '%';
  16812. break;
  16813. case Models.ARITHMETIC_TYPES.none:
  16814. context_menu += '...';
  16815. break;
  16816. }
  16817. context_menu += '</div><div class="menu">';
  16818. context_menu += '<div class="item" data-value="' + Models.ARITHMETIC_TYPES.plus + '">+</div>';
  16819. context_menu += '<div class="item" data-value="' + Models.ARITHMETIC_TYPES.minus + '">-</div>';
  16820. context_menu += '<div class="item" data-value="' + Models.ARITHMETIC_TYPES.multiplication + '">*</div>';
  16821. context_menu += '<div class="item" data-value="' + Models.ARITHMETIC_TYPES.division + '">/</div>';
  16822. context_menu += '<div class="item" data-value="' + Models.ARITHMETIC_TYPES.module + '">%</div>';
  16823. context_menu += '<div class="item" data-value="' + Models.ARITHMETIC_TYPES.none + '" data-text="...">Nenhum</div>';
  16824. context_menu += '</div></div>';
  16825. context_menu = (0, _jquery2.default)(context_menu);
  16826. temp_op.append(context_menu);
  16827. context_menu.dropdown({
  16828. onChange: function onChange(value, text, $selectedItem) {
  16829. expression_element.itens[index_op] = value;
  16830. }
  16831. });
  16832. }
  16833. function renderMenuAddExpression(command, function_obj, el, dom_append_menu, expression_append_new_expression) {
  16834. if (el.hasClass("command_container") == false) {
  16835. var hier = el.parentsUntil(".commands_list_div");
  16836. for (var i = 0; i < hier.length; i++) {
  16837. if ((0, _jquery2.default)(hier[i]).hasClass("command_container")) {
  16838. el = (0, _jquery2.default)(hier[i]);
  16839. break;
  16840. }
  16841. }
  16842. }
  16843. if (dom_append_menu.hasClass("expression_elements") == false) {
  16844. var hier = el.parentsUntil(".commands_list_div");
  16845. for (var i = 0; i < hier.length; i++) {
  16846. if ((0, _jquery2.default)(hier[i]).hasClass("expression_elements")) {
  16847. dom_append_menu = (0, _jquery2.default)(hier[i]);
  16848. break;
  16849. }
  16850. }
  16851. }
  16852. var context_menu = '<div class="ui dropdown"><div class="text"></div><i class="ui icon arrow alternate circle right outline"></i><div class="menu">';
  16853. context_menu += '<div class="item" data-value="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  16854. context_menu += '<div class="item" data-value="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  16855. context_menu += '<div class="item" data-value="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  16856. context_menu += '</div></div>';
  16857. context_menu = (0, _jquery2.default)(context_menu);
  16858. dom_append_menu.append(context_menu);
  16859. context_menu.dropdown({
  16860. onChange: function onChange(value, text, $selectedItem) {
  16861. switch (value) {
  16862. case Models.EXPRESSION_ELEMENTS.exp_op_exp:
  16863. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp, [new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true), Models.ARITHMETIC_TYPES.plus, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  16864. expression_append_new_expression.push(exp);
  16865. break;
  16866. case Models.EXPRESSION_ELEMENTS.op_exp:
  16867. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.op_exp, [Models.ARITHMETIC_TYPES.plus, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  16868. expression_append_new_expression.push(exp);
  16869. break;
  16870. case Models.EXPRESSION_ELEMENTS.par_exp_par:
  16871. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.par_exp_par, [new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  16872. expression_append_new_expression.push(exp);
  16873. break;
  16874. }
  16875. renderExpressionElements(command, function_obj, el);
  16876. }
  16877. });
  16878. }
  16879. function renderElement(command, function_obj, el, expression_element) {
  16880. switch (expression_element.type_exp) {
  16881. case Models.EXPRESSION_ELEMENTS.exp_op_exp:
  16882. var temp_op = (0, _jquery2.default)('<div class="component_element"></div>');
  16883. var temp_exp_1 = (0, _jquery2.default)('<div class="component_element"></div>');
  16884. var temp_exp_2 = (0, _jquery2.default)('<div class="component_element"></div>');
  16885. el.append(temp_exp_1);
  16886. el.append(temp_op);
  16887. el.append(temp_exp_2);
  16888. if (expression_element.itens[0].type) {
  16889. VariableValueMenu.renderMenu(command, expression_element.itens[0], temp_exp_1, function_obj, 2, expression_element);
  16890. } else {
  16891. renderElement(command, function_obj, temp_exp_1, expression_element.itens[0]);
  16892. }
  16893. renderOperator(command, function_obj, temp_op, expression_element, 1);
  16894. if (expression_element.itens[2].type) {
  16895. VariableValueMenu.renderMenu(command, expression_element.itens[2], temp_exp_2, function_obj, 2, expression_element);
  16896. } else {
  16897. renderElement(command, function_obj, temp_exp_2, expression_element.itens[2]);
  16898. }
  16899. break;
  16900. case Models.EXPRESSION_ELEMENTS.op_exp:
  16901. var temp_op = (0, _jquery2.default)('<div class="component_element"></div>');
  16902. var temp_exp = (0, _jquery2.default)('<div class="component_element"></div>');
  16903. el.append(temp_op);
  16904. el.append(temp_exp);
  16905. renderOperator(command, function_obj, temp_op, expression_element, 0);
  16906. if (expression_element.itens[1].type) {
  16907. VariableValueMenu.renderMenu(command, expression_element.itens[1], temp_exp, function_obj, 2, expression_element);
  16908. } else {
  16909. renderElement(command, function_obj, temp_exp, expression_element.itens[1]);
  16910. }
  16911. break;
  16912. case Models.EXPRESSION_ELEMENTS.par_exp_par:
  16913. var temp_par_1 = (0, _jquery2.default)('<div class="component_element"> ( </div>');
  16914. var temp_exp = (0, _jquery2.default)('<div class="component_element"></div>');
  16915. var temp_par_2 = (0, _jquery2.default)('<div class="component_element"> ) </div>');
  16916. el.append(temp_par_1);
  16917. el.append(temp_exp);
  16918. for (var j = 0; j < expression_element.itens.length; j++) {
  16919. if (expression_element.itens[j].type) {
  16920. VariableValueMenu.renderMenu(command, expression_element.itens[j], temp_exp, function_obj, 2, expression_element);
  16921. } else {
  16922. renderElement(command, function_obj, temp_exp, expression_element.itens[j]);
  16923. }
  16924. }
  16925. //renderMenuAddExpression(command, function_obj, el, el, expression_element.itens);
  16926. el.append(temp_par_2);
  16927. break;
  16928. }
  16929. }
  16930. function renderExpression(command, function_obj, el) {
  16931. var expression_div = el.find('.expression_elements');
  16932. expression_div.text('');
  16933. var menu_add_item = (0, _jquery2.default)('<div class="menu_add_item"></div>');
  16934. menu_add_item.data('index_add', 0);
  16935. expression_div.append(menu_add_item);
  16936. for (var i = 0; i < command.expression.length; i++) {
  16937. if (command.expression[i].type) {
  16938. var temp = (0, _jquery2.default)('<div class="expression_element"></div>');
  16939. temp.data('ref_element', command.expression[i]);
  16940. temp.data('ref_index', i);
  16941. expression_div.append(temp);
  16942. VariableValueMenu.renderMenu(command, command.expression[i], temp, function_obj);
  16943. } else if (command.expression[i] == "(" || command.expression[i] == ")") {
  16944. var temp = (0, _jquery2.default)('<div class="expression_element">' + command.expression[i] + '</div>');
  16945. temp.data('ref_element', command.expression[i]);
  16946. temp.data('ref_index', i);
  16947. expression_div.append(temp);
  16948. } else {
  16949. var temp = '<div class="expression_element">';
  16950. switch (command.expression[i]) {
  16951. case Models.ARITHMETIC_TYPES.plus:
  16952. temp += '+';
  16953. break;
  16954. case Models.ARITHMETIC_TYPES.minus:
  16955. temp += '-';
  16956. break;
  16957. case Models.ARITHMETIC_TYPES.multiplication:
  16958. temp += '*';
  16959. break;
  16960. case Models.ARITHMETIC_TYPES.division:
  16961. temp += '/';
  16962. break;
  16963. case Models.ARITHMETIC_TYPES.module:
  16964. temp += '%';
  16965. break;
  16966. }
  16967. temp += '</div>';
  16968. temp = (0, _jquery2.default)(temp);
  16969. temp.data('ref_element', command.expression[i]);
  16970. temp.data('ref_index', i);
  16971. expression_div.append(temp);
  16972. }
  16973. var menu_add_item_seq = (0, _jquery2.default)('<div class="menu_add_item"></div>');
  16974. var index_temp = i + 1;
  16975. menu_add_item_seq.data('index_add', index_temp);
  16976. expression_div.append(menu_add_item_seq);
  16977. }
  16978. addMenuItens(command, function_obj, el);
  16979. }
  16980. function addMenuItens(command, function_obj, expression_div) {
  16981. var divs_expression = expression_div.find('.menu_add_item');
  16982. for (var i = 0; i < divs_expression.length; i++) {
  16983. var temp = (0, _jquery2.default)(divs_expression[i]).data('index_add');
  16984. var context_menu = '<div class="ui dropdown context_menu_clear"><i class="ui icon plus square outline"></i><div class="menu">';
  16985. context_menu += '<div class="item" data-option="value" data-index="' + temp + '">' + _localizedStringsService.LocalizedStrings.getUI('text_value') + '</div>';
  16986. context_menu += '<div class="item" data-option="operator" data-index="' + temp + '">' + _localizedStringsService.LocalizedStrings.getUI('text_operator') + '</div>';
  16987. context_menu += '<div class="item" data-option="parentheses" data-index="' + temp + '">' + _localizedStringsService.LocalizedStrings.getUI('text_parentheses') + '</div>';
  16988. context_menu += '</div></div>';
  16989. context_menu = (0, _jquery2.default)(context_menu);
  16990. (0, _jquery2.default)(divs_expression[i]).append(context_menu);
  16991. context_menu.dropdown({
  16992. on: 'hover',
  16993. onChange: function onChange(value, text, $selectedItem) {
  16994. switch ($selectedItem.data('option')) {
  16995. case "value":
  16996. command.expression.splice($selectedItem.data('index'), 0, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  16997. renderExpression(command, function_obj, expression_div);
  16998. break;
  16999. case "operator":
  17000. command.expression.splice($selectedItem.data('index'), 0, Models.ARITHMETIC_TYPES.plus);
  17001. renderExpression(command, function_obj, expression_div);
  17002. break;
  17003. case "parentheses":
  17004. command.expression.splice($selectedItem.data('index'), 0, "(");
  17005. command.expression.splice($selectedItem.data('index') + 1, 0, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  17006. command.expression.splice($selectedItem.data('index') + 2, 0, ")");
  17007. renderExpression(command, function_obj, expression_div);
  17008. break;
  17009. }
  17010. }
  17011. });
  17012. }
  17013. }
  17014. function addHandlers(command, function_obj, attribution_dom) {
  17015. attribution_dom.find('.button_remove_command').on('click', function () {
  17016. if (CommandsManagement.removeCommand(command, function_obj, attribution_dom)) {
  17017. attribution_dom.fadeOut();
  17018. }
  17019. });
  17020. attribution_dom.find('.button_refresh_attribution').on('click', function () {
  17021. renderExpressionElements(command, function_obj, attribution_dom);
  17022. });
  17023. }
  17024. function renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected) {
  17025. /*console.log("recebido o seguinte DOM: ");
  17026. console.log(dom_object);
  17027. if (dom_object.hasClass('var_attributed')) {
  17028. return;
  17029. } else {
  17030. var hier = dom_object.parentsUntil(".command_container");
  17031. for (var i = 0; i < hier.length; i++) {
  17032. if ($(hier[i]).hasClass('var_attributed') || $(hier[i]).hasClass('parameters_function_called')) {
  17033. return;
  17034. }
  17035. }
  17036. }
  17037. dom_object.find('.context_menu_clear').remove();
  17038. var menu_operations = '<div class="ui dropdown menu_operations"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  17039. for (var tm in Models.ARITHMETIC_TYPES) {
  17040. menu_operations += '<div class="item" data-option="'+tm+'">'+LocalizedStrings.getUI('btn_arithmetic_' + tm)+'</div>';
  17041. }
  17042. menu_operations += '<div class="item" data-option="clear">'+LocalizedStrings.getUI('btn_clear')+'</div>';
  17043. menu_operations += '</div></div>';
  17044. menu_operations = $(menu_operations);
  17045. dom_object.append(menu_operations);
  17046. menu_operations.dropdown({
  17047. onChange: function(value, text, $selectedItem) {
  17048. switch ($($selectedItem).data('option')) {
  17049. case "clear":
  17050. $(dom_object).text('');
  17051. VariableValueMenu.renderMenu(command, ref_object, dom_object, function_obj);
  17052. break;
  17053. default:
  17054. createExpressionAround(command, ref_object, dom_object, function_obj);
  17055. menu_operations.find('.text').text('');
  17056. }
  17057. }
  17058. });*/
  17059. }
  17060. function createExpressionAround(command, ref_object, dom_object, function_obj) {
  17061. (0, _jquery2.default)('<span> ( </span>').insertBefore(dom_object);
  17062. (0, _jquery2.default)('<span> ) </span>').insertAfter(dom_object);
  17063. VariableValueMenu.renderMenu(command, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true), dom_object, function_obj);
  17064. }
  17065. /***/ }),
  17066. /***/ "./js/visualUI/commands/break.js":
  17067. /*!***************************************!*\
  17068. !*** ./js/visualUI/commands/break.js ***!
  17069. \***************************************/
  17070. /*! no static exports found */
  17071. /***/ (function(module, exports, __webpack_require__) {
  17072. "use strict";
  17073. Object.defineProperty(exports, "__esModule", {
  17074. value: true
  17075. });
  17076. exports.createFloatingCommand = createFloatingCommand;
  17077. exports.renderCommand = renderCommand;
  17078. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17079. var _jquery2 = _interopRequireDefault(_jquery);
  17080. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17081. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17082. var Models = _interopRequireWildcard(_ivprog_elements);
  17083. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17084. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17085. var CommandsManagement = _interopRequireWildcard(_commands);
  17086. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17087. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17088. function createFloatingCommand() {
  17089. return (0, _jquery2.default)('<div class="ui comment created_element"> <i class="ui icon small quote left"></i> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_break') + ' </span></div>');
  17090. }
  17091. function renderCommand(command, function_obj) {
  17092. var el = (0, _jquery2.default)('<div class="ui comment command_container"> <i class="ui icon small quote left"></i> <i class="ui icon times red button_remove_command"></i> <span>' + _localizedStringsService.LocalizedStrings.getUI('text_break') + '</span> </div>');
  17093. el.data('command', command);
  17094. addHandlers(command, function_obj, el);
  17095. return el;
  17096. }
  17097. function addHandlers(command, function_obj, break_dom) {
  17098. break_dom.find('.button_remove_command').on('click', function () {
  17099. if (CommandsManagement.removeCommand(command, function_obj, break_dom)) {
  17100. break_dom.fadeOut();
  17101. }
  17102. });
  17103. }
  17104. /***/ }),
  17105. /***/ "./js/visualUI/commands/comment.js":
  17106. /*!*****************************************!*\
  17107. !*** ./js/visualUI/commands/comment.js ***!
  17108. \*****************************************/
  17109. /*! no static exports found */
  17110. /***/ (function(module, exports, __webpack_require__) {
  17111. "use strict";
  17112. Object.defineProperty(exports, "__esModule", {
  17113. value: true
  17114. });
  17115. exports.createFloatingCommand = createFloatingCommand;
  17116. exports.renderCommand = renderCommand;
  17117. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17118. var _jquery2 = _interopRequireDefault(_jquery);
  17119. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17120. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17121. var Models = _interopRequireWildcard(_ivprog_elements);
  17122. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17123. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17124. var GlobalsManagement = _interopRequireWildcard(_globals);
  17125. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17126. var VariablesManagement = _interopRequireWildcard(_variables);
  17127. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17128. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  17129. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17130. var CommandsManagement = _interopRequireWildcard(_commands);
  17131. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17132. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17133. function createFloatingCommand() {
  17134. return (0, _jquery2.default)('<div class="ui comment created_element"> <i class="ui icon small quote left"></i> <span class="span_comment_text" "> ' + _localizedStringsService.LocalizedStrings.getUI('text_comment') + ' </span></div>');
  17135. }
  17136. function renderCommand(command, function_obj) {
  17137. var el = (0, _jquery2.default)('<div class="ui comment command_container"> <i class="ui icon small quote left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_value_menu_div"></div> <div class="div_comment_text">' + '</div> </div>');
  17138. el.data('command', command);
  17139. addHandlers(command, function_obj, el);
  17140. renderTextComment(command, function_obj, el);
  17141. return el;
  17142. }
  17143. function renderTextComment(command, function_obj, el) {
  17144. VariableValueMenu.renderMenu(command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
  17145. }
  17146. function addHandlers(command, function_obj, comment_dom) {
  17147. comment_dom.find('.button_remove_command').on('click', function () {
  17148. if (CommandsManagement.removeCommand(command, function_obj, comment_dom)) {
  17149. comment_dom.fadeOut();
  17150. }
  17151. });
  17152. }
  17153. /***/ }),
  17154. /***/ "./js/visualUI/commands/conditional_expression.js":
  17155. /*!********************************************************!*\
  17156. !*** ./js/visualUI/commands/conditional_expression.js ***!
  17157. \********************************************************/
  17158. /*! no static exports found */
  17159. /***/ (function(module, exports, __webpack_require__) {
  17160. "use strict";
  17161. Object.defineProperty(exports, "__esModule", {
  17162. value: true
  17163. });
  17164. exports.renderExpression = renderExpression;
  17165. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17166. var _jquery2 = _interopRequireDefault(_jquery);
  17167. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17168. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17169. var Models = _interopRequireWildcard(_ivprog_elements);
  17170. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17171. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17172. var GlobalsManagement = _interopRequireWildcard(_globals);
  17173. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17174. var VariablesManagement = _interopRequireWildcard(_variables);
  17175. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17176. var VariableValueMenuManagement = _interopRequireWildcard(_variable_value_menu);
  17177. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17178. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17179. function renderExpression(command, expression, function_obj, initial_el_to_render) {
  17180. expression.dom_object = initial_el_to_render;
  17181. if (expression.expression == null || expression.expression.length < 1) {
  17182. renderStartMenu(command, expression, function_obj, initial_el_to_render);
  17183. } else {
  17184. var main_div = (0, _jquery2.default)('<div class="expression_elements"></div>');
  17185. switch (expression.expression.type) {
  17186. case Models.EXPRESSION_TYPES.exp_logic:
  17187. renderLogicExpression(command, expression, expression.expression, function_obj, main_div, initial_el_to_render);
  17188. break;
  17189. case Models.EXPRESSION_TYPES.exp_arithmetic:
  17190. renderArithmeticExpression(command, expression, expression.expression, function_obj, main_div);
  17191. break;
  17192. }
  17193. initial_el_to_render.append(main_div);
  17194. var restartMenu = (0, _jquery2.default)('<div class="ui restart_expression"><i class="ui icon undo"></i></div>');
  17195. initial_el_to_render.append(restartMenu);
  17196. restartMenu.on('click', function (e) {
  17197. expression.expression = null;
  17198. initial_el_to_render.empty();
  17199. renderExpression(command, expression, function_obj, initial_el_to_render);
  17200. });
  17201. }
  17202. }
  17203. function renderArithmeticOperator(command, all_expression, expression_arithmetic, arithmetic_operator, function_obj, element_to_append) {
  17204. var menu_operator = (0, _jquery2.default)('<div class="ui dropdown"><div class="text"></div><i class="dropdown icon"></i></div>');
  17205. menu_operator.dropdown({
  17206. values: [{
  17207. name: '>',
  17208. value: Models.ARITHMETIC_COMPARISON.greater_than,
  17209. selected: arithmetic_operator == Models.ARITHMETIC_COMPARISON.greater_than
  17210. }, {
  17211. name: '<',
  17212. value: Models.ARITHMETIC_COMPARISON.less_than,
  17213. selected: arithmetic_operator == Models.ARITHMETIC_COMPARISON.less_than
  17214. }, {
  17215. name: '==',
  17216. value: Models.ARITHMETIC_COMPARISON.equals_to,
  17217. selected: arithmetic_operator == Models.ARITHMETIC_COMPARISON.equals_to
  17218. }, {
  17219. name: '!=',
  17220. value: Models.ARITHMETIC_COMPARISON.not_equals_to,
  17221. selected: arithmetic_operator == Models.ARITHMETIC_COMPARISON.not_equals_to
  17222. }, {
  17223. name: '>=',
  17224. value: Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to,
  17225. selected: arithmetic_operator == Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to
  17226. }, {
  17227. name: '<=',
  17228. value: Models.ARITHMETIC_COMPARISON.less_than_or_equals_to,
  17229. selected: arithmetic_operator == Models.ARITHMETIC_COMPARISON.less_than_or_equals_to
  17230. }],
  17231. onChange: function onChange(value, text, $selectedItem) {
  17232. expression_arithmetic.operator = value;
  17233. }
  17234. });
  17235. element_to_append.append(menu_operator);
  17236. }
  17237. function renderLogicOperator(command, all_expression, expression_logic, logic_operator, function_obj, element_to_append, initial_el_to_render) {
  17238. var menu_operator = (0, _jquery2.default)('<div class="ui dropdown"><div class="text"></div><i class="dropdown icon"></i></div>');
  17239. menu_operator.dropdown({
  17240. values: [{
  17241. name: '==',
  17242. value: Models.LOGIC_COMPARISON.equals_to,
  17243. selected: logic_operator == Models.LOGIC_COMPARISON.equals_to
  17244. }, {
  17245. name: '!=',
  17246. value: Models.LOGIC_COMPARISON.not_equals_to,
  17247. selected: logic_operator == Models.LOGIC_COMPARISON.not_equals_to
  17248. }, {
  17249. name: '&&',
  17250. value: Models.LOGIC_COMPARISON.and,
  17251. selected: logic_operator == Models.LOGIC_COMPARISON.and
  17252. }, {
  17253. name: '||',
  17254. value: Models.LOGIC_COMPARISON.or,
  17255. selected: logic_operator == Models.LOGIC_COMPARISON.or
  17256. }],
  17257. onChange: function onChange(value, text, $selectedItem) {
  17258. if ($selectedItem) {
  17259. expression_logic.operator = value;
  17260. if (expression_logic.second_operand == null) {
  17261. expression_logic.second_operand = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true);
  17262. initial_el_to_render.empty();
  17263. renderExpression(command, all_expression, function_obj, initial_el_to_render);
  17264. }
  17265. }
  17266. }
  17267. });
  17268. element_to_append.append(menu_operator);
  17269. }
  17270. function renderLogicExpression(command, all_expression, expression_logic, function_obj, element_to_append, initial_el_to_render) {
  17271. var exp_el_par_1 = (0, _jquery2.default)(' <span class="span_command_spec"> </span> ');
  17272. var exp_el_expr_el_1 = (0, _jquery2.default)('<div class="expression_element"></div>');
  17273. var exp_el_expr_operand = (0, _jquery2.default)('<div class="expression_element"></div>');
  17274. var exp_el_expr_el_2 = (0, _jquery2.default)('<div class="expression_element"></div>');
  17275. var exp_el_par_2 = (0, _jquery2.default)(' <span class="span_command_spec"> </span> ');
  17276. if (expression_logic.first_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  17277. renderLogicExpression(command, all_expression, expression_logic.first_operand, function_obj, exp_el_expr_el_1);
  17278. } else if (expression_logic.first_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  17279. renderArithmeticExpression(command, all_expression, expression_logic.first_operand, function_obj, exp_el_expr_el_1);
  17280. } else {
  17281. VariableValueMenuManagement.renderMenu(command, expression_logic.first_operand, exp_el_expr_el_1, function_obj);
  17282. }
  17283. element_to_append.append(exp_el_par_1);
  17284. element_to_append.append(exp_el_expr_el_1);
  17285. renderLogicOperator(command, all_expression, expression_logic, expression_logic.operator, function_obj, exp_el_expr_operand, initial_el_to_render);
  17286. element_to_append.append(exp_el_expr_operand);
  17287. if (expression_logic.second_operand) {
  17288. if (expression_logic.second_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  17289. renderLogicExpression(command, all_expression, expression_logic.second_operand, function_obj, exp_el_expr_el_2);
  17290. } else if (expression_logic.second_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  17291. renderArithmeticExpression(command, all_expression, expression_logic.second_operand, function_obj, exp_el_expr_el_2);
  17292. } else {
  17293. VariableValueMenuManagement.renderMenu(command, expression_logic.second_operand, exp_el_expr_el_2, function_obj);
  17294. }
  17295. element_to_append.append(exp_el_expr_el_2);
  17296. }
  17297. element_to_append.append(exp_el_par_2);
  17298. }
  17299. function renderArithmeticExpression(command, all_expression, expression_arithmetic, function_obj, element_to_append) {
  17300. var exp_el_par_1 = (0, _jquery2.default)(' <span class="span_command_spec"> </span> ');
  17301. var exp_el_expr_el_1 = (0, _jquery2.default)('<div class="expression_element"></div>');
  17302. var exp_el_expr_operand = (0, _jquery2.default)('<div class="expression_element"></div>');
  17303. var exp_el_expr_el_2 = (0, _jquery2.default)('<div class="expression_element"></div>');
  17304. var exp_el_par_2 = (0, _jquery2.default)(' <span class="span_command_spec"> </span> ');
  17305. if (expression_arithmetic.first_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  17306. renderLogicExpression(command, all_expression, expression_arithmetic.first_operand, function_obj, exp_el_expr_el_1);
  17307. } else if (expression_arithmetic.first_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  17308. renderArithmeticExpression(command, all_expression, expression_arithmetic.first_operand, function_obj, exp_el_expr_el_1);
  17309. } else {
  17310. VariableValueMenuManagement.renderMenu(command, expression_arithmetic.first_operand, exp_el_expr_el_1, function_obj);
  17311. }
  17312. if (expression_arithmetic.second_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
  17313. renderLogicExpression(command, all_expression, expression_arithmetic.second_operand, function_obj, exp_el_expr_el_2);
  17314. } else if (expression_arithmetic.second_operand.type == Models.EXPRESSION_TYPES.exp_arithmetic) {
  17315. renderArithmeticExpression(command, all_expression, expression_arithmetic.second_operand, function_obj, exp_el_expr_el_2);
  17316. } else {
  17317. VariableValueMenuManagement.renderMenu(command, expression_arithmetic.second_operand, exp_el_expr_el_2, function_obj);
  17318. }
  17319. renderArithmeticOperator(command, all_expression, expression_arithmetic, expression_arithmetic.operator, function_obj, exp_el_expr_operand);
  17320. element_to_append.append(exp_el_par_1);
  17321. element_to_append.append(exp_el_expr_el_1);
  17322. element_to_append.append(exp_el_expr_operand);
  17323. element_to_append.append(exp_el_expr_el_2);
  17324. element_to_append.append(exp_el_par_2);
  17325. }
  17326. function renderStartMenu(command, expression, function_obj, initial_el_to_render) {
  17327. var start_menu = '';
  17328. start_menu += '<div class="ui dropdown menu_start_rendered"><div class="text"><i>' + _localizedStringsService.LocalizedStrings.getUI('expression_menu_select') + '</i></div><i class="dropdown icon"></i><div class="menu">';
  17329. start_menu += '<div class="item" data-exp="' + Models.EXPRESSION_TYPES.exp_logic + '">' + _localizedStringsService.LocalizedStrings.getUI('text_logic_expression') + ' (EL == EL and EL)</div>';
  17330. start_menu += '<div class="item" data-exp="' + Models.EXPRESSION_TYPES.exp_arithmetic + '">' + _localizedStringsService.LocalizedStrings.getUI('text_arithmetic_expression') + ' (EA < EA)</div>';
  17331. start_menu += '</div></div>';
  17332. start_menu = (0, _jquery2.default)(start_menu);
  17333. start_menu.dropdown({
  17334. onChange: function onChange(value, text, $selectedItem) {
  17335. switch ($selectedItem.data('exp')) {
  17336. case Models.EXPRESSION_TYPES.exp_logic:
  17337. expression.expression = new Models.LogicExpression(false, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  17338. break;
  17339. case Models.EXPRESSION_TYPES.exp_arithmetic:
  17340. expression.expression = new Models.ArithmeticExpression(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true), new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true), Models.ARITHMETIC_COMPARISON.less_than);
  17341. break;
  17342. }
  17343. initial_el_to_render.html('');
  17344. renderExpression(command, expression, function_obj, initial_el_to_render);
  17345. },
  17346. selectOnKeydown: false
  17347. });
  17348. initial_el_to_render.append(' <span class="span_command_spec"> </span> ');
  17349. initial_el_to_render.append(start_menu);
  17350. initial_el_to_render.append(' <span class="span_command_spec"> </span> ');
  17351. }
  17352. /***/ }),
  17353. /***/ "./js/visualUI/commands/contextualized_menu.js":
  17354. /*!*****************************************************!*\
  17355. !*** ./js/visualUI/commands/contextualized_menu.js ***!
  17356. \*****************************************************/
  17357. /*! no static exports found */
  17358. /***/ (function(module, exports, __webpack_require__) {
  17359. "use strict";
  17360. Object.defineProperty(exports, "__esModule", {
  17361. value: true
  17362. });
  17363. exports.renderMenu = renderMenu;
  17364. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17365. var _jquery2 = _interopRequireDefault(_jquery);
  17366. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17367. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17368. var Models = _interopRequireWildcard(_ivprog_elements);
  17369. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17370. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17371. var CommandsManagement = _interopRequireWildcard(_commands);
  17372. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17373. var VariableValueMenuManagement = _interopRequireWildcard(_variable_value_menu);
  17374. var _switch = __webpack_require__(/*! ./switch */ "./js/visualUI/commands/switch.js");
  17375. var SwitchManagement = _interopRequireWildcard(_switch);
  17376. var _repeatNtimes = __webpack_require__(/*! ./repeatNtimes */ "./js/visualUI/commands/repeatNtimes.js");
  17377. var RepeatNTimesManagement = _interopRequireWildcard(_repeatNtimes);
  17378. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17379. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17380. function renderMenu(command, dom_where_render, function_obj, dom_command) {
  17381. var menu_div = '<div class="ui dropdown menu_commands" ><i class="icon code"></i> <div class="menu"> ';
  17382. if (command.type == Models.COMMAND_TYPES.repeatNtimes || command.type == Models.COMMAND_TYPES.whiletrue || command.type == Models.COMMAND_TYPES.dowhiletrue) {
  17383. menu_div += '<a class="item" data-command="' + Models.COMMAND_TYPES.break + '"><i class="download icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('btn_break') + ' </a>';
  17384. } else {
  17385. menu_div += '<a class="item" data-command="' + Models.COMMAND_TYPES.break + '"><i class="download icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('btn_break') + ' </a>';
  17386. menu_div += '<a class="item" data-command="' + Models.COMMAND_TYPES.switchcase + '"><i class="download icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('btn_case') + ' </a>';
  17387. }
  17388. menu_div += '</div></div>';
  17389. menu_div = (0, _jquery2.default)(menu_div);
  17390. dom_where_render.append(menu_div);
  17391. addHandlers(command, dom_where_render, function_obj, dom_command);
  17392. }
  17393. function addHandlers(command, dom_where_render, function_obj, dom_command) {
  17394. console.log('command, dom_where_render, function_obj, dom_command');
  17395. console.log(command, dom_where_render, function_obj, dom_command);
  17396. console.log(dom_where_render.parents());
  17397. dom_where_render.find('.menu_commands').dropdown({
  17398. on: 'hover'
  17399. });
  17400. dom_where_render.find('.menu_commands a').on('click', function (evt) {
  17401. if (command.type == Models.COMMAND_TYPES.repeatNtimes || command.type == Models.COMMAND_TYPES.whiletrue || command.type == Models.COMMAND_TYPES.dowhiletrue) {
  17402. if (command.commands_block == null || command.commands_block.length == 0) {
  17403. command.commands_block = [];
  17404. var new_cmd = CommandsManagement.genericCreateCommand((0, _jquery2.default)(this).data('command'));
  17405. command.commands_block.push(new_cmd);
  17406. CommandsManagement.renderCommand(new_cmd, dom_command.find('.block_commands'), 3, function_obj);
  17407. } else {
  17408. CommandsManagement.createFloatingCommand(function_obj, dom_command.find('.block_commands'), (0, _jquery2.default)(this).data('command'), evt);
  17409. }
  17410. } else {
  17411. switch ((0, _jquery2.default)(this).data('command')) {
  17412. case Models.COMMAND_TYPES.break:
  17413. CommandsManagement.createFloatingCommand(function_obj, dom_command.find('.block_commands'), (0, _jquery2.default)(this).data('command'), evt);
  17414. break;
  17415. case Models.COMMAND_TYPES.switchcase:
  17416. addCaseToSwitch(command, dom_where_render, function_obj, dom_command);
  17417. break;
  17418. }
  17419. }
  17420. });
  17421. }
  17422. function addCaseToSwitch(command, dom_where_render, function_obj, dom_command) {
  17423. if (command.cases == null) {
  17424. command.cases = [];
  17425. }
  17426. var sc = new Models.SwitchCase(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  17427. command.cases.push(sc);
  17428. SwitchManagement.renderCase(sc, command, function_obj, dom_command.find('.all_cases_div'));
  17429. }
  17430. /***/ }),
  17431. /***/ "./js/visualUI/commands/dowhiletrue.js":
  17432. /*!*********************************************!*\
  17433. !*** ./js/visualUI/commands/dowhiletrue.js ***!
  17434. \*********************************************/
  17435. /*! no static exports found */
  17436. /***/ (function(module, exports, __webpack_require__) {
  17437. "use strict";
  17438. Object.defineProperty(exports, "__esModule", {
  17439. value: true
  17440. });
  17441. exports.createFloatingCommand = createFloatingCommand;
  17442. exports.renderCommand = renderCommand;
  17443. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17444. var _jquery2 = _interopRequireDefault(_jquery);
  17445. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17446. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17447. var Models = _interopRequireWildcard(_ivprog_elements);
  17448. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17449. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17450. var GlobalsManagement = _interopRequireWildcard(_globals);
  17451. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17452. var VariablesManagement = _interopRequireWildcard(_variables);
  17453. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17454. var CommandsManagement = _interopRequireWildcard(_commands);
  17455. var _conditional_expression = __webpack_require__(/*! ./conditional_expression */ "./js/visualUI/commands/conditional_expression.js");
  17456. var ConditionalExpressionManagement = _interopRequireWildcard(_conditional_expression);
  17457. var _contextualized_menu = __webpack_require__(/*! ./contextualized_menu */ "./js/visualUI/commands/contextualized_menu.js");
  17458. var ContextualizedMenu = _interopRequireWildcard(_contextualized_menu);
  17459. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17460. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17461. function createFloatingCommand() {
  17462. return (0, _jquery2.default)('<div class="ui dowhiletrue created_element"> <i class="ui icon small sync"></i> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_command_do') + ' {<br>} ' + _localizedStringsService.LocalizedStrings.getUI('text_code_while') + '(x < 10) </span></div>');
  17463. }
  17464. function renderCommand(command, function_obj) {
  17465. var ret = '';
  17466. ret += '<div class="ui dowhiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div> <span class="span_command_spec"> ' + _localizedStringsService.LocalizedStrings.getUI('text_command_do') + ' </span>';
  17467. ret += '<div class="ui block_commands" data-subblock="" data-idcommand="">';
  17468. ret += '</div>';
  17469. ret += ' <span class="span_command_spec"> ' + _localizedStringsService.LocalizedStrings.getUI('text_code_while') + ' </span> <span class="span_command_spec"> ( </span> <div class="conditional_expression"></div> <span class="span_command_spec"> ) </span>';
  17470. ret += '</div>';
  17471. var el = (0, _jquery2.default)(ret);
  17472. el.data('command', command);
  17473. el.find('.block_commands').data('command', command);
  17474. addHandlers(command, function_obj, el);
  17475. ContextualizedMenu.renderMenu(command, el.find('.context_menu'), function_obj, el);
  17476. ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
  17477. if (command.commands_block) {
  17478. for (var j = 0; j < command.commands_block.length; j++) {
  17479. CommandsManagement.renderCommand(command.commands_block[j], (0, _jquery2.default)(el.find('.block_commands')[0]), 3, function_obj);
  17480. }
  17481. }
  17482. return el;
  17483. }
  17484. function addHandlers(command, function_obj, dowhiletrue_dom) {
  17485. dowhiletrue_dom.find('.button_remove_command').on('click', function () {
  17486. if (CommandsManagement.removeCommand(command, function_obj, dowhiletrue_dom)) {
  17487. dowhiletrue_dom.fadeOut();
  17488. }
  17489. });
  17490. }
  17491. /***/ }),
  17492. /***/ "./js/visualUI/commands/functioncall.js":
  17493. /*!**********************************************!*\
  17494. !*** ./js/visualUI/commands/functioncall.js ***!
  17495. \**********************************************/
  17496. /*! no static exports found */
  17497. /***/ (function(module, exports, __webpack_require__) {
  17498. "use strict";
  17499. Object.defineProperty(exports, "__esModule", {
  17500. value: true
  17501. });
  17502. exports.createFloatingCommand = createFloatingCommand;
  17503. exports.renderCommand = renderCommand;
  17504. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17505. var _jquery2 = _interopRequireDefault(_jquery);
  17506. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17507. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17508. var Models = _interopRequireWildcard(_ivprog_elements);
  17509. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17510. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17511. var GlobalsManagement = _interopRequireWildcard(_globals);
  17512. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17513. var VariablesManagement = _interopRequireWildcard(_variables);
  17514. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17515. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  17516. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17517. var CommandsManagement = _interopRequireWildcard(_commands);
  17518. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17519. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17520. function createFloatingCommand() {
  17521. return (0, _jquery2.default)('<div class="ui functioncall created_element"> <i class="hand point right icon"></i> <span> funcao() </span></div>');
  17522. }
  17523. function renderCommand(command, function_obj) {
  17524. var el = (0, _jquery2.default)('<div class="ui functioncall command_container"> <i class="hand point right icon command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_value_menu_div"></div> </div>');
  17525. el.data('command', command);
  17526. VariableValueMenu.renderMenu(command, command.function_called, el.find('.var_value_menu_div'), function_obj);
  17527. addHandlers(command, function_obj, el);
  17528. return el;
  17529. }
  17530. function addHandlers(command, function_obj, functioncall_dom) {
  17531. functioncall_dom.find('.button_remove_command').on('click', function () {
  17532. if (CommandsManagement.removeCommand(command, function_obj, functioncall_dom)) {
  17533. functioncall_dom.fadeOut();
  17534. }
  17535. });
  17536. }
  17537. /***/ }),
  17538. /***/ "./js/visualUI/commands/iftrue.js":
  17539. /*!****************************************!*\
  17540. !*** ./js/visualUI/commands/iftrue.js ***!
  17541. \****************************************/
  17542. /*! no static exports found */
  17543. /***/ (function(module, exports, __webpack_require__) {
  17544. "use strict";
  17545. Object.defineProperty(exports, "__esModule", {
  17546. value: true
  17547. });
  17548. exports.createFloatingCommand = createFloatingCommand;
  17549. exports.renderCommand = renderCommand;
  17550. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17551. var _jquery2 = _interopRequireDefault(_jquery);
  17552. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17553. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17554. var Models = _interopRequireWildcard(_ivprog_elements);
  17555. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17556. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17557. var GlobalsManagement = _interopRequireWildcard(_globals);
  17558. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17559. var VariablesManagement = _interopRequireWildcard(_variables);
  17560. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17561. var CommandsManagement = _interopRequireWildcard(_commands);
  17562. var _conditional_expression = __webpack_require__(/*! ./conditional_expression */ "./js/visualUI/commands/conditional_expression.js");
  17563. var ConditionalExpressionManagement = _interopRequireWildcard(_conditional_expression);
  17564. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17565. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17566. function createFloatingCommand() {
  17567. return (0, _jquery2.default)('<div class="ui iftrue created_element"> <i class="ui icon small random"></i> <span> if (x < 1) { } </span></div>');
  17568. }
  17569. function renderCommand(command, function_obj) {
  17570. var ret = '';
  17571. ret += '<div class="ui iftrue command_container"><div class="ui data_block_if" data-if="true"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i>';
  17572. ret += '<span class="span_command_spec"> ' + _localizedStringsService.LocalizedStrings.getUI('text_if') + '</span>';
  17573. ret += ' <span class="span_command_spec"> ( </span> <div class="conditional_expression"></div> <span class="span_command_spec"> ) </span>';
  17574. ret += '<span> </span> ';
  17575. ret += '<div class="ui block_commands commands_if conditional_comands_block" data-if="true">';
  17576. ret += '</div></div>';
  17577. ret += '<div class="ui data_block_else" data-else="true"> <span class="span_command_spec"> ' + _localizedStringsService.LocalizedStrings.getUI('text_else') + ' </span>';
  17578. ret += '<div class="ui block_commands commands_else conditional_comands_block" data-else="true">';
  17579. ret += '</div>';
  17580. ret += '<span></span></div>';
  17581. ret += '</div>';
  17582. var el = (0, _jquery2.default)(ret);
  17583. el.data('command', command);
  17584. el.find('.block_commands').data('command', command);
  17585. el.find('.data_block_if').data('command', command);
  17586. el.find('.data_block_else').data('command', command);
  17587. el.find('.commands_if').data('command', command);
  17588. addHandlers(command, function_obj, el);
  17589. ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
  17590. if (command.commands_block) {
  17591. for (var j = 0; j < command.commands_block.length; j++) {
  17592. CommandsManagement.renderCommand(command.commands_block[j], (0, _jquery2.default)(el.find('.commands_if')[0]), 3, function_obj);
  17593. }
  17594. }
  17595. if (command.commands_else) {
  17596. for (var j = 0; j < command.commands_else.length; j++) {
  17597. CommandsManagement.renderCommand(command.commands_else[j], (0, _jquery2.default)(el.find('.commands_else')[0]), 3, function_obj);
  17598. }
  17599. }
  17600. return el;
  17601. }
  17602. function addHandlers(command, function_obj, iftrue_dom) {
  17603. iftrue_dom.find('.button_remove_command').on('click', function () {
  17604. if (CommandsManagement.removeCommand(command, function_obj, iftrue_dom)) {
  17605. iftrue_dom.fadeOut();
  17606. }
  17607. });
  17608. }
  17609. /***/ }),
  17610. /***/ "./js/visualUI/commands/reader.js":
  17611. /*!****************************************!*\
  17612. !*** ./js/visualUI/commands/reader.js ***!
  17613. \****************************************/
  17614. /*! no static exports found */
  17615. /***/ (function(module, exports, __webpack_require__) {
  17616. "use strict";
  17617. Object.defineProperty(exports, "__esModule", {
  17618. value: true
  17619. });
  17620. exports.createFloatingCommand = createFloatingCommand;
  17621. exports.renderCommand = renderCommand;
  17622. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17623. var _jquery2 = _interopRequireDefault(_jquery);
  17624. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17625. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17626. var Models = _interopRequireWildcard(_ivprog_elements);
  17627. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17628. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17629. var GlobalsManagement = _interopRequireWildcard(_globals);
  17630. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17631. var VariablesManagement = _interopRequireWildcard(_variables);
  17632. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17633. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  17634. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17635. var CommandsManagement = _interopRequireWildcard(_commands);
  17636. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17637. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17638. function createFloatingCommand() {
  17639. return (0, _jquery2.default)('<div class="ui reader created_element"> <i class="ui icon small download"></i> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_command_read') + ' var </span></div>');
  17640. }
  17641. function renderCommand(command, function_obj) {
  17642. var el = '<div class="ui reader command_container"> <i class="ui icon small download command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec">' + _localizedStringsService.LocalizedStrings.getUI('text_command_read') + ' ( </span> <div class="var_value_menu_div"></div> <span class="close_parentheses span_command_spec">)</span> </div>';
  17643. el = (0, _jquery2.default)(el);
  17644. el.data('command', command);
  17645. VariableValueMenu.renderMenu(command, command.variable_value_menu, el.find('.var_value_menu_div'), function_obj);
  17646. addHandlers(command, function_obj, el);
  17647. return el;
  17648. }
  17649. function addHandlers(command, function_obj, reader_dom) {
  17650. reader_dom.find('.button_remove_command').on('click', function () {
  17651. if (CommandsManagement.removeCommand(command, function_obj, reader_dom)) {
  17652. reader_dom.fadeOut();
  17653. }
  17654. });
  17655. }
  17656. /***/ }),
  17657. /***/ "./js/visualUI/commands/repeatNtimes.js":
  17658. /*!**********************************************!*\
  17659. !*** ./js/visualUI/commands/repeatNtimes.js ***!
  17660. \**********************************************/
  17661. /*! no static exports found */
  17662. /***/ (function(module, exports, __webpack_require__) {
  17663. "use strict";
  17664. Object.defineProperty(exports, "__esModule", {
  17665. value: true
  17666. });
  17667. exports.createFloatingCommand = createFloatingCommand;
  17668. exports.renderCommand = renderCommand;
  17669. exports.manageExpressionElements = manageExpressionElements;
  17670. exports.manageClearExpressionElements = manageClearExpressionElements;
  17671. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17672. var _jquery2 = _interopRequireDefault(_jquery);
  17673. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17674. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17675. var Models = _interopRequireWildcard(_ivprog_elements);
  17676. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17677. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17678. var GlobalsManagement = _interopRequireWildcard(_globals);
  17679. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17680. var VariablesManagement = _interopRequireWildcard(_variables);
  17681. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17682. var CommandsManagement = _interopRequireWildcard(_commands);
  17683. var _conditional_expression = __webpack_require__(/*! ./conditional_expression */ "./js/visualUI/commands/conditional_expression.js");
  17684. var ConditionalExpressionManagement = _interopRequireWildcard(_conditional_expression);
  17685. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17686. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  17687. var _contextualized_menu = __webpack_require__(/*! ./contextualized_menu */ "./js/visualUI/commands/contextualized_menu.js");
  17688. var ContextualizedMenu = _interopRequireWildcard(_contextualized_menu);
  17689. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17690. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17691. function createFloatingCommand() {
  17692. return (0, _jquery2.default)('<div class="ui repeatNtimes created_element"> <i class="ui icon small sync"></i> <span> para (x = 0; x < 10; x ++) { } </span></div>');
  17693. }
  17694. function renderCommand(command, function_obj) {
  17695. var ret = '<div class="ui repeatNtimes command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div> <span class="span_command_spec"> ' + _localizedStringsService.LocalizedStrings.getUI('text_for') + ' ( </span> <div class="ui attribution_expression"><div class="ui variable_attribution"></div> <span class="text_receives span_command_spec"></span> <div class="ui var_value_expression div_expression_st"></div> </div> <span class="span_command_spec separator_character">;</span> <div class="conditional_expression"></div> <span class="span_command_spec separator_character">;</span> <div class="ui incrementation_field"><div class="ui incrementation_variable"></div> <span class="text_inc_receives span_command_spec"></span> <div class="ui first_operand"></div><div class="ui operator"></div><div class="ui second_operand"></div></div> <span class="span_command_spec"> ) </span>';
  17696. ret += '<div class="ui block_commands">';
  17697. ret += '</div>';
  17698. ret += '<span> </span>';
  17699. ret += '</div>';
  17700. var el = (0, _jquery2.default)(ret);
  17701. el.data('command', command);
  17702. el.find('.block_commands').data('command', command);
  17703. addHandlers(command, function_obj, el);
  17704. ContextualizedMenu.renderMenu(command, el.find('.context_menu'), function_obj, el);
  17705. VariableValueMenu.renderMenu(command, command.var_attribution, el.find('.variable_attribution'), function_obj);
  17706. ConditionalExpressionManagement.renderExpression(command, command.expression2, function_obj, el.find('.conditional_expression'));
  17707. VariableValueMenu.renderMenu(command, command.var_incrementation, el.find('.incrementation_variable'), function_obj);
  17708. if (command.expression1) {
  17709. el.find('.text_receives').text(_localizedStringsService.LocalizedStrings.getUI('text_receives'));
  17710. VariableValueMenu.renderMenu(command, command.expression1, el.find('.var_value_expression'), function_obj);
  17711. }
  17712. if (command.expression3) {
  17713. el.find('.text_inc_receives').text(_localizedStringsService.LocalizedStrings.getUI('text_receives'));
  17714. VariableValueMenu.renderMenu(command, command.expression3.itens[0], el.find('.first_operand'), function_obj);
  17715. renderOperator(command, function_obj, el.find('.operator'), command.expression3, 1);
  17716. VariableValueMenu.renderMenu(command, command.expression3.itens[2], el.find('.second_operand'), function_obj);
  17717. }
  17718. if (command.commands_block) {
  17719. for (var j = 0; j < command.commands_block.length; j++) {
  17720. CommandsManagement.renderCommand(command.commands_block[j], (0, _jquery2.default)(el.find('.block_commands')[0]), 3, function_obj);
  17721. }
  17722. }
  17723. return el;
  17724. }
  17725. function manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element) {
  17726. if (dom_object.hasClass('variable_attribution')) {
  17727. if (!command.expression3) {
  17728. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp, [command.var_attribution, Models.ARITHMETIC_TYPES.plus, new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, "1", null, null, true)]);
  17729. command.expression3 = exp;
  17730. command.var_incrementation = command.var_attribution;
  17731. var cond_exp = new Models.ArithmeticExpression(command.var_attribution, new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), Models.ARITHMETIC_COMPARISON.less_than);
  17732. command.expression2.expression = cond_exp;
  17733. }
  17734. dom_object.parent().find('.text_receives').text(_localizedStringsService.LocalizedStrings.getUI('text_receives'));
  17735. command.expression1 = new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, "0", null, null, true);
  17736. dom_object.parent().find('.var_value_expression').empty();
  17737. VariableValueMenu.renderMenu(command, command.expression1, dom_object.parent().find('.var_value_expression'), function_obj);
  17738. renderAlgorithm();
  17739. }
  17740. if (dom_object.hasClass('incrementation_variable')) {
  17741. dom_object.parent().find('.text_inc_receives').text(_localizedStringsService.LocalizedStrings.getUI('text_receives'));
  17742. var exp = new Models.ExpressionElement(Models.EXPRESSION_ELEMENTS.exp_op_exp, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), Models.ARITHMETIC_TYPES.plus, new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)]);
  17743. command.expression3 = exp;
  17744. VariableValueMenu.renderMenu(command, command.expression3.itens[0], dom_object.parent().find('.first_operand'), function_obj);
  17745. renderOperator(command, function_obj, dom_object.parent().find('.operator'), command.expression3, 1);
  17746. VariableValueMenu.renderMenu(command, command.expression3.itens[2], dom_object.parent().find('.second_operand'), function_obj);
  17747. }
  17748. }
  17749. function manageClearExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element) {
  17750. if (dom_object.hasClass('variable_attribution')) {
  17751. (0, _jquery2.default)(dom_object).parent().find('.text_receives').text('');
  17752. command.expression1 = null;
  17753. (0, _jquery2.default)(dom_object).parent().find('.var_value_expression').empty();
  17754. }
  17755. if (dom_object.hasClass('incrementation_variable')) {
  17756. (0, _jquery2.default)(dom_object).parent().find('.text_inc_receives').text('');
  17757. command.expression3 = null;
  17758. (0, _jquery2.default)(dom_object).parent().find('.first_operand').empty();
  17759. (0, _jquery2.default)(dom_object).parent().find('.operator').empty();
  17760. (0, _jquery2.default)(dom_object).parent().find('.second_operand').empty();
  17761. }
  17762. }
  17763. function addHandlers(command, function_obj, repeatNtimes_dom) {
  17764. repeatNtimes_dom.find('.button_remove_command').on('click', function () {
  17765. if (CommandsManagement.removeCommand(command, function_obj, repeatNtimes_dom)) {
  17766. repeatNtimes_dom.fadeOut();
  17767. }
  17768. });
  17769. }
  17770. function renderOperator(command, function_obj, temp_op, expression_element, index_op) {
  17771. var menu_operator = (0, _jquery2.default)('<div class="ui dropdown"><div class="text"></div></div>');
  17772. menu_operator.dropdown({
  17773. values: [{
  17774. name: '+',
  17775. value: Models.ARITHMETIC_TYPES.plus,
  17776. selected: expression_element.itens[index_op] == Models.ARITHMETIC_TYPES.plus
  17777. }, {
  17778. name: '-',
  17779. value: Models.ARITHMETIC_TYPES.minus,
  17780. selected: expression_element.itens[index_op] == Models.ARITHMETIC_TYPES.minus
  17781. }, {
  17782. name: '*',
  17783. value: Models.ARITHMETIC_TYPES.multiplication,
  17784. selected: expression_element.itens[index_op] == Models.ARITHMETIC_TYPES.multiplication
  17785. }, {
  17786. name: '/',
  17787. value: Models.ARITHMETIC_TYPES.division,
  17788. selected: expression_element.itens[index_op] == Models.ARITHMETIC_TYPES.division
  17789. }, {
  17790. name: '%',
  17791. value: Models.ARITHMETIC_TYPES.module,
  17792. selected: expression_element.itens[index_op] == Models.ARITHMETIC_TYPES.module
  17793. }],
  17794. onChange: function onChange(value, text, $selectedItem) {
  17795. expression_element.itens[index_op] = value;
  17796. }
  17797. });
  17798. temp_op.append(menu_operator);
  17799. }
  17800. /***/ }),
  17801. /***/ "./js/visualUI/commands/return.js":
  17802. /*!****************************************!*\
  17803. !*** ./js/visualUI/commands/return.js ***!
  17804. \****************************************/
  17805. /*! no static exports found */
  17806. /***/ (function(module, exports, __webpack_require__) {
  17807. "use strict";
  17808. Object.defineProperty(exports, "__esModule", {
  17809. value: true
  17810. });
  17811. exports.createFloatingCommand = createFloatingCommand;
  17812. exports.renderCommand = renderCommand;
  17813. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17814. var _jquery2 = _interopRequireDefault(_jquery);
  17815. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17816. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17817. var Models = _interopRequireWildcard(_ivprog_elements);
  17818. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17819. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17820. var GlobalsManagement = _interopRequireWildcard(_globals);
  17821. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17822. var VariablesManagement = _interopRequireWildcard(_variables);
  17823. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17824. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  17825. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17826. var CommandsManagement = _interopRequireWildcard(_commands);
  17827. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17828. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17829. function createFloatingCommand() {
  17830. return (0, _jquery2.default)('<div class="ui return created_element"> <i class="ui icon small reply"></i> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_return') + ' </span></div>');
  17831. }
  17832. function renderCommand(command, function_obj) {
  17833. var el = (0, _jquery2.default)('<div class="ui return command_container"> <i class="ui icon small reply command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec"> ' + _localizedStringsService.LocalizedStrings.getUI('text_return') + ' </span> <div class="var_value_menu_div"></div></div>');
  17834. el.data('command', command);
  17835. addHandlers(command, function_obj, el);
  17836. if (function_obj.return_type != _types.Types.VOID) {
  17837. VariableValueMenu.renderMenu(command, command.variable_value_menu, el.find('.var_value_menu_div'), function_obj);
  17838. } else {
  17839. el.find('.var_value_menu_div').remove();
  17840. command.variable_value_menu = null;
  17841. }
  17842. return el;
  17843. }
  17844. function addHandlers(command, function_obj, return_dom) {
  17845. return_dom.find('.button_remove_command').on('click', function () {
  17846. if (CommandsManagement.removeCommand(command, function_obj, return_dom)) {
  17847. return_dom.fadeOut();
  17848. }
  17849. });
  17850. }
  17851. /***/ }),
  17852. /***/ "./js/visualUI/commands/switch.js":
  17853. /*!****************************************!*\
  17854. !*** ./js/visualUI/commands/switch.js ***!
  17855. \****************************************/
  17856. /*! no static exports found */
  17857. /***/ (function(module, exports, __webpack_require__) {
  17858. "use strict";
  17859. Object.defineProperty(exports, "__esModule", {
  17860. value: true
  17861. });
  17862. exports.createFloatingCommand = createFloatingCommand;
  17863. exports.renderCommand = renderCommand;
  17864. exports.renderCase = renderCase;
  17865. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17866. var _jquery2 = _interopRequireDefault(_jquery);
  17867. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17868. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17869. var Models = _interopRequireWildcard(_ivprog_elements);
  17870. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17871. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17872. var GlobalsManagement = _interopRequireWildcard(_globals);
  17873. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17874. var VariablesManagement = _interopRequireWildcard(_variables);
  17875. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  17876. var CommandsManagement = _interopRequireWildcard(_commands);
  17877. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  17878. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  17879. var _contextualized_menu = __webpack_require__(/*! ./contextualized_menu */ "./js/visualUI/commands/contextualized_menu.js");
  17880. var ContextualizedMenu = _interopRequireWildcard(_contextualized_menu);
  17881. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17882. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17883. function createFloatingCommand() {
  17884. return (0, _jquery2.default)('<div class="ui switch created_element"> <i class="ui icon small random"></i> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_code_switch') + ' ( x ) { <br> ' + _localizedStringsService.LocalizedStrings.getUI('text_code_case') + ' 1: <br> ' + _localizedStringsService.LocalizedStrings.getUI('text_code_case') + ' 2: <br> } </span></div>');
  17885. }
  17886. function renderCommand(command, function_obj) {
  17887. var ret = '';
  17888. ret += '<div class="ui switch command_container"> <i class="ui icon small random command_drag" ></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_code_switch') + ' ( <div class="ui variable_to_switch"></div> ) <div class="ui all_cases_div"></div></span>';
  17889. ret += '</div>';
  17890. var el = (0, _jquery2.default)(ret);
  17891. el.data('command', command);
  17892. addHandlers(command, function_obj, el);
  17893. ContextualizedMenu.renderMenu(command, el.find('.context_menu'), function_obj, el);
  17894. VariableValueMenu.renderMenu(command, command.variable, el.find('.variable_to_switch'), function_obj);
  17895. if (command.cases) {
  17896. for (var i = 0; i < command.cases.length; i++) {
  17897. renderCase(command.cases[i], command, function_obj, el.find('.all_cases_div'));
  17898. }
  17899. }
  17900. return el;
  17901. }
  17902. function renderCase(switchcase, command, function_obj, el) {
  17903. var casediv = (0, _jquery2.default)('<div class="ui case_div"><i class="ui icon times red button_remove_command"></i><span>' + _localizedStringsService.LocalizedStrings.getUI('text_code_case') + '</span> <div class="ui variable_case"></div>: <div class="case_commands_block"></div></div>');
  17904. VariableValueMenu.renderMenu(command, switchcase.variable_value_menu, casediv.find('.variable_case'), function_obj);
  17905. casediv.data('switchcase', switchcase);
  17906. casediv.find('.case_commands_block').data('switchcase', switchcase);
  17907. el.append(casediv);
  17908. if (switchcase.commands_block) {
  17909. for (var j = 0; j < switchcase.commands_block.length; j++) {
  17910. CommandsManagement.renderCommand(switchcase.commands_block[j], (0, _jquery2.default)(casediv.find('.case_commands_block')[0]), 3, function_obj);
  17911. }
  17912. }
  17913. casediv.find('.button_remove_command').on('click', function () {
  17914. for (var i = 0; i < command.cases.length; i++) {
  17915. if (switchcase == command.cases[i]) {
  17916. delete command.cases[i];
  17917. command.cases.splice(i, 1);
  17918. casediv.remove();
  17919. break;
  17920. }
  17921. }
  17922. });
  17923. }
  17924. function addHandlers(command, function_obj, switch_dom) {
  17925. switch_dom.find('.button_remove_command').on('click', function () {
  17926. if (CommandsManagement.removeCommand(command, function_obj, switch_dom)) {
  17927. switch_dom.fadeOut();
  17928. }
  17929. });
  17930. }
  17931. /***/ }),
  17932. /***/ "./js/visualUI/commands/variable_value_menu.js":
  17933. /*!*****************************************************!*\
  17934. !*** ./js/visualUI/commands/variable_value_menu.js ***!
  17935. \*****************************************************/
  17936. /*! no static exports found */
  17937. /***/ (function(module, exports, __webpack_require__) {
  17938. "use strict";
  17939. Object.defineProperty(exports, "__esModule", {
  17940. value: true
  17941. });
  17942. exports.VAR_OR_VALUE_TYPES = undefined;
  17943. exports.renderMenu = renderMenu;
  17944. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  17945. var _jquery2 = _interopRequireDefault(_jquery);
  17946. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  17947. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  17948. var Models = _interopRequireWildcard(_ivprog_elements);
  17949. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  17950. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  17951. var GlobalsManagement = _interopRequireWildcard(_globals);
  17952. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  17953. var VariablesManagement = _interopRequireWildcard(_variables);
  17954. var _attribution = __webpack_require__(/*! ./attribution */ "./js/visualUI/commands/attribution.js");
  17955. var AttribuitionsManagement = _interopRequireWildcard(_attribution);
  17956. var _writer = __webpack_require__(/*! ./writer */ "./js/visualUI/commands/writer.js");
  17957. var WritersManagement = _interopRequireWildcard(_writer);
  17958. var _repeatNtimes = __webpack_require__(/*! ./repeatNtimes */ "./js/visualUI/commands/repeatNtimes.js");
  17959. var RepeatNTimesManagement = _interopRequireWildcard(_repeatNtimes);
  17960. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  17961. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17962. var VAR_OR_VALUE_TYPES = exports.VAR_OR_VALUE_TYPES = Object.freeze({ only_variable: 1, only_value: 2, only_function: 3, variable_and_function: 4, variable_and_value_opt: 5,
  17963. value_and_function: 6, all: 7 });
  17964. function renderMenu(command, ref_object, dom_object, function_obj) {
  17965. var size_field = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2;
  17966. var expression_element = arguments[5];
  17967. // Verificar se o objeto atual trata-se de uma chamada de função e conferir se possui a quantidade correta de parâmetros
  17968. // Caso não possua, tem que adicionar as variáveis que servirão de parâmetros:
  17969. if (ref_object.function_called) {
  17970. if (ref_object.function_called.parameters_list) {
  17971. while (ref_object.function_called.parameters_list.length != ref_object.parameters_list.length) {
  17972. if (ref_object.parameters_list.length > ref_object.function_called.parameters_list.length) {
  17973. ref_object.parameters_list.pop();
  17974. } else {
  17975. ref_object.parameters_list.push(new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true));
  17976. }
  17977. }
  17978. }
  17979. }
  17980. var menu_var_or_value = '<div class="ui dropdown menu_var_or_value_dom" data-varmenu="true"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  17981. if (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.only_variable) {
  17982. menu_var_or_value = '<div class="ui dropdown menu_var_or_value_dom" data-varmenu="true"><div class="text"></div><i class="dropdown icon"></i><div class="menu menu_only_vars">';
  17983. menu_var_or_value += '</div>';
  17984. }
  17985. if (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.variable_and_function || ref_object.variable_and_value == VAR_OR_VALUE_TYPES.variable_and_value_opt || ref_object.variable_and_value == VAR_OR_VALUE_TYPES.all) {
  17986. menu_var_or_value += '<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_variable + '"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('variable');
  17987. menu_var_or_value += '<div class="menu menu_only_vars">';
  17988. menu_var_or_value += '</div></div>';
  17989. }
  17990. if (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.only_value) {
  17991. menu_var_or_value = '<input type="text" class="width-dynamic" size="' + size_field + '" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />';
  17992. }
  17993. if (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.variable_and_value_opt || ref_object.variable_and_value == VAR_OR_VALUE_TYPES.value_and_function || ref_object.variable_and_value == VAR_OR_VALUE_TYPES.all) {
  17994. menu_var_or_value += '<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_value + '">' + _localizedStringsService.LocalizedStrings.getUI('text_value') + '</div>';
  17995. }
  17996. if (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.only_function) {
  17997. menu_var_or_value = '<div class="ui dropdown menu_var_or_value_dom" data-varmenu="true"><div class="text"></div><i class="dropdown icon"></i><div class="menu menu_only_functions">';
  17998. menu_var_or_value += '</div>';
  17999. }
  18000. if (ref_object.variable_and_value == VAR_OR_VALUE_TYPES.variable_and_function || ref_object.variable_and_value == VAR_OR_VALUE_TYPES.value_and_function || ref_object.variable_and_value == VAR_OR_VALUE_TYPES.all) {
  18001. menu_var_or_value += '<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_function + '"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('btn_function');
  18002. menu_var_or_value += '<div class="menu menu_only_functions">';
  18003. menu_var_or_value += '</div></div>';
  18004. if (command.type == Models.COMMAND_TYPES.attribution) {
  18005. menu_var_or_value += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18006. menu_var_or_value += '<div class="menu">';
  18007. menu_var_or_value += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18008. menu_var_or_value += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18009. menu_var_or_value += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18010. menu_var_or_value += '</div></div>';
  18011. }
  18012. }
  18013. menu_var_or_value += '</div></div>';
  18014. menu_var_or_value = (0, _jquery2.default)(menu_var_or_value);
  18015. dom_object.append(menu_var_or_value);
  18016. ref_object.dom_object = menu_var_or_value;
  18017. addHandlers(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element);
  18018. addVariablesToMenu(function_obj, menu_var_or_value, ref_object, expression_element);
  18019. addFunctionsToMenu(function_obj, menu_var_or_value, ref_object, expression_element);
  18020. addIVProgFunctionsToMenu(function_obj, menu_var_or_value, ref_object, expression_element);
  18021. if (ref_object.content || ref_object.function_called) {
  18022. if (ref_object.content) {
  18023. // Verificar se a variável ainda existe:
  18024. var variable_fun = isVarInProgram(ref_object.content, function_obj);
  18025. if (variable_fun) {
  18026. ref_object.content = variable_fun;
  18027. renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
  18028. } else {
  18029. if (ref_object.content && ref_object.content.type) {
  18030. ref_object.content = null;
  18031. appendSelectText(ref_object, menu_var_or_value);
  18032. } else {
  18033. renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
  18034. }
  18035. }
  18036. } else if (ref_object.function_called) {
  18037. // Verificar se a função ainda existe:
  18038. var ret_function = isFunctionInProgram(ref_object.function_called);
  18039. if (ret_function) {
  18040. ref_object.function_called = ret_function;
  18041. renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
  18042. } else {
  18043. ref_object.content = null;
  18044. ref_object.row = null;
  18045. ref_object.column = null;
  18046. delete ref_object.function_called;
  18047. delete ref_object.parameters_list;
  18048. appendSelectText(ref_object, menu_var_or_value);
  18049. }
  18050. }
  18051. } else {
  18052. appendSelectText(ref_object, menu_var_or_value);
  18053. }
  18054. }
  18055. function appendSelectText(ref_object, menu_var_or_value) {
  18056. switch (ref_object.variable_and_value) {
  18057. case VAR_OR_VALUE_TYPES.only_variable:
  18058. menu_var_or_value.find('.text').append('<i>' + _localizedStringsService.LocalizedStrings.getUI('var_menu_select_var') + '</i>');
  18059. break;
  18060. case VAR_OR_VALUE_TYPES.all:
  18061. menu_var_or_value.find('.text').append('<i>' + _localizedStringsService.LocalizedStrings.getUI('var_menu_select_all') + '</i>');
  18062. break;
  18063. case VAR_OR_VALUE_TYPES.variable_and_function:
  18064. menu_var_or_value.find('.text').append('<i>' + _localizedStringsService.LocalizedStrings.getUI('var_menu_select_all') + '</i>');
  18065. break;
  18066. case VAR_OR_VALUE_TYPES.only_function:
  18067. menu_var_or_value.find('.text').append('<i>' + _localizedStringsService.LocalizedStrings.getUI('var_menu_select_function') + '</i>');
  18068. break;
  18069. }
  18070. }
  18071. function isFunctionInProgram(function_called_obj) {
  18072. if (function_called_obj.name) {
  18073. if (window.program_obj.functions) {
  18074. for (var i = 0; i < window.program_obj.functions.length; i++) {
  18075. if (window.program_obj.functions[i] == function_called_obj) {
  18076. return window.program_obj.functions[i];
  18077. }
  18078. }
  18079. for (var i = 0; i < window.program_obj.functions.length; i++) {
  18080. if (window.program_obj.functions[i].name == function_called_obj.name) {
  18081. return window.program_obj.functions[i];
  18082. }
  18083. }
  18084. }
  18085. } else if (function_called_obj.identifier) {
  18086. for (var i = 0; i < window.system_functions.length; i++) {
  18087. if (window.system_functions[i].identifier == function_called_obj.identifier) {
  18088. return window.system_functions[i];
  18089. }
  18090. }
  18091. }
  18092. return null;
  18093. }
  18094. function isVarInProgram(var_obj, function_obj) {
  18095. // Verify in locals:
  18096. if (function_obj.variables_list) {
  18097. for (var i = 0; i < function_obj.variables_list.length; i++) {
  18098. if (function_obj.variables_list[i] == var_obj) {
  18099. return function_obj.variables_list[i];
  18100. }
  18101. }
  18102. }
  18103. // Verify in parameters:
  18104. if (function_obj.parameters_list) {
  18105. for (var i = 0; i < function_obj.parameters_list.length; i++) {
  18106. if (function_obj.parameters_list[i] == var_obj) {
  18107. return function_obj.parameters_list[i];
  18108. }
  18109. }
  18110. }
  18111. // Verify in globals:
  18112. if (window.program_obj.globals) {
  18113. for (var i = 0; i < window.program_obj.globals.length; i++) {
  18114. if (window.program_obj.globals[i] == var_obj) {
  18115. return window.program_obj.globals[i];
  18116. }
  18117. }
  18118. }
  18119. // If not found, verify if the reference was lost
  18120. if (var_obj) {
  18121. if (function_obj.variables_list) {
  18122. for (var i = 0; i < function_obj.variables_list.length; i++) {
  18123. if (function_obj.variables_list[i].name == var_obj.name) {
  18124. return function_obj.variables_list[i];
  18125. }
  18126. }
  18127. }
  18128. if (function_obj.parameters_list) {
  18129. for (var i = 0; i < function_obj.parameters_list.length; i++) {
  18130. if (function_obj.parameters_list[i].name == var_obj.name) {
  18131. return function_obj.parameters_list[i];
  18132. }
  18133. }
  18134. }
  18135. if (window.program_obj.globals) {
  18136. for (var i = 0; i < window.program_obj.globals.length; i++) {
  18137. if (window.program_obj.globals[i].name == var_obj.name) {
  18138. return window.program_obj.globals[i];
  18139. }
  18140. }
  18141. }
  18142. }
  18143. return null;
  18144. }
  18145. function renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element) {
  18146. if (ref_object.function_called) {
  18147. menu_var_or_value.remove();
  18148. variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value, expression_element);
  18149. } else if (ref_object.content.type) {
  18150. menu_var_or_value.remove();
  18151. variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value, expression_element);
  18152. } else {
  18153. menu_var_or_value.remove();
  18154. variableValueMenuCode(command, ref_object, dom_object, function_obj, menu_var_or_value, expression_element);
  18155. }
  18156. }
  18157. function variableValueMenuCode(command, variable_obj, dom_object, function_obj, menu_var_or_value, expression_element) {
  18158. if (variable_obj.content || variable_obj.function_called) {
  18159. // Verificar se a variável ainda existe:
  18160. var var_fun = isVarInProgram(variable_obj.content, function_obj);
  18161. if (var_fun) {
  18162. variable_obj.content = var_fun;
  18163. } else {
  18164. if (variable_obj.content && variable_obj.content.type) {
  18165. variable_obj.content = null;
  18166. appendSelectText(variable_obj, menu_var_or_value);
  18167. }
  18168. }
  18169. } else {
  18170. appendSelectText(variable_obj, menu_var_or_value);
  18171. }
  18172. if (variable_obj.content == null && variable_obj.function_called == null) {
  18173. renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
  18174. return;
  18175. }
  18176. var ret = '';
  18177. if (variable_obj.function_called) {
  18178. if (variable_obj.function_called.parameters_list == null || variable_obj.function_called.length == 0) {
  18179. menu_var_or_value.find('.text').text(' ');
  18180. dom_object.find('.menu_var_or_value_dom').remove();
  18181. var parameters_menu;
  18182. if (variable_obj.function_called.name) {
  18183. parameters_menu = '<div class="parameters_function_called"> ' + variable_obj.function_called.name + ' <span> ( </span>';
  18184. } else {
  18185. parameters_menu = '<div class="parameters_function_called"> <i>' + _localizedStringsService.LocalizedStrings.getUI(variable_obj.function_called.category) + '.' + _localizedStringsService.LocalizedStrings.getUI(variable_obj.function_called.identifier) + '</i> <span> ( </span>';
  18186. }
  18187. parameters_menu += '<span> ) </span></div>';
  18188. parameters_menu = (0, _jquery2.default)(parameters_menu);
  18189. dom_object.append(parameters_menu);
  18190. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18191. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18192. if (command.type == Models.COMMAND_TYPES.attribution) {
  18193. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18194. context_menu += '<div class="menu">';
  18195. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18196. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18197. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18198. context_menu += '</div></div>';
  18199. }
  18200. context_menu += '</div></div>';
  18201. context_menu = (0, _jquery2.default)(context_menu);
  18202. context_menu.insertAfter(dom_object.find('.parameters_function_called'));
  18203. context_menu.dropdown({
  18204. onChange: function onChange(value, text, $selectedItem) {
  18205. console.log('S1');
  18206. if ($selectedItem.data('clear')) {
  18207. console.log('PP1');
  18208. dom_object.text('');
  18209. variable_obj.content = null;
  18210. variable_obj.row = null;
  18211. variable_obj.column = null;
  18212. delete variable_obj.function_called;
  18213. delete variable_obj.parameters_list;
  18214. renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
  18215. }
  18216. if ($selectedItem.data('exp')) {
  18217. AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18218. }
  18219. },
  18220. selectOnKeydown: false
  18221. });
  18222. } else {
  18223. menu_var_or_value.find('.text').text(' ');
  18224. dom_object.find('.menu_var_or_value_dom').remove();
  18225. var parameters_menu;
  18226. if (variable_obj.function_called.name) {
  18227. parameters_menu = '<div class="parameters_function_called"> ' + variable_obj.function_called.name + ' <span> ( </span>';
  18228. } else {
  18229. parameters_menu = '<div class="parameters_function_called"> <i>' + _localizedStringsService.LocalizedStrings.getUI(variable_obj.function_called.category) + '.' + _localizedStringsService.LocalizedStrings.getUI(variable_obj.function_called.identifier) + '</i> <span> ( </span>';
  18230. }
  18231. for (var j = 0; j < variable_obj.function_called.parameters_list.length; j++) {
  18232. parameters_menu += '<div class="render_style_param parameter_' + j + '"></div>';
  18233. if (j + 1 != variable_obj.function_called.parameters_list.length) {
  18234. parameters_menu += ' , ';
  18235. }
  18236. }
  18237. parameters_menu += '<span> ) </span></div>';
  18238. parameters_menu = (0, _jquery2.default)(parameters_menu);
  18239. dom_object.append(parameters_menu);
  18240. for (var j = 0; j < variable_obj.function_called.parameters_list.length; j++) {
  18241. renderMenu(command, variable_obj.parameters_list[j], parameters_menu.find('.parameter_' + j), function_obj, 2, expression_element);
  18242. }
  18243. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18244. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18245. if (command.type == Models.COMMAND_TYPES.attribution) {
  18246. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18247. context_menu += '<div class="menu">';
  18248. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18249. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18250. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18251. context_menu += '</div></div>';
  18252. }
  18253. context_menu += '</div></div>';
  18254. context_menu = (0, _jquery2.default)(context_menu);
  18255. context_menu.insertAfter(parameters_menu);
  18256. context_menu.dropdown({
  18257. onChange: function onChange(value, text, $selectedItem) {
  18258. console.log('S2');
  18259. if ($selectedItem.data('clear')) {
  18260. console.log('PP2');
  18261. dom_object.text('');
  18262. variable_obj.content = null;
  18263. variable_obj.row = null;
  18264. variable_obj.column = null;
  18265. delete variable_obj.function_called;
  18266. delete variable_obj.parameters_list;
  18267. renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
  18268. }
  18269. if ($selectedItem.data('exp')) {
  18270. AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18271. }
  18272. },
  18273. selectOnKeydown: false
  18274. });
  18275. }
  18276. } else if (variable_obj.content.type) {
  18277. var variable_render = "";
  18278. if (variable_obj.content.dimensions == 1 && variable_obj.dimensions != 1) {
  18279. variable_render = '<div class="variable_rendered"> <span class="var_name">' + variable_obj.content.name + '</span>';
  18280. variable_render += ' <span>[ </span> <div class="column_container"></div> <span> ]</span>';
  18281. variable_render += '</div>';
  18282. variable_render = (0, _jquery2.default)(variable_render);
  18283. dom_object.append(variable_render);
  18284. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18285. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18286. if (command.type == Models.COMMAND_TYPES.attribution) {
  18287. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18288. context_menu += '<div class="menu">';
  18289. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18290. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18291. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18292. context_menu += '</div></div>';
  18293. }
  18294. context_menu += '</div></div>';
  18295. context_menu = (0, _jquery2.default)(context_menu);
  18296. variable_render.append(context_menu);
  18297. context_menu.dropdown({
  18298. onChange: function onChange(value, text, $selectedItem) {
  18299. console.log('S3');
  18300. if ($selectedItem.data('clear')) {
  18301. console.log('PP3');
  18302. dom_object.text('');
  18303. variable_obj.content = null;
  18304. variable_obj.row = null;
  18305. variable_obj.column = null;
  18306. delete variable_obj.function_called;
  18307. delete variable_obj.parameters_list;
  18308. renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
  18309. }
  18310. if ($selectedItem.data('exp')) {
  18311. AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18312. }
  18313. },
  18314. selectOnKeydown: false
  18315. });
  18316. if (!variable_obj.column) {
  18317. variable_obj.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
  18318. }
  18319. variableValueMenuCode(command, variable_obj.column, (0, _jquery2.default)(variable_render.find('.column_container')), function_obj, menu_var_or_value, expression_element);
  18320. } else if (variable_obj.content.dimensions == 2 && variable_obj.dimensions != 2) {
  18321. variable_render = '<div class="variable_rendered"> <span class="var_name">' + variable_obj.content.name + '</span>';
  18322. variable_render += ' <span>[ </span> <div class="row_container"></div> <span> ]</span>';
  18323. variable_render += ' <span>[ </span> <div class="column_container"></div> <span> ] </span>';
  18324. variable_render += '</div>';
  18325. variable_render = (0, _jquery2.default)(variable_render);
  18326. dom_object.append(variable_render);
  18327. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18328. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18329. if (command.type == Models.COMMAND_TYPES.attribution) {
  18330. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18331. context_menu += '<div class="menu">';
  18332. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18333. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18334. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18335. context_menu += '</div></div>';
  18336. }
  18337. context_menu += '</div></div>';
  18338. context_menu = (0, _jquery2.default)(context_menu);
  18339. variable_render.append(context_menu);
  18340. context_menu.dropdown({
  18341. onChange: function onChange(value, text, $selectedItem) {
  18342. console.log('S4');
  18343. if ($selectedItem.data('clear')) {
  18344. console.log('PP4');
  18345. dom_object.text('');
  18346. variable_obj.content = null;
  18347. variable_obj.row = null;
  18348. variable_obj.column = null;
  18349. delete variable_obj.function_called;
  18350. delete variable_obj.parameters_list;
  18351. renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
  18352. }
  18353. if ($selectedItem.data('exp')) {
  18354. AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18355. }
  18356. },
  18357. selectOnKeydown: false
  18358. });
  18359. if (!variable_obj.column) {
  18360. variable_obj.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
  18361. }
  18362. if (!variable_obj.row) {
  18363. variable_obj.row = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
  18364. }
  18365. variableValueMenuCode(command, variable_obj.row, (0, _jquery2.default)(variable_render.find('.row_container')), function_obj, menu_var_or_value, expression_element);
  18366. variableValueMenuCode(command, variable_obj.column, (0, _jquery2.default)(variable_render.find('.column_container')), function_obj, menu_var_or_value, expression_element);
  18367. } else {
  18368. variable_render = '<div class="variable_rendered"> <span class="var_name">' + variable_obj.content.name + '</span>';
  18369. variable_render += '</div>';
  18370. variable_render = (0, _jquery2.default)(variable_render);
  18371. dom_object.append(variable_render);
  18372. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18373. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18374. if (command.type == Models.COMMAND_TYPES.attribution && !dom_object.hasClass('var_attributed')) {
  18375. console.log('dom_object6');
  18376. console.log(dom_object);
  18377. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18378. context_menu += '<div class="menu">';
  18379. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18380. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18381. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18382. context_menu += '</div></div>';
  18383. }
  18384. context_menu += '</div></div>';
  18385. context_menu = (0, _jquery2.default)(context_menu);
  18386. variable_render.append(context_menu);
  18387. context_menu.dropdown({
  18388. onChange: function onChange(value, text, $selectedItem) {
  18389. console.log('S5');
  18390. if ($selectedItem.data('clear')) {
  18391. console.log('PP5');
  18392. dom_object.text('');
  18393. variable_obj.content = null;
  18394. variable_obj.row = null;
  18395. variable_obj.column = null;
  18396. delete variable_obj.function_called;
  18397. delete variable_obj.parameters_list;
  18398. renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
  18399. }
  18400. if ($selectedItem.data('exp')) {
  18401. AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18402. }
  18403. },
  18404. selectOnKeydown: false
  18405. });
  18406. }
  18407. } else {
  18408. var variable_render = '<div class="variable_rendered"> <span class="var_name">' + variable_obj.content + '</span>';
  18409. variable_render += '</div>';
  18410. variable_render = (0, _jquery2.default)(variable_render);
  18411. dom_object.append(variable_render);
  18412. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18413. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18414. if (command.type == Models.COMMAND_TYPES.attribution) {
  18415. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18416. context_menu += '<div class="menu">';
  18417. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18418. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18419. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18420. context_menu += '</div></div>';
  18421. }
  18422. context_menu += '</div></div>';
  18423. context_menu = (0, _jquery2.default)(context_menu);
  18424. if (variable_obj.variable_and_value != VAR_OR_VALUE_TYPES.only_value) {
  18425. context_menu.insertAfter(variable_render);
  18426. }
  18427. context_menu.dropdown({
  18428. onChange: function onChange(value, text, $selectedItem) {
  18429. console.log('S6');
  18430. if ($selectedItem.data('clear')) {
  18431. console.log('PP6');
  18432. dom_object.text('');
  18433. variable_obj.content = null;
  18434. variable_obj.row = null;
  18435. variable_obj.column = null;
  18436. delete variable_obj.function_called;
  18437. delete variable_obj.parameters_list;
  18438. dom_object.find('.value_rendered').remove();
  18439. dom_object.find('.context_menu_clear').remove();
  18440. dom_object.find('.width-dynamic-minus').remove();
  18441. renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
  18442. }
  18443. if ($selectedItem.data('exp')) {
  18444. AttribuitionsManagement.manageExpressionElements(command, variable_obj, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18445. }
  18446. },
  18447. selectOnKeydown: false
  18448. });
  18449. variable_render.on('click', function (e) {
  18450. variable_render.remove();
  18451. variable_render.empty();
  18452. variable_render.remove();
  18453. dom_object.empty();
  18454. dom_object.append('<span class="menu_var_or_value_dom"> </span>');
  18455. openInputToValue(command, variable_obj, dom_object, menu_var_or_value, function_obj, expression_element);
  18456. });
  18457. }
  18458. }
  18459. function addIVProgFunctionsToMenu(function_obj, menu_var_or_value, ref_object, expression_element) {
  18460. var sub_menu = menu_var_or_value.find('.menu_only_functions');
  18461. sub_menu.append('<div class="divider"></div><div class="header">' + _localizedStringsService.LocalizedStrings.getUI('text_header_ivprog_functions') + '</div>');
  18462. sub_menu.append('<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_menu_functions_math') + '<div class="menu menu_math_functions"></div></div>');
  18463. sub_menu.append('<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_menu_functions_text') + '<div class="menu menu_text_functions"></div></div>');
  18464. sub_menu.append('<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_menu_functions_arrangement') + '<div class="menu menu_arrangement_functions"></div></div>');
  18465. sub_menu.append('<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_menu_functions_conversion') + '<div class="menu menu_conversion_functions"></div></div>');
  18466. // Insert Math functions:
  18467. for (var i = 0; i < window.system_functions.length; i++) {
  18468. var t = (0, _jquery2.default)('<div class="item"></div>');
  18469. t.data('function_reference', window.system_functions[i]);
  18470. t.data('option', VAR_OR_VALUE_TYPES.only_function);
  18471. t.text(_localizedStringsService.LocalizedStrings.getUI(window.system_functions[i].identifier));
  18472. switch (window.system_functions[i].category) {
  18473. case Models.SYSTEM_FUNCTIONS_CATEGORIES.math:
  18474. sub_menu.find('.menu_math_functions').append(t);
  18475. break;
  18476. case Models.SYSTEM_FUNCTIONS_CATEGORIES.text:
  18477. sub_menu.find('.menu_text_functions').append(t);
  18478. break;
  18479. case Models.SYSTEM_FUNCTIONS_CATEGORIES.arrangement:
  18480. sub_menu.find('.menu_arrangement_functions').append(t);
  18481. break;
  18482. case Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion:
  18483. sub_menu.find('.menu_conversion_functions').append(t);
  18484. break;
  18485. }
  18486. }
  18487. }
  18488. function addFunctionsToMenu(function_obj, menu_var_or_value, ref_object, expression_element) {
  18489. var sub_menu = menu_var_or_value.find('.menu_only_functions');
  18490. sub_menu.text('');
  18491. for (var i = 0; i < window.program_obj.functions.length; i++) {
  18492. var temp = (0, _jquery2.default)('<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_function + '">' + window.program_obj.functions[i].name + ' </div>');
  18493. temp.data('function_reference', window.program_obj.functions[i]);
  18494. sub_menu.append(temp);
  18495. }
  18496. }
  18497. function addVariablesToMenu(function_obj, menu_var_or_value, ref_object, expression_element) {
  18498. var sub_menu = menu_var_or_value.find('.menu_only_vars');
  18499. sub_menu.text('');
  18500. var is_there = false;
  18501. if (window.program_obj.globals) {
  18502. if (ref_object.include_constant) {
  18503. for (var i = 0; i < window.program_obj.globals.length; i++) {
  18504. var temp = (0, _jquery2.default)('<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_variable + '">' + window.program_obj.globals[i].name + ' </div>');
  18505. temp.data('variable_reference', window.program_obj.globals[i]);
  18506. sub_menu.append(temp);
  18507. is_there = true;
  18508. }
  18509. } else {
  18510. for (var i = 0; i < window.program_obj.globals.length; i++) {
  18511. if (!window.program_obj.globals[i].is_constant) {
  18512. var temp = (0, _jquery2.default)('<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_variable + '">' + window.program_obj.globals[i].name + ' </div>');
  18513. temp.data('variable_reference', window.program_obj.globals[i]);
  18514. sub_menu.append(temp);
  18515. is_there = true;
  18516. }
  18517. }
  18518. }
  18519. }
  18520. if (function_obj.parameters_list) {
  18521. for (var i = 0; i < function_obj.parameters_list.length; i++) {
  18522. var temp = (0, _jquery2.default)('<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_variable + '">' + function_obj.parameters_list[i].name + ' </div>');
  18523. temp.data('variable_reference', function_obj.parameters_list[i]);
  18524. sub_menu.append(temp);
  18525. is_there = true;
  18526. }
  18527. }
  18528. if (function_obj.variables_list) {
  18529. for (var i = 0; i < function_obj.variables_list.length; i++) {
  18530. var temp = (0, _jquery2.default)('<div class="item" data-option="' + VAR_OR_VALUE_TYPES.only_variable + '">' + function_obj.variables_list[i].name + ' </div>');
  18531. temp.data('variable_reference', function_obj.variables_list[i]);
  18532. sub_menu.append(temp);
  18533. is_there = true;
  18534. }
  18535. }
  18536. if (!is_there) {
  18537. sub_menu.append((0, _jquery2.default)('<div class="header">' + _localizedStringsService.LocalizedStrings.getUI('text_none_variable') + '</div>'));
  18538. sub_menu.append((0, _jquery2.default)('<div class="item disabled">' + _localizedStringsService.LocalizedStrings.getUI('text_none_variable_instruction') + '</div>'));
  18539. }
  18540. }
  18541. function addHandlers(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element) {
  18542. if (ref_object.variable_and_value != VAR_OR_VALUE_TYPES.only_value) {
  18543. menu_var_or_value.dropdown({
  18544. onChange: function onChange(value, text, $selectedItem) {
  18545. console.log('S7');
  18546. dom_object.find('.var_name').remove();
  18547. switch ($selectedItem.data('option')) {
  18548. case VAR_OR_VALUE_TYPES.only_function:
  18549. openInputToFunction(command, ref_object, dom_object, menu_var_or_value, function_obj, (0, _jquery2.default)($selectedItem).data('function_reference'), expression_element);
  18550. break;
  18551. case VAR_OR_VALUE_TYPES.only_value:
  18552. openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element);
  18553. break;
  18554. case VAR_OR_VALUE_TYPES.only_variable:
  18555. openInputToVariable(command, ref_object, dom_object, menu_var_or_value, function_obj, (0, _jquery2.default)($selectedItem).data('variable_reference'), expression_element);
  18556. break;
  18557. }
  18558. if ($selectedItem.data('exp')) {
  18559. AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18560. }
  18561. if (command.type == Models.COMMAND_TYPES.repeatNtimes) {
  18562. RepeatNTimesManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18563. }
  18564. },
  18565. selectOnKeydown: false
  18566. });
  18567. }
  18568. dom_object.find('.width-dynamic').on('input', function () {
  18569. var inputWidth = (0, _jquery2.default)(this).textWidth() + 10;
  18570. (0, _jquery2.default)(this).focus();
  18571. var tmpStr = (0, _jquery2.default)(this).val();
  18572. (0, _jquery2.default)(this).val('');
  18573. (0, _jquery2.default)(this).val(tmpStr);
  18574. (0, _jquery2.default)(this).css({
  18575. width: inputWidth
  18576. });
  18577. }).trigger('input');
  18578. if (command.type == Models.COMMAND_TYPES.comment) {
  18579. dom_object.parent().on('click', function (e) {
  18580. dom_object.find('.value_rendered').remove();
  18581. dom_object.find('.value_rendered').empty();
  18582. dom_object.find('.value_rendered').remove();
  18583. dom_object.empty();
  18584. dom_object.append('<span class="menu_var_or_value_dom"> </span>');
  18585. openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element);
  18586. });
  18587. }
  18588. }
  18589. function openInputToFunction(command, ref_object, dom_object, menu_var_or_value, function_obj, function_selected, expression_element) {
  18590. ref_object.function_called = function_selected;
  18591. ref_object.parameters_list = [];
  18592. if (function_selected.parameters_list != null && function_selected.parameters_list.length > 0) {
  18593. menu_var_or_value.find('.text').text(' ');
  18594. dom_object.find('.menu_var_or_value_dom').remove();
  18595. var parameters_menu;
  18596. if (function_selected.name) {
  18597. parameters_menu = '<div class="parameters_function_called"> ' + function_selected.name + ' <span> ( </span>';
  18598. } else {
  18599. parameters_menu = '<div class="parameters_function_called"> <i>' + _localizedStringsService.LocalizedStrings.getUI(function_selected.category) + '.' + _localizedStringsService.LocalizedStrings.getUI(function_selected.identifier) + '</i> <span> ( </span>';
  18600. }
  18601. for (var j = 0; j < function_selected.parameters_list.length; j++) {
  18602. parameters_menu += '<div class="render_style_param parameter_' + j + '"></div>';
  18603. if (j + 1 != function_selected.parameters_list.length) {
  18604. parameters_menu += ' , ';
  18605. }
  18606. }
  18607. parameters_menu += '<span> ) </span></div>';
  18608. parameters_menu = (0, _jquery2.default)(parameters_menu);
  18609. dom_object.append(parameters_menu);
  18610. for (var j = 0; j < function_selected.parameters_list.length; j++) {
  18611. var temp;
  18612. if (function_selected.parameters_list[j].dimensions > 0) {
  18613. temp = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.variable_and_function, null, null, null, true, function_selected.parameters_list[j].dimensions);
  18614. } else {
  18615. temp = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
  18616. }
  18617. ref_object.parameters_list.push(temp);
  18618. renderMenu(command, temp, parameters_menu.find('.parameter_' + j), function_obj, 2, expression_element);
  18619. }
  18620. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18621. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18622. if (command.type == Models.COMMAND_TYPES.attribution) {
  18623. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18624. context_menu += '<div class="menu">';
  18625. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18626. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18627. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18628. context_menu += '</div></div>';
  18629. }
  18630. context_menu += '</div></div>';
  18631. context_menu = (0, _jquery2.default)(context_menu);
  18632. context_menu.insertAfter(dom_object.find('.parameters_function_called'));
  18633. context_menu.dropdown({
  18634. onChange: function onChange(value, text, $selectedItem) {
  18635. console.log('S8');
  18636. if ($selectedItem.data('clear')) {
  18637. console.log('PP7');
  18638. dom_object.text('');
  18639. ref_object.content = null;
  18640. ref_object.row = null;
  18641. ref_object.column = null;
  18642. delete ref_object.function_called;
  18643. delete ref_object.parameters_list;
  18644. renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
  18645. }
  18646. if ($selectedItem.data('exp')) {
  18647. AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18648. }
  18649. },
  18650. selectOnKeydown: false
  18651. });
  18652. } else {
  18653. menu_var_or_value.find('.text').text(' ');
  18654. dom_object.find('.menu_var_or_value_dom').remove();
  18655. var parameters_menu;
  18656. if (function_selected.name) {
  18657. parameters_menu = '<div class="parameters_function_called"> ' + function_selected.name + ' <span> ( </span>';
  18658. } else {
  18659. parameters_menu = '<div class="parameters_function_called"> <i>' + _localizedStringsService.LocalizedStrings.getUI(function_selected.category) + '.' + _localizedStringsService.LocalizedStrings.getUI(function_selected.identifier) + '</i> <span> ( </span>';
  18660. }
  18661. parameters_menu += '<span> ) </span></div>';
  18662. parameters_menu = (0, _jquery2.default)(parameters_menu);
  18663. dom_object.append(parameters_menu);
  18664. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18665. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18666. if (command.type == Models.COMMAND_TYPES.attribution) {
  18667. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18668. context_menu += '<div class="menu">';
  18669. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18670. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18671. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18672. context_menu += '</div></div>';
  18673. }
  18674. context_menu += '</div></div>';
  18675. context_menu = (0, _jquery2.default)(context_menu);
  18676. context_menu.insertAfter(dom_object.find('.parameters_function_called'));
  18677. context_menu.dropdown({
  18678. onChange: function onChange(value, text, $selectedItem) {
  18679. console.log('S9');
  18680. if ($selectedItem.data('clear')) {
  18681. console.log('PP8');
  18682. dom_object.text('');
  18683. ref_object.content = null;
  18684. ref_object.row = null;
  18685. ref_object.column = null;
  18686. delete ref_object.function_called;
  18687. delete ref_object.parameters_list;
  18688. renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
  18689. }
  18690. if ($selectedItem.data('exp')) {
  18691. AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18692. }
  18693. },
  18694. selectOnKeydown: false
  18695. });
  18696. }
  18697. if (command.type == Models.COMMAND_TYPES.attribution) {
  18698. AttribuitionsManagement.renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj);
  18699. }
  18700. }
  18701. function openInputToVariable(command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected, expression_element) {
  18702. ref_object.content = variable_selected;
  18703. menu_var_or_value.find('.text').text(' ');
  18704. dom_object.find('.menu_var_or_value_dom').remove();
  18705. var variable_render = '<div class="variable_rendered"> <span class="var_name">' + variable_selected.name + '</span>';
  18706. if (variable_selected.dimensions == 1 && ref_object.dimensions != 1) {
  18707. variable_render += ' <span>[ </span> <div class="column_container"></div> <span> ]</span>';
  18708. }
  18709. if (variable_selected.dimensions == 2 && ref_object.dimensions != 2) {
  18710. variable_render += ' <span>[ </span> <div class="row_container"></div> <span> ]</span> ';
  18711. variable_render += ' <span>[ </span> <div class="column_container"></div> <span> ]</span>';
  18712. }
  18713. variable_render += '</div>';
  18714. variable_render = (0, _jquery2.default)(variable_render);
  18715. dom_object.append(variable_render);
  18716. if (variable_selected.dimensions == 1 && ref_object.dimensions != 1) {
  18717. ref_object.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
  18718. renderMenu(command, ref_object.column, variable_render.find('.column_container'), function_obj, 2, expression_element);
  18719. }
  18720. if (variable_selected.dimensions == 2 && ref_object.dimensions != 2) {
  18721. ref_object.row = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
  18722. renderMenu(command, ref_object.row, variable_render.find('.row_container'), function_obj, 2, expression_element);
  18723. ref_object.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
  18724. renderMenu(command, ref_object.column, variable_render.find('.column_container'), function_obj, 2, expression_element);
  18725. }
  18726. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18727. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18728. if (command.type == Models.COMMAND_TYPES.attribution && !dom_object.hasClass('var_attributed')) {
  18729. console.log("dom_object 10: ");
  18730. console.log(dom_object);
  18731. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18732. context_menu += '<div class="menu">';
  18733. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18734. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18735. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18736. context_menu += '</div></div>';
  18737. }
  18738. context_menu += '</div></div>';
  18739. context_menu = (0, _jquery2.default)(context_menu);
  18740. context_menu.insertAfter(dom_object.find('.variable_rendered'));
  18741. context_menu.dropdown({
  18742. onChange: function onChange(value, text, $selectedItem) {
  18743. console.log('S10');
  18744. if ($selectedItem.data('clear')) {
  18745. console.log('PP9');
  18746. dom_object.text('');
  18747. ref_object.content = null;
  18748. ref_object.row = null;
  18749. ref_object.column = null;
  18750. delete ref_object.function_called;
  18751. delete ref_object.parameters_list;
  18752. renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
  18753. }
  18754. if ($selectedItem.data('exp')) {
  18755. AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18756. }
  18757. if (command.type == Models.COMMAND_TYPES.repeatNtimes) {
  18758. RepeatNTimesManagement.manageClearExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18759. }
  18760. },
  18761. selectOnKeydown: false
  18762. });
  18763. if (command.type == Models.COMMAND_TYPES.attribution) {
  18764. AttribuitionsManagement.renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected);
  18765. }
  18766. }
  18767. function openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element) {
  18768. if (ref_object.content == null) {
  18769. ref_object.content = "";
  18770. }
  18771. menu_var_or_value.find('.text').text(' ');
  18772. var field = (0, _jquery2.default)('<input type="text" size="2" class="width-dynamic-minus" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />');
  18773. field.insertBefore(dom_object.find('.menu_var_or_value_dom'));
  18774. var rendered = (0, _jquery2.default)('<div class="value_rendered"></div>');
  18775. rendered.insertBefore(field);
  18776. field.focus();
  18777. field.val(ref_object.content);
  18778. var context_menu = '<div class="ui dropdown context_menu_clear"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
  18779. context_menu += '<div class="item" data-clear="true">' + _localizedStringsService.LocalizedStrings.getUI('btn_clear') + '</div>';
  18780. if (command.type == Models.COMMAND_TYPES.attribution) {
  18781. context_menu += '<div class="item"><i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('text_change');
  18782. context_menu += '<div class="menu">';
  18783. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.exp_op_exp + '">EXP OP EXP</div>';
  18784. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.op_exp + '">OP EXP</div>';
  18785. context_menu += '<div class="item" data-exp="' + Models.EXPRESSION_ELEMENTS.par_exp_par + '">( EXP )</div>';
  18786. context_menu += '</div></div>';
  18787. }
  18788. context_menu += '</div></div>';
  18789. context_menu = (0, _jquery2.default)(context_menu);
  18790. dom_object.find('.menu_var_or_value_dom').remove();
  18791. if (ref_object.variable_and_value != VAR_OR_VALUE_TYPES.only_value) {
  18792. context_menu.insertAfter(field);
  18793. }
  18794. context_menu.dropdown({
  18795. onChange: function onChange(value, text, $selectedItem) {
  18796. console.log('S11');
  18797. if ($selectedItem.data('clear')) {
  18798. console.log('PP10');
  18799. dom_object.text('');
  18800. dom_object.find('.value_rendered').remove();
  18801. dom_object.find('.context_menu_clear').remove();
  18802. dom_object.find('.width-dynamic-minus').remove();
  18803. ref_object.content = null;
  18804. ref_object.row = null;
  18805. ref_object.column = null;
  18806. delete ref_object.function_called;
  18807. delete ref_object.parameters_list;
  18808. renderMenu(command, ref_object, dom_object, function_obj, 2, expression_element);
  18809. }
  18810. if ($selectedItem.data('exp')) {
  18811. AttribuitionsManagement.manageExpressionElements(command, ref_object, dom_object, menu_var_or_value, function_obj, $selectedItem, expression_element);
  18812. }
  18813. },
  18814. selectOnKeydown: false
  18815. });
  18816. dom_object.find('.width-dynamic-minus').focusout(function () {
  18817. if ((0, _jquery2.default)(this).val().trim()) {
  18818. ref_object.content = (0, _jquery2.default)(this).val().trim();
  18819. }
  18820. rendered.text(ref_object.content);
  18821. (0, _jquery2.default)(this).remove();
  18822. });
  18823. dom_object.find('.width-dynamic-minus').on('keydown', function (e) {
  18824. var code = e.keyCode || e.which;
  18825. if (code == 13) {
  18826. if ((0, _jquery2.default)(this).val().trim()) {
  18827. ref_object.content = (0, _jquery2.default)(this).val().trim();
  18828. }
  18829. rendered.text(ref_object.content);
  18830. (0, _jquery2.default)(this).remove();
  18831. }
  18832. if (code == 27) {
  18833. rendered.text(ref_object.content);
  18834. (0, _jquery2.default)(this).remove();
  18835. }
  18836. });
  18837. if (command.type == Models.COMMAND_TYPES.comment) {
  18838. /*rendered.parent().on('click', function(e) {
  18839. rendered.parent().off();
  18840. console.log("TTT14");
  18841. rendered.remove();
  18842. rendered.empty();
  18843. rendered.remove();
  18844. dom_object.empty();
  18845. dom_object.append('<span class="menu_var_or_value_dom"> </span>');
  18846. openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element)
  18847. });*/
  18848. }
  18849. rendered.on('click', function (e) {
  18850. console.log("TTT2");
  18851. rendered.remove();
  18852. rendered.empty();
  18853. rendered.remove();
  18854. dom_object.empty();
  18855. dom_object.append('<span class="menu_var_or_value_dom"> </span>');
  18856. openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element);
  18857. });
  18858. if (command.type == Models.COMMAND_TYPES.attribution) {
  18859. AttribuitionsManagement.renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj);
  18860. }
  18861. }
  18862. _jquery2.default.fn.textWidth = function (text, font) {
  18863. if (!_jquery2.default.fn.textWidth.fakeEl) _jquery2.default.fn.textWidth.fakeEl = (0, _jquery2.default)('<span>').hide().appendTo(document.body);
  18864. _jquery2.default.fn.textWidth.fakeEl.text(text || this.val() || this.text() || this.attr('placeholder')).css('font', font || this.css('font'));
  18865. return _jquery2.default.fn.textWidth.fakeEl.width();
  18866. };
  18867. /***/ }),
  18868. /***/ "./js/visualUI/commands/whiletrue.js":
  18869. /*!*******************************************!*\
  18870. !*** ./js/visualUI/commands/whiletrue.js ***!
  18871. \*******************************************/
  18872. /*! no static exports found */
  18873. /***/ (function(module, exports, __webpack_require__) {
  18874. "use strict";
  18875. Object.defineProperty(exports, "__esModule", {
  18876. value: true
  18877. });
  18878. exports.createFloatingCommand = createFloatingCommand;
  18879. exports.renderCommand = renderCommand;
  18880. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  18881. var _jquery2 = _interopRequireDefault(_jquery);
  18882. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  18883. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  18884. var Models = _interopRequireWildcard(_ivprog_elements);
  18885. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  18886. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  18887. var GlobalsManagement = _interopRequireWildcard(_globals);
  18888. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  18889. var VariablesManagement = _interopRequireWildcard(_variables);
  18890. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  18891. var CommandsManagement = _interopRequireWildcard(_commands);
  18892. var _conditional_expression = __webpack_require__(/*! ./conditional_expression */ "./js/visualUI/commands/conditional_expression.js");
  18893. var ConditionalExpressionManagement = _interopRequireWildcard(_conditional_expression);
  18894. var _contextualized_menu = __webpack_require__(/*! ./contextualized_menu */ "./js/visualUI/commands/contextualized_menu.js");
  18895. var ContextualizedMenu = _interopRequireWildcard(_contextualized_menu);
  18896. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  18897. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18898. function createFloatingCommand() {
  18899. return (0, _jquery2.default)('<div class="ui whiletrue created_element"> <i class="ui icon small sync"></i> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_code_while') + ' ( x < 10 ) { } </span></div>');
  18900. }
  18901. function renderCommand(command, function_obj) {
  18902. var ret = '';
  18903. ret += '<div class="ui whiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div> <span class="span_command_spec"> ' + _localizedStringsService.LocalizedStrings.getUI('text_code_while') + ' </span>';
  18904. ret += '<span class="span_command_spec"> ( </span> <div class="conditional_expression"></div> <span class="span_command_spec"> ) </span>';
  18905. ret += ' </span>';
  18906. ret += '<div class="ui block_commands">';
  18907. ret += '</div>';
  18908. ret += '<span> </span>';
  18909. ret += '</div>';
  18910. var el = (0, _jquery2.default)(ret);
  18911. el.data('command', command);
  18912. el.find('.block_commands').data('command', command);
  18913. addHandlers(command, function_obj, el);
  18914. ContextualizedMenu.renderMenu(command, el.find('.context_menu'), function_obj, el);
  18915. ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
  18916. if (command.commands_block) {
  18917. for (var j = 0; j < command.commands_block.length; j++) {
  18918. CommandsManagement.renderCommand(command.commands_block[j], (0, _jquery2.default)(el.find('.block_commands')[0]), 3, function_obj);
  18919. }
  18920. }
  18921. return el;
  18922. }
  18923. function addHandlers(command, function_obj, whiletrue_dom) {
  18924. whiletrue_dom.find('.button_remove_command').on('click', function () {
  18925. if (CommandsManagement.removeCommand(command, function_obj, whiletrue_dom)) {
  18926. whiletrue_dom.fadeOut();
  18927. }
  18928. });
  18929. }
  18930. /***/ }),
  18931. /***/ "./js/visualUI/commands/writer.js":
  18932. /*!****************************************!*\
  18933. !*** ./js/visualUI/commands/writer.js ***!
  18934. \****************************************/
  18935. /*! no static exports found */
  18936. /***/ (function(module, exports, __webpack_require__) {
  18937. "use strict";
  18938. Object.defineProperty(exports, "__esModule", {
  18939. value: true
  18940. });
  18941. exports.createFloatingCommand = createFloatingCommand;
  18942. exports.renderCommand = renderCommand;
  18943. exports.addContent = addContent;
  18944. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  18945. var _jquery2 = _interopRequireDefault(_jquery);
  18946. var _types = __webpack_require__(/*! ../types */ "./js/visualUI/types.js");
  18947. var _ivprog_elements = __webpack_require__(/*! ../ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  18948. var Models = _interopRequireWildcard(_ivprog_elements);
  18949. var _localizedStringsService = __webpack_require__(/*! ../../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  18950. var _globals = __webpack_require__(/*! ../globals */ "./js/visualUI/globals.js");
  18951. var GlobalsManagement = _interopRequireWildcard(_globals);
  18952. var _variables = __webpack_require__(/*! ../variables */ "./js/visualUI/variables.js");
  18953. var VariablesManagement = _interopRequireWildcard(_variables);
  18954. var _variable_value_menu = __webpack_require__(/*! ./variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  18955. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  18956. var VariableValueMenuManagement = _interopRequireWildcard(_variable_value_menu);
  18957. var _commands = __webpack_require__(/*! ../commands */ "./js/visualUI/commands.js");
  18958. var CommandsManagement = _interopRequireWildcard(_commands);
  18959. __webpack_require__(/*! ../../Sortable.js */ "./js/Sortable.js");
  18960. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  18961. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18962. function createFloatingCommand() {
  18963. return (0, _jquery2.default)('<div class="ui writer created_element"> <i class="ui icon small upload"></i> <span> ' + _localizedStringsService.LocalizedStrings.getUI('text_command_write') + ' var </span></div>');
  18964. }
  18965. function renderCommand(command, function_obj) {
  18966. var ret = '';
  18967. ret += '<div class="ui writer command_container"> <i class="ui icon small upload command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec">' + _localizedStringsService.LocalizedStrings.getUI('text_command_write') + ' ( </span><div class="all_elements_write"></div> <span class="close_parentheses span_command_spec">)</span> </div>';
  18968. var el = (0, _jquery2.default)(ret);
  18969. el.data('command', command);
  18970. for (var i = 0; i < command.content.length; i++) {
  18971. var new_div_item = (0, _jquery2.default)('<div class="var_value_menu_div"></div>');
  18972. var div_parent_with_handler = (0, _jquery2.default)('<div class="div_parent_handler"></div>');
  18973. div_parent_with_handler.append((0, _jquery2.default)('<i class="ui icon ellipsis vertical inverted handler"></i>'));
  18974. div_parent_with_handler.append(new_div_item);
  18975. div_parent_with_handler.append((0, _jquery2.default)('<i class="white inverted icon times handler"></i>'));
  18976. el.find('.all_elements_write').append(div_parent_with_handler);
  18977. VariableValueMenu.renderMenu(command, command.content[i], new_div_item, function_obj);
  18978. addHandlerIconAdd(el.find('.all_elements_write'), command, function_obj);
  18979. addHandlersManager(command, function_obj, el, div_parent_with_handler, command.content[i]);
  18980. }
  18981. if (command.content.length == 0) {
  18982. addHandlerIconAdd(el.find('.all_elements_write'), command, function_obj);
  18983. }
  18984. addHandlers(command, function_obj, el);
  18985. return el;
  18986. }
  18987. function addHandlersManager(command, function_obj, writer_dom, item_div, content_element) {
  18988. item_div.find('.times').on('click', function () {
  18989. for (var i = 0; i < command.content.length; i++) {
  18990. if (command.content[i] == content_element) {
  18991. delete command.content[i];
  18992. command.content.splice(i, 1);
  18993. item_div.children().off();
  18994. item_div.off();
  18995. item_div.fadeOut();
  18996. if (command.content.length > 0) {
  18997. item_div.next('.icon_add_item_to_writer').fadeOut();
  18998. }
  18999. break;
  19000. }
  19001. }
  19002. });
  19003. }
  19004. function addHandlers(command, function_obj, writer_dom) {
  19005. writer_dom.find('.button_remove_command').on('click', function () {
  19006. if (CommandsManagement.removeCommand(command, function_obj, writer_dom)) {
  19007. writer_dom.fadeOut();
  19008. }
  19009. });
  19010. Sortable.create(writer_dom.find(".all_elements_write")[0], {
  19011. handle: '.ellipsis',
  19012. animation: 100,
  19013. ghostClass: 'ghost',
  19014. group: 'writer_' + Math.floor(Math.random() * 10000000),
  19015. draggable: '.div_parent_handler',
  19016. onEnd: function onEnd(evt) {
  19017. command.content.splice(evt.newIndex, 0, command.content.splice(evt.oldIndex, 1)[0]);
  19018. writer_dom.empty();
  19019. writer_dom.replaceWith(renderCommand(command, function_obj));
  19020. }
  19021. });
  19022. }
  19023. function addHandlerIconAdd(dom_object, command, function_obj) {
  19024. var insert_after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  19025. var after_which = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  19026. var icon_add_item = (0, _jquery2.default)('<i class="ui icon plus square outline icon_add_item_to_writer"></i> ');
  19027. if (!insert_after) {
  19028. dom_object.append(icon_add_item);
  19029. } else {
  19030. icon_add_item.insertAfter(after_which);
  19031. }
  19032. icon_add_item.on('click', function (e) {
  19033. var div_parent_with_handler = (0, _jquery2.default)('<div class="div_parent_handler" style="display:none;"></div>');
  19034. var new_div_item = (0, _jquery2.default)('<div class="var_value_menu_div"></div>');
  19035. div_parent_with_handler.append((0, _jquery2.default)('<i class="ui icon ellipsis vertical inverted handler"></i>'));
  19036. div_parent_with_handler.append(new_div_item);
  19037. div_parent_with_handler.append((0, _jquery2.default)('<i class="white inverted icon times handler"></i>'));
  19038. div_parent_with_handler.insertAfter(icon_add_item);
  19039. var new_related_menu = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true);
  19040. VariableValueMenu.renderMenu(command, new_related_menu, new_div_item, function_obj);
  19041. addHandlerIconAdd(dom_object, command, function_obj, true, div_parent_with_handler);
  19042. addHandlersManager(command, function_obj, dom_object, div_parent_with_handler, new_related_menu);
  19043. var pos = 1;
  19044. dom_object.find('.icon_add_item_to_writer').each(function () {
  19045. if ((0, _jquery2.default)(this).get(0) === icon_add_item.get(0)) {
  19046. command.content.splice(pos, 0, new_related_menu);
  19047. } else {
  19048. pos++;
  19049. }
  19050. });
  19051. if (command.content.length == 1) {
  19052. icon_add_item.remove();
  19053. }
  19054. div_parent_with_handler.fadeIn();
  19055. });
  19056. }
  19057. function addContent(command, ref_object, dom_object, menu_var_or_value, function_obj, ref_object_content) {
  19058. if (dom_object.hasClass('var_value_menu_div')) {
  19059. var icon_add_item = (0, _jquery2.default)('<i class="ui icon plus square outline icon_add_item_to_writer"></i> ');
  19060. icon_add_item.insertAfter(dom_object);
  19061. icon_add_item.on('click', function (e) {
  19062. var div_parent_with_handler = (0, _jquery2.default)('<div class="div_parent_handler"></div>');
  19063. div_parent_with_handler.append((0, _jquery2.default)('<i class="ui icon ellipsis vertical inverted handler"></i>'));
  19064. div_parent_with_handler.append(new_div_item);
  19065. div_parent_with_handler.append((0, _jquery2.default)('<i class="white inverted icon times handler"></i>'));
  19066. div_parent_with_handler.insertAfter(icon_add_item);
  19067. var new_related_menu = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true);
  19068. VariableValueMenu.renderMenu(command, new_related_menu, new_div_item, function_obj);
  19069. addHandlersManager(command, function_obj, dom_object, div_parent_with_handler, new_related_menu);
  19070. command.content.push(new_related_menu);
  19071. if (command.content.length == 1) {
  19072. icon_add_item.remove();
  19073. }
  19074. });
  19075. }
  19076. }
  19077. /***/ }),
  19078. /***/ "./js/visualUI/functions.js":
  19079. /*!**********************************!*\
  19080. !*** ./js/visualUI/functions.js ***!
  19081. \**********************************/
  19082. /*! no static exports found */
  19083. /***/ (function(module, exports, __webpack_require__) {
  19084. "use strict";
  19085. Object.defineProperty(exports, "__esModule", {
  19086. value: true
  19087. });
  19088. exports.renderFunction = renderFunction;
  19089. exports.initVisualUI = initVisualUI;
  19090. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  19091. var _jquery2 = _interopRequireDefault(_jquery);
  19092. var _types = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
  19093. var _ivprog_elements = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  19094. var Models = _interopRequireWildcard(_ivprog_elements);
  19095. var _localizedStringsService = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  19096. var _globals = __webpack_require__(/*! ./globals */ "./js/visualUI/globals.js");
  19097. var GlobalsManagement = _interopRequireWildcard(_globals);
  19098. var _variables = __webpack_require__(/*! ./variables */ "./js/visualUI/variables.js");
  19099. var VariablesManagement = _interopRequireWildcard(_variables);
  19100. var _commands = __webpack_require__(/*! ./commands */ "./js/visualUI/commands.js");
  19101. var CommandsManagement = _interopRequireWildcard(_commands);
  19102. var _code_generator = __webpack_require__(/*! ./code_generator */ "./js/visualUI/code_generator.js");
  19103. var CodeManagement = _interopRequireWildcard(_code_generator);
  19104. var _variable_value_menu = __webpack_require__(/*! ./commands/variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  19105. var VariableValueMenu = _interopRequireWildcard(_variable_value_menu);
  19106. var _domConsole = __webpack_require__(/*! ./../io/domConsole */ "./js/io/domConsole.js");
  19107. var _ivprogParser = __webpack_require__(/*! ./../ast/ivprogParser */ "./js/ast/ivprogParser.js");
  19108. var _ivprogProcessor = __webpack_require__(/*! ./../processor/ivprogProcessor */ "./js/processor/ivprogProcessor.js");
  19109. var _melankeWatchjs = __webpack_require__(/*! melanke-watchjs */ "./node_modules/melanke-watchjs/src/watch.js");
  19110. var _melankeWatchjs2 = _interopRequireDefault(_melankeWatchjs);
  19111. var _semanticAnalyser = __webpack_require__(/*! ../processor/semantic/semanticAnalyser */ "./js/processor/semantic/semanticAnalyser.js");
  19112. var _ivprogAssessment = __webpack_require__(/*! ../assessment/ivprogAssessment */ "./js/assessment/ivprogAssessment.js");
  19113. var _algorithm = __webpack_require__(/*! ./algorithm */ "./js/visualUI/algorithm.js");
  19114. var AlgorithmManagement = _interopRequireWildcard(_algorithm);
  19115. var _utils = __webpack_require__(/*! ./utils */ "./js/visualUI/utils.js");
  19116. var Utils = _interopRequireWildcard(_utils);
  19117. __webpack_require__(/*! ../Sortable.js */ "./js/Sortable.js");
  19118. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  19119. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19120. var counter_new_functions = 0;
  19121. var counter_new_parameters = 0;
  19122. var ivprog_version = '2019_01_13 Build 18_55';
  19123. var studentTemp = null;
  19124. var domConsole = null;
  19125. window.studentGrade = null;
  19126. window.LocalizedStrings = _localizedStringsService.LocalizedStrings;
  19127. var program = new Models.Program();
  19128. window.system_functions = [];
  19129. // Adding math functions:
  19130. window.system_functions.push(new Models.SystemFunction('$sin', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19131. window.system_functions.push(new Models.SystemFunction('$cos', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19132. window.system_functions.push(new Models.SystemFunction('$tan', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19133. window.system_functions.push(new Models.SystemFunction('$sqrt', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19134. window.system_functions.push(new Models.SystemFunction('$pow', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19135. window.system_functions.push(new Models.SystemFunction('$log', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19136. window.system_functions.push(new Models.SystemFunction('$abs', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19137. window.system_functions.push(new Models.SystemFunction('$negate', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19138. window.system_functions.push(new Models.SystemFunction('$invert', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19139. window.system_functions.push(new Models.SystemFunction('$max', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19140. window.system_functions.push(new Models.SystemFunction('$min', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
  19141. // Adding text functions:
  19142. window.system_functions.push(new Models.SystemFunction('$substring', _types.Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
  19143. window.system_functions.push(new Models.SystemFunction('$length', _types.Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
  19144. window.system_functions.push(new Models.SystemFunction('$uppercase', _types.Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
  19145. window.system_functions.push(new Models.SystemFunction('$lowercase', _types.Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
  19146. window.system_functions.push(new Models.SystemFunction('$charAt', _types.Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
  19147. // Adding arrangement functions:
  19148. window.system_functions.push(new Models.SystemFunction('$numElements', _types.Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.variable_and_function, null, null, null, true, 1)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.arrangement));
  19149. window.system_functions.push(new Models.SystemFunction('$matrixLines', _types.Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.variable_and_function, null, null, null, true, 2)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.arrangement));
  19150. window.system_functions.push(new Models.SystemFunction('$matrixColumns', _types.Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.variable_and_function, null, null, null, true, 2)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.arrangement));
  19151. // Adding conversion functions:
  19152. window.system_functions.push(new Models.SystemFunction('$isReal', _types.Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
  19153. window.system_functions.push(new Models.SystemFunction('$isInt', _types.Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
  19154. window.system_functions.push(new Models.SystemFunction('$isBool', _types.Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
  19155. window.system_functions.push(new Models.SystemFunction('$castReal', _types.Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
  19156. window.system_functions.push(new Models.SystemFunction('$castInt', _types.Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
  19157. window.system_functions.push(new Models.SystemFunction('$castBool', _types.Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
  19158. window.system_functions.push(new Models.SystemFunction('$castString', _types.Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
  19159. console.log(' ___ ___ ________ \n / / / / / ____/ \n / / / / / / \n / / / / ______ ___ / /__ \n / / / / / \\ / / / ___/ \n / /______ / / / /\\ \\/ / / / \n / / / / / / \\ / / /____ \n/__________/ /___/ /___/ \\___/ /________/ \n\n Laboratório de Informática na Educação\n http://line.ime.usp.br');
  19160. var mainFunction = new Models.Function(_localizedStringsService.LocalizedStrings.getUI("start"), _types.Types.VOID, 0, [], true, false);
  19161. mainFunction.function_comment = new Models.Comment(_localizedStringsService.LocalizedStrings.getUI('text_comment_main'));
  19162. program.addFunction(mainFunction);
  19163. window.program_obj = program;
  19164. window.generator = CodeManagement.generate;
  19165. window.runCodeAssessment = runCodeAssessment;
  19166. window.renderAlgorithm = AlgorithmManagement.renderAlgorithm;
  19167. window.insertContext = false;
  19168. window.watchW = _melankeWatchjs2.default;
  19169. _melankeWatchjs2.default.watch(window.program_obj.globals, function () {
  19170. if (window.insertContext) {
  19171. setTimeout(function () {
  19172. AlgorithmManagement.renderAlgorithm();
  19173. }, 300);
  19174. window.insertContext = false;
  19175. } else {
  19176. AlgorithmManagement.renderAlgorithm();
  19177. }
  19178. }, 1);
  19179. _melankeWatchjs2.default.watch(window.program_obj.functions, function () {
  19180. if (window.insertContext) {
  19181. setTimeout(function () {
  19182. AlgorithmManagement.renderAlgorithm();
  19183. }, 300);
  19184. window.insertContext = false;
  19185. } else {
  19186. AlgorithmManagement.renderAlgorithm();
  19187. }
  19188. }, 1);
  19189. function addFunctionHandler() {
  19190. var new_function = new Models.Function(_localizedStringsService.LocalizedStrings.getUI("new_function") + "_" + counter_new_functions, _types.Types.VOID, 0, [], false, false, [], new Models.Comment(_localizedStringsService.LocalizedStrings.getUI('text_comment_start')));
  19191. program.addFunction(new_function);
  19192. counter_new_functions++;
  19193. window.insertContext = true;
  19194. var newe = renderFunction(new_function);
  19195. newe.css('display', 'none');
  19196. newe.fadeIn();
  19197. }
  19198. function addParameter(function_obj, function_container) {
  19199. var is_from_click = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  19200. if (function_obj.parameters_list == null) {
  19201. function_obj.parameters_list = [];
  19202. }
  19203. var new_parameter = new Models.Variable(_types.Types.INTEGER, _localizedStringsService.LocalizedStrings.getUI("new_parameter") + "_" + counter_new_parameters);
  19204. function_obj.parameters_list.push(new_parameter);
  19205. counter_new_parameters++;
  19206. var newe = renderParameter(function_obj, new_parameter, function_container);
  19207. if (is_from_click) {
  19208. newe.css('display', 'none');
  19209. newe.fadeIn();
  19210. }
  19211. }
  19212. function updateReturnType(function_obj, new_type) {
  19213. var new_dimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  19214. function_obj.return_type = new_type;
  19215. function_obj.return_dimensions = new_dimensions;
  19216. }
  19217. function removeFunction(function_obj) {
  19218. var index = program.functions.indexOf(function_obj);
  19219. if (index > -1) {
  19220. program.functions.splice(index, 1);
  19221. }
  19222. }
  19223. function minimizeFunction(function_obj) {
  19224. function_obj.is_hidden = !function_obj.is_hidden;
  19225. }
  19226. function addHandlers(function_obj, function_container) {
  19227. function_container.find('.ui.dropdown.function_return').dropdown({
  19228. onChange: function onChange(value, text, $selectedItem) {
  19229. if ($selectedItem.data('dimensions')) {
  19230. updateReturnType(function_obj, _types.Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
  19231. } else {
  19232. updateReturnType(function_obj, _types.Types[$selectedItem.data('type')]);
  19233. }
  19234. },
  19235. selectOnKeydown: false
  19236. });
  19237. function_container.find(".name_function_updated").on('click', function (e) {
  19238. enableNameFunctionUpdate(function_obj, function_container);
  19239. });
  19240. function_container.find(".add_parameter_button").on('click', function (e) {
  19241. window.insertContext = true;
  19242. addParameter(function_obj, function_container, true);
  19243. });
  19244. function_container.find('.menu_commands').dropdown({
  19245. on: 'hover'
  19246. });
  19247. function_container.find('.menu_commands a').on('click', function (evt) {
  19248. if (function_obj.commands == null || function_obj.commands.length == 0) {
  19249. function_obj.commands = [];
  19250. var new_cmd = CommandsManagement.genericCreateCommand((0, _jquery2.default)(this).data('command'));
  19251. function_obj.commands.push(new_cmd);
  19252. CommandsManagement.renderCommand(new_cmd, function_container.find('.commands_list_div'), 3, function_obj);
  19253. } else {
  19254. CommandsManagement.createFloatingCommand(function_obj, function_container, (0, _jquery2.default)(this).data('command'), evt);
  19255. }
  19256. });
  19257. function_container.find('.add_var_button_function').on('click', function (e) {
  19258. window.insertContext = true;
  19259. VariablesManagement.addVariable(function_obj, function_container, true);
  19260. });
  19261. function_container.find('.remove_function_button').on('click', function (e) {
  19262. removeFunction(function_obj);
  19263. function_container.fadeOut();
  19264. });
  19265. function_container.find('.minimize_function_button').on('click', function (e) {
  19266. minimizeFunction(function_obj);
  19267. if (function_obj.is_hidden) {
  19268. function_container.find(".add_var_button_function").toggle();
  19269. function_container.find(".inline_add_command").toggle();
  19270. function_container.find(".function_area").slideToggle();
  19271. } else {
  19272. function_container.find(".function_area").slideToggle(function () {
  19273. function_container.find(".add_var_button_function").toggle();
  19274. function_container.find(".inline_add_command").toggle();
  19275. });
  19276. }
  19277. });
  19278. }
  19279. // Essa função imprime o tipo de retorno da função e cria o menu do tipo 'select' para alteração
  19280. function renderFunctionReturn(function_obj, function_element) {
  19281. var ret = '<div class="ui dropdown function_return">';
  19282. if (function_obj.return_dimensions > 0) {
  19283. ret += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI("vector") + ':' + _localizedStringsService.LocalizedStrings.getUI(function_obj.return_type);
  19284. if (function_obj.return_dimensions == 1) {
  19285. ret += ' [ ] ';
  19286. } else {
  19287. ret += ' [ ] [ ] ';
  19288. }
  19289. ret += '</div>';
  19290. } else {
  19291. ret += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI(function_obj.return_type) + '</div>';
  19292. }
  19293. ret += '<div class="menu">';
  19294. for (var tm in _types.Types) {
  19295. ret += '<div class="item ' + (function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions < 1 ? ' selected ' : '') + '" data-type="' + tm + '" >' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '</div>';
  19296. }
  19297. for (var tm in _types.Types) {
  19298. if (tm == _types.Types.VOID.toUpperCase()) {
  19299. continue;
  19300. }
  19301. ret += '<div class="item">' + '<i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '<div class="menu">' + '<div class="item ' + (function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions > 0 ? ' selected ' : '') + '" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] " data-type="' + tm + '" data-dimensions="1">[ ]</div>' + '<div class="item ' + (function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions > 0 ? ' selected ' : '') + '" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] [ ] " data-type="' + tm + '" data-dimensions="2">[ ] [ ] </div>' + '</div>' + '</div>';
  19302. }
  19303. ret += '</div></div>';
  19304. ret = (0, _jquery2.default)(ret);
  19305. function_element.find('.function_return').append(ret);
  19306. }
  19307. function renderFunction(function_obj) {
  19308. var appender = '<div class="ui secondary segment function_div list-group-item">';
  19309. if (function_obj.function_comment) {
  19310. //appender += renderComment(function_obj.function_comment, sequence, true, -1);
  19311. }
  19312. appender += '<span class="glyphicon glyphicon-move move_function" aria-hidden="true"><i class="icon sort alternate vertical"></i></span>';
  19313. appender += (function_obj.is_main ? '<div class="div_start_minimize_v"> </div>' : '<button class="ui icon button large remove_function_button"><i class="red icon times"></i></button>') + '<button class="ui icon button tiny minimize_function_button"><i class="icon window minimize"></i></button>';
  19314. appender += '<div class="function_signature_div">' + _localizedStringsService.LocalizedStrings.getUI("function") + ' ';
  19315. if (function_obj.is_main) {
  19316. appender += '<div class="function_name_div"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' + _localizedStringsService.LocalizedStrings.getUI('void') + ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="span_name_function" >' + function_obj.name + '</span> </div> ' + ' <span class="parethesis_function">( </span> <div class="ui large labels parameters_list">';
  19317. } else {
  19318. appender += '<div class="ui function_return"></div>';
  19319. appender += '<div class="function_name_div function_name_div_updated"><span class="span_name_function name_function_updated">' + function_obj.name + '</span> </div> ' + ' <span class="parethesis_function"> ( </span> <i class="ui icon plus square outline add_parameter_button"></i> <div class="ui large labels parameters_list container_parameters_list">';
  19320. }
  19321. appender += '</div> <span class="parethesis_function"> ) </span> </div>' + (function_obj.is_hidden ? ' <div class="function_area" style="display: none;"> ' : ' <div class="function_area"> ');
  19322. appender += '<div class="ui add_var_context add_var_button_function" style="float: left;"><i class="icon plus circle purple"></i><i class="icon circle white back"></i><div class="ui icon button purple"><i class="icon superscript"></i></div></div>';
  19323. appender += '<div class="ui top attached segment variables_list_div"></div>';
  19324. appender += '<div class="ui inline_add_command"><i class="icon plus circle purple"></i><i class="icon circle white back"></i><div class="ui icon button dropdown menu_commands orange" style="float: left;" ><i class="icon code"></i> <div class="menu"> ';
  19325. appender += '<a class="item" data-command="' + Models.COMMAND_TYPES.reader + '"><i class="download icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_read_var') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.writer + '"><i class="upload icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_write_var') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.comment + '"><i class="quote left icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_comment') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.attribution + '"><i class="arrow left icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_attribution') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.functioncall + '"><i class="hand point right icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_functioncall') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.iftrue + '" ><i class="random icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_iftrue') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.repeatNtimes + '"><i class="sync icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_repeatNtimes') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.whiletrue + '"><i class="sync icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_whiletrue') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.dowhiletrue + '"><i class="sync icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_dowhiletrue') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.switch + '"><i class="list icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_switch') + '</a>' + '<a class="item" data-command="' + Models.COMMAND_TYPES.return + '"><i class="reply icon"></i> ' + _localizedStringsService.LocalizedStrings.getUI('text_btn_return') + '</a>' + '</div></div></div>';
  19326. appender += '<div class="ui bottom attached segment commands_list_div"></div>';
  19327. appender += '</div></div>';
  19328. appender = (0, _jquery2.default)(appender);
  19329. (0, _jquery2.default)('.all_functions').append(appender);
  19330. appender.data('fun', function_obj);
  19331. appender.find('.commands_list_div').data('fun', function_obj);
  19332. renderFunctionReturn(function_obj, appender);
  19333. addHandlers(function_obj, appender);
  19334. // Rendering parameters:
  19335. for (var j = 0; j < function_obj.parameters_list.length; j++) {
  19336. renderParameter(function_obj, function_obj.parameters_list[j], appender);
  19337. }
  19338. // Rendering variables:
  19339. for (var j = 0; j < function_obj.variables_list.length; j++) {
  19340. VariablesManagement.renderVariable(appender, function_obj.variables_list[j], function_obj);
  19341. }
  19342. // Rendering commands:
  19343. for (var j = 0; j < function_obj.commands.length; j++) {
  19344. CommandsManagement.renderCommand(function_obj.commands[j], (0, _jquery2.default)(appender.find('.commands_list_div')[0]), 3, function_obj);
  19345. }
  19346. (0, _jquery2.default)('.minimize_function_button').popup({
  19347. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_minimize"),
  19348. delay: {
  19349. show: 750,
  19350. hide: 0
  19351. }
  19352. });
  19353. var function_index = program.functions.indexOf(function_obj);
  19354. Sortable.create(appender.find(".variables_list_div")[0], {
  19355. handle: '.ellipsis',
  19356. animation: 100,
  19357. ghostClass: 'ghost',
  19358. group: 'local_vars_drag_' + function_index,
  19359. onEnd: function onEnd(evt) {
  19360. updateSequenceLocals(evt.oldIndex, evt.newIndex, function_obj);
  19361. }
  19362. });
  19363. addSortableHandler(appender.find(".commands_list_div")[0], function_index);
  19364. if (!function_obj.is_main) {
  19365. Sortable.create(appender.find(".container_parameters_list")[0], {
  19366. handle: '.ellipsis',
  19367. animation: 100,
  19368. ghostClass: 'ghost',
  19369. group: 'parameters_drag_' + program.functions.indexOf(function_obj),
  19370. onEnd: function onEnd(evt) {
  19371. updateSequenceParameters(evt.oldIndex, evt.newIndex, function_obj);
  19372. }
  19373. });
  19374. }
  19375. return appender;
  19376. }
  19377. window.evento_drag;
  19378. function updateProgramObjDrag() {
  19379. var nodes = Array.prototype.slice.call((0, _jquery2.default)('.all_functions').children());
  19380. var function_index;
  19381. var start_index;
  19382. var function_obj;
  19383. (0, _jquery2.default)(evento_drag.item).parentsUntil(".all_functions").each(function (index) {
  19384. if ((0, _jquery2.default)(this).hasClass('function_div')) {
  19385. function_index = nodes.indexOf(this);
  19386. start_index = index;
  19387. function_obj = (0, _jquery2.default)(this);
  19388. }
  19389. });
  19390. console.log(function_index);
  19391. var path_target = [];
  19392. (0, _jquery2.default)(evento_drag.item).parentsUntil(".all_functions").each(function (index) {
  19393. if ((0, _jquery2.default)(this).hasClass('command_container')) {
  19394. path_target.push(this);
  19395. }
  19396. });
  19397. if (path_target.length == 0) {
  19398. //console.log('soltou na raiz, na posição: ' + evento_drag.newIndex + ' mas ainda não sei de onde saiu ');
  19399. } else {
  19400. //console.log('soltou dentro de algum bloco, sequência vem logo abaixo (de baixo pra cima): ');
  19401. //console.log(path_target);
  19402. }
  19403. var index_each = [];
  19404. var path_relative = [];
  19405. for (var i = path_target.length - 1; i >= 0; i--) {
  19406. console.log('da vez', (0, _jquery2.default)(path_target[i + 1]));
  19407. if (i == path_target.length - 1) {
  19408. // está na raiz
  19409. var indice_na_raiz = function_obj.find('.command_container').index(path_target[i]);
  19410. console.log('índice na raiz: ', indice_na_raiz);
  19411. } else {
  19412. if ((0, _jquery2.default)(path_target[i + 1]).hasClass('iftrue')) {
  19413. if ((0, _jquery2.default)(path_target[i]).parent().hasClass('commands_if')) {
  19414. path_relative.push('if');
  19415. index_each.push((0, _jquery2.default)(path_target[i]).parent().find('.command_container').index(path_target[i]));
  19416. } else {
  19417. path_relative.push('else');
  19418. index_each.push((0, _jquery2.default)(path_target[i]).parent().find('.command_container').index(path_target[i]));
  19419. }
  19420. } else if ((0, _jquery2.default)(path_target[i + 1]).hasClass('dowhiletrue')) {
  19421. path_relative.push('dowhiletrue');
  19422. index_each.push((0, _jquery2.default)(path_target[i + 1]).find('.command_container').index(path_target[i]));
  19423. } else if ((0, _jquery2.default)(path_target[i + 1]).hasClass('repeatNtimes')) {
  19424. path_relative.push('repeatNtimes');
  19425. index_each.push((0, _jquery2.default)(path_target[i + 1]).find('.command_container').index(path_target[i]));
  19426. } else if ((0, _jquery2.default)(path_target[i + 1]).hasClass('whiletrue')) {
  19427. path_relative.push('whiletrue');
  19428. index_each.push((0, _jquery2.default)(path_target[i + 1]).find('.command_container').index(path_target[i]));
  19429. } else if ((0, _jquery2.default)(path_target[i + 1]).hasClass('switch')) {
  19430. path_relative.push('switch');
  19431. //index_each.push($(path_target[i + 1]).find('.command_container').index(path_target[i]));
  19432. }
  19433. }
  19434. }
  19435. var index_in_block = -1;
  19436. var is_in_else = (0, _jquery2.default)(evento_drag.item).parent().hasClass('commands_else');
  19437. index_in_block = (0, _jquery2.default)(evento_drag.item).parent().find('.command_container').index(evento_drag.item);
  19438. var is_in_case_switch = (0, _jquery2.default)(evento_drag.item).parent().hasClass('case_commands_block');
  19439. var index_case_of_switch = -1;
  19440. if (is_in_case_switch) {
  19441. index_case_of_switch = (0, _jquery2.default)(evento_drag.item).parent().parent().parent().find('.case_div').index((0, _jquery2.default)(evento_drag.item).parent().parent());
  19442. }
  19443. /*console.log('path_relative:');
  19444. console.log(path_relative);
  19445. console.log('index_each:');
  19446. console.log(index_each);
  19447. console.log('index_in_block:');
  19448. console.log(index_in_block);
  19449. console.log('ele está em algum bloco de senão? ');
  19450. console.log(is_in_else);
  19451. console.log('ele está dentro de um case de switch?');
  19452. console.log(is_in_case_switch);
  19453. console.log('qual é o índice do case: ');
  19454. console.log(index_case_of_switch);*/
  19455. // encontrar o elemento na árvore:
  19456. var command_start_point = window.program_obj.functions[function_index].commands[indice_na_raiz];
  19457. var block_to_insert = command_start_point;
  19458. for (var i = 0; i < index_each.length; i++) {
  19459. if (path_relative[i] == "else") {
  19460. block_to_insert = block_to_insert.commands_else[index_each[i]];
  19461. } else if (path_relative[i] == "switch") {} else {
  19462. block_to_insert = block_to_insert.commands_block[index_each[i]];
  19463. }
  19464. }
  19465. //console.log('command_start_point', command_start_point);
  19466. //console.log('block_to_insert', block_to_insert);
  19467. // agora tem que alocar o comando na árvore, mas considerar as quatro situações:
  19468. // (1) se está em um else ou (2) se está em switch ou (3) será um caso padrão ou (4) se será na raiz.
  19469. if (path_target.length == 0) {
  19470. // soltou na raiz:
  19471. window.program_obj.functions[function_index].commands.splice(evento_drag.newIndex, 0, command_in_drag);
  19472. } else if (is_in_else) {
  19473. if (block_to_insert.commands_else) {
  19474. block_to_insert.commands_else.splice(evento_drag.newIndex, 0, command_in_drag);
  19475. } else {
  19476. block_to_insert.commands_else = [];
  19477. block_to_insert.commands_else.push(command_in_drag);
  19478. }
  19479. } else if (is_in_case_switch) {} else {
  19480. // verificar se tem alguma coisa no bloco:
  19481. if (block_to_insert.commands_block) {
  19482. block_to_insert.commands_block.splice(evento_drag.newIndex, 0, command_in_drag);
  19483. } else {
  19484. block_to_insert.commands_block = [];
  19485. block_to_insert.commands_block.push(command_in_drag);
  19486. }
  19487. }
  19488. window.draging = false;
  19489. renderAlgorithm();
  19490. }
  19491. function prepareDragHandler(evt) {
  19492. window.draging = true;
  19493. var nodes = Array.prototype.slice.call((0, _jquery2.default)('.all_functions').children());
  19494. var function_index;
  19495. var function_obj;
  19496. (0, _jquery2.default)(evt.item).parentsUntil(".all_functions").each(function (index) {
  19497. if ((0, _jquery2.default)(this).hasClass('function_div')) {
  19498. function_index = nodes.indexOf(this);
  19499. function_obj = window.program_obj.functions[function_index];
  19500. }
  19501. });
  19502. command_in_drag = (0, _jquery2.default)(evt.item).data("command");
  19503. //console.log('$(evt.item).parent(): ');
  19504. //console.log($(evt.item).parent());
  19505. // descobrir qual das quatro situações:
  19506. if ((0, _jquery2.default)(evt.item).parent().hasClass('commands_list_div')) {
  19507. // está na raiz:
  19508. if (function_obj.commands.indexOf(command_in_drag) > -1) {
  19509. function_obj.commands.splice(function_obj.commands.indexOf(command_in_drag), 1);
  19510. }
  19511. } else if ((0, _jquery2.default)(evt.item).parent().hasClass('commands_else')) {
  19512. // está no else:
  19513. if ((0, _jquery2.default)(evt.item).parent().data('command').commands_else.indexOf(command_in_drag) > -1) {
  19514. (0, _jquery2.default)(evt.item).parent().data('command').commands_else.splice((0, _jquery2.default)(evt.item).parent().data('command').commands_else.indexOf(command_in_drag), 1);
  19515. }
  19516. } else if ((0, _jquery2.default)(evt.item).parent().hasClass('case_commands_block')) {// está em um switch:
  19517. } else {
  19518. // caso padrão:
  19519. if ((0, _jquery2.default)(evt.item).parent().data('command').commands_block.indexOf(command_in_drag) > -1) {
  19520. (0, _jquery2.default)(evt.item).parent().data('command').commands_block.splice((0, _jquery2.default)(evt.item).parent().data('command').commands_block.indexOf(command_in_drag), 1);
  19521. }
  19522. }
  19523. }
  19524. var command_in_drag;
  19525. function addSortableHandler(element, id_function) {
  19526. var n_group = 'commands_drag_' + id_function;
  19527. Sortable.create(element, {
  19528. handle: '.command_drag',
  19529. ghostClass: 'ghost',
  19530. animation: 300,
  19531. group: { name: n_group },
  19532. onEnd: function onEnd(evt) {
  19533. //updateSequenceLocals(evt.oldIndex, evt.newIndex, function_obj);
  19534. var itemEl = evt.item; // dragged HTMLElement
  19535. evt.to; // target list
  19536. evt.from; // previous list
  19537. evt.oldIndex; // element's old index within old parent
  19538. evt.newIndex; // element's new index within new parent
  19539. //console.log('::EVT::');
  19540. //console.log(evt);
  19541. window.evento_drag = evt;
  19542. try {
  19543. updateProgramObjDrag();
  19544. } catch (e) {
  19545. window.draging = false;
  19546. }
  19547. },
  19548. onStart: function onStart(evt) {
  19549. //console.log("START::EVT::");
  19550. //console.log(evt);
  19551. //console.log("\n\ncommand_in_drag");
  19552. try {
  19553. prepareDragHandler(evt);
  19554. } catch (e) {
  19555. window.draging = false;
  19556. }
  19557. }
  19558. });
  19559. element = (0, _jquery2.default)(element);
  19560. element.find(".iftrue").each(function (index) {
  19561. addSortableHandler((0, _jquery2.default)(this).find(".block_commands")[0], id_function);
  19562. addSortableHandler((0, _jquery2.default)(this).find(".block_commands")[1], id_function);
  19563. });
  19564. element.find(".repeatNtimes").each(function (index) {
  19565. addSortableHandler((0, _jquery2.default)(this).find(".block_commands")[0], id_function);
  19566. });
  19567. element.find(".dowhiletrue").each(function (index) {
  19568. addSortableHandler((0, _jquery2.default)(this).find(".block_commands")[0], id_function);
  19569. });
  19570. element.find(".whiletrue").each(function (index) {
  19571. addSortableHandler((0, _jquery2.default)(this).find(".block_commands")[0], id_function);
  19572. });
  19573. element.find(".switch").each(function (index) {
  19574. (0, _jquery2.default)(this).find(".case_div").each(function (index) {
  19575. addSortableHandler((0, _jquery2.default)(this).find(".case_commands_block")[0], id_function);
  19576. });
  19577. });
  19578. }
  19579. function initVisualUI() {
  19580. // MUST USE CONST, LET, OR VAR !!!!!!
  19581. var mainDiv = (0, _jquery2.default)('#visual-main-div');
  19582. // fill mainDiv with functions and globals...
  19583. // renderAlgorithm()...
  19584. (0, _jquery2.default)('.add_function_button').on('click', function () {
  19585. addFunctionHandler();
  19586. });
  19587. (0, _jquery2.default)('.add_global_button').on('click', function () {
  19588. window.insertContext = true;
  19589. GlobalsManagement.addGlobal(program, true);
  19590. });
  19591. (0, _jquery2.default)('.run_button').on('click', function () {
  19592. runCode();
  19593. });
  19594. (0, _jquery2.default)('.visual_coding_button').on('click', function () {
  19595. toggleVisualCoding();
  19596. });
  19597. (0, _jquery2.default)('.textual_coding_button').on('click', function () {
  19598. toggleTextualCoding();
  19599. });
  19600. (0, _jquery2.default)('.assessment').on('click', function () {
  19601. runCodeAssessment();
  19602. is_iassign = true;
  19603. });
  19604. (0, _jquery2.default)('.div_toggle_console').on('click', function () {
  19605. toggleConsole();
  19606. });
  19607. (0, _jquery2.default)('.expand_button').on('click', function () {
  19608. full_screen();
  19609. });
  19610. (0, _jquery2.default)('.main_title h2').prop('title', _localizedStringsService.LocalizedStrings.getUI('text_ivprog_description'));
  19611. }
  19612. var is_iassign = false;
  19613. (0, _jquery2.default)(document).ready(function () {
  19614. var time_show = 750;
  19615. (0, _jquery2.default)('.visual_coding_button').popup({
  19616. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_visual"),
  19617. delay: {
  19618. show: time_show,
  19619. hide: 0
  19620. }
  19621. });
  19622. (0, _jquery2.default)('.textual_coding_button').popup({
  19623. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_textual"),
  19624. delay: {
  19625. show: time_show,
  19626. hide: 0
  19627. }
  19628. });
  19629. (0, _jquery2.default)('.upload_file_button').popup({
  19630. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_upload"),
  19631. delay: {
  19632. show: time_show,
  19633. hide: 0
  19634. }
  19635. });
  19636. (0, _jquery2.default)('.download_file_button').popup({
  19637. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_download"),
  19638. delay: {
  19639. show: time_show,
  19640. hide: 0
  19641. }
  19642. });
  19643. (0, _jquery2.default)('.undo_button').popup({
  19644. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_undo"),
  19645. delay: {
  19646. show: time_show,
  19647. hide: 0
  19648. }
  19649. });
  19650. (0, _jquery2.default)('.redo_button').popup({
  19651. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_redo"),
  19652. delay: {
  19653. show: time_show,
  19654. hide: 0
  19655. }
  19656. });
  19657. (0, _jquery2.default)('.run_button').popup({
  19658. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_run"),
  19659. delay: {
  19660. show: time_show,
  19661. hide: 0
  19662. }
  19663. });
  19664. (0, _jquery2.default)('.assessment_button').popup({
  19665. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_evaluate"),
  19666. delay: {
  19667. show: time_show,
  19668. hide: 0
  19669. }
  19670. });
  19671. (0, _jquery2.default)('.help_button').popup({
  19672. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_help") + ' - ' + _localizedStringsService.LocalizedStrings.getUI("text_ivprog_version") + ' ' + ivprog_version,
  19673. delay: {
  19674. show: time_show,
  19675. hide: 0
  19676. }
  19677. });
  19678. (0, _jquery2.default)('.add_global_button').popup({
  19679. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_add_global"),
  19680. delay: {
  19681. show: time_show,
  19682. hide: 0
  19683. }
  19684. });
  19685. (0, _jquery2.default)('.div_toggle_console').popup({
  19686. content: _localizedStringsService.LocalizedStrings.getUI("tooltip_console"),
  19687. delay: {
  19688. show: time_show,
  19689. hide: 0
  19690. }
  19691. });
  19692. Sortable.create(listWithHandle, {
  19693. handle: '.glyphicon-move',
  19694. animation: 100,
  19695. ghostClass: 'ghost',
  19696. group: 'functions_divs_drag',
  19697. onEnd: function onEnd(evt) {
  19698. updateSequenceFunction(evt.oldIndex, evt.newIndex);
  19699. }
  19700. });
  19701. var listGlobalsHandle = document.getElementById("listGlobalsHandle");
  19702. Sortable.create(listGlobalsHandle, {
  19703. handle: '.ellipsis',
  19704. animation: 100,
  19705. ghostClass: 'ghost',
  19706. group: 'globals_divs_drag',
  19707. onEnd: function onEnd(evt) {
  19708. updateSequenceGlobals(evt.oldIndex, evt.newIndex);
  19709. }
  19710. });
  19711. });
  19712. function updateSequenceParameters(oldIndex, newIndex, function_obj) {
  19713. function_obj.parameters_list.splice(newIndex, 0, function_obj.parameters_list.splice(oldIndex, 1)[0]);
  19714. }
  19715. function updateSequenceLocals(oldIndex, newIndex, function_obj) {
  19716. function_obj.variables_list.splice(newIndex, 0, function_obj.variables_list.splice(oldIndex, 1)[0]);
  19717. }
  19718. function updateSequenceGlobals(oldIndex, newIndex) {
  19719. program_obj.globals.splice(newIndex, 0, program_obj.globals.splice(oldIndex, 1)[0]);
  19720. }
  19721. function updateSequenceFunction(oldIndex, newIndex) {
  19722. program_obj.functions.splice(newIndex, 0, program_obj.functions.splice(oldIndex, 1)[0]);
  19723. }
  19724. function runCodeAssessment() {
  19725. window.studentGrade = null;
  19726. studentTemp = null;
  19727. var strCode = CodeManagement.generate();
  19728. if (strCode == null) {
  19729. return;
  19730. }
  19731. toggleConsole(true);
  19732. if (domConsole == null) domConsole = new _domConsole.DOMConsole("#ivprog-term");
  19733. (0, _jquery2.default)("#ivprog-term").slideDown(500);
  19734. var runner = new _ivprogAssessment.IVProgAssessment(strCode, testCases, domConsole);
  19735. runner.runTest().then(function (grade) {
  19736. if (!is_iassign) {
  19737. parent.getEvaluationCallback(grade);
  19738. } else {
  19739. is_iassign = false;
  19740. }
  19741. }).catch(function (err) {
  19742. return console.log(err);
  19743. });
  19744. }
  19745. function runCode() {
  19746. var strCode = CodeManagement.generate();
  19747. if (strCode == null) {
  19748. return;
  19749. }
  19750. toggleConsole(true);
  19751. if (domConsole == null) domConsole = new _domConsole.DOMConsole("#ivprog-term");
  19752. (0, _jquery2.default)("#ivprog-term").slideDown(500);
  19753. try {
  19754. var parser = _ivprogParser.IVProgParser.createParser(strCode);
  19755. var analyser = new _semanticAnalyser.SemanticAnalyser(parser.parseTree());
  19756. var data = analyser.analyseTree();
  19757. var proc = new _ivprogProcessor.IVProgProcessor(data);
  19758. proc.registerInput(domConsole);
  19759. proc.registerOutput(domConsole);
  19760. (0, _jquery2.default)("#ivprog-term").addClass('ivprog-term-active');
  19761. proc.interpretAST().then(function (_) {
  19762. domConsole.info("Programa executado com sucesso!");
  19763. (0, _jquery2.default)("#ivprog-term").removeClass('ivprog-term-active');
  19764. }).catch(function (err) {
  19765. domConsole.err(err.message);
  19766. (0, _jquery2.default)("#ivprog-term").removeClass('ivprog-term-active');
  19767. });
  19768. } catch (error) {
  19769. domConsole.err(error.message);
  19770. console.log(error);
  19771. }
  19772. }
  19773. function toggleConsole(is_running) {
  19774. if (is_running) {
  19775. (0, _jquery2.default)('.ivprog-term-div').css('display', 'block');
  19776. (0, _jquery2.default)('#ivprog-term').css('min-height', '160px');
  19777. (0, _jquery2.default)('#ivprog-term').css('margin-top', '-170px');
  19778. return;
  19779. }
  19780. if ((0, _jquery2.default)('#ivprog-term').css('min-height') == '160px') {
  19781. // esconder
  19782. (0, _jquery2.default)('.ivprog-term-div').css('display', 'none');
  19783. (0, _jquery2.default)('#ivprog-term').css('min-height', '0');
  19784. (0, _jquery2.default)('#ivprog-term').css('margin-top', '-30px');
  19785. (0, _jquery2.default)('#ivprog-term').css('padding', '5px');
  19786. } else {
  19787. // mostrar
  19788. (0, _jquery2.default)('.ivprog-term-div').css('display', 'block');
  19789. (0, _jquery2.default)('#ivprog-term').css('min-height', '160px');
  19790. (0, _jquery2.default)('#ivprog-term').css('margin-top', '-170px');
  19791. }
  19792. }
  19793. function waitToCloseConsole() {
  19794. domConsole.info("Aperte qualquer tecla para fechar...");
  19795. var p = new Promise(function (resolve, _) {
  19796. domConsole.requestInput(resolve, true);
  19797. });
  19798. p.then(function (_) {
  19799. domConsole.dispose();
  19800. domConsole = null;
  19801. (0, _jquery2.default)("#ivprog-term").hide();
  19802. });
  19803. }
  19804. function toggleTextualCoding() {
  19805. var code = CodeManagement.generate();
  19806. if (code == null) {
  19807. return;
  19808. }
  19809. (0, _jquery2.default)('.ivprog_visual_panel').css('display', 'none');
  19810. (0, _jquery2.default)('.ivprog_textual_panel').css('display', 'block');
  19811. (0, _jquery2.default)('.ivprog_textual_panel').removeClass('loading');
  19812. (0, _jquery2.default)('.ivprog_textual_code').text(code);
  19813. (0, _jquery2.default)('.visual_coding_button').removeClass('active');
  19814. (0, _jquery2.default)('.textual_coding_button').addClass('active');
  19815. }
  19816. function toggleVisualCoding() {
  19817. (0, _jquery2.default)('.ivprog_textual_panel').addClass('loading');
  19818. (0, _jquery2.default)('.ivprog_textual_panel').css('display', 'none');
  19819. (0, _jquery2.default)('.ivprog_visual_panel').css('display', 'block');
  19820. (0, _jquery2.default)('.textual_coding_button').removeClass('active');
  19821. (0, _jquery2.default)('.visual_coding_button').addClass('active');
  19822. }
  19823. function removeParameter(function_obj, parameter_obj, parameter_container) {
  19824. var index = function_obj.parameters_list.indexOf(parameter_obj);
  19825. if (index > -1) {
  19826. window.insertContext = true;
  19827. function_obj.parameters_list.splice(index, 1);
  19828. }
  19829. (0, _jquery2.default)(parameter_container).fadeOut();
  19830. }
  19831. function updateParameterType(parameter_obj, new_type) {
  19832. var new_dimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  19833. parameter_obj.type = new_type;
  19834. parameter_obj.dimensions = new_dimensions;
  19835. if (new_dimensions > 0) {
  19836. parameter_obj.rows = new_dimensions;
  19837. parameter_obj.columns = 2;
  19838. }
  19839. }
  19840. function renderParameter(function_obj, parameter_obj, function_container) {
  19841. var ret = "";
  19842. ret += '<div class="ui label function_name_parameter pink"><i class="ui icon ellipsis vertical inverted"></i>';
  19843. ret += '<div class="ui dropdown parameter_type">';
  19844. if (parameter_obj.dimensions > 0) {
  19845. ret += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(parameter_obj.type);
  19846. if (parameter_obj.dimensions == 1) {
  19847. ret += ' [ ] ';
  19848. } else {
  19849. ret += ' [ ] [ ] ';
  19850. }
  19851. ret += '</div>';
  19852. } else {
  19853. ret += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI(parameter_obj.type) + '</div>';
  19854. }
  19855. ret += '<div class="menu">';
  19856. for (var tm in _types.Types) {
  19857. if (tm == _types.Types.VOID.toUpperCase()) {
  19858. continue;
  19859. }
  19860. ret += '<div class="item ' + (parameter_obj.type == tm.toLowerCase() ? ' selected ' : '') + '" data-type="' + tm + '" >' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '</div>';
  19861. }
  19862. for (var tm in _types.Types) {
  19863. if (tm == _types.Types.VOID.toUpperCase()) {
  19864. continue;
  19865. }
  19866. ret += '<div class="item">' + '<i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '<div class="menu">' + '<div class="item" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] " data-type="' + tm + '" data-dimensions="1">[ ]</div>' + '<div class="item" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] [ ] " data-type="' + tm + '" data-dimensions="2">[ ] [ ] </div>' + '</div>' + '</div>';
  19867. }
  19868. ret += '</div></div>';
  19869. ret += '<div class="parameter_div_edit"><span class="span_name_parameter label_enable_name_parameter">' + parameter_obj.name + '</span></div> ';
  19870. ret += ' <i class="yellow inverted icon times remove_parameter"></i></div>';
  19871. ret = (0, _jquery2.default)(ret);
  19872. function_container.find('.container_parameters_list').append(ret);
  19873. ret.find('.remove_parameter').on('click', function (e) {
  19874. removeParameter(function_obj, parameter_obj, ret);
  19875. });
  19876. ret.find('.ui.dropdown.parameter_type').dropdown({
  19877. onChange: function onChange(value, text, $selectedItem) {
  19878. if ($selectedItem.data('dimensions')) {
  19879. updateParameterType(parameter_obj, _types.Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
  19880. } else {
  19881. updateParameterType(parameter_obj, _types.Types[$selectedItem.data('type')]);
  19882. }
  19883. },
  19884. selectOnKeydown: false
  19885. });
  19886. ret.find('.label_enable_name_parameter').on('click', function (e) {
  19887. enableNameParameterUpdate(parameter_obj, ret, function_obj);
  19888. });
  19889. return ret;
  19890. }
  19891. function updateParameterName(parameter_var, new_name, parameter_obj_dom, function_obj) {
  19892. if (parameter_var.name == new_name) {
  19893. return;
  19894. }
  19895. if (isValidIdentifier(new_name)) {
  19896. if (variableNameAlreadyExists(new_name, function_obj)) {
  19897. Utils.renderErrorMessage(parameter_obj_dom.find('.parameter_div_edit'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_variable_duplicated'));
  19898. } else {
  19899. parameter_var.name = new_name;
  19900. }
  19901. } else {
  19902. Utils.renderErrorMessage(parameter_obj_dom.find('.parameter_div_edit'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_name'));
  19903. }
  19904. }
  19905. function variableNameAlreadyExists(name_var, function_obj) {
  19906. if (function_obj.parameters_list) {
  19907. for (var i = 0; i < function_obj.parameters_list.length; i++) {
  19908. if (function_obj.parameters_list[i].name == name_var) {
  19909. return true;
  19910. }
  19911. }
  19912. }
  19913. if (function_obj.variables_list) {
  19914. for (var i = 0; i < function_obj.variables_list.length; i++) {
  19915. if (function_obj.variables_list[i].name == name_var) {
  19916. return true;
  19917. }
  19918. }
  19919. }
  19920. return false;
  19921. }
  19922. function updateFunctionName(function_var, new_name, function_obj_dom) {
  19923. if (function_var.name == new_name) {
  19924. return;
  19925. }
  19926. if (isValidIdentifier(new_name)) {
  19927. if (functionNameAlreadyExists(new_name)) {
  19928. Utils.renderErrorMessage(function_obj_dom.find('.function_name_div'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_name_duplicated'));
  19929. } else {
  19930. function_var.name = new_name;
  19931. }
  19932. } else {
  19933. Utils.renderErrorMessage(function_obj_dom.find('.function_name_div'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_name'));
  19934. }
  19935. }
  19936. function functionNameAlreadyExists(function_name) {
  19937. for (var i = 0; i < window.program_obj.functions.length; i++) {
  19938. if (window.program_obj.functions[i].name == function_name) {
  19939. return true;
  19940. }
  19941. }
  19942. return false;
  19943. }
  19944. function isValidIdentifier(identifier_str) {
  19945. return (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier_str)
  19946. );
  19947. }
  19948. var opened_name_parameter = false;
  19949. var opened_input_parameter = null;
  19950. function enableNameParameterUpdate(parameter_obj, parent_node, function_obj) {
  19951. if (opened_name_parameter) {
  19952. opened_input_parameter.focus();
  19953. return;
  19954. }
  19955. opened_name_parameter = true;
  19956. parent_node = (0, _jquery2.default)(parent_node);
  19957. var input_field;
  19958. parent_node.find('.span_name_parameter').text('');
  19959. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + parameter_obj.name + "' />");
  19960. input_field.insertBefore(parent_node.find('.span_name_parameter'));
  19961. input_field.on('input', function () {
  19962. var inputWidth = input_field.textWidth() + 10;
  19963. opened_input_parameter = input_field;
  19964. input_field.focus();
  19965. var tmpStr = input_field.val();
  19966. input_field.val('');
  19967. input_field.val(tmpStr);
  19968. input_field.css({
  19969. width: inputWidth
  19970. });
  19971. }).trigger('input');
  19972. input_field.focusout(function () {
  19973. /// update array:
  19974. if (input_field.val().trim()) {
  19975. updateParameterName(parameter_obj, input_field.val().trim(), parent_node, function_obj);
  19976. parent_node.find('.span_name_parameter').text(parameter_obj.name);
  19977. }
  19978. input_field.off();
  19979. input_field.remove();
  19980. /// update elements:
  19981. opened_name_parameter = false;
  19982. opened_input_parameter = false;
  19983. });
  19984. input_field.on('keydown', function (e) {
  19985. var code = e.keyCode || e.which;
  19986. if (code == 13) {
  19987. if (input_field.val().trim()) {
  19988. updateParameterName(parameter_obj, input_field.val().trim(), parent_node, function_obj);
  19989. parent_node.find('.span_name_parameter').text(parameter_obj.name);
  19990. }
  19991. input_field.off();
  19992. input_field.remove();
  19993. /// update elements:
  19994. opened_name_parameter = false;
  19995. opened_input_parameter = false;
  19996. }
  19997. if (code == 27) {
  19998. parent_node.find('.span_name_parameter').text(parameter_obj.name);
  19999. input_field.off();
  20000. input_field.remove();
  20001. /// update elements:
  20002. opened_name_parameter = false;
  20003. opened_input_parameter = false;
  20004. }
  20005. });
  20006. input_field.select();
  20007. }
  20008. var opened_name_function = false;
  20009. var opened_input = null;
  20010. var previousPadding = null;
  20011. function enableNameFunctionUpdate(function_obj, parent_node) {
  20012. if (opened_name_function) {
  20013. opened_input.focus();
  20014. return;
  20015. }
  20016. parent_node = (0, _jquery2.default)(parent_node);
  20017. parent_node.find('.span_name_function').text('');
  20018. var input_field;
  20019. if (!previousPadding) {
  20020. previousPadding = parent_node.find('.span_name_function').css('padding-left');
  20021. }
  20022. parent_node.find('.span_name_function').css('padding-left', '0');
  20023. parent_node.find('.span_name_function').css('padding-right', '0');
  20024. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + function_obj.name + "' />");
  20025. input_field.insertBefore(parent_node.find('.span_name_function'));
  20026. input_field.on('input', function () {
  20027. var inputWidth = input_field.textWidth() + 10;
  20028. opened_input = input_field;
  20029. input_field.focus();
  20030. var tmpStr = input_field.val();
  20031. input_field.val('');
  20032. input_field.val(tmpStr);
  20033. input_field.css({
  20034. width: inputWidth
  20035. });
  20036. }).trigger('input');
  20037. input_field.focusout(function () {
  20038. /// update array:
  20039. if (input_field.val().trim()) {
  20040. updateFunctionName(function_obj, input_field.val().trim(), parent_node);
  20041. }
  20042. input_field.off();
  20043. input_field.remove();
  20044. parent_node.find('.span_name_function').css('padding-left', previousPadding);
  20045. parent_node.find('.span_name_function').css('padding-right', previousPadding);
  20046. parent_node.find('.span_name_function').text(function_obj.name);
  20047. /// update elements:
  20048. opened_name_function = false;
  20049. opened_input = false;
  20050. });
  20051. input_field.on('keydown', function (e) {
  20052. var code = e.keyCode || e.which;
  20053. if (code == 13) {
  20054. if (input_field.val().trim()) {
  20055. updateFunctionName(function_obj, input_field.val().trim(), parent_node);
  20056. }
  20057. input_field.off();
  20058. input_field.remove();
  20059. parent_node.find('.span_name_function').css('padding-left', previousPadding);
  20060. parent_node.find('.span_name_function').css('padding-right', previousPadding);
  20061. parent_node.find('.span_name_function').text(function_obj.name);
  20062. /// update elements:
  20063. opened_name_function = false;
  20064. opened_input = false;
  20065. }
  20066. if (code == 27) {
  20067. input_field.off();
  20068. input_field.remove();
  20069. parent_node.find('.span_name_function').css('padding-left', previousPadding);
  20070. parent_node.find('.span_name_function').css('padding-right', previousPadding);
  20071. parent_node.find('.span_name_function').text(function_obj.name);
  20072. /// update elements:
  20073. opened_name_function = false;
  20074. opened_input = false;
  20075. }
  20076. });
  20077. input_field.select();
  20078. }
  20079. /***/ }),
  20080. /***/ "./js/visualUI/globals.js":
  20081. /*!********************************!*\
  20082. !*** ./js/visualUI/globals.js ***!
  20083. \********************************/
  20084. /*! no static exports found */
  20085. /***/ (function(module, exports, __webpack_require__) {
  20086. "use strict";
  20087. Object.defineProperty(exports, "__esModule", {
  20088. value: true
  20089. });
  20090. exports.addGlobal = addGlobal;
  20091. exports.renderGlobal = renderGlobal;
  20092. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  20093. var _jquery2 = _interopRequireDefault(_jquery);
  20094. var _types = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
  20095. var _ivprog_elements = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  20096. var Models = _interopRequireWildcard(_ivprog_elements);
  20097. var _localizedStringsService = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  20098. var _utils = __webpack_require__(/*! ./utils */ "./js/visualUI/utils.js");
  20099. var Utils = _interopRequireWildcard(_utils);
  20100. __webpack_require__(/*! ../semantic/semantic.min.js */ "./js/semantic/semantic.min.js");
  20101. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  20102. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20103. window.jQuery = _jquery2.default;
  20104. var counter_new_globals = 0;
  20105. function addGlobal(program) {
  20106. var is_from_click = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  20107. var new_global = new Models.Variable(_types.Types.INTEGER, _localizedStringsService.LocalizedStrings.getUI('new_global') + '_' + counter_new_globals, 1);
  20108. counter_new_globals++;
  20109. program.addGlobal(new_global);
  20110. var newe = renderGlobal(new_global);
  20111. if (is_from_click) {
  20112. newe.css('display', 'none');
  20113. newe.fadeIn();
  20114. }
  20115. }
  20116. function toggleConstant(global_var) {
  20117. global_var.is_constant = !global_var.is_constant;
  20118. }
  20119. function updateName(global_var, new_name, global_obj_dom) {
  20120. if (global_var.name == new_name) {
  20121. return;
  20122. }
  20123. if (isValidIdentifier(new_name)) {
  20124. if (globalNameAlreadyExists(new_name)) {
  20125. Utils.renderErrorMessage(global_obj_dom.find('.editing_name_var'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_global_duplicated'));
  20126. } else {
  20127. global_var.name = new_name;
  20128. }
  20129. } else {
  20130. Utils.renderErrorMessage(global_obj_dom.find('.editing_name_var'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_name'));
  20131. }
  20132. }
  20133. function globalNameAlreadyExists(global_name) {
  20134. for (var i = 0; i < window.program_obj.globals.length; i++) {
  20135. if (window.program_obj.globals[i].name == global_name) {
  20136. return true;
  20137. }
  20138. }
  20139. return false;
  20140. }
  20141. function isValidIdentifier(identifier_str) {
  20142. return (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier_str)
  20143. );
  20144. }
  20145. function updateType(global_var, new_type) {
  20146. var new_dimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  20147. global_var.type = new_type;
  20148. global_var.dimensions = new_dimensions;
  20149. if (new_dimensions > 0) {
  20150. global_var.rows = new_dimensions;
  20151. global_var.columns = 2;
  20152. }
  20153. updateInitialValues(global_var);
  20154. }
  20155. function removeGlobal(global_var, global_container) {
  20156. var index = window.program_obj.globals.indexOf(global_var);
  20157. if (index > -1) {
  20158. window.insertContext = true;
  20159. window.program_obj.globals.splice(index, 1);
  20160. }
  20161. global_container.children().off();
  20162. global_container.off();
  20163. global_container.fadeOut();
  20164. }
  20165. function updateInitialValues(global_var) {
  20166. if (global_var.type == _types.Types.INTEGER) {
  20167. if (global_var.dimensions == 0) {
  20168. global_var.value = 1;
  20169. }
  20170. if (global_var.dimensions == 1) {
  20171. global_var.value = [1, 1];
  20172. }
  20173. if (global_var.dimensions == 2) {
  20174. global_var.value = [[1, 1], [1, 1]];
  20175. }
  20176. }
  20177. if (global_var.type == _types.Types.REAL) {
  20178. if (global_var.dimensions == 0) {
  20179. global_var.value = 1.0;
  20180. }
  20181. if (global_var.dimensions == 1) {
  20182. global_var.value = [1.0, 1.0];
  20183. }
  20184. if (global_var.dimensions == 2) {
  20185. global_var.value = [[1.0, 1.0], [1.0, 1.0]];
  20186. }
  20187. }
  20188. if (global_var.type == _types.Types.TEXT) {
  20189. if (global_var.dimensions == 0) {
  20190. global_var.value = _localizedStringsService.LocalizedStrings.getUI('text_start');
  20191. }
  20192. if (global_var.dimensions == 1) {
  20193. global_var.value = [_localizedStringsService.LocalizedStrings.getUI('text_start'), _localizedStringsService.LocalizedStrings.getUI('text_start')];
  20194. }
  20195. if (global_var.dimensions == 2) {
  20196. global_var.value = [[_localizedStringsService.LocalizedStrings.getUI('text_start'), _localizedStringsService.LocalizedStrings.getUI('text_start')], [_localizedStringsService.LocalizedStrings.getUI('text_start'), _localizedStringsService.LocalizedStrings.getUI('text_start')]];
  20197. }
  20198. }
  20199. if (global_var.type == _types.Types.BOOLEAN) {
  20200. if (global_var.dimensions == 0) {
  20201. global_var.value = true;
  20202. }
  20203. if (global_var.dimensions == 1) {
  20204. global_var.value = [true, true];
  20205. }
  20206. if (global_var.dimensions == 2) {
  20207. global_var.value = [[true, true], [true, true]];
  20208. }
  20209. }
  20210. }
  20211. function alternateBooleanGlobalValue(global_var, value_container) {
  20212. global_var.value = !global_var.value;
  20213. (0, _jquery2.default)(value_container).find('.span_value_variable').text(_localizedStringsService.LocalizedStrings.getUI(global_var.value));
  20214. }
  20215. function alternateBooleanGlobalVectorValue(global_var, index, value_container) {
  20216. global_var.value[index] = !global_var.value[index];
  20217. (0, _jquery2.default)(value_container).find('.span_value_variable').text(_localizedStringsService.LocalizedStrings.getUI(global_var.value[index]));
  20218. }
  20219. function removeGlobalColumnVector(global_var) {
  20220. if (global_var.columns == 0) {
  20221. return;
  20222. }
  20223. global_var.columns--;
  20224. global_var.value.splice(global_var.value.length - 1, 1);
  20225. }
  20226. function addGlobalColumnVector(global_var) {
  20227. global_var.columns++;
  20228. if (global_var.type == _types.Types.INTEGER) {
  20229. global_var.value.push(1);
  20230. }
  20231. if (global_var.type == _types.Types.REAL) {
  20232. global_var.value.push(1.0);
  20233. }
  20234. if (global_var.type == _types.Types.TEXT) {
  20235. global_var.value.push(_localizedStringsService.LocalizedStrings.getUI('text_start'));
  20236. }
  20237. if (global_var.type == _types.Types.BOOLEAN) {
  20238. global_var.value.push(true);
  20239. }
  20240. }
  20241. function removeColumnGlobalMatrix(global_var) {
  20242. if (global_var.columns == 0) {
  20243. return;
  20244. }
  20245. global_var.columns--;
  20246. for (var i = 0; i < global_var.rows; i++) {
  20247. global_var.value[i].splice(global_var.value[i].length - 1, 1);
  20248. }
  20249. }
  20250. function addColumnGlobalMatrix(global_var) {
  20251. global_var.columns++;
  20252. if (global_var.type == _types.Types.INTEGER) {
  20253. for (var i = 0; i < global_var.rows; i++) {
  20254. global_var.value[i].push(1);
  20255. }
  20256. }
  20257. if (global_var.type == _types.Types.REAL) {
  20258. for (var i = 0; i < global_var.rows; i++) {
  20259. global_var.value[i].push(1.0);
  20260. }
  20261. }
  20262. if (global_var.type == _types.Types.TEXT) {
  20263. for (var i = 0; i < global_var.rows; i++) {
  20264. global_var.value[i].push(_localizedStringsService.LocalizedStrings.getUI('text_start'));
  20265. }
  20266. }
  20267. if (global_var.type == _types.Types.BOOLEAN) {
  20268. for (var i = 0; i < global_var.rows; i++) {
  20269. global_var.value[i].push(true);
  20270. }
  20271. }
  20272. }
  20273. function removeLineGlobalMatrix(global_var) {
  20274. if (global_var.rows == 0) {
  20275. return;
  20276. }
  20277. global_var.rows--;
  20278. global_var.value.splice(global_var.value.length - 1, 1);
  20279. }
  20280. function addLineGlobalMatrix(global_var) {
  20281. global_var.rows++;
  20282. if (global_var.type == _types.Types.INTEGER) {
  20283. var n_l = [];
  20284. for (var i = 0; i < global_var.columns; i++) {
  20285. n_l.push(1);
  20286. }
  20287. global_var.value.push(n_l);
  20288. }
  20289. if (global_var.type == _types.Types.REAL) {
  20290. var n_l = [];
  20291. for (i = 0; i < global_var.columns; i++) {
  20292. n_l.push(1.0);
  20293. }
  20294. global_var.value.push(n_l);
  20295. }
  20296. if (global_var.type == _types.Types.TEXT) {
  20297. var n_l = [];
  20298. for (i = 0; i < global_var.columns; i++) {
  20299. n_l.push(_localizedStringsService.LocalizedStrings.getUI('text_start'));
  20300. }
  20301. global_var.value.push(n_l);
  20302. }
  20303. if (global_var.type == _types.Types.BOOLEAN) {
  20304. var n_l = [];
  20305. for (i = 0; i < global_var.columns; i++) {
  20306. n_l.push(true);
  20307. }
  20308. global_var.value.push(n_l);
  20309. }
  20310. }
  20311. function alternateBooleanGlobalMatrixValue(global_var, row, index, value_container) {
  20312. global_var.value[row][index] = !global_var.value[row][index];
  20313. (0, _jquery2.default)(value_container).find('.span_value_variable').text(_localizedStringsService.LocalizedStrings.getUI(global_var.value[row][index]));
  20314. }
  20315. function renderValues(global_var, global_container) {
  20316. var ret = "";
  20317. var j = 0;
  20318. if (global_var.dimensions == 0) {
  20319. if (global_var.type == _types.Types.REAL) {
  20320. ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">' + global_var.value.toFixed(1) + '</span> </div> ';
  20321. } else {
  20322. if (global_var.type == _types.Types.BOOLEAN) {
  20323. ret += '<div class="created_div_valor_var"><span class="span_value_variable boolean_simple_type">' + _localizedStringsService.LocalizedStrings.getUI(global_var.value) + '</span> </div> ';
  20324. } else {
  20325. ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">' + global_var.value + '</span> </div> ';
  20326. }
  20327. }
  20328. } else {
  20329. ret += '<table class="tabela_var">';
  20330. if (global_var.dimensions == 1) {
  20331. ret += '<tr>';
  20332. if (global_var.type == _types.Types.REAL) {
  20333. for (var k = 0; k < global_var.columns; k++) {
  20334. ret += '<td><span class="span_value_variable vector_var" data-index="' + k + '">' + global_var.value[k].toFixed(1) + '</span></td>';
  20335. }
  20336. } else {
  20337. for (var k = 0; k < global_var.columns; k++) {
  20338. if (global_var.type == _types.Types.BOOLEAN) {
  20339. ret += '<td><span class="span_value_variable boolean_vector_var" data-index="' + k + '">' + _localizedStringsService.LocalizedStrings.getUI(global_var.value[k]) + '</span></td>';
  20340. } else {
  20341. ret += '<td><span class="span_value_variable vector_var" data-index="' + k + '">' + global_var.value[k] + '</span>' + '</td>';
  20342. }
  20343. }
  20344. }
  20345. ret += '</tr>';
  20346. ret += '</table>';
  20347. ret += '<div class="buttons_manage_columns"><i class="ui icon minus square outline remove_global_vector_column"></i>' + ' <i class="ui icon plus square outline add_global_vector_column"></i></div>';
  20348. }
  20349. if (global_var.dimensions == 2) {
  20350. if (global_var.type == _types.Types.REAL) {
  20351. for (var l = 0; l < global_var.rows; l++) {
  20352. ret += '<tr>';
  20353. for (var k = 0; k < global_var.columns; k++) {
  20354. ret += '<td><span class="span_value_variable matrix_var" data-index="' + k + '" data-row="' + l + '">' + global_var.value[l][k].toFixed(1) + '</span>' + '</td>';
  20355. }
  20356. ret += '</tr>';
  20357. }
  20358. } else {
  20359. for (var l = 0; l < global_var.rows; l++) {
  20360. ret += '<tr>';
  20361. for (var k = 0; k < global_var.columns; k++) {
  20362. if (global_var.type == _types.Types.BOOLEAN) {
  20363. ret += '<td><span class="span_value_variable boolean_matrix_var" data-index="' + k + '" data-row="' + l + '">' + _localizedStringsService.LocalizedStrings.getUI(global_var.value[l][k]) + '</span></td>';
  20364. } else {
  20365. ret += '<td><span class="span_value_variable matrix_var" data-index="' + k + '" data-row="' + l + '">' + global_var.value[l][k] + '</span></td>';
  20366. }
  20367. }
  20368. ret += '</tr>';
  20369. }
  20370. }
  20371. if (global_var.rows == 0) {
  20372. ret += '<tr><td></td></tr>';
  20373. }
  20374. ret += '<tr><td colspan="' + global_var.columns + '" class="tr_manage_lines"><i class="ui icon minus square outline remove_global_matrix_line"></i>' + ' <i class="ui icon plus square outline add_global_matrix_line"></i></td></tr>';
  20375. ret += '</table>';
  20376. ret += '<div class="buttons_manage_columns"><i class="ui icon minus square outline remove_global_matrix_column"></i>' + ' <i class="ui icon plus square outline add_global_matrix_column"></i></div>';
  20377. }
  20378. }
  20379. global_container.find(".div_valor_var").html('');
  20380. ret = (0, _jquery2.default)(ret);
  20381. ret.find('.span_value_variable').data('associatedOject', global_var);
  20382. ret.find(".boolean_simple_type").on('click', function (e) {
  20383. alternateBooleanGlobalValue(global_var, this.parentNode);
  20384. });
  20385. ret.find(".simple_var").on('click', function (e) {
  20386. enableGlobalValueUpdate(global_var, this.parentNode);
  20387. });
  20388. ret.find(".boolean_vector_var").on('click', function (e) {
  20389. alternateBooleanGlobalVectorValue(global_var, (0, _jquery2.default)(this).data('index'), this.parentNode);
  20390. });
  20391. ret.find(".vector_var").on('click', function (e) {
  20392. enableGlobalVectorValueUpdate(global_var, (0, _jquery2.default)(this).data('index'), this.parentNode);
  20393. });
  20394. ret.find(".remove_global_vector_column").on('click', function (e) {
  20395. removeGlobalColumnVector(global_var);
  20396. global_container.find(".div_valor_var").html('');
  20397. renderValues(global_var, global_container);
  20398. });
  20399. ret.find(".add_global_vector_column").on('click', function (e) {
  20400. addGlobalColumnVector(global_var);
  20401. global_container.find(".div_valor_var").html('');
  20402. renderValues(global_var, global_container);
  20403. });
  20404. ret.find(".remove_global_matrix_column").on('click', function (e) {
  20405. removeColumnGlobalMatrix(global_var);
  20406. global_container.find(".div_valor_var").html('');
  20407. renderValues(global_var, global_container);
  20408. });
  20409. ret.find(".add_global_matrix_column").on('click', function (e) {
  20410. addColumnGlobalMatrix(global_var);
  20411. global_container.find(".div_valor_var").html('');
  20412. renderValues(global_var, global_container);
  20413. });
  20414. ret.find(".remove_global_matrix_line").on('click', function (e) {
  20415. removeLineGlobalMatrix(global_var);
  20416. global_container.find(".div_valor_var").html('');
  20417. renderValues(global_var, global_container);
  20418. });
  20419. ret.find(".add_global_matrix_line").on('click', function (e) {
  20420. addLineGlobalMatrix(global_var);
  20421. global_container.find(".div_valor_var").html('');
  20422. renderValues(global_var, global_container);
  20423. });
  20424. ret.find(".boolean_matrix_var").on('click', function (e) {
  20425. alternateBooleanGlobalMatrixValue(global_var, (0, _jquery2.default)(this).data('row'), (0, _jquery2.default)(this).data('index'), this.parentNode);
  20426. });
  20427. ret.find(".matrix_var").on('click', function (e) {
  20428. enableGlobalMatrixValueUpdate(global_var, (0, _jquery2.default)(this).data('row'), (0, _jquery2.default)(this).data('index'), this.parentNode);
  20429. });
  20430. global_container.find(".div_valor_var").append(ret);
  20431. updateColumnsAndRowsText(global_container, global_var);
  20432. }
  20433. function addHandlers(global_container) {
  20434. var global_var = global_container.data('associatedOject');
  20435. // Manage constant option:
  20436. global_container.find(".alternate_constant").on('click', function (e) {
  20437. toggleConstant(global_var);
  20438. (0, _jquery2.default)(this).removeClass("on off");
  20439. if (global_var.is_constant) {
  20440. (0, _jquery2.default)(this).addClass("on");
  20441. } else {
  20442. (0, _jquery2.default)(this).addClass("off");
  20443. }
  20444. });
  20445. // Manage global name:
  20446. global_container.find(".enable_edit_name_parameter").on('click', function (e) {
  20447. enableNameUpdate(global_container);
  20448. });
  20449. // Menu to change type:
  20450. global_container.find('.ui.dropdown.global_type').dropdown({
  20451. onChange: function onChange(value, text, $selectedItem) {
  20452. if ($selectedItem.data('dimensions')) {
  20453. updateType(global_var, _types.Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
  20454. } else {
  20455. updateType(global_var, _types.Types[$selectedItem.data('type')]);
  20456. }
  20457. renderValues(global_var, global_container);
  20458. },
  20459. selectOnKeydown: false
  20460. });
  20461. // Remove global:
  20462. global_container.find(".remove_global").on('click', function (e) {
  20463. removeGlobal(global_var, global_container);
  20464. });
  20465. }
  20466. function updateColumnsAndRowsText(global_container, global_var) {
  20467. var prev = global_container.find('.text').text().split('[');
  20468. if (prev.length == 2) {
  20469. var ff = prev[0] + '[ ' + global_var.columns + ' ] ';
  20470. global_container.find('.text').empty();
  20471. global_container.find('.text').text(ff);
  20472. }
  20473. if (prev.length == 3) {
  20474. var ff = prev[0] + '[ ' + global_var.columns + ' ] [ ' + global_var.rows + ' ] ';
  20475. global_container.find('.text').empty();
  20476. global_container.find('.text').text(ff);
  20477. }
  20478. }
  20479. function renderGlobal(global_var) {
  20480. var element = '<div class="ui label global_container pink"><i class="ui icon ellipsis vertical inverted"></i><div class="global_const">const: ';
  20481. element += '<i class="ui icon toggle ' + (global_var.is_constant ? "on" : "off") + ' alternate_constant"></i></div>';
  20482. element += '<div class="ui dropdown global_type">';
  20483. if (global_var.dimensions > 0) {
  20484. element += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(global_var.type);
  20485. for (var i = 0; i < global_var.dimensions; i++) {
  20486. element += ' [ <span class="dimensions_' + i + '"></span> ] ';
  20487. }
  20488. element += '</div>';
  20489. } else {
  20490. element += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI(global_var.type.toLowerCase()) + '</div>';
  20491. }
  20492. element += '<div class="menu">';
  20493. for (var tm in _types.Types) {
  20494. if (tm == _types.Types.VOID.toUpperCase()) {
  20495. continue;
  20496. }
  20497. element += '<div class="item ' + (global_var.type == tm.toLowerCase() ? ' selected ' : '') + '" data-type="' + tm + '" >' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '</div>';
  20498. }
  20499. for (var tm in _types.Types) {
  20500. if (tm == _types.Types.VOID.toUpperCase()) {
  20501. continue;
  20502. }
  20503. element += '<div class="item">' + '<i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '<div class="menu">' + '<div class="item" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] " data-type="' + tm + '" data-dimensions="1">[ ]</div>' + '<div class="item" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] [ ] " data-type="' + tm + '" data-dimensions="2">[ ] [ ] </div>' + '</div>' + '</div>';
  20504. }
  20505. element += '</div></div> <div class="editing_name_var"> <span class="span_name_variable enable_edit_name_parameter">' + global_var.name + '</span> </div> <span class="character_equals"> = </span> ';
  20506. element += '<div class="ui div_valor_var">' + global_var.value + '</div>';
  20507. element += ' <i class="yellow inverted icon times remove_global"></i></div>';
  20508. var complete_element = (0, _jquery2.default)(element);
  20509. complete_element.data('associatedOject', global_var);
  20510. (0, _jquery2.default)('.list_globals').append(complete_element);
  20511. addHandlers(complete_element);
  20512. renderValues(global_var, complete_element);
  20513. if (global_var.dimensions == 1) {
  20514. complete_element.find('.dimensions_0').text(global_var.columns);
  20515. }
  20516. if (global_var.dimensions == 2) {
  20517. complete_element.find('.dimensions_0').text(global_var.columns);
  20518. complete_element.find('.dimensions_1').text(global_var.rows);
  20519. }
  20520. return complete_element;
  20521. }
  20522. var opened_name_value_matrix_global_v = false;
  20523. var opened_input_value_matrix_global_v = null;
  20524. function enableGlobalMatrixValueUpdate(global_var, row, index, parent_node) {
  20525. if (opened_name_value_matrix_global_v) {
  20526. opened_input_value_matrix_global_v.focus();
  20527. return;
  20528. }
  20529. parent_node = (0, _jquery2.default)(parent_node);
  20530. opened_name_value_matrix_global_v = true;
  20531. parent_node.find('.span_value_variable').text('');
  20532. var input_field;
  20533. if (global_var.type == _types.Types.REAL) {
  20534. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + global_var.value[row][index].toFixed(1) + "' />");
  20535. input_field.insertBefore(parent_node.find('.span_value_variable'));
  20536. } else {
  20537. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + global_var.value[row][index] + "' />");
  20538. input_field.insertBefore(parent_node.find('.span_value_variable'));
  20539. }
  20540. input_field.on('input', function () {
  20541. var inputWidth = input_field.textWidth() + 10;
  20542. opened_input_value_matrix_global_v = input_field;
  20543. input_field.focus();
  20544. var tmpStr = input_field.val();
  20545. input_field.val('');
  20546. input_field.val(tmpStr);
  20547. input_field.css({
  20548. width: inputWidth
  20549. });
  20550. }).trigger('input');
  20551. input_field.focusout(function () {
  20552. /// update array:
  20553. if (input_field.val().trim()) {
  20554. if (global_var.type == _types.Types.REAL) {
  20555. global_var.value[row][index] = parseFloat(input_field.val().trim());
  20556. parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
  20557. } else {
  20558. if (global_var.type == _types.Types.INTEGER) {
  20559. global_var.value[row][index] = parseInt(input_field.val().trim());
  20560. } else {
  20561. global_var.value[row][index] = input_field.val().trim();
  20562. }
  20563. parent_node.find('.span_value_variable').text(global_var.value[row][index]);
  20564. }
  20565. } else {
  20566. if (global_var.type == _types.Types.REAL) {
  20567. parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
  20568. } else {
  20569. parent_node.find('.span_value_variable').text(global_var.value[row][index]);
  20570. }
  20571. }
  20572. if (global_var.type == _types.Types.TEXT) {
  20573. global_var.value[row][index] = input_field.val();
  20574. parent_node.find('.span_value_variable').text(global_var.value[row][index]);
  20575. }
  20576. input_field.off();
  20577. input_field.remove();
  20578. /// update elements:
  20579. opened_name_value_matrix_global_v = false;
  20580. opened_input_value_matrix_global_v = false;
  20581. });
  20582. input_field.on('keydown', function (e) {
  20583. var code = e.keyCode || e.which;
  20584. if (code == 13) {
  20585. if (input_field.val().trim()) {
  20586. if (global_var.type == _types.Types.REAL) {
  20587. global_var.value[row][index] = parseFloat(input_field.val().trim());
  20588. parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
  20589. } else {
  20590. if (global_var.type == _types.Types.INTEGER) {
  20591. global_var.value[row][index] = parseInt(input_field.val().trim());
  20592. } else {
  20593. global_var.value[row][index] = input_field.val().trim();
  20594. }
  20595. parent_node.find('.span_value_variable').text(global_var.value[row][index]);
  20596. }
  20597. } else {
  20598. if (global_var.type == _types.Types.REAL) {
  20599. parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
  20600. } else {
  20601. parent_node.find('.span_value_variable').text(global_var.value[row][index]);
  20602. }
  20603. }
  20604. if (global_var.type == _types.Types.TEXT) {
  20605. global_var.value[row][index] = input_field.val();
  20606. parent_node.find('.span_value_variable').text(global_var.value[row][index]);
  20607. }
  20608. input_field.off();
  20609. input_field.remove();
  20610. /// update elements:
  20611. opened_name_value_matrix_global_v = false;
  20612. opened_input_value_matrix_global_v = false;
  20613. }
  20614. if (code == 27) {
  20615. if (global_var.type == _types.Types.REAL) {
  20616. parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
  20617. } else {
  20618. parent_node.find('.span_value_variable').text(global_var.value[row][index]);
  20619. }
  20620. input_field.off();
  20621. input_field.remove();
  20622. /// update elements:
  20623. opened_name_value_matrix_global_v = false;
  20624. opened_input_value_matrix_global_v = false;
  20625. }
  20626. });
  20627. input_field.select();
  20628. }
  20629. var opened_name_value_global_var = false;
  20630. var opened_input_value_global_ar = null;
  20631. function enableGlobalValueUpdate(global_var, parent_node) {
  20632. if (opened_name_value_global_var) {
  20633. opened_input_value_global_ar.focus();
  20634. return;
  20635. }
  20636. parent_node = (0, _jquery2.default)(parent_node);
  20637. opened_name_value_global_var = true;
  20638. parent_node.find('.span_value_variable').text('');
  20639. var input_field;
  20640. if (global_var.type == _types.Types.REAL) {
  20641. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + global_var.value.toFixed(1) + "' />");
  20642. input_field.insertBefore(parent_node.find('.span_value_variable'));
  20643. } else {
  20644. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + global_var.value + "' />");
  20645. input_field.insertBefore(parent_node.find('.span_value_variable'));
  20646. }
  20647. input_field.on('input', function () {
  20648. var inputWidth = input_field.textWidth() + 10;
  20649. opened_input_value_global_ar = input_field;
  20650. input_field.focus();
  20651. var tmpStr = input_field.val();
  20652. input_field.val('');
  20653. input_field.val(tmpStr);
  20654. input_field.css({
  20655. width: inputWidth
  20656. });
  20657. }).trigger('input');
  20658. input_field.focusout(function () {
  20659. /// update array:
  20660. if (input_field.val().trim()) {
  20661. if (global_var.type == _types.Types.REAL) {
  20662. global_var.value = parseFloat(input_field.val().trim());
  20663. parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
  20664. } else {
  20665. if (global_var.type == _types.Types.INTEGER) {
  20666. global_var.value = parseInt(input_field.val().trim());
  20667. } else {
  20668. global_var.value = input_field.val().trim();
  20669. }
  20670. parent_node.find('.span_value_variable').text(global_var.value);
  20671. }
  20672. } else {
  20673. if (global_var.type == _types.Types.REAL) {
  20674. parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
  20675. } else {
  20676. parent_node.find('.span_value_variable').text(global_var.value);
  20677. }
  20678. }
  20679. if (global_var.type == _types.Types.TEXT) {
  20680. global_var.value = input_field.val();
  20681. parent_node.find('.span_value_variable').text(global_var.value);
  20682. }
  20683. input_field.off();
  20684. input_field.remove();
  20685. /// update elements:
  20686. opened_name_value_global_var = false;
  20687. opened_input_value_global_ar = false;
  20688. });
  20689. input_field.on('keydown', function (e) {
  20690. var code = e.keyCode || e.which;
  20691. if (code == 13) {
  20692. if (input_field.val().trim()) {
  20693. if (global_var.type == _types.Types.REAL) {
  20694. global_var.value = parseFloat(input_field.val().trim());
  20695. parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
  20696. } else {
  20697. if (global_var.type == _types.Types.INTEGER) {
  20698. global_var.value = parseInt(input_field.val().trim());
  20699. } else {
  20700. global_var.value = input_field.val().trim();
  20701. }
  20702. parent_node.find('.span_value_variable').text(global_var.value);
  20703. }
  20704. } else {
  20705. if (global_var.type == _types.Types.REAL) {
  20706. parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
  20707. } else {
  20708. parent_node.find('.span_value_variable').text(global_var.value);
  20709. }
  20710. }
  20711. if (global_var.type == _types.Types.TEXT) {
  20712. global_var.value = input_field.val();
  20713. parent_node.find('.span_value_variable').text(global_var.value);
  20714. }
  20715. input_field.off();
  20716. input_field.remove();
  20717. /// update elements:
  20718. opened_name_value_global_var = false;
  20719. opened_input_value_global_ar = false;
  20720. }
  20721. if (code == 27) {
  20722. if (global_var.type == _types.Types.REAL) {
  20723. parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
  20724. } else {
  20725. parent_node.find('.span_value_variable').text(global_var.value);
  20726. }
  20727. input_field.off();
  20728. input_field.remove();
  20729. /// update elements:
  20730. opened_name_value_global_var = false;
  20731. opened_input_value_global_ar = false;
  20732. }
  20733. });
  20734. input_field.select();
  20735. }
  20736. var opened_name_global = false;
  20737. var opened_input_global = null;
  20738. function enableNameUpdate(global_container) {
  20739. var global_var = global_container.data('associatedOject');
  20740. if (opened_name_global) {
  20741. opened_input_global.focus();
  20742. return;
  20743. }
  20744. opened_name_global = true;
  20745. global_container.find('.span_name_variable').text('');
  20746. var input_name = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + global_var.name + "' />");
  20747. input_name.insertBefore(global_container.find('.span_name_variable'));
  20748. input_name.on('input', function () {
  20749. var inputWidth = input_name.textWidth() + 10;
  20750. opened_input_global = input_name;
  20751. opened_input_global.focus();
  20752. opened_input_global.css({
  20753. width: inputWidth
  20754. });
  20755. }).trigger('input');
  20756. input_name.focusout(function () {
  20757. /// update array:
  20758. if (input_name.val().trim().length > 0) {
  20759. updateName(global_var, input_name.val().trim(), global_container);
  20760. global_container.find('.span_name_variable').text(global_var.name);
  20761. } else {
  20762. global_container.find('.span_name_variable').text(global_var.name);
  20763. }
  20764. input_name.off();
  20765. input_name.remove();
  20766. /// update elements:
  20767. opened_name_global = false;
  20768. opened_input_global = false;
  20769. });
  20770. input_name.on('keydown', function (e) {
  20771. var code = e.keyCode || e.which;
  20772. if (code == 13) {
  20773. if (input_name.val().trim()) {
  20774. updateName(global_var, input_name.val().trim(), global_container);
  20775. global_container.find('.span_name_variable').text(global_var.name);
  20776. } else {
  20777. global_container.find('.span_name_variable').text(global_var.name);
  20778. }
  20779. input_name.off();
  20780. input_name.remove();
  20781. /// update elements:
  20782. opened_name_global = false;
  20783. opened_input_global = false;
  20784. }
  20785. if (code == 27) {
  20786. global_container.find('.span_name_variable').text(global_var.name);
  20787. input_name.off();
  20788. input_name.remove();
  20789. /// update elements:
  20790. opened_name_global = false;
  20791. opened_input_global = false;
  20792. }
  20793. });
  20794. input_name.select();
  20795. }
  20796. var opened_name_value_vector_global_ = false;
  20797. var opened_input_value_vector_global_ = null;
  20798. function enableGlobalVectorValueUpdate(global_var, index, parent_node) {
  20799. if (opened_name_value_vector_global_) {
  20800. opened_input_value_vector_global_.focus();
  20801. return;
  20802. }
  20803. parent_node = (0, _jquery2.default)(parent_node);
  20804. opened_name_value_vector_global_ = true;
  20805. parent_node.find('.span_value_variable').text('');
  20806. var input_field;
  20807. if (global_var.type == _types.Types.REAL) {
  20808. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + global_var.value[index].toFixed(1) + "' />");
  20809. input_field.insertBefore(parent_node.find('.span_value_variable'));
  20810. } else {
  20811. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + global_var.value[index] + "' />");
  20812. input_field.insertBefore(parent_node.find('.span_value_variable'));
  20813. }
  20814. input_field.on('input', function () {
  20815. var inputWidth = input_field.textWidth() + 10;
  20816. opened_input_value_vector_global_ = input_field;
  20817. input_field.focus();
  20818. var tmpStr = input_field.val();
  20819. input_field.val('');
  20820. input_field.val(tmpStr);
  20821. input_field.css({
  20822. width: inputWidth
  20823. });
  20824. }).trigger('input');
  20825. input_field.focusout(function () {
  20826. /// update array:
  20827. if (input_field.val().trim()) {
  20828. if (global_var.type == _types.Types.REAL) {
  20829. global_var.value[index] = parseFloat(input_field.val().trim());
  20830. parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
  20831. } else {
  20832. if (global_var.type == _types.Types.INTEGER) {
  20833. global_var.value[index] = parseInt(input_field.val().trim());
  20834. } else {
  20835. global_var.value[index] = input_field.val().trim();
  20836. }
  20837. parent_node.find('.span_value_variable').text(global_var.value[index]);
  20838. }
  20839. } else {
  20840. if (global_var.type == _types.Types.REAL) {
  20841. parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
  20842. } else {
  20843. parent_node.find('.span_value_variable').text(global_var.value[index]);
  20844. }
  20845. }
  20846. if (global_var.type == _types.Types.TEXT) {
  20847. global_var.value[index] = input_field.val();
  20848. parent_node.find('.span_value_variable').text(global_var.value[index]);
  20849. }
  20850. input_field.off();
  20851. input_field.remove();
  20852. /// update elements:
  20853. opened_name_value_vector_global_ = false;
  20854. opened_input_value_vector_global_ = false;
  20855. });
  20856. input_field.on('keydown', function (e) {
  20857. var code = e.keyCode || e.which;
  20858. if (code == 13) {
  20859. if (input_field.val().trim()) {
  20860. if (global_var.type == _types.Types.REAL) {
  20861. global_var.value[index] = parseFloat(input_field.val().trim());
  20862. parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
  20863. } else {
  20864. if (global_var.type == _types.Types.INTEGER) {
  20865. global_var.value[index] = parseInt(input_field.val().trim());
  20866. } else {
  20867. global_var.value[index] = input_field.val().trim();
  20868. }
  20869. parent_node.find('.span_value_variable').text(global_var.value[index]);
  20870. }
  20871. } else {
  20872. if (global_var.type == _types.Types.REAL) {
  20873. parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
  20874. } else {
  20875. parent_node.find('.span_value_variable').text(global_var.value[index]);
  20876. }
  20877. }
  20878. if (global_var.type == _types.Types.TEXT) {
  20879. global_var.value[index] = input_field.val();
  20880. parent_node.find('.span_value_variable').text(global_var.value[index]);
  20881. }
  20882. input_field.off();
  20883. input_field.remove();
  20884. /// update elements:
  20885. opened_name_value_vector_global_ = false;
  20886. opened_input_value_vector_global_ = false;
  20887. }
  20888. if (code == 27) {
  20889. if (global_var.type == _types.Types.REAL) {
  20890. parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
  20891. } else {
  20892. parent_node.find('.span_value_variable').text(global_var.value[index]);
  20893. }
  20894. input_field.off();
  20895. input_field.remove();
  20896. /// update elements:
  20897. opened_name_value_vector_global_ = false;
  20898. opened_input_value_vector_global_ = false;
  20899. }
  20900. });
  20901. input_field.select();
  20902. }
  20903. _jquery2.default.fn.textWidth = function (text, font) {
  20904. if (!_jquery2.default.fn.textWidth.fakeEl) _jquery2.default.fn.textWidth.fakeEl = (0, _jquery2.default)('<span>').hide().appendTo(document.body);
  20905. _jquery2.default.fn.textWidth.fakeEl.text(text || this.val() || this.text() || this.attr('placeholder')).css('font', font || this.css('font'));
  20906. return _jquery2.default.fn.textWidth.fakeEl.width();
  20907. };
  20908. /***/ }),
  20909. /***/ "./js/visualUI/ivprog_elements.js":
  20910. /*!****************************************!*\
  20911. !*** ./js/visualUI/ivprog_elements.js ***!
  20912. \****************************************/
  20913. /*! no static exports found */
  20914. /***/ (function(module, exports, __webpack_require__) {
  20915. "use strict";
  20916. Object.defineProperty(exports, "__esModule", {
  20917. value: true
  20918. });
  20919. exports.Program = exports.FunctionCallMenu = exports.VariableValueMenu = exports.FunctionCall = exports.SwitchCase = exports.Return = exports.Switch = exports.DoWhileTrue = exports.WhileTrue = exports.RepeatNTimes = exports.IfTrue = exports.ArithmeticExpression = exports.LogicExpression = exports.ConditionalExpression = exports.ExpressionElement = exports.Attribution = exports.Writer = exports.Reader = exports.Break = exports.Comment = exports.SystemFunction = exports.Function = exports.Variable = exports.SYSTEM_FUNCTIONS_CATEGORIES = exports.LOGIC_COMPARISON = exports.ARITHMETIC_COMPARISON = exports.EXPRESSION_TYPES = exports.EXPRESSION_ELEMENTS = exports.ARITHMETIC_TYPES = exports.COMMAND_TYPES = undefined;
  20920. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  20921. var _variable_value_menu = __webpack_require__(/*! ./commands/variable_value_menu */ "./js/visualUI/commands/variable_value_menu.js");
  20922. var VariableValueMenuManagement = _interopRequireWildcard(_variable_value_menu);
  20923. var _types = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
  20924. var _melankeWatchjs = __webpack_require__(/*! melanke-watchjs */ "./node_modules/melanke-watchjs/src/watch.js");
  20925. var _melankeWatchjs2 = _interopRequireDefault(_melankeWatchjs);
  20926. var _algorithm = __webpack_require__(/*! ./algorithm */ "./js/visualUI/algorithm.js");
  20927. var AlgorithmManagement = _interopRequireWildcard(_algorithm);
  20928. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20929. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  20930. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20931. var COMMAND_TYPES = exports.COMMAND_TYPES = Object.freeze({ function: "function", comment: "comment", reader: "reader", writer: "writer", attribution: "attribution", iftrue: "iftrue",
  20932. repeatNtimes: "repeatNtimes", whiletrue: "whiletrue", dowhiletrue: "dowhiletrue", switch: "switch", switchcase: "switchcase", functioncall: "functioncall", break: "break",
  20933. return: "return" });
  20934. var ARITHMETIC_TYPES = exports.ARITHMETIC_TYPES = Object.freeze({ plus: "plus", minus: "minus", multiplication: "multiplication", division: "division", module: "module", none: "none" });
  20935. var EXPRESSION_ELEMENTS = exports.EXPRESSION_ELEMENTS = Object.freeze({ exp_op_exp: "exp_op_exp", op_exp: "op_exp", par_exp_par: "par_exp_par", start_point: "start_point" });
  20936. var EXPRESSION_TYPES = exports.EXPRESSION_TYPES = Object.freeze({ exp_conditional: "exp_conditional", exp_logic: "exp_logic", exp_arithmetic: "exp_arithmetic" });
  20937. var ARITHMETIC_COMPARISON = exports.ARITHMETIC_COMPARISON = Object.freeze({ greater_than: "greater_than", less_than: "less_than", equals_to: "equals_to", not_equals_to: "not_equals_to", greater_than_or_equals_to: "greater_than_or_equals_to", less_than_or_equals_to: "less_than_or_equals_to" });
  20938. var LOGIC_COMPARISON = exports.LOGIC_COMPARISON = Object.freeze({ equals_to: "equals_to", not_equals_to: "not_equals_to", and: "and", or: "or" });
  20939. var SYSTEM_FUNCTIONS_CATEGORIES = exports.SYSTEM_FUNCTIONS_CATEGORIES = Object.freeze({ math: "math", text: "text_t", arrangement: "arrangement", conversion: "conversion" });
  20940. var Variable = exports.Variable = function Variable(type, name, value) {
  20941. var dimensions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  20942. var is_constant = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  20943. var rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  20944. var columns = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
  20945. _classCallCheck(this, Variable);
  20946. this.type = type;
  20947. this.name = name;
  20948. this.value = value;
  20949. this.dimensions = dimensions;
  20950. this.is_constant = is_constant;
  20951. this.rows = rows;
  20952. this.columns = columns;
  20953. };
  20954. var Function = exports.Function = function Function(name) {
  20955. var return_type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types.Types.VOID;
  20956. var return_dimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  20957. var parameters_list = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
  20958. var is_main = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  20959. var is_hidden = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
  20960. var variables_list = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [];
  20961. var function_comment = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  20962. var commands = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : [];
  20963. _classCallCheck(this, Function);
  20964. this.type = COMMAND_TYPES.function;
  20965. this.name = name;
  20966. this.return_type = return_type;
  20967. this.return_dimensions = return_dimensions;
  20968. this.parameters_list = parameters_list;
  20969. this.is_main = is_main;
  20970. this.is_hidden = is_hidden;
  20971. this.variables_list = variables_list;
  20972. this.function_comment = function_comment;
  20973. this.commands = commands;
  20974. };
  20975. var SystemFunction = exports.SystemFunction = function SystemFunction(identifier, return_type, return_dimensions, parameters_list) {
  20976. var function_comment = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  20977. var category = arguments[5];
  20978. _classCallCheck(this, SystemFunction);
  20979. this.type = COMMAND_TYPES.function;
  20980. this.identifier = identifier;
  20981. this.return_type = return_type;
  20982. this.return_dimensions = return_dimensions;
  20983. this.parameters_list = parameters_list;
  20984. this.function_comment = function_comment;
  20985. this.category = category;
  20986. };
  20987. var Comment = exports.Comment = function Comment(comment_text) {
  20988. _classCallCheck(this, Comment);
  20989. this.type = COMMAND_TYPES.comment;
  20990. this.comment_text = comment_text;
  20991. };
  20992. var Break = exports.Break = function Break() {
  20993. _classCallCheck(this, Break);
  20994. this.type = COMMAND_TYPES.break;
  20995. };
  20996. var Reader = exports.Reader = function Reader() {
  20997. var variable_value_menu = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new VariableValueMenu();
  20998. _classCallCheck(this, Reader);
  20999. this.type = COMMAND_TYPES.reader;
  21000. this.variable_value_menu = variable_value_menu;
  21001. };
  21002. var Writer = exports.Writer = function Writer(content) {
  21003. _classCallCheck(this, Writer);
  21004. this.type = COMMAND_TYPES.writer;
  21005. this.content = content;
  21006. };
  21007. var Attribution = exports.Attribution = function Attribution(variable) {
  21008. var expression = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  21009. _classCallCheck(this, Attribution);
  21010. this.type = COMMAND_TYPES.attribution;
  21011. this.variable = variable;
  21012. this.expression = expression;
  21013. };
  21014. var ExpressionElement = exports.ExpressionElement = function ExpressionElement(type_exp) {
  21015. var itens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  21016. _classCallCheck(this, ExpressionElement);
  21017. this.type_exp = type_exp;
  21018. this.itens = itens;
  21019. };
  21020. var ConditionalExpression = exports.ConditionalExpression = function ConditionalExpression(expression) {
  21021. _classCallCheck(this, ConditionalExpression);
  21022. this.type = EXPRESSION_TYPES.exp_conditional;
  21023. this.expression = expression;
  21024. };
  21025. var LogicExpression = exports.LogicExpression = function LogicExpression(has_neg, first_operand, second_operand, operator) {
  21026. _classCallCheck(this, LogicExpression);
  21027. this.type = EXPRESSION_TYPES.exp_logic;
  21028. this.has_neg = has_neg;
  21029. this.first_operand = first_operand;
  21030. this.second_operand = second_operand;
  21031. this.operator = operator;
  21032. };
  21033. var ArithmeticExpression = exports.ArithmeticExpression = function ArithmeticExpression(first_operand, second_operand, operator) {
  21034. _classCallCheck(this, ArithmeticExpression);
  21035. this.type = EXPRESSION_TYPES.exp_arithmetic;
  21036. this.first_operand = first_operand;
  21037. this.second_operand = second_operand;
  21038. this.operator = operator;
  21039. };
  21040. var IfTrue = exports.IfTrue = function IfTrue(expression, commands_block, commands_else) {
  21041. _classCallCheck(this, IfTrue);
  21042. this.type = COMMAND_TYPES.iftrue;
  21043. this.expression = expression;
  21044. this.commands_block = commands_block;
  21045. this.commands_else = commands_else;
  21046. };
  21047. var RepeatNTimes = exports.RepeatNTimes = function RepeatNTimes(var_attribution, var_incrementation, expression1, expression2, expression3, commands_block) {
  21048. _classCallCheck(this, RepeatNTimes);
  21049. this.type = COMMAND_TYPES.repeatNtimes;
  21050. this.var_attribution = var_attribution;
  21051. this.var_incrementation = var_incrementation;
  21052. this.expression1 = expression1;
  21053. this.expression2 = expression2;
  21054. this.expression3 = expression3;
  21055. this.commands_block = commands_block;
  21056. };
  21057. var WhileTrue = exports.WhileTrue = function WhileTrue(expression, commands_block) {
  21058. _classCallCheck(this, WhileTrue);
  21059. this.type = COMMAND_TYPES.whiletrue;
  21060. this.expression = expression;
  21061. this.commands_block = commands_block;
  21062. };
  21063. var DoWhileTrue = exports.DoWhileTrue = function DoWhileTrue(expression, commands_block) {
  21064. _classCallCheck(this, DoWhileTrue);
  21065. this.type = COMMAND_TYPES.dowhiletrue;
  21066. this.expression = expression;
  21067. this.commands_block = commands_block;
  21068. };
  21069. var Switch = exports.Switch = function Switch(variable) {
  21070. var cases = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  21071. _classCallCheck(this, Switch);
  21072. this.type = COMMAND_TYPES.switch;
  21073. this.variable = variable;
  21074. this.cases = cases;
  21075. };
  21076. var Return = exports.Return = function Return(variable_value_menu) {
  21077. _classCallCheck(this, Return);
  21078. this.type = COMMAND_TYPES.return;
  21079. this.variable_value_menu = variable_value_menu;
  21080. };
  21081. var SwitchCase = exports.SwitchCase = function SwitchCase(variable_value_menu) {
  21082. var commands_block = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  21083. _classCallCheck(this, SwitchCase);
  21084. this.type = COMMAND_TYPES.switchcase;
  21085. this.variable_value_menu = variable_value_menu;
  21086. this.commands_block = commands_block;
  21087. };
  21088. var FunctionCall = exports.FunctionCall = function FunctionCall(function_called, parameters_list) {
  21089. _classCallCheck(this, FunctionCall);
  21090. this.type = COMMAND_TYPES.functioncall;
  21091. this.function_called = function_called;
  21092. this.parameters_list = parameters_list;
  21093. };
  21094. var VariableValueMenu = exports.VariableValueMenu = function VariableValueMenu() {
  21095. var variable_and_value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 7;
  21096. var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  21097. var row = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  21098. var column = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  21099. var include_constant = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  21100. var dimensions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  21101. _classCallCheck(this, VariableValueMenu);
  21102. this.type = "var_value";
  21103. this.variable_and_value = variable_and_value;
  21104. this.content = content;
  21105. this.row = row;
  21106. this.column = column;
  21107. this.include_constant = include_constant;
  21108. this.dimensions = dimensions;
  21109. };
  21110. var FunctionCallMenu = exports.FunctionCallMenu = function FunctionCallMenu() {
  21111. var function_called = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  21112. var parameters_list = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  21113. _classCallCheck(this, FunctionCallMenu);
  21114. this.type = "function_call";
  21115. this.function_called = function_called;
  21116. this.parameters_list = parameters_list;
  21117. };
  21118. var Program = exports.Program = function () {
  21119. function Program() {
  21120. _classCallCheck(this, Program);
  21121. this.functions = [];
  21122. this.globals = [];
  21123. }
  21124. _createClass(Program, [{
  21125. key: 'addFunction',
  21126. value: function addFunction(function_to_add) {
  21127. _melankeWatchjs2.default.watch(function_to_add.parameters_list, function () {
  21128. if (window.insertContext) {
  21129. setTimeout(function () {
  21130. AlgorithmManagement.renderAlgorithm();
  21131. }, 300);
  21132. window.insertContext = false;
  21133. } else {
  21134. AlgorithmManagement.renderAlgorithm();
  21135. }
  21136. }, 1);
  21137. _melankeWatchjs2.default.watch(function_to_add.variables_list, function () {
  21138. if (window.insertContext) {
  21139. setTimeout(function () {
  21140. AlgorithmManagement.renderAlgorithm();
  21141. }, 300);
  21142. window.insertContext = false;
  21143. } else {
  21144. AlgorithmManagement.renderAlgorithm();
  21145. }
  21146. }, 1);
  21147. this.functions.push(function_to_add);
  21148. }
  21149. }, {
  21150. key: 'addVariable',
  21151. value: function addVariable(function_to_receive, variable) {
  21152. if (this.functions[function_to_receive].variable === null) {
  21153. this.functions[function_to_receive].variables_list = [];
  21154. }
  21155. this.functions[function_to_receive].variables_list.push(variable);
  21156. }
  21157. }, {
  21158. key: 'addGlobal',
  21159. value: function addGlobal(variable) {
  21160. this.globals.push(variable);
  21161. }
  21162. }]);
  21163. return Program;
  21164. }();
  21165. /***/ }),
  21166. /***/ "./js/visualUI/types.js":
  21167. /*!******************************!*\
  21168. !*** ./js/visualUI/types.js ***!
  21169. \******************************/
  21170. /*! no static exports found */
  21171. /***/ (function(module, exports, __webpack_require__) {
  21172. "use strict";
  21173. Object.defineProperty(exports, "__esModule", {
  21174. value: true
  21175. });
  21176. var Types = exports.Types = Object.freeze({
  21177. INTEGER: "integer",
  21178. REAL: "real",
  21179. TEXT: "text",
  21180. BOOLEAN: "boolean",
  21181. VOID: "void"
  21182. });
  21183. /***/ }),
  21184. /***/ "./js/visualUI/utils.js":
  21185. /*!******************************!*\
  21186. !*** ./js/visualUI/utils.js ***!
  21187. \******************************/
  21188. /*! no static exports found */
  21189. /***/ (function(module, exports, __webpack_require__) {
  21190. "use strict";
  21191. Object.defineProperty(exports, "__esModule", {
  21192. value: true
  21193. });
  21194. exports.renderErrorMessage = renderErrorMessage;
  21195. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  21196. var _jquery2 = _interopRequireDefault(_jquery);
  21197. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21198. function renderErrorMessage(dom_obj_target, message_text) {
  21199. dom_obj_target.popup({
  21200. html: '<i class="ui icon inverted exclamation triangle yellow"></i>' + message_text,
  21201. transition: "fade up",
  21202. on: 'click',
  21203. closable: true,
  21204. movePopup: true,
  21205. boundary: window,
  21206. preserve: false,
  21207. target: false,
  21208. className: {
  21209. popup: 'ui popup invalid-identifier'
  21210. },
  21211. onHidden: function onHidden($module) {
  21212. dom_obj_target.popup('destroy');
  21213. }
  21214. }).popup('toggle');
  21215. }
  21216. /***/ }),
  21217. /***/ "./js/visualUI/variables.js":
  21218. /*!**********************************!*\
  21219. !*** ./js/visualUI/variables.js ***!
  21220. \**********************************/
  21221. /*! no static exports found */
  21222. /***/ (function(module, exports, __webpack_require__) {
  21223. "use strict";
  21224. Object.defineProperty(exports, "__esModule", {
  21225. value: true
  21226. });
  21227. exports.addVariable = addVariable;
  21228. exports.renderVariable = renderVariable;
  21229. var _jquery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  21230. var _jquery2 = _interopRequireDefault(_jquery);
  21231. var _types = __webpack_require__(/*! ./types */ "./js/visualUI/types.js");
  21232. var _ivprog_elements = __webpack_require__(/*! ./ivprog_elements */ "./js/visualUI/ivprog_elements.js");
  21233. var Models = _interopRequireWildcard(_ivprog_elements);
  21234. var _localizedStringsService = __webpack_require__(/*! ./../services/localizedStringsService */ "./js/services/localizedStringsService.js");
  21235. var _utils = __webpack_require__(/*! ./utils */ "./js/visualUI/utils.js");
  21236. var Utils = _interopRequireWildcard(_utils);
  21237. __webpack_require__(/*! ../semantic/semantic.min.js */ "./js/semantic/semantic.min.js");
  21238. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  21239. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21240. window.jQuery = _jquery2.default;
  21241. var counter_new_variables = 0;
  21242. function addVariable(function_obj, function_container) {
  21243. var is_in_click = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  21244. var new_var = new Models.Variable(_types.Types.INTEGER, _localizedStringsService.LocalizedStrings.getUI('new_variable') + '_' + counter_new_variables, 1);
  21245. if (function_obj.variables_list == null) {
  21246. function_obj.variables_list = [];
  21247. }
  21248. function_obj.variables_list.push(new_var);
  21249. counter_new_variables++;
  21250. var newe = renderVariable(function_container, new_var, function_obj);
  21251. if (is_in_click) {
  21252. newe.css('display', 'none');
  21253. newe.fadeIn();
  21254. }
  21255. }
  21256. function updateName(variable_obj, new_name, variable_obj_dom, function_obj) {
  21257. if (variable_obj.name == new_name) {
  21258. return;
  21259. }
  21260. if (isValidIdentifier(new_name)) {
  21261. if (variableNameAlreadyExists(new_name, function_obj)) {
  21262. Utils.renderErrorMessage(variable_obj_dom.find('.editing_name_var'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_variable_duplicated'));
  21263. } else {
  21264. variable_obj.name = new_name;
  21265. }
  21266. } else {
  21267. Utils.renderErrorMessage(variable_obj_dom.find('.editing_name_var'), _localizedStringsService.LocalizedStrings.getUI('inform_valid_name'));
  21268. }
  21269. }
  21270. function variableNameAlreadyExists(name_var, function_obj) {
  21271. if (function_obj.parameters_list) {
  21272. for (var i = 0; i < function_obj.parameters_list.length; i++) {
  21273. if (function_obj.parameters_list[i].name == name_var) {
  21274. return true;
  21275. }
  21276. }
  21277. }
  21278. if (function_obj.variables_list) {
  21279. for (var i = 0; i < function_obj.variables_list.length; i++) {
  21280. if (function_obj.variables_list[i].name == name_var) {
  21281. return true;
  21282. }
  21283. }
  21284. }
  21285. return false;
  21286. }
  21287. function isValidIdentifier(identifier_str) {
  21288. return (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier_str)
  21289. );
  21290. }
  21291. function removeVariable(variable_obj, variable_container) {
  21292. var function_associated = variable_container.data('associatedFunction');
  21293. var index = function_associated.variables_list.indexOf(variable_obj);
  21294. if (index > -1) {
  21295. window.insertContext = true;
  21296. delete function_associated.variables_list[index];
  21297. function_associated.variables_list.splice(index, 1);
  21298. }
  21299. variable_container.children().off();
  21300. variable_container.off();
  21301. variable_container.fadeOut();
  21302. }
  21303. function updateType(variable_obj, new_type) {
  21304. var new_dimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  21305. variable_obj.type = new_type;
  21306. variable_obj.dimensions = new_dimensions;
  21307. if (new_dimensions > 0) {
  21308. variable_obj.rows = new_dimensions;
  21309. variable_obj.columns = 2;
  21310. }
  21311. updateInitialValues(variable_obj);
  21312. }
  21313. function addHandlers(variable_obj, variable_container, function_obj) {
  21314. // Manage variable name:
  21315. variable_container.find(".enable_edit_name_variable").on('click', function (e) {
  21316. enableNameUpdate(variable_obj, variable_container, function_obj);
  21317. });
  21318. // Menu to change type:
  21319. variable_container.find('.ui.dropdown.variable_type').dropdown({
  21320. onChange: function onChange(value, text, $selectedItem) {
  21321. if ($selectedItem.data('dimensions')) {
  21322. updateType(variable_obj, _types.Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
  21323. } else {
  21324. updateType(variable_obj, _types.Types[$selectedItem.data('type')]);
  21325. }
  21326. renderValues(variable_obj, variable_container);
  21327. },
  21328. selectOnKeydown: false
  21329. });
  21330. // Remove variable:
  21331. variable_container.find(".remove_variable").on('click', function (e) {
  21332. removeVariable(variable_obj, variable_container);
  21333. });
  21334. }
  21335. function renderVariable(function_container, new_var, function_obj) {
  21336. var element = '<div class="ui label variable_container pink"><i class="ui icon ellipsis vertical inverted"></i>';
  21337. element += '<div class="ui dropdown variable_type">';
  21338. if (new_var.dimensions > 0) {
  21339. element += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(new_var.type.toLowerCase());
  21340. for (var i = 0; i < new_var.dimensions; i++) {
  21341. element += ' [ ] ';
  21342. }
  21343. element += '</div>';
  21344. } else {
  21345. element += '<div class="text">' + _localizedStringsService.LocalizedStrings.getUI(new_var.type.toLowerCase()) + '</div>';
  21346. }
  21347. element += '<div class="menu">';
  21348. for (var tm in _types.Types) {
  21349. if (tm == _types.Types.VOID.toUpperCase()) {
  21350. continue;
  21351. }
  21352. element += '<div class="item ' + (new_var.type == tm.toLowerCase() ? ' selected ' : '') + '" data-type="' + tm + '" >' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '</div>';
  21353. }
  21354. for (var tm in _types.Types) {
  21355. if (tm == _types.Types.VOID.toUpperCase()) {
  21356. continue;
  21357. }
  21358. element += '<div class="item">' + '<i class="dropdown icon"></i>' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + '<div class="menu">' + '<div class="item" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] " data-type="' + tm + '" data-dimensions="1">[ ]</div>' + '<div class="item" data-text="' + _localizedStringsService.LocalizedStrings.getUI('vector') + ':' + _localizedStringsService.LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] [ ] " data-type="' + tm + '" data-dimensions="2">[ ] [ ] </div>' + '</div>' + '</div>';
  21359. }
  21360. element += '</div></div> ';
  21361. element += '<div class="editing_name_var"><span class="span_name_variable enable_edit_name_variable">' + new_var.name + '</span> </div>';
  21362. element += ' <span class="character_equals"> = </span> <div class="ui div_valor_var">' + new_var.value + '</div>';
  21363. element += ' <i class="yellow inverted icon times remove_variable"></i></div>';
  21364. element = (0, _jquery2.default)(element);
  21365. element.data('associatedFunction', function_obj);
  21366. function_container.find('.variables_list_div').append(element);
  21367. addHandlers(new_var, element, function_obj);
  21368. renderValues(new_var, element);
  21369. return element;
  21370. }
  21371. function updateColumnsAndRowsText(variable_container, variable_var) {
  21372. var prev = variable_container.find('.text').text().split('[');
  21373. if (prev.length == 2) {
  21374. var ff = prev[0] + '[ ' + variable_var.columns + ' ] ';
  21375. variable_container.find('.text').empty();
  21376. variable_container.find('.text').text(ff);
  21377. }
  21378. if (prev.length == 3) {
  21379. var ff = prev[0] + '[ ' + variable_var.columns + ' ] [ ' + variable_var.rows + ' ] ';
  21380. variable_container.find('.text').empty();
  21381. variable_container.find('.text').text(ff);
  21382. }
  21383. }
  21384. function renderValues(new_var, variable_container) {
  21385. var ret = "";
  21386. var j = 0;
  21387. if (new_var.dimensions == 0) {
  21388. if (new_var.type == _types.Types.REAL) {
  21389. ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">' + new_var.value.toFixed(1) + '</span> </div> ';
  21390. } else {
  21391. if (new_var.type == _types.Types.BOOLEAN) {
  21392. ret += '<div class="created_div_valor_var"><span class="span_value_variable boolean_simple_type">' + _localizedStringsService.LocalizedStrings.getUI(new_var.value) + '</span> </div> ';
  21393. } else {
  21394. ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">' + new_var.value + '</span> </div> ';
  21395. }
  21396. }
  21397. } else {
  21398. ret += '<table class="tabela_var">';
  21399. if (new_var.dimensions == 1) {
  21400. ret += '<tr>';
  21401. if (new_var.type == _types.Types.REAL) {
  21402. for (var k = 0; k < new_var.columns; k++) {
  21403. ret += '<td><span class="span_value_variable vector_var" data-index="' + k + '">' + new_var.value[k].toFixed(1) + '</span></td>';
  21404. }
  21405. } else {
  21406. for (var k = 0; k < new_var.columns; k++) {
  21407. if (new_var.type == _types.Types.BOOLEAN) {
  21408. ret += '<td><span class="span_value_variable boolean_vector_var" data-index="' + k + '">' + _localizedStringsService.LocalizedStrings.getUI(new_var.value[k]) + '</span></td>';
  21409. } else {
  21410. ret += '<td><span class="span_value_variable vector_var" data-index="' + k + '">' + new_var.value[k] + '</span>' + '</td>';
  21411. }
  21412. }
  21413. }
  21414. ret += '</tr>';
  21415. ret += '</table>';
  21416. ret += '<div class="buttons_manage_columns"><i class="ui icon minus square outline remove_global_vector_column"></i>' + ' <i class="ui icon plus square outline add_global_vector_column"></i></div>';
  21417. }
  21418. if (new_var.dimensions == 2) {
  21419. if (new_var.type == _types.Types.REAL) {
  21420. for (var l = 0; l < new_var.rows; l++) {
  21421. ret += '<tr>';
  21422. for (var k = 0; k < new_var.columns; k++) {
  21423. ret += '<td><span class="span_value_variable matrix_var" data-index="' + k + '" data-row="' + l + '">' + new_var.value[l][k].toFixed(1) + '</span>' + '</td>';
  21424. }
  21425. ret += '</tr>';
  21426. }
  21427. } else {
  21428. for (var l = 0; l < new_var.rows; l++) {
  21429. ret += '<tr>';
  21430. for (var k = 0; k < new_var.columns; k++) {
  21431. if (new_var.type == _types.Types.BOOLEAN) {
  21432. ret += '<td><span class="span_value_variable boolean_matrix_var" data-index="' + k + '" data-row="' + l + '">' + _localizedStringsService.LocalizedStrings.getUI(new_var.value[l][k]) + '</span></td>';
  21433. } else {
  21434. ret += '<td><span class="span_value_variable matrix_var" data-index="' + k + '" data-row="' + l + '">' + new_var.value[l][k] + '</span></td>';
  21435. }
  21436. }
  21437. ret += '</tr>';
  21438. }
  21439. }
  21440. if (new_var.rows == 0) {
  21441. ret += '<tr><td></td></tr>';
  21442. }
  21443. ret += '<tr><td colspan="' + new_var.columns + '" class="tr_manage_lines"><i class="ui icon minus square outline remove_global_matrix_line"></i>' + ' <i class="ui icon plus square outline add_global_matrix_line"></i></td></tr>';
  21444. ret += '</table>';
  21445. ret += '<div class="buttons_manage_columns"><i class="ui icon minus square outline remove_global_matrix_column"></i>' + ' <i class="ui icon plus square outline add_global_matrix_column"></i></div>';
  21446. }
  21447. }
  21448. (0, _jquery2.default)(variable_container).find(".div_valor_var").html('');
  21449. ret = (0, _jquery2.default)(ret);
  21450. (0, _jquery2.default)(ret).find('.span_value_variable').data('associatedOject', new_var);
  21451. (0, _jquery2.default)(ret).find(".boolean_simple_type").on('click', function (e) {
  21452. alternateBooleanValue(new_var, this.parentNode);
  21453. });
  21454. (0, _jquery2.default)(ret).find(".simple_var").on('click', function (e) {
  21455. enableValueUpdate(new_var, this.parentNode);
  21456. });
  21457. (0, _jquery2.default)(ret).find(".boolean_vector_var").on('click', function (e) {
  21458. alternateBooleanVectorValue(new_var, (0, _jquery2.default)(this).data('index'), this.parentNode);
  21459. });
  21460. (0, _jquery2.default)(ret).find(".vector_var").on('click', function (e) {
  21461. enableVectorValueUpdate(new_var, (0, _jquery2.default)(this).data('index'), this.parentNode);
  21462. });
  21463. (0, _jquery2.default)(ret).find(".remove_global_vector_column").on('click', function (e) {
  21464. removeColumnVector(new_var);
  21465. (0, _jquery2.default)(variable_container).find(".div_valor_var").html('');
  21466. renderValues(new_var, variable_container);
  21467. });
  21468. (0, _jquery2.default)(ret).find(".add_global_vector_column").on('click', function (e) {
  21469. addColumnVector(new_var);
  21470. (0, _jquery2.default)(variable_container).find(".div_valor_var").html('');
  21471. renderValues(new_var, variable_container);
  21472. });
  21473. (0, _jquery2.default)(ret).find(".remove_global_matrix_column").on('click', function (e) {
  21474. removeColumnMatrix(new_var);
  21475. (0, _jquery2.default)(variable_container).find(".div_valor_var").html('');
  21476. renderValues(new_var, variable_container);
  21477. });
  21478. (0, _jquery2.default)(ret).find(".add_global_matrix_column").on('click', function (e) {
  21479. addColumnMatrix(new_var);
  21480. (0, _jquery2.default)(variable_container).find(".div_valor_var").html('');
  21481. renderValues(new_var, variable_container);
  21482. });
  21483. (0, _jquery2.default)(ret).find(".remove_global_matrix_line").on('click', function (e) {
  21484. removeLineMatrix(new_var);
  21485. (0, _jquery2.default)(variable_container).find(".div_valor_var").html('');
  21486. renderValues(new_var, variable_container);
  21487. });
  21488. (0, _jquery2.default)(ret).find(".add_global_matrix_line").on('click', function (e) {
  21489. addLineMatrix(new_var);
  21490. (0, _jquery2.default)(variable_container).find(".div_valor_var").html('');
  21491. renderValues(new_var, variable_container);
  21492. });
  21493. (0, _jquery2.default)(ret).find(".boolean_matrix_var").on('click', function (e) {
  21494. alternateBooleanMatrixValue(new_var, (0, _jquery2.default)(this).data('row'), (0, _jquery2.default)(this).data('index'), this.parentNode);
  21495. });
  21496. (0, _jquery2.default)(ret).find(".matrix_var").on('click', function (e) {
  21497. enableMatrixValueUpdate(new_var, (0, _jquery2.default)(this).data('row'), (0, _jquery2.default)(this).data('index'), this.parentNode);
  21498. });
  21499. (0, _jquery2.default)(variable_container).find(".div_valor_var").append(ret);
  21500. updateColumnsAndRowsText(variable_container, new_var);
  21501. }
  21502. function alternateBooleanMatrixValue(var_obj, row, index, value_container) {
  21503. var_obj.value[row][index] = !var_obj.value[row][index];
  21504. (0, _jquery2.default)(value_container).find('.span_value_variable').text(_localizedStringsService.LocalizedStrings.getUI(var_obj.value[row][index]));
  21505. }
  21506. function addLineMatrix(var_obj) {
  21507. var_obj.rows++;
  21508. if (var_obj.type == _types.Types.INTEGER) {
  21509. var n_l = [];
  21510. for (var i = 0; i < var_obj.columns; i++) {
  21511. n_l.push(1);
  21512. }
  21513. var_obj.value.push(n_l);
  21514. }
  21515. if (var_obj.type == _types.Types.REAL) {
  21516. var n_l = [];
  21517. for (i = 0; i < var_obj.columns; i++) {
  21518. n_l.push(1.0);
  21519. }
  21520. var_obj.value.push(n_l);
  21521. }
  21522. if (var_obj.type == _types.Types.TEXT) {
  21523. var n_l = [];
  21524. for (i = 0; i < var_obj.columns; i++) {
  21525. n_l.push(_localizedStringsService.LocalizedStrings.getUI('text_start'));
  21526. }
  21527. var_obj.value.push(n_l);
  21528. }
  21529. if (var_obj.type == _types.Types.BOOLEAN) {
  21530. var n_l = [];
  21531. for (i = 0; i < var_obj.columns; i++) {
  21532. n_l.push(true);
  21533. }
  21534. var_obj.value.push(n_l);
  21535. }
  21536. }
  21537. function removeLineMatrix(var_obj) {
  21538. if (var_obj.rows == 0) {
  21539. return;
  21540. }
  21541. var_obj.rows--;
  21542. var_obj.value.splice(var_obj.value.length - 1, 1);
  21543. }
  21544. function addColumnMatrix(var_obj) {
  21545. var_obj.columns++;
  21546. if (var_obj.type == _types.Types.INTEGER) {
  21547. for (var i = 0; i < var_obj.rows; i++) {
  21548. var_obj.value[i].push(1);
  21549. }
  21550. }
  21551. if (var_obj.type == _types.Types.REAL) {
  21552. for (var i = 0; i < var_obj.rows; i++) {
  21553. var_obj.value[i].push(1.0);
  21554. }
  21555. }
  21556. if (var_obj.type == _types.Types.TEXT) {
  21557. for (var i = 0; i < var_obj.rows; i++) {
  21558. var_obj.value[i].push(_localizedStringsService.LocalizedStrings.getUI('text_start'));
  21559. }
  21560. }
  21561. if (var_obj.type == _types.Types.BOOLEAN) {
  21562. for (var i = 0; i < var_obj.rows; i++) {
  21563. var_obj.value[i].push(true);
  21564. }
  21565. }
  21566. }
  21567. function removeColumnMatrix(var_obj) {
  21568. if (var_obj.columns == 0) {
  21569. return;
  21570. }
  21571. var_obj.columns--;
  21572. for (var i = 0; i < var_obj.rows; i++) {
  21573. var_obj.value[i].splice(var_obj.value[i].length - 1, 1);
  21574. }
  21575. }
  21576. function addColumnVector(var_obj) {
  21577. var_obj.columns++;
  21578. if (var_obj.type == _types.Types.INTEGER) {
  21579. var_obj.value.push(1);
  21580. }
  21581. if (var_obj.type == _types.Types.REAL) {
  21582. var_obj.value.push(1.0);
  21583. }
  21584. if (var_obj.type == _types.Types.TEXT) {
  21585. var_obj.value.push(_localizedStringsService.LocalizedStrings.getUI('text_start'));
  21586. }
  21587. if (var_obj.type == _types.Types.BOOLEAN) {
  21588. var_obj.value.push(true);
  21589. }
  21590. }
  21591. function removeColumnVector(var_obj) {
  21592. if (var_obj.columns == 0) {
  21593. return;
  21594. }
  21595. var_obj.columns--;
  21596. var_obj.value.splice(var_obj.value.length - 1, 1);
  21597. }
  21598. function alternateBooleanValue(var_obj, value_container) {
  21599. var_obj.value = !var_obj.value;
  21600. (0, _jquery2.default)(value_container).find('.span_value_variable').text(_localizedStringsService.LocalizedStrings.getUI(var_obj.value));
  21601. }
  21602. function alternateBooleanVectorValue(var_obj, index, value_container) {
  21603. var_obj.value[index] = !var_obj.value[index];
  21604. (0, _jquery2.default)(value_container).find('.span_value_variable').text(_localizedStringsService.LocalizedStrings.getUI(var_obj.value[index]));
  21605. }
  21606. function updateInitialValues(variable_obj) {
  21607. if (variable_obj.type == _types.Types.INTEGER) {
  21608. if (variable_obj.dimensions == 0) {
  21609. variable_obj.value = 1;
  21610. }
  21611. if (variable_obj.dimensions == 1) {
  21612. variable_obj.value = [1, 1];
  21613. }
  21614. if (variable_obj.dimensions == 2) {
  21615. variable_obj.value = [[1, 1], [1, 1]];
  21616. }
  21617. }
  21618. if (variable_obj.type == _types.Types.REAL) {
  21619. if (variable_obj.dimensions == 0) {
  21620. variable_obj.value = 1.0;
  21621. }
  21622. if (variable_obj.dimensions == 1) {
  21623. variable_obj.value = [1.0, 1.0];
  21624. }
  21625. if (variable_obj.dimensions == 2) {
  21626. variable_obj.value = [[1.0, 1.0], [1.0, 1.0]];
  21627. }
  21628. }
  21629. if (variable_obj.type == _types.Types.TEXT) {
  21630. if (variable_obj.dimensions == 0) {
  21631. variable_obj.value = _localizedStringsService.LocalizedStrings.getUI('text_start');
  21632. }
  21633. if (variable_obj.dimensions == 1) {
  21634. variable_obj.value = [_localizedStringsService.LocalizedStrings.getUI('text_start'), _localizedStringsService.LocalizedStrings.getUI('text_start')];
  21635. }
  21636. if (variable_obj.dimensions == 2) {
  21637. variable_obj.value = [[_localizedStringsService.LocalizedStrings.getUI('text_start'), _localizedStringsService.LocalizedStrings.getUI('text_start')], [_localizedStringsService.LocalizedStrings.getUI('text_start'), _localizedStringsService.LocalizedStrings.getUI('text_start')]];
  21638. }
  21639. }
  21640. if (variable_obj.type == _types.Types.BOOLEAN) {
  21641. if (variable_obj.dimensions == 0) {
  21642. variable_obj.value = true;
  21643. }
  21644. if (variable_obj.dimensions == 1) {
  21645. variable_obj.value = [true, true];
  21646. }
  21647. if (variable_obj.dimensions == 2) {
  21648. variable_obj.value = [[true, true], [true, true]];
  21649. }
  21650. }
  21651. }
  21652. var opened_name_value_vector_global_ = false;
  21653. var opened_input_value_vector_global_ = null;
  21654. function enableVectorValueUpdate(var_obj, index, parent_node) {
  21655. if (opened_name_value_vector_global_) {
  21656. opened_input_value_vector_global_.focus();
  21657. return;
  21658. }
  21659. parent_node = (0, _jquery2.default)(parent_node);
  21660. opened_name_value_vector_global_ = true;
  21661. parent_node.find('.span_value_variable').text('');
  21662. var input_field;
  21663. if (var_obj.type == _types.Types.REAL) {
  21664. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + var_obj.value[index].toFixed(1) + "' />");
  21665. input_field.insertBefore(parent_node.find('.span_value_variable'));
  21666. } else {
  21667. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + var_obj.value[index] + "' />");
  21668. input_field.insertBefore(parent_node.find('.span_value_variable'));
  21669. }
  21670. input_field.on('input', function () {
  21671. var inputWidth = input_field.textWidth() + 10;
  21672. opened_input_value_vector_global_ = input_field;
  21673. input_field.focus();
  21674. var tmpStr = input_field.val();
  21675. input_field.val('');
  21676. input_field.val(tmpStr);
  21677. input_field.css({
  21678. width: inputWidth
  21679. });
  21680. }).trigger('input');
  21681. input_field.focusout(function () {
  21682. /// update array:
  21683. if (input_field.val().trim()) {
  21684. if (var_obj.type == _types.Types.REAL) {
  21685. var_obj.value[index] = parseFloat(input_field.val().trim());
  21686. parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
  21687. } else {
  21688. if (var_obj.type == _types.Types.INTEGER) {
  21689. var_obj.value[index] = parseInt(input_field.val().trim());
  21690. } else {
  21691. var_obj.value[index] = input_field.val().trim();
  21692. }
  21693. parent_node.find('.span_value_variable').text(var_obj.value[index]);
  21694. }
  21695. } else {
  21696. if (var_obj.type == _types.Types.REAL) {
  21697. parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
  21698. } else {
  21699. parent_node.find('.span_value_variable').text(var_obj.value[index]);
  21700. }
  21701. }
  21702. if (var_obj.type == _types.Types.TEXT) {
  21703. var_obj.value[index] = input_field.val();
  21704. parent_node.find('.span_value_variable').text(var_obj.value[index]);
  21705. }
  21706. input_field.off();
  21707. input_field.remove();
  21708. /// update elements:
  21709. opened_name_value_vector_global_ = false;
  21710. opened_input_value_vector_global_ = false;
  21711. });
  21712. input_field.on('keydown', function (e) {
  21713. var code = e.keyCode || e.which;
  21714. if (code == 13) {
  21715. if (input_field.val().trim()) {
  21716. if (var_obj.type == _types.Types.REAL) {
  21717. var_obj.value[index] = parseFloat(input_field.val().trim());
  21718. parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
  21719. } else {
  21720. if (var_obj.type == _types.Types.INTEGER) {
  21721. var_obj.value[index] = parseInt(input_field.val().trim());
  21722. } else {
  21723. var_obj.value[index] = input_field.val().trim();
  21724. }
  21725. parent_node.find('.span_value_variable').text(var_obj.value[index]);
  21726. }
  21727. } else {
  21728. if (var_obj.type == _types.Types.REAL) {
  21729. parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
  21730. } else {
  21731. parent_node.find('.span_value_variable').text(var_obj.value[index]);
  21732. }
  21733. }
  21734. if (var_obj.type == _types.Types.TEXT) {
  21735. var_obj.value[index] = input_field.val();
  21736. parent_node.find('.span_value_variable').text(var_obj.value[index]);
  21737. }
  21738. input_field.off();
  21739. input_field.remove();
  21740. /// update elements:
  21741. opened_name_value_vector_global_ = false;
  21742. opened_input_value_vector_global_ = false;
  21743. }
  21744. if (code == 27) {
  21745. if (var_obj.type == _types.Types.REAL) {
  21746. parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
  21747. } else {
  21748. parent_node.find('.span_value_variable').text(var_obj.value[index]);
  21749. }
  21750. input_field.off();
  21751. input_field.remove();
  21752. /// update elements:
  21753. opened_name_value_vector_global_ = false;
  21754. opened_input_value_vector_global_ = false;
  21755. }
  21756. });
  21757. input_field.select();
  21758. }
  21759. var opened_name_value_global_var = false;
  21760. var opened_input_value_global_ar = null;
  21761. function enableValueUpdate(var_obj, parent_node) {
  21762. if (opened_name_value_global_var) {
  21763. opened_input_value_global_ar.focus();
  21764. return;
  21765. }
  21766. parent_node = (0, _jquery2.default)(parent_node);
  21767. opened_name_value_global_var = true;
  21768. var input_field;
  21769. parent_node.find('.span_value_variable').text('');
  21770. if (var_obj.type == _types.Types.REAL) {
  21771. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + var_obj.value.toFixed(1) + "' />");
  21772. input_field.insertBefore(parent_node.find('.span_value_variable'));
  21773. } else {
  21774. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + var_obj.value + "' />");
  21775. input_field.insertBefore(parent_node.find('.span_value_variable'));
  21776. }
  21777. input_field.on('input', function () {
  21778. var inputWidth = input_field.textWidth() + 10;
  21779. opened_input_value_global_ar = input_field;
  21780. input_field.focus();
  21781. var tmpStr = input_field.val();
  21782. input_field.val('');
  21783. input_field.val(tmpStr);
  21784. input_field.css({
  21785. width: inputWidth
  21786. });
  21787. }).trigger('input');
  21788. input_field.focusout(function () {
  21789. /// update array:
  21790. if (input_field.val().trim()) {
  21791. if (var_obj.type == _types.Types.REAL) {
  21792. var_obj.value = parseFloat(input_field.val().trim());
  21793. parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
  21794. } else {
  21795. if (var_obj.type == _types.Types.INTEGER) {
  21796. var_obj.value = parseInt(input_field.val().trim());
  21797. } else {
  21798. var_obj.value = input_field.val().trim();
  21799. }
  21800. parent_node.find('.span_value_variable').text(var_obj.value);
  21801. }
  21802. } else {
  21803. if (var_obj.type == _types.Types.REAL) {
  21804. parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
  21805. } else {
  21806. parent_node.find('.span_value_variable').text(var_obj.value);
  21807. }
  21808. }
  21809. if (var_obj.type == _types.Types.TEXT) {
  21810. var_obj.value = input_field.val();
  21811. parent_node.find('.span_value_variable').text(var_obj.value);
  21812. }
  21813. input_field.off();
  21814. input_field.remove();
  21815. /// update elements:
  21816. opened_name_value_global_var = false;
  21817. opened_input_value_global_ar = false;
  21818. });
  21819. input_field.on('keydown', function (e) {
  21820. var code = e.keyCode || e.which;
  21821. if (code == 13) {
  21822. if (input_field.val().trim()) {
  21823. if (var_obj.type == _types.Types.REAL) {
  21824. var_obj.value = parseFloat(input_field.val().trim());
  21825. parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
  21826. } else {
  21827. if (var_obj.type == _types.Types.INTEGER) {
  21828. var_obj.value = parseInt(input_field.val().trim());
  21829. } else {
  21830. var_obj.value = input_field.val().trim();
  21831. }
  21832. parent_node.find('.span_value_variable').text(var_obj.value);
  21833. }
  21834. } else {
  21835. if (var_obj.type == _types.Types.REAL) {
  21836. parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
  21837. } else {
  21838. parent_node.find('.span_value_variable').text(var_obj.value);
  21839. }
  21840. }
  21841. if (var_obj.type == _types.Types.TEXT) {
  21842. var_obj.value = input_field.val();
  21843. parent_node.find('.span_value_variable').text(var_obj.value);
  21844. }
  21845. input_field.off();
  21846. input_field.remove();
  21847. /// update elements:
  21848. opened_name_value_global_var = false;
  21849. opened_input_value_global_ar = false;
  21850. }
  21851. if (code == 27) {
  21852. if (var_obj.type == _types.Types.REAL) {
  21853. parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
  21854. } else {
  21855. parent_node.find('.span_value_variable').text(var_obj.value);
  21856. }
  21857. input_field.off();
  21858. input_field.remove();
  21859. /// update elements:
  21860. opened_name_value_global_var = false;
  21861. opened_input_value_global_ar = false;
  21862. }
  21863. });
  21864. input_field.select();
  21865. }
  21866. var opened_name_global = false;
  21867. var opened_input_global = null;
  21868. function enableNameUpdate(variable_obj, variable_container, function_obj) {
  21869. if (opened_name_global) {
  21870. opened_input_global.focus();
  21871. return;
  21872. }
  21873. opened_name_global = true;
  21874. variable_container.find('.span_name_variable').text('');
  21875. var input_name;
  21876. input_name = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + variable_obj.name + "' />");
  21877. input_name.insertBefore(variable_container.find('.span_name_variable'));
  21878. input_name.on('input', function () {
  21879. var inputWidth = input_name.textWidth() + 10;
  21880. opened_input_global = input_name;
  21881. input_name.focus();
  21882. var tmpStr = input_name.val();
  21883. input_name.val('');
  21884. input_name.val(tmpStr);
  21885. input_name.css({
  21886. width: inputWidth
  21887. });
  21888. }).trigger('input');
  21889. input_name.focusout(function () {
  21890. /// update array:
  21891. if (input_name.val().trim().length > 0) {
  21892. updateName(variable_obj, input_name.val().trim(), variable_container, function_obj);
  21893. variable_container.find('.span_name_variable').text(variable_obj.name);
  21894. } else {
  21895. variable_container.find('.span_name_variable').text(variable_obj.name);
  21896. }
  21897. input_name.off();
  21898. input_name.remove();
  21899. /// update elements:
  21900. opened_name_global = false;
  21901. opened_input_global = false;
  21902. });
  21903. input_name.on('keydown', function (e) {
  21904. var code = e.keyCode || e.which;
  21905. if (code == 13) {
  21906. if (input_name.val().trim().length > 0) {
  21907. updateName(variable_obj, input_name.val().trim(), variable_container, function_obj);
  21908. variable_container.find('.span_name_variable').text(variable_obj.name);
  21909. } else {
  21910. variable_container.find('.span_name_variable').text(variable_obj.name);
  21911. }
  21912. input_name.off();
  21913. input_name.remove();
  21914. /// update elements:
  21915. opened_name_global = false;
  21916. opened_input_global = false;
  21917. }
  21918. if (code == 27) {
  21919. variable_container.find('.span_name_variable').text(variable_obj.name);
  21920. input_name.off();
  21921. input_name.remove();
  21922. /// update elements:
  21923. opened_name_global = false;
  21924. opened_input_global = false;
  21925. }
  21926. });
  21927. input_name.select();
  21928. }
  21929. var opened_name_value_matrix_global_v = false;
  21930. var opened_input_value_matrix_global_v = null;
  21931. function enableMatrixValueUpdate(var_obj, row, index, parent_node) {
  21932. if (opened_name_value_matrix_global_v) {
  21933. opened_input_value_matrix_global_v.focus();
  21934. return;
  21935. }
  21936. parent_node = (0, _jquery2.default)(parent_node);
  21937. opened_name_value_matrix_global_v = true;
  21938. parent_node.find('.span_value_variable').text('');
  21939. var input_field;
  21940. if (var_obj.type == _types.Types.REAL) {
  21941. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + var_obj.value[row][index].toFixed(1) + "' />");
  21942. input_field.insertBefore(parent_node.find('.span_value_variable'));
  21943. } else {
  21944. input_field = (0, _jquery2.default)("<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='" + var_obj.value[row][index] + "' />");
  21945. input_field.insertBefore(parent_node.find('.span_value_variable'));
  21946. }
  21947. input_field.on('input', function () {
  21948. var inputWidth = input_field.textWidth() + 10;
  21949. opened_input_value_matrix_global_v = input_field;
  21950. input_field.focus();
  21951. var tmpStr = input_field.val();
  21952. input_field.val('');
  21953. input_field.val(tmpStr);
  21954. input_field.css({
  21955. width: inputWidth
  21956. });
  21957. }).trigger('input');
  21958. input_field.focusout(function () {
  21959. /// update array:
  21960. if (input_field.val().trim()) {
  21961. if (var_obj.type == _types.Types.REAL) {
  21962. var_obj.value[row][index] = parseFloat(input_field.val().trim());
  21963. parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
  21964. } else {
  21965. if (var_obj.type == _types.Types.INTEGER) {
  21966. var_obj.value[row][index] = parseInt(input_field.val().trim());
  21967. } else {
  21968. var_obj.value[row][index] = input_field.val().trim();
  21969. }
  21970. parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
  21971. }
  21972. } else {
  21973. if (var_obj.type == _types.Types.REAL) {
  21974. parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
  21975. } else {
  21976. parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
  21977. }
  21978. }
  21979. if (var_obj.type == _types.Types.TEXT) {
  21980. var_obj.value[row][index] = input_field.val();
  21981. parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
  21982. }
  21983. input_field.off();
  21984. input_field.remove();
  21985. /// update elements:
  21986. opened_name_value_matrix_global_v = false;
  21987. opened_input_value_matrix_global_v = false;
  21988. });
  21989. input_field.on('keydown', function (e) {
  21990. var code = e.keyCode || e.which;
  21991. if (code == 13) {
  21992. if (input_field.val().trim()) {
  21993. if (var_obj.type == _types.Types.REAL) {
  21994. var_obj.value[row][index] = parseFloat(input_field.val().trim());
  21995. parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
  21996. } else {
  21997. if (var_obj.type == _types.Types.INTEGER) {
  21998. var_obj.value[row][index] = parseInt(input_field.val().trim());
  21999. } else {
  22000. var_obj.value[row][index] = input_field.val().trim();
  22001. }
  22002. parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
  22003. }
  22004. } else {
  22005. if (var_obj.type == _types.Types.REAL) {
  22006. parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
  22007. } else {
  22008. parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
  22009. }
  22010. }
  22011. if (var_obj.type == _types.Types.TEXT) {
  22012. var_obj.value[row][index] = input_field.val();
  22013. parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
  22014. }
  22015. input_field.off();
  22016. input_field.remove();
  22017. /// update elements:
  22018. opened_name_value_matrix_global_v = false;
  22019. opened_input_value_matrix_global_v = false;
  22020. }
  22021. if (code == 27) {
  22022. if (var_obj.type == _types.Types.REAL) {
  22023. parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
  22024. } else {
  22025. parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
  22026. }
  22027. input_field.off();
  22028. input_field.remove();
  22029. /// update elements:
  22030. opened_name_value_matrix_global_v = false;
  22031. opened_input_value_matrix_global_v = false;
  22032. }
  22033. });
  22034. input_field.select();
  22035. }
  22036. /***/ }),
  22037. /***/ "./node_modules/antlr4/BufferedTokenStream.js":
  22038. /*!****************************************************!*\
  22039. !*** ./node_modules/antlr4/BufferedTokenStream.js ***!
  22040. \****************************************************/
  22041. /*! no static exports found */
  22042. /***/ (function(module, exports, __webpack_require__) {
  22043. "use strict";
  22044. //
  22045. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  22046. * Use of this file is governed by the BSD 3-clause license that
  22047. * can be found in the LICENSE.txt file in the project root.
  22048. */
  22049. // This implementation of {@link TokenStream} loads tokens from a
  22050. // {@link TokenSource} on-demand, and places the tokens in a buffer to provide
  22051. // access to any previous token by index.
  22052. //
  22053. // <p>
  22054. // This token stream ignores the value of {@link Token//getChannel}. If your
  22055. // parser requires the token stream filter tokens to only those on a particular
  22056. // channel, such as {@link Token//DEFAULT_CHANNEL} or
  22057. // {@link Token//HIDDEN_CHANNEL}, use a filtering token stream such a
  22058. // {@link CommonTokenStream}.</p>
  22059. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  22060. var Lexer = __webpack_require__(/*! ./Lexer */ "./node_modules/antlr4/Lexer.js").Lexer;
  22061. var Interval = __webpack_require__(/*! ./IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  22062. // this is just to keep meaningful parameter types to Parser
  22063. function TokenStream() {
  22064. return this;
  22065. }
  22066. function BufferedTokenStream(tokenSource) {
  22067. TokenStream.call(this);
  22068. // The {@link TokenSource} from which tokens for this stream are fetched.
  22069. this.tokenSource = tokenSource;
  22070. // A collection of all tokens fetched from the token source. The list is
  22071. // considered a complete view of the input once {@link //fetchedEOF} is set
  22072. // to {@code true}.
  22073. this.tokens = [];
  22074. // The index into {@link //tokens} of the current token (next token to
  22075. // {@link //consume}). {@link //tokens}{@code [}{@link //p}{@code ]} should
  22076. // be
  22077. // {@link //LT LT(1)}.
  22078. //
  22079. // <p>This field is set to -1 when the stream is first constructed or when
  22080. // {@link //setTokenSource} is called, indicating that the first token has
  22081. // not yet been fetched from the token source. For additional information,
  22082. // see the documentation of {@link IntStream} for a description of
  22083. // Initializing Methods.</p>
  22084. this.index = -1;
  22085. // Indicates whether the {@link Token//EOF} token has been fetched from
  22086. // {@link //tokenSource} and added to {@link //tokens}. This field improves
  22087. // performance for the following cases:
  22088. //
  22089. // <ul>
  22090. // <li>{@link //consume}: The lookahead check in {@link //consume} to
  22091. // prevent
  22092. // consuming the EOF symbol is optimized by checking the values of
  22093. // {@link //fetchedEOF} and {@link //p} instead of calling {@link
  22094. // //LA}.</li>
  22095. // <li>{@link //fetch}: The check to prevent adding multiple EOF symbols
  22096. // into
  22097. // {@link //tokens} is trivial with this field.</li>
  22098. // <ul>
  22099. this.fetchedEOF = false;
  22100. return this;
  22101. }
  22102. BufferedTokenStream.prototype = Object.create(TokenStream.prototype);
  22103. BufferedTokenStream.prototype.constructor = BufferedTokenStream;
  22104. BufferedTokenStream.prototype.mark = function () {
  22105. return 0;
  22106. };
  22107. BufferedTokenStream.prototype.release = function (marker) {
  22108. // no resources to release
  22109. };
  22110. BufferedTokenStream.prototype.reset = function () {
  22111. this.seek(0);
  22112. };
  22113. BufferedTokenStream.prototype.seek = function (index) {
  22114. this.lazyInit();
  22115. this.index = this.adjustSeekIndex(index);
  22116. };
  22117. BufferedTokenStream.prototype.get = function (index) {
  22118. this.lazyInit();
  22119. return this.tokens[index];
  22120. };
  22121. BufferedTokenStream.prototype.consume = function () {
  22122. var skipEofCheck = false;
  22123. if (this.index >= 0) {
  22124. if (this.fetchedEOF) {
  22125. // the last token in tokens is EOF. skip check if p indexes any
  22126. // fetched token except the last.
  22127. skipEofCheck = this.index < this.tokens.length - 1;
  22128. } else {
  22129. // no EOF token in tokens. skip check if p indexes a fetched token.
  22130. skipEofCheck = this.index < this.tokens.length;
  22131. }
  22132. } else {
  22133. // not yet initialized
  22134. skipEofCheck = false;
  22135. }
  22136. if (!skipEofCheck && this.LA(1) === Token.EOF) {
  22137. throw "cannot consume EOF";
  22138. }
  22139. if (this.sync(this.index + 1)) {
  22140. this.index = this.adjustSeekIndex(this.index + 1);
  22141. }
  22142. };
  22143. // Make sure index {@code i} in tokens has a token.
  22144. //
  22145. // @return {@code true} if a token is located at index {@code i}, otherwise
  22146. // {@code false}.
  22147. // @see //get(int i)
  22148. // /
  22149. BufferedTokenStream.prototype.sync = function (i) {
  22150. var n = i - this.tokens.length + 1; // how many more elements we need?
  22151. if (n > 0) {
  22152. var fetched = this.fetch(n);
  22153. return fetched >= n;
  22154. }
  22155. return true;
  22156. };
  22157. // Add {@code n} elements to buffer.
  22158. //
  22159. // @return The actual number of elements added to the buffer.
  22160. // /
  22161. BufferedTokenStream.prototype.fetch = function (n) {
  22162. if (this.fetchedEOF) {
  22163. return 0;
  22164. }
  22165. for (var i = 0; i < n; i++) {
  22166. var t = this.tokenSource.nextToken();
  22167. t.tokenIndex = this.tokens.length;
  22168. this.tokens.push(t);
  22169. if (t.type === Token.EOF) {
  22170. this.fetchedEOF = true;
  22171. return i + 1;
  22172. }
  22173. }
  22174. return n;
  22175. };
  22176. // Get all tokens from start..stop inclusively///
  22177. BufferedTokenStream.prototype.getTokens = function (start, stop, types) {
  22178. if (types === undefined) {
  22179. types = null;
  22180. }
  22181. if (start < 0 || stop < 0) {
  22182. return null;
  22183. }
  22184. this.lazyInit();
  22185. var subset = [];
  22186. if (stop >= this.tokens.length) {
  22187. stop = this.tokens.length - 1;
  22188. }
  22189. for (var i = start; i < stop; i++) {
  22190. var t = this.tokens[i];
  22191. if (t.type === Token.EOF) {
  22192. break;
  22193. }
  22194. if (types === null || types.contains(t.type)) {
  22195. subset.push(t);
  22196. }
  22197. }
  22198. return subset;
  22199. };
  22200. BufferedTokenStream.prototype.LA = function (i) {
  22201. return this.LT(i).type;
  22202. };
  22203. BufferedTokenStream.prototype.LB = function (k) {
  22204. if (this.index - k < 0) {
  22205. return null;
  22206. }
  22207. return this.tokens[this.index - k];
  22208. };
  22209. BufferedTokenStream.prototype.LT = function (k) {
  22210. this.lazyInit();
  22211. if (k === 0) {
  22212. return null;
  22213. }
  22214. if (k < 0) {
  22215. return this.LB(-k);
  22216. }
  22217. var i = this.index + k - 1;
  22218. this.sync(i);
  22219. if (i >= this.tokens.length) {
  22220. // return EOF token
  22221. // EOF must be last token
  22222. return this.tokens[this.tokens.length - 1];
  22223. }
  22224. return this.tokens[i];
  22225. };
  22226. // Allowed derived classes to modify the behavior of operations which change
  22227. // the current stream position by adjusting the target token index of a seek
  22228. // operation. The default implementation simply returns {@code i}. If an
  22229. // exception is thrown in this method, the current stream index should not be
  22230. // changed.
  22231. //
  22232. // <p>For example, {@link CommonTokenStream} overrides this method to ensure
  22233. // that
  22234. // the seek target is always an on-channel token.</p>
  22235. //
  22236. // @param i The target token index.
  22237. // @return The adjusted target token index.
  22238. BufferedTokenStream.prototype.adjustSeekIndex = function (i) {
  22239. return i;
  22240. };
  22241. BufferedTokenStream.prototype.lazyInit = function () {
  22242. if (this.index === -1) {
  22243. this.setup();
  22244. }
  22245. };
  22246. BufferedTokenStream.prototype.setup = function () {
  22247. this.sync(0);
  22248. this.index = this.adjustSeekIndex(0);
  22249. };
  22250. // Reset this token stream by setting its token source.///
  22251. BufferedTokenStream.prototype.setTokenSource = function (tokenSource) {
  22252. this.tokenSource = tokenSource;
  22253. this.tokens = [];
  22254. this.index = -1;
  22255. this.fetchedEOF = false;
  22256. };
  22257. // Given a starting index, return the index of the next token on channel.
  22258. // Return i if tokens[i] is on channel. Return -1 if there are no tokens
  22259. // on channel between i and EOF.
  22260. // /
  22261. BufferedTokenStream.prototype.nextTokenOnChannel = function (i, channel) {
  22262. this.sync(i);
  22263. if (i >= this.tokens.length) {
  22264. return -1;
  22265. }
  22266. var token = this.tokens[i];
  22267. while (token.channel !== this.channel) {
  22268. if (token.type === Token.EOF) {
  22269. return -1;
  22270. }
  22271. i += 1;
  22272. this.sync(i);
  22273. token = this.tokens[i];
  22274. }
  22275. return i;
  22276. };
  22277. // Given a starting index, return the index of the previous token on channel.
  22278. // Return i if tokens[i] is on channel. Return -1 if there are no tokens
  22279. // on channel between i and 0.
  22280. BufferedTokenStream.prototype.previousTokenOnChannel = function (i, channel) {
  22281. while (i >= 0 && this.tokens[i].channel !== channel) {
  22282. i -= 1;
  22283. }
  22284. return i;
  22285. };
  22286. // Collect all tokens on specified channel to the right of
  22287. // the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or
  22288. // EOF. If channel is -1, find any non default channel token.
  22289. BufferedTokenStream.prototype.getHiddenTokensToRight = function (tokenIndex, channel) {
  22290. if (channel === undefined) {
  22291. channel = -1;
  22292. }
  22293. this.lazyInit();
  22294. if (tokenIndex < 0 || tokenIndex >= this.tokens.length) {
  22295. throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1;
  22296. }
  22297. var nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL);
  22298. var from_ = tokenIndex + 1;
  22299. // if none onchannel to right, nextOnChannel=-1 so set to = last token
  22300. var to = nextOnChannel === -1 ? this.tokens.length - 1 : nextOnChannel;
  22301. return this.filterForChannel(from_, to, channel);
  22302. };
  22303. // Collect all tokens on specified channel to the left of
  22304. // the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
  22305. // If channel is -1, find any non default channel token.
  22306. BufferedTokenStream.prototype.getHiddenTokensToLeft = function (tokenIndex, channel) {
  22307. if (channel === undefined) {
  22308. channel = -1;
  22309. }
  22310. this.lazyInit();
  22311. if (tokenIndex < 0 || tokenIndex >= this.tokens.length) {
  22312. throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1;
  22313. }
  22314. var prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL);
  22315. if (prevOnChannel === tokenIndex - 1) {
  22316. return null;
  22317. }
  22318. // if none on channel to left, prevOnChannel=-1 then from=0
  22319. var from_ = prevOnChannel + 1;
  22320. var to = tokenIndex - 1;
  22321. return this.filterForChannel(from_, to, channel);
  22322. };
  22323. BufferedTokenStream.prototype.filterForChannel = function (left, right, channel) {
  22324. var hidden = [];
  22325. for (var i = left; i < right + 1; i++) {
  22326. var t = this.tokens[i];
  22327. if (channel === -1) {
  22328. if (t.channel !== Lexer.DEFAULT_TOKEN_CHANNEL) {
  22329. hidden.push(t);
  22330. }
  22331. } else if (t.channel === channel) {
  22332. hidden.push(t);
  22333. }
  22334. }
  22335. if (hidden.length === 0) {
  22336. return null;
  22337. }
  22338. return hidden;
  22339. };
  22340. BufferedTokenStream.prototype.getSourceName = function () {
  22341. return this.tokenSource.getSourceName();
  22342. };
  22343. // Get the text of all tokens in this buffer.///
  22344. BufferedTokenStream.prototype.getText = function (interval) {
  22345. this.lazyInit();
  22346. this.fill();
  22347. if (interval === undefined || interval === null) {
  22348. interval = new Interval(0, this.tokens.length - 1);
  22349. }
  22350. var start = interval.start;
  22351. if (start instanceof Token) {
  22352. start = start.tokenIndex;
  22353. }
  22354. var stop = interval.stop;
  22355. if (stop instanceof Token) {
  22356. stop = stop.tokenIndex;
  22357. }
  22358. if (start === null || stop === null || start < 0 || stop < 0) {
  22359. return "";
  22360. }
  22361. if (stop >= this.tokens.length) {
  22362. stop = this.tokens.length - 1;
  22363. }
  22364. var s = "";
  22365. for (var i = start; i < stop + 1; i++) {
  22366. var t = this.tokens[i];
  22367. if (t.type === Token.EOF) {
  22368. break;
  22369. }
  22370. s = s + t.text;
  22371. }
  22372. return s;
  22373. };
  22374. // Get all tokens from lexer until EOF///
  22375. BufferedTokenStream.prototype.fill = function () {
  22376. this.lazyInit();
  22377. while (this.fetch(1000) === 1000) {
  22378. continue;
  22379. }
  22380. };
  22381. exports.BufferedTokenStream = BufferedTokenStream;
  22382. /***/ }),
  22383. /***/ "./node_modules/antlr4/CharStreams.js":
  22384. /*!********************************************!*\
  22385. !*** ./node_modules/antlr4/CharStreams.js ***!
  22386. \********************************************/
  22387. /*! no static exports found */
  22388. /***/ (function(module, exports, __webpack_require__) {
  22389. "use strict";
  22390. //
  22391. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  22392. * Use of this file is governed by the BSD 3-clause license that
  22393. * can be found in the LICENSE.txt file in the project root.
  22394. */
  22395. //
  22396. var InputStream = __webpack_require__(/*! ./InputStream */ "./node_modules/antlr4/InputStream.js").InputStream;
  22397. var isNodeJs = typeof window === 'undefined' && typeof importScripts === 'undefined';
  22398. var fs = isNodeJs ? __webpack_require__(/*! fs */ "./node_modules/node-libs-browser/mock/empty.js") : null;
  22399. // Utility functions to create InputStreams from various sources.
  22400. //
  22401. // All returned InputStreams support the full range of Unicode
  22402. // up to U+10FFFF (the default behavior of InputStream only supports
  22403. // code points up to U+FFFF).
  22404. var CharStreams = {
  22405. // Creates an InputStream from a string.
  22406. fromString: function fromString(str) {
  22407. return new InputStream(str, true);
  22408. },
  22409. // Asynchronously creates an InputStream from a blob given the
  22410. // encoding of the bytes in that blob (defaults to 'utf8' if
  22411. // encoding is null).
  22412. //
  22413. // Invokes onLoad(result) on success, onError(error) on
  22414. // failure.
  22415. fromBlob: function fromBlob(blob, encoding, onLoad, onError) {
  22416. var reader = FileReader();
  22417. reader.onload = function (e) {
  22418. var is = new InputStream(e.target.result, true);
  22419. onLoad(is);
  22420. };
  22421. reader.onerror = onError;
  22422. reader.readAsText(blob, encoding);
  22423. },
  22424. // Creates an InputStream from a Buffer given the
  22425. // encoding of the bytes in that buffer (defaults to 'utf8' if
  22426. // encoding is null).
  22427. fromBuffer: function fromBuffer(buffer, encoding) {
  22428. return new InputStream(buffer.toString(encoding), true);
  22429. },
  22430. // Asynchronously creates an InputStream from a file on disk given
  22431. // the encoding of the bytes in that file (defaults to 'utf8' if
  22432. // encoding is null).
  22433. //
  22434. // Invokes callback(error, result) on completion.
  22435. fromPath: function fromPath(path, encoding, callback) {
  22436. fs.readFile(path, encoding, function (err, data) {
  22437. var is = null;
  22438. if (data !== null) {
  22439. is = new InputStream(data, true);
  22440. }
  22441. callback(err, is);
  22442. });
  22443. },
  22444. // Synchronously creates an InputStream given a path to a file
  22445. // on disk and the encoding of the bytes in that file (defaults to
  22446. // 'utf8' if encoding is null).
  22447. fromPathSync: function fromPathSync(path, encoding) {
  22448. var data = fs.readFileSync(path, encoding);
  22449. return new InputStream(data, true);
  22450. }
  22451. };
  22452. exports.CharStreams = CharStreams;
  22453. /***/ }),
  22454. /***/ "./node_modules/antlr4/CommonTokenFactory.js":
  22455. /*!***************************************************!*\
  22456. !*** ./node_modules/antlr4/CommonTokenFactory.js ***!
  22457. \***************************************************/
  22458. /*! no static exports found */
  22459. /***/ (function(module, exports, __webpack_require__) {
  22460. "use strict";
  22461. //
  22462. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  22463. * Use of this file is governed by the BSD 3-clause license that
  22464. * can be found in the LICENSE.txt file in the project root.
  22465. */
  22466. //
  22467. //
  22468. // This default implementation of {@link TokenFactory} creates
  22469. // {@link CommonToken} objects.
  22470. //
  22471. var CommonToken = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").CommonToken;
  22472. function TokenFactory() {
  22473. return this;
  22474. }
  22475. function CommonTokenFactory(copyText) {
  22476. TokenFactory.call(this);
  22477. // Indicates whether {@link CommonToken//setText} should be called after
  22478. // constructing tokens to explicitly set the text. This is useful for cases
  22479. // where the input stream might not be able to provide arbitrary substrings
  22480. // of text from the input after the lexer creates a token (e.g. the
  22481. // implementation of {@link CharStream//getText} in
  22482. // {@link UnbufferedCharStream} throws an
  22483. // {@link UnsupportedOperationException}). Explicitly setting the token text
  22484. // allows {@link Token//getText} to be called at any time regardless of the
  22485. // input stream implementation.
  22486. //
  22487. // <p>
  22488. // The default value is {@code false} to avoid the performance and memory
  22489. // overhead of copying text for every token unless explicitly requested.</p>
  22490. //
  22491. this.copyText = copyText === undefined ? false : copyText;
  22492. return this;
  22493. }
  22494. CommonTokenFactory.prototype = Object.create(TokenFactory.prototype);
  22495. CommonTokenFactory.prototype.constructor = CommonTokenFactory;
  22496. //
  22497. // The default {@link CommonTokenFactory} instance.
  22498. //
  22499. // <p>
  22500. // This token factory does not explicitly copy token text when constructing
  22501. // tokens.</p>
  22502. //
  22503. CommonTokenFactory.DEFAULT = new CommonTokenFactory();
  22504. CommonTokenFactory.prototype.create = function (source, type, text, channel, start, stop, line, column) {
  22505. var t = new CommonToken(source, type, channel, start, stop);
  22506. t.line = line;
  22507. t.column = column;
  22508. if (text !== null) {
  22509. t.text = text;
  22510. } else if (this.copyText && source[1] !== null) {
  22511. t.text = source[1].getText(start, stop);
  22512. }
  22513. return t;
  22514. };
  22515. CommonTokenFactory.prototype.createThin = function (type, text) {
  22516. var t = new CommonToken(null, type);
  22517. t.text = text;
  22518. return t;
  22519. };
  22520. exports.CommonTokenFactory = CommonTokenFactory;
  22521. /***/ }),
  22522. /***/ "./node_modules/antlr4/CommonTokenStream.js":
  22523. /*!**************************************************!*\
  22524. !*** ./node_modules/antlr4/CommonTokenStream.js ***!
  22525. \**************************************************/
  22526. /*! no static exports found */
  22527. /***/ (function(module, exports, __webpack_require__) {
  22528. "use strict";
  22529. //
  22530. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  22531. * Use of this file is governed by the BSD 3-clause license that
  22532. * can be found in the LICENSE.txt file in the project root.
  22533. */
  22534. ///
  22535. //
  22536. // This class extends {@link BufferedTokenStream} with functionality to filter
  22537. // token streams to tokens on a particular channel (tokens where
  22538. // {@link Token//getChannel} returns a particular value).
  22539. //
  22540. // <p>
  22541. // This token stream provides access to all tokens by index or when calling
  22542. // methods like {@link //getText}. The channel filtering is only used for code
  22543. // accessing tokens via the lookahead methods {@link //LA}, {@link //LT}, and
  22544. // {@link //LB}.</p>
  22545. //
  22546. // <p>
  22547. // By default, tokens are placed on the default channel
  22548. // ({@link Token//DEFAULT_CHANNEL}), but may be reassigned by using the
  22549. // {@code ->channel(HIDDEN)} lexer command, or by using an embedded action to
  22550. // call {@link Lexer//setChannel}.
  22551. // </p>
  22552. //
  22553. // <p>
  22554. // Note: lexer rules which use the {@code ->skip} lexer command or call
  22555. // {@link Lexer//skip} do not produce tokens at all, so input text matched by
  22556. // such a rule will not be available as part of the token stream, regardless of
  22557. // channel.</p>
  22558. ///
  22559. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  22560. var BufferedTokenStream = __webpack_require__(/*! ./BufferedTokenStream */ "./node_modules/antlr4/BufferedTokenStream.js").BufferedTokenStream;
  22561. function CommonTokenStream(lexer, channel) {
  22562. BufferedTokenStream.call(this, lexer);
  22563. this.channel = channel === undefined ? Token.DEFAULT_CHANNEL : channel;
  22564. return this;
  22565. }
  22566. CommonTokenStream.prototype = Object.create(BufferedTokenStream.prototype);
  22567. CommonTokenStream.prototype.constructor = CommonTokenStream;
  22568. CommonTokenStream.prototype.adjustSeekIndex = function (i) {
  22569. return this.nextTokenOnChannel(i, this.channel);
  22570. };
  22571. CommonTokenStream.prototype.LB = function (k) {
  22572. if (k === 0 || this.index - k < 0) {
  22573. return null;
  22574. }
  22575. var i = this.index;
  22576. var n = 1;
  22577. // find k good tokens looking backwards
  22578. while (n <= k) {
  22579. // skip off-channel tokens
  22580. i = this.previousTokenOnChannel(i - 1, this.channel);
  22581. n += 1;
  22582. }
  22583. if (i < 0) {
  22584. return null;
  22585. }
  22586. return this.tokens[i];
  22587. };
  22588. CommonTokenStream.prototype.LT = function (k) {
  22589. this.lazyInit();
  22590. if (k === 0) {
  22591. return null;
  22592. }
  22593. if (k < 0) {
  22594. return this.LB(-k);
  22595. }
  22596. var i = this.index;
  22597. var n = 1; // we know tokens[pos] is a good one
  22598. // find k good tokens
  22599. while (n < k) {
  22600. // skip off-channel tokens, but make sure to not look past EOF
  22601. if (this.sync(i + 1)) {
  22602. i = this.nextTokenOnChannel(i + 1, this.channel);
  22603. }
  22604. n += 1;
  22605. }
  22606. return this.tokens[i];
  22607. };
  22608. // Count EOF just once.///
  22609. CommonTokenStream.prototype.getNumberOfOnChannelTokens = function () {
  22610. var n = 0;
  22611. this.fill();
  22612. for (var i = 0; i < this.tokens.length; i++) {
  22613. var t = this.tokens[i];
  22614. if (t.channel === this.channel) {
  22615. n += 1;
  22616. }
  22617. if (t.type === Token.EOF) {
  22618. break;
  22619. }
  22620. }
  22621. return n;
  22622. };
  22623. exports.CommonTokenStream = CommonTokenStream;
  22624. /***/ }),
  22625. /***/ "./node_modules/antlr4/FileStream.js":
  22626. /*!*******************************************!*\
  22627. !*** ./node_modules/antlr4/FileStream.js ***!
  22628. \*******************************************/
  22629. /*! no static exports found */
  22630. /***/ (function(module, exports, __webpack_require__) {
  22631. "use strict";
  22632. //
  22633. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  22634. * Use of this file is governed by the BSD 3-clause license that
  22635. * can be found in the LICENSE.txt file in the project root.
  22636. */
  22637. //
  22638. //
  22639. // This is an InputStream that is loaded from a file all at once
  22640. // when you construct the object.
  22641. //
  22642. var InputStream = __webpack_require__(/*! ./InputStream */ "./node_modules/antlr4/InputStream.js").InputStream;
  22643. var isNodeJs = typeof window === 'undefined' && typeof importScripts === 'undefined';
  22644. var fs = isNodeJs ? __webpack_require__(/*! fs */ "./node_modules/node-libs-browser/mock/empty.js") : null;
  22645. function FileStream(fileName, decodeToUnicodeCodePoints) {
  22646. var data = fs.readFileSync(fileName, "utf8");
  22647. InputStream.call(this, data, decodeToUnicodeCodePoints);
  22648. this.fileName = fileName;
  22649. return this;
  22650. }
  22651. FileStream.prototype = Object.create(InputStream.prototype);
  22652. FileStream.prototype.constructor = FileStream;
  22653. exports.FileStream = FileStream;
  22654. /***/ }),
  22655. /***/ "./node_modules/antlr4/InputStream.js":
  22656. /*!********************************************!*\
  22657. !*** ./node_modules/antlr4/InputStream.js ***!
  22658. \********************************************/
  22659. /*! no static exports found */
  22660. /***/ (function(module, exports, __webpack_require__) {
  22661. "use strict";
  22662. //
  22663. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  22664. * Use of this file is governed by the BSD 3-clause license that
  22665. * can be found in the LICENSE.txt file in the project root.
  22666. */
  22667. //
  22668. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  22669. __webpack_require__(/*! ./polyfills/codepointat */ "./node_modules/antlr4/polyfills/codepointat.js");
  22670. __webpack_require__(/*! ./polyfills/fromcodepoint */ "./node_modules/antlr4/polyfills/fromcodepoint.js");
  22671. // Vacuum all input from a string and then treat it like a buffer.
  22672. function _loadString(stream, decodeToUnicodeCodePoints) {
  22673. stream._index = 0;
  22674. stream.data = [];
  22675. if (stream.decodeToUnicodeCodePoints) {
  22676. for (var i = 0; i < stream.strdata.length;) {
  22677. var codePoint = stream.strdata.codePointAt(i);
  22678. stream.data.push(codePoint);
  22679. i += codePoint <= 0xFFFF ? 1 : 2;
  22680. }
  22681. } else {
  22682. for (var i = 0; i < stream.strdata.length; i++) {
  22683. var codeUnit = stream.strdata.charCodeAt(i);
  22684. stream.data.push(codeUnit);
  22685. }
  22686. }
  22687. stream._size = stream.data.length;
  22688. }
  22689. // If decodeToUnicodeCodePoints is true, the input is treated
  22690. // as a series of Unicode code points.
  22691. //
  22692. // Otherwise, the input is treated as a series of 16-bit UTF-16 code
  22693. // units.
  22694. function InputStream(data, decodeToUnicodeCodePoints) {
  22695. this.name = "<empty>";
  22696. this.strdata = data;
  22697. this.decodeToUnicodeCodePoints = decodeToUnicodeCodePoints || false;
  22698. _loadString(this);
  22699. return this;
  22700. }
  22701. Object.defineProperty(InputStream.prototype, "index", {
  22702. get: function get() {
  22703. return this._index;
  22704. }
  22705. });
  22706. Object.defineProperty(InputStream.prototype, "size", {
  22707. get: function get() {
  22708. return this._size;
  22709. }
  22710. });
  22711. // Reset the stream so that it's in the same state it was
  22712. // when the object was created *except* the data array is not
  22713. // touched.
  22714. //
  22715. InputStream.prototype.reset = function () {
  22716. this._index = 0;
  22717. };
  22718. InputStream.prototype.consume = function () {
  22719. if (this._index >= this._size) {
  22720. // assert this.LA(1) == Token.EOF
  22721. throw "cannot consume EOF";
  22722. }
  22723. this._index += 1;
  22724. };
  22725. InputStream.prototype.LA = function (offset) {
  22726. if (offset === 0) {
  22727. return 0; // undefined
  22728. }
  22729. if (offset < 0) {
  22730. offset += 1; // e.g., translate LA(-1) to use offset=0
  22731. }
  22732. var pos = this._index + offset - 1;
  22733. if (pos < 0 || pos >= this._size) {
  22734. // invalid
  22735. return Token.EOF;
  22736. }
  22737. return this.data[pos];
  22738. };
  22739. InputStream.prototype.LT = function (offset) {
  22740. return this.LA(offset);
  22741. };
  22742. // mark/release do nothing; we have entire buffer
  22743. InputStream.prototype.mark = function () {
  22744. return -1;
  22745. };
  22746. InputStream.prototype.release = function (marker) {};
  22747. // consume() ahead until p==_index; can't just set p=_index as we must
  22748. // update line and column. If we seek backwards, just set p
  22749. //
  22750. InputStream.prototype.seek = function (_index) {
  22751. if (_index <= this._index) {
  22752. this._index = _index; // just jump; don't update stream state (line,
  22753. // ...)
  22754. return;
  22755. }
  22756. // seek forward
  22757. this._index = Math.min(_index, this._size);
  22758. };
  22759. InputStream.prototype.getText = function (start, stop) {
  22760. if (stop >= this._size) {
  22761. stop = this._size - 1;
  22762. }
  22763. if (start >= this._size) {
  22764. return "";
  22765. } else {
  22766. if (this.decodeToUnicodeCodePoints) {
  22767. var result = "";
  22768. for (var i = start; i <= stop; i++) {
  22769. result += String.fromCodePoint(this.data[i]);
  22770. }
  22771. return result;
  22772. } else {
  22773. return this.strdata.slice(start, stop + 1);
  22774. }
  22775. }
  22776. };
  22777. InputStream.prototype.toString = function () {
  22778. return this.strdata;
  22779. };
  22780. exports.InputStream = InputStream;
  22781. /***/ }),
  22782. /***/ "./node_modules/antlr4/IntervalSet.js":
  22783. /*!********************************************!*\
  22784. !*** ./node_modules/antlr4/IntervalSet.js ***!
  22785. \********************************************/
  22786. /*! no static exports found */
  22787. /***/ (function(module, exports, __webpack_require__) {
  22788. "use strict";
  22789. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  22790. * Use of this file is governed by the BSD 3-clause license that
  22791. * can be found in the LICENSE.txt file in the project root.
  22792. */
  22793. /*jslint smarttabs:true */
  22794. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  22795. /* stop is not included! */
  22796. function Interval(start, stop) {
  22797. this.start = start;
  22798. this.stop = stop;
  22799. return this;
  22800. }
  22801. Interval.prototype.contains = function (item) {
  22802. return item >= this.start && item < this.stop;
  22803. };
  22804. Interval.prototype.toString = function () {
  22805. if (this.start === this.stop - 1) {
  22806. return this.start.toString();
  22807. } else {
  22808. return this.start.toString() + ".." + (this.stop - 1).toString();
  22809. }
  22810. };
  22811. Object.defineProperty(Interval.prototype, "length", {
  22812. get: function get() {
  22813. return this.stop - this.start;
  22814. }
  22815. });
  22816. function IntervalSet() {
  22817. this.intervals = null;
  22818. this.readOnly = false;
  22819. }
  22820. IntervalSet.prototype.first = function (v) {
  22821. if (this.intervals === null || this.intervals.length === 0) {
  22822. return Token.INVALID_TYPE;
  22823. } else {
  22824. return this.intervals[0].start;
  22825. }
  22826. };
  22827. IntervalSet.prototype.addOne = function (v) {
  22828. this.addInterval(new Interval(v, v + 1));
  22829. };
  22830. IntervalSet.prototype.addRange = function (l, h) {
  22831. this.addInterval(new Interval(l, h + 1));
  22832. };
  22833. IntervalSet.prototype.addInterval = function (v) {
  22834. if (this.intervals === null) {
  22835. this.intervals = [];
  22836. this.intervals.push(v);
  22837. } else {
  22838. // find insert pos
  22839. for (var k = 0; k < this.intervals.length; k++) {
  22840. var i = this.intervals[k];
  22841. // distinct range -> insert
  22842. if (v.stop < i.start) {
  22843. this.intervals.splice(k, 0, v);
  22844. return;
  22845. }
  22846. // contiguous range -> adjust
  22847. else if (v.stop === i.start) {
  22848. this.intervals[k].start = v.start;
  22849. return;
  22850. }
  22851. // overlapping range -> adjust and reduce
  22852. else if (v.start <= i.stop) {
  22853. this.intervals[k] = new Interval(Math.min(i.start, v.start), Math.max(i.stop, v.stop));
  22854. this.reduce(k);
  22855. return;
  22856. }
  22857. }
  22858. // greater than any existing
  22859. this.intervals.push(v);
  22860. }
  22861. };
  22862. IntervalSet.prototype.addSet = function (other) {
  22863. if (other.intervals !== null) {
  22864. for (var k = 0; k < other.intervals.length; k++) {
  22865. var i = other.intervals[k];
  22866. this.addInterval(new Interval(i.start, i.stop));
  22867. }
  22868. }
  22869. return this;
  22870. };
  22871. IntervalSet.prototype.reduce = function (k) {
  22872. // only need to reduce if k is not the last
  22873. if (k < this.intervalslength - 1) {
  22874. var l = this.intervals[k];
  22875. var r = this.intervals[k + 1];
  22876. // if r contained in l
  22877. if (l.stop >= r.stop) {
  22878. this.intervals.pop(k + 1);
  22879. this.reduce(k);
  22880. } else if (l.stop >= r.start) {
  22881. this.intervals[k] = new Interval(l.start, r.stop);
  22882. this.intervals.pop(k + 1);
  22883. }
  22884. }
  22885. };
  22886. IntervalSet.prototype.complement = function (start, stop) {
  22887. var result = new IntervalSet();
  22888. result.addInterval(new Interval(start, stop + 1));
  22889. for (var i = 0; i < this.intervals.length; i++) {
  22890. result.removeRange(this.intervals[i]);
  22891. }
  22892. return result;
  22893. };
  22894. IntervalSet.prototype.contains = function (item) {
  22895. if (this.intervals === null) {
  22896. return false;
  22897. } else {
  22898. for (var k = 0; k < this.intervals.length; k++) {
  22899. if (this.intervals[k].contains(item)) {
  22900. return true;
  22901. }
  22902. }
  22903. return false;
  22904. }
  22905. };
  22906. Object.defineProperty(IntervalSet.prototype, "length", {
  22907. get: function get() {
  22908. var len = 0;
  22909. this.intervals.map(function (i) {
  22910. len += i.length;
  22911. });
  22912. return len;
  22913. }
  22914. });
  22915. IntervalSet.prototype.removeRange = function (v) {
  22916. if (v.start === v.stop - 1) {
  22917. this.removeOne(v.start);
  22918. } else if (this.intervals !== null) {
  22919. var k = 0;
  22920. for (var n = 0; n < this.intervals.length; n++) {
  22921. var i = this.intervals[k];
  22922. // intervals are ordered
  22923. if (v.stop <= i.start) {
  22924. return;
  22925. }
  22926. // check for including range, split it
  22927. else if (v.start > i.start && v.stop < i.stop) {
  22928. this.intervals[k] = new Interval(i.start, v.start);
  22929. var x = new Interval(v.stop, i.stop);
  22930. this.intervals.splice(k, 0, x);
  22931. return;
  22932. }
  22933. // check for included range, remove it
  22934. else if (v.start <= i.start && v.stop >= i.stop) {
  22935. this.intervals.splice(k, 1);
  22936. k = k - 1; // need another pass
  22937. }
  22938. // check for lower boundary
  22939. else if (v.start < i.stop) {
  22940. this.intervals[k] = new Interval(i.start, v.start);
  22941. }
  22942. // check for upper boundary
  22943. else if (v.stop < i.stop) {
  22944. this.intervals[k] = new Interval(v.stop, i.stop);
  22945. }
  22946. k += 1;
  22947. }
  22948. }
  22949. };
  22950. IntervalSet.prototype.removeOne = function (v) {
  22951. if (this.intervals !== null) {
  22952. for (var k = 0; k < this.intervals.length; k++) {
  22953. var i = this.intervals[k];
  22954. // intervals is ordered
  22955. if (v < i.start) {
  22956. return;
  22957. }
  22958. // check for single value range
  22959. else if (v === i.start && v === i.stop - 1) {
  22960. this.intervals.splice(k, 1);
  22961. return;
  22962. }
  22963. // check for lower boundary
  22964. else if (v === i.start) {
  22965. this.intervals[k] = new Interval(i.start + 1, i.stop);
  22966. return;
  22967. }
  22968. // check for upper boundary
  22969. else if (v === i.stop - 1) {
  22970. this.intervals[k] = new Interval(i.start, i.stop - 1);
  22971. return;
  22972. }
  22973. // split existing range
  22974. else if (v < i.stop - 1) {
  22975. var x = new Interval(i.start, v);
  22976. i.start = v + 1;
  22977. this.intervals.splice(k, 0, x);
  22978. return;
  22979. }
  22980. }
  22981. }
  22982. };
  22983. IntervalSet.prototype.toString = function (literalNames, symbolicNames, elemsAreChar) {
  22984. literalNames = literalNames || null;
  22985. symbolicNames = symbolicNames || null;
  22986. elemsAreChar = elemsAreChar || false;
  22987. if (this.intervals === null) {
  22988. return "{}";
  22989. } else if (literalNames !== null || symbolicNames !== null) {
  22990. return this.toTokenString(literalNames, symbolicNames);
  22991. } else if (elemsAreChar) {
  22992. return this.toCharString();
  22993. } else {
  22994. return this.toIndexString();
  22995. }
  22996. };
  22997. IntervalSet.prototype.toCharString = function () {
  22998. var names = [];
  22999. for (var i = 0; i < this.intervals.length; i++) {
  23000. var v = this.intervals[i];
  23001. if (v.stop === v.start + 1) {
  23002. if (v.start === Token.EOF) {
  23003. names.push("<EOF>");
  23004. } else {
  23005. names.push("'" + String.fromCharCode(v.start) + "'");
  23006. }
  23007. } else {
  23008. names.push("'" + String.fromCharCode(v.start) + "'..'" + String.fromCharCode(v.stop - 1) + "'");
  23009. }
  23010. }
  23011. if (names.length > 1) {
  23012. return "{" + names.join(", ") + "}";
  23013. } else {
  23014. return names[0];
  23015. }
  23016. };
  23017. IntervalSet.prototype.toIndexString = function () {
  23018. var names = [];
  23019. for (var i = 0; i < this.intervals.length; i++) {
  23020. var v = this.intervals[i];
  23021. if (v.stop === v.start + 1) {
  23022. if (v.start === Token.EOF) {
  23023. names.push("<EOF>");
  23024. } else {
  23025. names.push(v.start.toString());
  23026. }
  23027. } else {
  23028. names.push(v.start.toString() + ".." + (v.stop - 1).toString());
  23029. }
  23030. }
  23031. if (names.length > 1) {
  23032. return "{" + names.join(", ") + "}";
  23033. } else {
  23034. return names[0];
  23035. }
  23036. };
  23037. IntervalSet.prototype.toTokenString = function (literalNames, symbolicNames) {
  23038. var names = [];
  23039. for (var i = 0; i < this.intervals.length; i++) {
  23040. var v = this.intervals[i];
  23041. for (var j = v.start; j < v.stop; j++) {
  23042. names.push(this.elementName(literalNames, symbolicNames, j));
  23043. }
  23044. }
  23045. if (names.length > 1) {
  23046. return "{" + names.join(", ") + "}";
  23047. } else {
  23048. return names[0];
  23049. }
  23050. };
  23051. IntervalSet.prototype.elementName = function (literalNames, symbolicNames, a) {
  23052. if (a === Token.EOF) {
  23053. return "<EOF>";
  23054. } else if (a === Token.EPSILON) {
  23055. return "<EPSILON>";
  23056. } else {
  23057. return literalNames[a] || symbolicNames[a];
  23058. }
  23059. };
  23060. exports.Interval = Interval;
  23061. exports.IntervalSet = IntervalSet;
  23062. /***/ }),
  23063. /***/ "./node_modules/antlr4/LL1Analyzer.js":
  23064. /*!********************************************!*\
  23065. !*** ./node_modules/antlr4/LL1Analyzer.js ***!
  23066. \********************************************/
  23067. /*! no static exports found */
  23068. /***/ (function(module, exports, __webpack_require__) {
  23069. "use strict";
  23070. //
  23071. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  23072. * Use of this file is governed by the BSD 3-clause license that
  23073. * can be found in the LICENSE.txt file in the project root.
  23074. */
  23075. ///
  23076. var Set = __webpack_require__(/*! ./Utils */ "./node_modules/antlr4/Utils.js").Set;
  23077. var BitSet = __webpack_require__(/*! ./Utils */ "./node_modules/antlr4/Utils.js").BitSet;
  23078. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  23079. var ATNConfig = __webpack_require__(/*! ./atn/ATNConfig */ "./node_modules/antlr4/atn/ATNConfig.js").ATNConfig;
  23080. var Interval = __webpack_require__(/*! ./IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  23081. var IntervalSet = __webpack_require__(/*! ./IntervalSet */ "./node_modules/antlr4/IntervalSet.js").IntervalSet;
  23082. var RuleStopState = __webpack_require__(/*! ./atn/ATNState */ "./node_modules/antlr4/atn/ATNState.js").RuleStopState;
  23083. var RuleTransition = __webpack_require__(/*! ./atn/Transition */ "./node_modules/antlr4/atn/Transition.js").RuleTransition;
  23084. var NotSetTransition = __webpack_require__(/*! ./atn/Transition */ "./node_modules/antlr4/atn/Transition.js").NotSetTransition;
  23085. var WildcardTransition = __webpack_require__(/*! ./atn/Transition */ "./node_modules/antlr4/atn/Transition.js").WildcardTransition;
  23086. var AbstractPredicateTransition = __webpack_require__(/*! ./atn/Transition */ "./node_modules/antlr4/atn/Transition.js").AbstractPredicateTransition;
  23087. var pc = __webpack_require__(/*! ./PredictionContext */ "./node_modules/antlr4/PredictionContext.js");
  23088. var predictionContextFromRuleContext = pc.predictionContextFromRuleContext;
  23089. var PredictionContext = pc.PredictionContext;
  23090. var SingletonPredictionContext = pc.SingletonPredictionContext;
  23091. function LL1Analyzer(atn) {
  23092. this.atn = atn;
  23093. }
  23094. //* Special value added to the lookahead sets to indicate that we hit
  23095. // a predicate during analysis if {@code seeThruPreds==false}.
  23096. ///
  23097. LL1Analyzer.HIT_PRED = Token.INVALID_TYPE;
  23098. //*
  23099. // Calculates the SLL(1) expected lookahead set for each outgoing transition
  23100. // of an {@link ATNState}. The returned array has one element for each
  23101. // outgoing transition in {@code s}. If the closure from transition
  23102. // <em>i</em> leads to a semantic predicate before matching a symbol, the
  23103. // element at index <em>i</em> of the result will be {@code null}.
  23104. //
  23105. // @param s the ATN state
  23106. // @return the expected symbols for each outgoing transition of {@code s}.
  23107. ///
  23108. LL1Analyzer.prototype.getDecisionLookahead = function (s) {
  23109. if (s === null) {
  23110. return null;
  23111. }
  23112. var count = s.transitions.length;
  23113. var look = [];
  23114. for (var alt = 0; alt < count; alt++) {
  23115. look[alt] = new IntervalSet();
  23116. var lookBusy = new Set();
  23117. var seeThruPreds = false; // fail to get lookahead upon pred
  23118. this._LOOK(s.transition(alt).target, null, PredictionContext.EMPTY, look[alt], lookBusy, new BitSet(), seeThruPreds, false);
  23119. // Wipe out lookahead for this alternative if we found nothing
  23120. // or we had a predicate when we !seeThruPreds
  23121. if (look[alt].length === 0 || look[alt].contains(LL1Analyzer.HIT_PRED)) {
  23122. look[alt] = null;
  23123. }
  23124. }
  23125. return look;
  23126. };
  23127. //*
  23128. // Compute set of tokens that can follow {@code s} in the ATN in the
  23129. // specified {@code ctx}.
  23130. //
  23131. // <p>If {@code ctx} is {@code null} and the end of the rule containing
  23132. // {@code s} is reached, {@link Token//EPSILON} is added to the result set.
  23133. // If {@code ctx} is not {@code null} and the end of the outermost rule is
  23134. // reached, {@link Token//EOF} is added to the result set.</p>
  23135. //
  23136. // @param s the ATN state
  23137. // @param stopState the ATN state to stop at. This can be a
  23138. // {@link BlockEndState} to detect epsilon paths through a closure.
  23139. // @param ctx the complete parser context, or {@code null} if the context
  23140. // should be ignored
  23141. //
  23142. // @return The set of tokens that can follow {@code s} in the ATN in the
  23143. // specified {@code ctx}.
  23144. ///
  23145. LL1Analyzer.prototype.LOOK = function (s, stopState, ctx) {
  23146. var r = new IntervalSet();
  23147. var seeThruPreds = true; // ignore preds; get all lookahead
  23148. ctx = ctx || null;
  23149. var lookContext = ctx !== null ? predictionContextFromRuleContext(s.atn, ctx) : null;
  23150. this._LOOK(s, stopState, lookContext, r, new Set(), new BitSet(), seeThruPreds, true);
  23151. return r;
  23152. };
  23153. //*
  23154. // Compute set of tokens that can follow {@code s} in the ATN in the
  23155. // specified {@code ctx}.
  23156. //
  23157. // <p>If {@code ctx} is {@code null} and {@code stopState} or the end of the
  23158. // rule containing {@code s} is reached, {@link Token//EPSILON} is added to
  23159. // the result set. If {@code ctx} is not {@code null} and {@code addEOF} is
  23160. // {@code true} and {@code stopState} or the end of the outermost rule is
  23161. // reached, {@link Token//EOF} is added to the result set.</p>
  23162. //
  23163. // @param s the ATN state.
  23164. // @param stopState the ATN state to stop at. This can be a
  23165. // {@link BlockEndState} to detect epsilon paths through a closure.
  23166. // @param ctx The outer context, or {@code null} if the outer context should
  23167. // not be used.
  23168. // @param look The result lookahead set.
  23169. // @param lookBusy A set used for preventing epsilon closures in the ATN
  23170. // from causing a stack overflow. Outside code should pass
  23171. // {@code new Set<ATNConfig>} for this argument.
  23172. // @param calledRuleStack A set used for preventing left recursion in the
  23173. // ATN from causing a stack overflow. Outside code should pass
  23174. // {@code new BitSet()} for this argument.
  23175. // @param seeThruPreds {@code true} to true semantic predicates as
  23176. // implicitly {@code true} and "see through them", otherwise {@code false}
  23177. // to treat semantic predicates as opaque and add {@link //HIT_PRED} to the
  23178. // result if one is encountered.
  23179. // @param addEOF Add {@link Token//EOF} to the result if the end of the
  23180. // outermost context is reached. This parameter has no effect if {@code ctx}
  23181. // is {@code null}.
  23182. ///
  23183. LL1Analyzer.prototype._LOOK = function (s, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) {
  23184. var c = new ATNConfig({ state: s, alt: 0, context: ctx }, null);
  23185. if (lookBusy.contains(c)) {
  23186. return;
  23187. }
  23188. lookBusy.add(c);
  23189. if (s === stopState) {
  23190. if (ctx === null) {
  23191. look.addOne(Token.EPSILON);
  23192. return;
  23193. } else if (ctx.isEmpty() && addEOF) {
  23194. look.addOne(Token.EOF);
  23195. return;
  23196. }
  23197. }
  23198. if (s instanceof RuleStopState) {
  23199. if (ctx === null) {
  23200. look.addOne(Token.EPSILON);
  23201. return;
  23202. } else if (ctx.isEmpty() && addEOF) {
  23203. look.addOne(Token.EOF);
  23204. return;
  23205. }
  23206. if (ctx !== PredictionContext.EMPTY) {
  23207. // run thru all possible stack tops in ctx
  23208. for (var i = 0; i < ctx.length; i++) {
  23209. var returnState = this.atn.states[ctx.getReturnState(i)];
  23210. var removed = calledRuleStack.contains(returnState.ruleIndex);
  23211. try {
  23212. calledRuleStack.remove(returnState.ruleIndex);
  23213. this._LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
  23214. } finally {
  23215. if (removed) {
  23216. calledRuleStack.add(returnState.ruleIndex);
  23217. }
  23218. }
  23219. }
  23220. return;
  23221. }
  23222. }
  23223. for (var j = 0; j < s.transitions.length; j++) {
  23224. var t = s.transitions[j];
  23225. if (t.constructor === RuleTransition) {
  23226. if (calledRuleStack.contains(t.target.ruleIndex)) {
  23227. continue;
  23228. }
  23229. var newContext = SingletonPredictionContext.create(ctx, t.followState.stateNumber);
  23230. try {
  23231. calledRuleStack.add(t.target.ruleIndex);
  23232. this._LOOK(t.target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
  23233. } finally {
  23234. calledRuleStack.remove(t.target.ruleIndex);
  23235. }
  23236. } else if (t instanceof AbstractPredicateTransition) {
  23237. if (seeThruPreds) {
  23238. this._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
  23239. } else {
  23240. look.addOne(LL1Analyzer.HIT_PRED);
  23241. }
  23242. } else if (t.isEpsilon) {
  23243. this._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
  23244. } else if (t.constructor === WildcardTransition) {
  23245. look.addRange(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
  23246. } else {
  23247. var set = t.label;
  23248. if (set !== null) {
  23249. if (t instanceof NotSetTransition) {
  23250. set = set.complement(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
  23251. }
  23252. look.addSet(set);
  23253. }
  23254. }
  23255. }
  23256. };
  23257. exports.LL1Analyzer = LL1Analyzer;
  23258. /***/ }),
  23259. /***/ "./node_modules/antlr4/Lexer.js":
  23260. /*!**************************************!*\
  23261. !*** ./node_modules/antlr4/Lexer.js ***!
  23262. \**************************************/
  23263. /*! no static exports found */
  23264. /***/ (function(module, exports, __webpack_require__) {
  23265. "use strict";
  23266. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  23267. * Use of this file is governed by the BSD 3-clause license that
  23268. * can be found in the LICENSE.txt file in the project root.
  23269. */
  23270. ///
  23271. // A lexer is recognizer that draws input symbols from a character stream.
  23272. // lexer grammars result in a subclass of this object. A Lexer object
  23273. // uses simplified match() and error recovery mechanisms in the interest of speed.
  23274. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  23275. var Recognizer = __webpack_require__(/*! ./Recognizer */ "./node_modules/antlr4/Recognizer.js").Recognizer;
  23276. var CommonTokenFactory = __webpack_require__(/*! ./CommonTokenFactory */ "./node_modules/antlr4/CommonTokenFactory.js").CommonTokenFactory;
  23277. var RecognitionException = __webpack_require__(/*! ./error/Errors */ "./node_modules/antlr4/error/Errors.js").RecognitionException;
  23278. var LexerNoViableAltException = __webpack_require__(/*! ./error/Errors */ "./node_modules/antlr4/error/Errors.js").LexerNoViableAltException;
  23279. function TokenSource() {
  23280. return this;
  23281. }
  23282. function Lexer(input) {
  23283. Recognizer.call(this);
  23284. this._input = input;
  23285. this._factory = CommonTokenFactory.DEFAULT;
  23286. this._tokenFactorySourcePair = [this, input];
  23287. this._interp = null; // child classes must populate this
  23288. // The goal of all lexer rules/methods is to create a token object.
  23289. // this is an instance variable as multiple rules may collaborate to
  23290. // create a single token. nextToken will return this object after
  23291. // matching lexer rule(s). If you subclass to allow multiple token
  23292. // emissions, then set this to the last token to be matched or
  23293. // something nonnull so that the auto token emit mechanism will not
  23294. // emit another token.
  23295. this._token = null;
  23296. // What character index in the stream did the current token start at?
  23297. // Needed, for example, to get the text for current token. Set at
  23298. // the start of nextToken.
  23299. this._tokenStartCharIndex = -1;
  23300. // The line on which the first character of the token resides///
  23301. this._tokenStartLine = -1;
  23302. // The character position of first character within the line///
  23303. this._tokenStartColumn = -1;
  23304. // Once we see EOF on char stream, next token will be EOF.
  23305. // If you have DONE : EOF ; then you see DONE EOF.
  23306. this._hitEOF = false;
  23307. // The channel number for the current token///
  23308. this._channel = Token.DEFAULT_CHANNEL;
  23309. // The token type for the current token///
  23310. this._type = Token.INVALID_TYPE;
  23311. this._modeStack = [];
  23312. this._mode = Lexer.DEFAULT_MODE;
  23313. // You can set the text for the current token to override what is in
  23314. // the input char buffer. Use setText() or can set this instance var.
  23315. // /
  23316. this._text = null;
  23317. return this;
  23318. }
  23319. Lexer.prototype = Object.create(Recognizer.prototype);
  23320. Lexer.prototype.constructor = Lexer;
  23321. Lexer.DEFAULT_MODE = 0;
  23322. Lexer.MORE = -2;
  23323. Lexer.SKIP = -3;
  23324. Lexer.DEFAULT_TOKEN_CHANNEL = Token.DEFAULT_CHANNEL;
  23325. Lexer.HIDDEN = Token.HIDDEN_CHANNEL;
  23326. Lexer.MIN_CHAR_VALUE = 0x0000;
  23327. Lexer.MAX_CHAR_VALUE = 0x10FFFF;
  23328. Lexer.prototype.reset = function () {
  23329. // wack Lexer state variables
  23330. if (this._input !== null) {
  23331. this._input.seek(0); // rewind the input
  23332. }
  23333. this._token = null;
  23334. this._type = Token.INVALID_TYPE;
  23335. this._channel = Token.DEFAULT_CHANNEL;
  23336. this._tokenStartCharIndex = -1;
  23337. this._tokenStartColumn = -1;
  23338. this._tokenStartLine = -1;
  23339. this._text = null;
  23340. this._hitEOF = false;
  23341. this._mode = Lexer.DEFAULT_MODE;
  23342. this._modeStack = [];
  23343. this._interp.reset();
  23344. };
  23345. // Return a token from this source; i.e., match a token on the char stream.
  23346. Lexer.prototype.nextToken = function () {
  23347. if (this._input === null) {
  23348. throw "nextToken requires a non-null input stream.";
  23349. }
  23350. // Mark start location in char stream so unbuffered streams are
  23351. // guaranteed at least have text of current token
  23352. var tokenStartMarker = this._input.mark();
  23353. try {
  23354. while (true) {
  23355. if (this._hitEOF) {
  23356. this.emitEOF();
  23357. return this._token;
  23358. }
  23359. this._token = null;
  23360. this._channel = Token.DEFAULT_CHANNEL;
  23361. this._tokenStartCharIndex = this._input.index;
  23362. this._tokenStartColumn = this._interp.column;
  23363. this._tokenStartLine = this._interp.line;
  23364. this._text = null;
  23365. var continueOuter = false;
  23366. while (true) {
  23367. this._type = Token.INVALID_TYPE;
  23368. var ttype = Lexer.SKIP;
  23369. try {
  23370. ttype = this._interp.match(this._input, this._mode);
  23371. } catch (e) {
  23372. if (e instanceof RecognitionException) {
  23373. this.notifyListeners(e); // report error
  23374. this.recover(e);
  23375. } else {
  23376. console.log(e.stack);
  23377. throw e;
  23378. }
  23379. }
  23380. if (this._input.LA(1) === Token.EOF) {
  23381. this._hitEOF = true;
  23382. }
  23383. if (this._type === Token.INVALID_TYPE) {
  23384. this._type = ttype;
  23385. }
  23386. if (this._type === Lexer.SKIP) {
  23387. continueOuter = true;
  23388. break;
  23389. }
  23390. if (this._type !== Lexer.MORE) {
  23391. break;
  23392. }
  23393. }
  23394. if (continueOuter) {
  23395. continue;
  23396. }
  23397. if (this._token === null) {
  23398. this.emit();
  23399. }
  23400. return this._token;
  23401. }
  23402. } finally {
  23403. // make sure we release marker after match or
  23404. // unbuffered char stream will keep buffering
  23405. this._input.release(tokenStartMarker);
  23406. }
  23407. };
  23408. // Instruct the lexer to skip creating a token for current lexer rule
  23409. // and look for another token. nextToken() knows to keep looking when
  23410. // a lexer rule finishes with token set to SKIP_TOKEN. Recall that
  23411. // if token==null at end of any token rule, it creates one for you
  23412. // and emits it.
  23413. // /
  23414. Lexer.prototype.skip = function () {
  23415. this._type = Lexer.SKIP;
  23416. };
  23417. Lexer.prototype.more = function () {
  23418. this._type = Lexer.MORE;
  23419. };
  23420. Lexer.prototype.mode = function (m) {
  23421. this._mode = m;
  23422. };
  23423. Lexer.prototype.pushMode = function (m) {
  23424. if (this._interp.debug) {
  23425. console.log("pushMode " + m);
  23426. }
  23427. this._modeStack.push(this._mode);
  23428. this.mode(m);
  23429. };
  23430. Lexer.prototype.popMode = function () {
  23431. if (this._modeStack.length === 0) {
  23432. throw "Empty Stack";
  23433. }
  23434. if (this._interp.debug) {
  23435. console.log("popMode back to " + this._modeStack.slice(0, -1));
  23436. }
  23437. this.mode(this._modeStack.pop());
  23438. return this._mode;
  23439. };
  23440. // Set the char stream and reset the lexer
  23441. Object.defineProperty(Lexer.prototype, "inputStream", {
  23442. get: function get() {
  23443. return this._input;
  23444. },
  23445. set: function set(input) {
  23446. this._input = null;
  23447. this._tokenFactorySourcePair = [this, this._input];
  23448. this.reset();
  23449. this._input = input;
  23450. this._tokenFactorySourcePair = [this, this._input];
  23451. }
  23452. });
  23453. Object.defineProperty(Lexer.prototype, "sourceName", {
  23454. get: function sourceName() {
  23455. return this._input.sourceName;
  23456. }
  23457. });
  23458. // By default does not support multiple emits per nextToken invocation
  23459. // for efficiency reasons. Subclass and override this method, nextToken,
  23460. // and getToken (to push tokens into a list and pull from that list
  23461. // rather than a single variable as this implementation does).
  23462. // /
  23463. Lexer.prototype.emitToken = function (token) {
  23464. this._token = token;
  23465. };
  23466. // The standard method called to automatically emit a token at the
  23467. // outermost lexical rule. The token object should point into the
  23468. // char buffer start..stop. If there is a text override in 'text',
  23469. // use that to set the token's text. Override this method to emit
  23470. // custom Token objects or provide a new factory.
  23471. // /
  23472. Lexer.prototype.emit = function () {
  23473. var t = this._factory.create(this._tokenFactorySourcePair, this._type, this._text, this._channel, this._tokenStartCharIndex, this.getCharIndex() - 1, this._tokenStartLine, this._tokenStartColumn);
  23474. this.emitToken(t);
  23475. return t;
  23476. };
  23477. Lexer.prototype.emitEOF = function () {
  23478. var cpos = this.column;
  23479. var lpos = this.line;
  23480. var eof = this._factory.create(this._tokenFactorySourcePair, Token.EOF, null, Token.DEFAULT_CHANNEL, this._input.index, this._input.index - 1, lpos, cpos);
  23481. this.emitToken(eof);
  23482. return eof;
  23483. };
  23484. Object.defineProperty(Lexer.prototype, "type", {
  23485. get: function get() {
  23486. return this.type;
  23487. },
  23488. set: function set(type) {
  23489. this._type = type;
  23490. }
  23491. });
  23492. Object.defineProperty(Lexer.prototype, "line", {
  23493. get: function get() {
  23494. return this._interp.line;
  23495. },
  23496. set: function set(line) {
  23497. this._interp.line = line;
  23498. }
  23499. });
  23500. Object.defineProperty(Lexer.prototype, "column", {
  23501. get: function get() {
  23502. return this._interp.column;
  23503. },
  23504. set: function set(column) {
  23505. this._interp.column = column;
  23506. }
  23507. });
  23508. // What is the index of the current character of lookahead?///
  23509. Lexer.prototype.getCharIndex = function () {
  23510. return this._input.index;
  23511. };
  23512. // Return the text matched so far for the current token or any text override.
  23513. //Set the complete text of this token; it wipes any previous changes to the text.
  23514. Object.defineProperty(Lexer.prototype, "text", {
  23515. get: function get() {
  23516. if (this._text !== null) {
  23517. return this._text;
  23518. } else {
  23519. return this._interp.getText(this._input);
  23520. }
  23521. },
  23522. set: function set(text) {
  23523. this._text = text;
  23524. }
  23525. });
  23526. // Return a list of all Token objects in input char stream.
  23527. // Forces load of all tokens. Does not include EOF token.
  23528. // /
  23529. Lexer.prototype.getAllTokens = function () {
  23530. var tokens = [];
  23531. var t = this.nextToken();
  23532. while (t.type !== Token.EOF) {
  23533. tokens.push(t);
  23534. t = this.nextToken();
  23535. }
  23536. return tokens;
  23537. };
  23538. Lexer.prototype.notifyListeners = function (e) {
  23539. var start = this._tokenStartCharIndex;
  23540. var stop = this._input.index;
  23541. var text = this._input.getText(start, stop);
  23542. var msg = "token recognition error at: '" + this.getErrorDisplay(text) + "'";
  23543. var listener = this.getErrorListenerDispatch();
  23544. listener.syntaxError(this, null, this._tokenStartLine, this._tokenStartColumn, msg, e);
  23545. };
  23546. Lexer.prototype.getErrorDisplay = function (s) {
  23547. var d = [];
  23548. for (var i = 0; i < s.length; i++) {
  23549. d.push(s[i]);
  23550. }
  23551. return d.join('');
  23552. };
  23553. Lexer.prototype.getErrorDisplayForChar = function (c) {
  23554. if (c.charCodeAt(0) === Token.EOF) {
  23555. return "<EOF>";
  23556. } else if (c === '\n') {
  23557. return "\\n";
  23558. } else if (c === '\t') {
  23559. return "\\t";
  23560. } else if (c === '\r') {
  23561. return "\\r";
  23562. } else {
  23563. return c;
  23564. }
  23565. };
  23566. Lexer.prototype.getCharErrorDisplay = function (c) {
  23567. return "'" + this.getErrorDisplayForChar(c) + "'";
  23568. };
  23569. // Lexers can normally match any char in it's vocabulary after matching
  23570. // a token, so do the easy thing and just kill a character and hope
  23571. // it all works out. You can instead use the rule invocation stack
  23572. // to do sophisticated error recovery if you are in a fragment rule.
  23573. // /
  23574. Lexer.prototype.recover = function (re) {
  23575. if (this._input.LA(1) !== Token.EOF) {
  23576. if (re instanceof LexerNoViableAltException) {
  23577. // skip a char and try again
  23578. this._interp.consume(this._input);
  23579. } else {
  23580. // TODO: Do we lose character or line position information?
  23581. this._input.consume();
  23582. }
  23583. }
  23584. };
  23585. exports.Lexer = Lexer;
  23586. /***/ }),
  23587. /***/ "./node_modules/antlr4/Parser.js":
  23588. /*!***************************************!*\
  23589. !*** ./node_modules/antlr4/Parser.js ***!
  23590. \***************************************/
  23591. /*! no static exports found */
  23592. /***/ (function(module, exports, __webpack_require__) {
  23593. "use strict";
  23594. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  23595. * Use of this file is governed by the BSD 3-clause license that
  23596. * can be found in the LICENSE.txt file in the project root.
  23597. */
  23598. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  23599. var ParseTreeListener = __webpack_require__(/*! ./tree/Tree */ "./node_modules/antlr4/tree/Tree.js").ParseTreeListener;
  23600. var Recognizer = __webpack_require__(/*! ./Recognizer */ "./node_modules/antlr4/Recognizer.js").Recognizer;
  23601. var DefaultErrorStrategy = __webpack_require__(/*! ./error/ErrorStrategy */ "./node_modules/antlr4/error/ErrorStrategy.js").DefaultErrorStrategy;
  23602. var ATNDeserializer = __webpack_require__(/*! ./atn/ATNDeserializer */ "./node_modules/antlr4/atn/ATNDeserializer.js").ATNDeserializer;
  23603. var ATNDeserializationOptions = __webpack_require__(/*! ./atn/ATNDeserializationOptions */ "./node_modules/antlr4/atn/ATNDeserializationOptions.js").ATNDeserializationOptions;
  23604. var TerminalNode = __webpack_require__(/*! ./tree/Tree */ "./node_modules/antlr4/tree/Tree.js").TerminalNode;
  23605. var ErrorNode = __webpack_require__(/*! ./tree/Tree */ "./node_modules/antlr4/tree/Tree.js").ErrorNode;
  23606. function TraceListener(parser) {
  23607. ParseTreeListener.call(this);
  23608. this.parser = parser;
  23609. return this;
  23610. }
  23611. TraceListener.prototype = Object.create(ParseTreeListener.prototype);
  23612. TraceListener.prototype.constructor = TraceListener;
  23613. TraceListener.prototype.enterEveryRule = function (ctx) {
  23614. console.log("enter " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text);
  23615. };
  23616. TraceListener.prototype.visitTerminal = function (node) {
  23617. console.log("consume " + node.symbol + " rule " + this.parser.ruleNames[this.parser._ctx.ruleIndex]);
  23618. };
  23619. TraceListener.prototype.exitEveryRule = function (ctx) {
  23620. console.log("exit " + this.parser.ruleNames[ctx.ruleIndex] + ", LT(1)=" + this.parser._input.LT(1).text);
  23621. };
  23622. // this is all the parsing support code essentially; most of it is error
  23623. // recovery stuff.//
  23624. function Parser(input) {
  23625. Recognizer.call(this);
  23626. // The input stream.
  23627. this._input = null;
  23628. // The error handling strategy for the parser. The default value is a new
  23629. // instance of {@link DefaultErrorStrategy}.
  23630. this._errHandler = new DefaultErrorStrategy();
  23631. this._precedenceStack = [];
  23632. this._precedenceStack.push(0);
  23633. // The {@link ParserRuleContext} object for the currently executing rule.
  23634. // this is always non-null during the parsing process.
  23635. this._ctx = null;
  23636. // Specifies whether or not the parser should construct a parse tree during
  23637. // the parsing process. The default value is {@code true}.
  23638. this.buildParseTrees = true;
  23639. // When {@link //setTrace}{@code (true)} is called, a reference to the
  23640. // {@link TraceListener} is stored here so it can be easily removed in a
  23641. // later call to {@link //setTrace}{@code (false)}. The listener itself is
  23642. // implemented as a parser listener so this field is not directly used by
  23643. // other parser methods.
  23644. this._tracer = null;
  23645. // The list of {@link ParseTreeListener} listeners registered to receive
  23646. // events during the parse.
  23647. this._parseListeners = null;
  23648. // The number of syntax errors reported during parsing. this value is
  23649. // incremented each time {@link //notifyErrorListeners} is called.
  23650. this._syntaxErrors = 0;
  23651. this.setInputStream(input);
  23652. return this;
  23653. }
  23654. Parser.prototype = Object.create(Recognizer.prototype);
  23655. Parser.prototype.contructor = Parser;
  23656. // this field maps from the serialized ATN string to the deserialized {@link
  23657. // ATN} with
  23658. // bypass alternatives.
  23659. //
  23660. // @see ATNDeserializationOptions//isGenerateRuleBypassTransitions()
  23661. //
  23662. Parser.bypassAltsAtnCache = {};
  23663. // reset the parser's state//
  23664. Parser.prototype.reset = function () {
  23665. if (this._input !== null) {
  23666. this._input.seek(0);
  23667. }
  23668. this._errHandler.reset(this);
  23669. this._ctx = null;
  23670. this._syntaxErrors = 0;
  23671. this.setTrace(false);
  23672. this._precedenceStack = [];
  23673. this._precedenceStack.push(0);
  23674. if (this._interp !== null) {
  23675. this._interp.reset();
  23676. }
  23677. };
  23678. // Match current input symbol against {@code ttype}. If the symbol type
  23679. // matches, {@link ANTLRErrorStrategy//reportMatch} and {@link //consume} are
  23680. // called to complete the match process.
  23681. //
  23682. // <p>If the symbol type does not match,
  23683. // {@link ANTLRErrorStrategy//recoverInline} is called on the current error
  23684. // strategy to attempt recovery. If {@link //getBuildParseTree} is
  23685. // {@code true} and the token index of the symbol returned by
  23686. // {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to
  23687. // the parse tree by calling {@link ParserRuleContext//addErrorNode}.</p>
  23688. //
  23689. // @param ttype the token type to match
  23690. // @return the matched symbol
  23691. // @throws RecognitionException if the current input symbol did not match
  23692. // {@code ttype} and the error strategy could not recover from the
  23693. // mismatched symbol
  23694. Parser.prototype.match = function (ttype) {
  23695. var t = this.getCurrentToken();
  23696. if (t.type === ttype) {
  23697. this._errHandler.reportMatch(this);
  23698. this.consume();
  23699. } else {
  23700. t = this._errHandler.recoverInline(this);
  23701. if (this.buildParseTrees && t.tokenIndex === -1) {
  23702. // we must have conjured up a new token during single token
  23703. // insertion
  23704. // if it's not the current symbol
  23705. this._ctx.addErrorNode(t);
  23706. }
  23707. }
  23708. return t;
  23709. };
  23710. // Match current input symbol as a wildcard. If the symbol type matches
  23711. // (i.e. has a value greater than 0), {@link ANTLRErrorStrategy//reportMatch}
  23712. // and {@link //consume} are called to complete the match process.
  23713. //
  23714. // <p>If the symbol type does not match,
  23715. // {@link ANTLRErrorStrategy//recoverInline} is called on the current error
  23716. // strategy to attempt recovery. If {@link //getBuildParseTree} is
  23717. // {@code true} and the token index of the symbol returned by
  23718. // {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to
  23719. // the parse tree by calling {@link ParserRuleContext//addErrorNode}.</p>
  23720. //
  23721. // @return the matched symbol
  23722. // @throws RecognitionException if the current input symbol did not match
  23723. // a wildcard and the error strategy could not recover from the mismatched
  23724. // symbol
  23725. Parser.prototype.matchWildcard = function () {
  23726. var t = this.getCurrentToken();
  23727. if (t.type > 0) {
  23728. this._errHandler.reportMatch(this);
  23729. this.consume();
  23730. } else {
  23731. t = this._errHandler.recoverInline(this);
  23732. if (this._buildParseTrees && t.tokenIndex === -1) {
  23733. // we must have conjured up a new token during single token
  23734. // insertion
  23735. // if it's not the current symbol
  23736. this._ctx.addErrorNode(t);
  23737. }
  23738. }
  23739. return t;
  23740. };
  23741. Parser.prototype.getParseListeners = function () {
  23742. return this._parseListeners || [];
  23743. };
  23744. // Registers {@code listener} to receive events during the parsing process.
  23745. //
  23746. // <p>To support output-preserving grammar transformations (including but not
  23747. // limited to left-recursion removal, automated left-factoring, and
  23748. // optimized code generation), calls to listener methods during the parse
  23749. // may differ substantially from calls made by
  23750. // {@link ParseTreeWalker//DEFAULT} used after the parse is complete. In
  23751. // particular, rule entry and exit events may occur in a different order
  23752. // during the parse than after the parser. In addition, calls to certain
  23753. // rule entry methods may be omitted.</p>
  23754. //
  23755. // <p>With the following specific exceptions, calls to listener events are
  23756. // <em>deterministic</em>, i.e. for identical input the calls to listener
  23757. // methods will be the same.</p>
  23758. //
  23759. // <ul>
  23760. // <li>Alterations to the grammar used to generate code may change the
  23761. // behavior of the listener calls.</li>
  23762. // <li>Alterations to the command line options passed to ANTLR 4 when
  23763. // generating the parser may change the behavior of the listener calls.</li>
  23764. // <li>Changing the version of the ANTLR Tool used to generate the parser
  23765. // may change the behavior of the listener calls.</li>
  23766. // </ul>
  23767. //
  23768. // @param listener the listener to add
  23769. //
  23770. // @throws NullPointerException if {@code} listener is {@code null}
  23771. //
  23772. Parser.prototype.addParseListener = function (listener) {
  23773. if (listener === null) {
  23774. throw "listener";
  23775. }
  23776. if (this._parseListeners === null) {
  23777. this._parseListeners = [];
  23778. }
  23779. this._parseListeners.push(listener);
  23780. };
  23781. //
  23782. // Remove {@code listener} from the list of parse listeners.
  23783. //
  23784. // <p>If {@code listener} is {@code null} or has not been added as a parse
  23785. // listener, this method does nothing.</p>
  23786. // @param listener the listener to remove
  23787. //
  23788. Parser.prototype.removeParseListener = function (listener) {
  23789. if (this._parseListeners !== null) {
  23790. var idx = this._parseListeners.indexOf(listener);
  23791. if (idx >= 0) {
  23792. this._parseListeners.splice(idx, 1);
  23793. }
  23794. if (this._parseListeners.length === 0) {
  23795. this._parseListeners = null;
  23796. }
  23797. }
  23798. };
  23799. // Remove all parse listeners.
  23800. Parser.prototype.removeParseListeners = function () {
  23801. this._parseListeners = null;
  23802. };
  23803. // Notify any parse listeners of an enter rule event.
  23804. Parser.prototype.triggerEnterRuleEvent = function () {
  23805. if (this._parseListeners !== null) {
  23806. var ctx = this._ctx;
  23807. this._parseListeners.map(function (listener) {
  23808. listener.enterEveryRule(ctx);
  23809. ctx.enterRule(listener);
  23810. });
  23811. }
  23812. };
  23813. //
  23814. // Notify any parse listeners of an exit rule event.
  23815. //
  23816. // @see //addParseListener
  23817. //
  23818. Parser.prototype.triggerExitRuleEvent = function () {
  23819. if (this._parseListeners !== null) {
  23820. // reverse order walk of listeners
  23821. var ctx = this._ctx;
  23822. this._parseListeners.slice(0).reverse().map(function (listener) {
  23823. ctx.exitRule(listener);
  23824. listener.exitEveryRule(ctx);
  23825. });
  23826. }
  23827. };
  23828. Parser.prototype.getTokenFactory = function () {
  23829. return this._input.tokenSource._factory;
  23830. };
  23831. // Tell our token source and error strategy about a new way to create tokens.//
  23832. Parser.prototype.setTokenFactory = function (factory) {
  23833. this._input.tokenSource._factory = factory;
  23834. };
  23835. // The ATN with bypass alternatives is expensive to create so we create it
  23836. // lazily.
  23837. //
  23838. // @throws UnsupportedOperationException if the current parser does not
  23839. // implement the {@link //getSerializedATN()} method.
  23840. //
  23841. Parser.prototype.getATNWithBypassAlts = function () {
  23842. var serializedAtn = this.getSerializedATN();
  23843. if (serializedAtn === null) {
  23844. throw "The current parser does not support an ATN with bypass alternatives.";
  23845. }
  23846. var result = this.bypassAltsAtnCache[serializedAtn];
  23847. if (result === null) {
  23848. var deserializationOptions = new ATNDeserializationOptions();
  23849. deserializationOptions.generateRuleBypassTransitions = true;
  23850. result = new ATNDeserializer(deserializationOptions).deserialize(serializedAtn);
  23851. this.bypassAltsAtnCache[serializedAtn] = result;
  23852. }
  23853. return result;
  23854. };
  23855. // The preferred method of getting a tree pattern. For example, here's a
  23856. // sample use:
  23857. //
  23858. // <pre>
  23859. // ParseTree t = parser.expr();
  23860. // ParseTreePattern p = parser.compileParseTreePattern("&lt;ID&gt;+0",
  23861. // MyParser.RULE_expr);
  23862. // ParseTreeMatch m = p.match(t);
  23863. // String id = m.get("ID");
  23864. // </pre>
  23865. var Lexer = __webpack_require__(/*! ./Lexer */ "./node_modules/antlr4/Lexer.js").Lexer;
  23866. Parser.prototype.compileParseTreePattern = function (pattern, patternRuleIndex, lexer) {
  23867. lexer = lexer || null;
  23868. if (lexer === null) {
  23869. if (this.getTokenStream() !== null) {
  23870. var tokenSource = this.getTokenStream().tokenSource;
  23871. if (tokenSource instanceof Lexer) {
  23872. lexer = tokenSource;
  23873. }
  23874. }
  23875. }
  23876. if (lexer === null) {
  23877. throw "Parser can't discover a lexer to use";
  23878. }
  23879. var m = new ParseTreePatternMatcher(lexer, this);
  23880. return m.compile(pattern, patternRuleIndex);
  23881. };
  23882. Parser.prototype.getInputStream = function () {
  23883. return this.getTokenStream();
  23884. };
  23885. Parser.prototype.setInputStream = function (input) {
  23886. this.setTokenStream(input);
  23887. };
  23888. Parser.prototype.getTokenStream = function () {
  23889. return this._input;
  23890. };
  23891. // Set the token stream and reset the parser.//
  23892. Parser.prototype.setTokenStream = function (input) {
  23893. this._input = null;
  23894. this.reset();
  23895. this._input = input;
  23896. };
  23897. // Match needs to return the current input symbol, which gets put
  23898. // into the label for the associated token ref; e.g., x=ID.
  23899. //
  23900. Parser.prototype.getCurrentToken = function () {
  23901. return this._input.LT(1);
  23902. };
  23903. Parser.prototype.notifyErrorListeners = function (msg, offendingToken, err) {
  23904. offendingToken = offendingToken || null;
  23905. err = err || null;
  23906. if (offendingToken === null) {
  23907. offendingToken = this.getCurrentToken();
  23908. }
  23909. this._syntaxErrors += 1;
  23910. var line = offendingToken.line;
  23911. var column = offendingToken.column;
  23912. var listener = this.getErrorListenerDispatch();
  23913. listener.syntaxError(this, offendingToken, line, column, msg, err);
  23914. };
  23915. //
  23916. // Consume and return the {@linkplain //getCurrentToken current symbol}.
  23917. //
  23918. // <p>E.g., given the following input with {@code A} being the current
  23919. // lookahead symbol, this function moves the cursor to {@code B} and returns
  23920. // {@code A}.</p>
  23921. //
  23922. // <pre>
  23923. // A B
  23924. // ^
  23925. // </pre>
  23926. //
  23927. // If the parser is not in error recovery mode, the consumed symbol is added
  23928. // to the parse tree using {@link ParserRuleContext//addChild(Token)}, and
  23929. // {@link ParseTreeListener//visitTerminal} is called on any parse listeners.
  23930. // If the parser <em>is</em> in error recovery mode, the consumed symbol is
  23931. // added to the parse tree using
  23932. // {@link ParserRuleContext//addErrorNode(Token)}, and
  23933. // {@link ParseTreeListener//visitErrorNode} is called on any parse
  23934. // listeners.
  23935. //
  23936. Parser.prototype.consume = function () {
  23937. var o = this.getCurrentToken();
  23938. if (o.type !== Token.EOF) {
  23939. this.getInputStream().consume();
  23940. }
  23941. var hasListener = this._parseListeners !== null && this._parseListeners.length > 0;
  23942. if (this.buildParseTrees || hasListener) {
  23943. var node;
  23944. if (this._errHandler.inErrorRecoveryMode(this)) {
  23945. node = this._ctx.addErrorNode(o);
  23946. } else {
  23947. node = this._ctx.addTokenNode(o);
  23948. }
  23949. node.invokingState = this.state;
  23950. if (hasListener) {
  23951. this._parseListeners.map(function (listener) {
  23952. if (node instanceof ErrorNode || node.isErrorNode !== undefined && node.isErrorNode()) {
  23953. listener.visitErrorNode(node);
  23954. } else if (node instanceof TerminalNode) {
  23955. listener.visitTerminal(node);
  23956. }
  23957. });
  23958. }
  23959. }
  23960. return o;
  23961. };
  23962. Parser.prototype.addContextToParseTree = function () {
  23963. // add current context to parent if we have a parent
  23964. if (this._ctx.parentCtx !== null) {
  23965. this._ctx.parentCtx.addChild(this._ctx);
  23966. }
  23967. };
  23968. // Always called by generated parsers upon entry to a rule. Access field
  23969. // {@link //_ctx} get the current context.
  23970. Parser.prototype.enterRule = function (localctx, state, ruleIndex) {
  23971. this.state = state;
  23972. this._ctx = localctx;
  23973. this._ctx.start = this._input.LT(1);
  23974. if (this.buildParseTrees) {
  23975. this.addContextToParseTree();
  23976. }
  23977. if (this._parseListeners !== null) {
  23978. this.triggerEnterRuleEvent();
  23979. }
  23980. };
  23981. Parser.prototype.exitRule = function () {
  23982. this._ctx.stop = this._input.LT(-1);
  23983. // trigger event on _ctx, before it reverts to parent
  23984. if (this._parseListeners !== null) {
  23985. this.triggerExitRuleEvent();
  23986. }
  23987. this.state = this._ctx.invokingState;
  23988. this._ctx = this._ctx.parentCtx;
  23989. };
  23990. Parser.prototype.enterOuterAlt = function (localctx, altNum) {
  23991. localctx.setAltNumber(altNum);
  23992. // if we have new localctx, make sure we replace existing ctx
  23993. // that is previous child of parse tree
  23994. if (this.buildParseTrees && this._ctx !== localctx) {
  23995. if (this._ctx.parentCtx !== null) {
  23996. this._ctx.parentCtx.removeLastChild();
  23997. this._ctx.parentCtx.addChild(localctx);
  23998. }
  23999. }
  24000. this._ctx = localctx;
  24001. };
  24002. // Get the precedence level for the top-most precedence rule.
  24003. //
  24004. // @return The precedence level for the top-most precedence rule, or -1 if
  24005. // the parser context is not nested within a precedence rule.
  24006. Parser.prototype.getPrecedence = function () {
  24007. if (this._precedenceStack.length === 0) {
  24008. return -1;
  24009. } else {
  24010. return this._precedenceStack[this._precedenceStack.length - 1];
  24011. }
  24012. };
  24013. Parser.prototype.enterRecursionRule = function (localctx, state, ruleIndex, precedence) {
  24014. this.state = state;
  24015. this._precedenceStack.push(precedence);
  24016. this._ctx = localctx;
  24017. this._ctx.start = this._input.LT(1);
  24018. if (this._parseListeners !== null) {
  24019. this.triggerEnterRuleEvent(); // simulates rule entry for
  24020. // left-recursive rules
  24021. }
  24022. };
  24023. //
  24024. // Like {@link //enterRule} but for recursive rules.
  24025. Parser.prototype.pushNewRecursionContext = function (localctx, state, ruleIndex) {
  24026. var previous = this._ctx;
  24027. previous.parentCtx = localctx;
  24028. previous.invokingState = state;
  24029. previous.stop = this._input.LT(-1);
  24030. this._ctx = localctx;
  24031. this._ctx.start = previous.start;
  24032. if (this.buildParseTrees) {
  24033. this._ctx.addChild(previous);
  24034. }
  24035. if (this._parseListeners !== null) {
  24036. this.triggerEnterRuleEvent(); // simulates rule entry for
  24037. // left-recursive rules
  24038. }
  24039. };
  24040. Parser.prototype.unrollRecursionContexts = function (parentCtx) {
  24041. this._precedenceStack.pop();
  24042. this._ctx.stop = this._input.LT(-1);
  24043. var retCtx = this._ctx; // save current ctx (return value)
  24044. // unroll so _ctx is as it was before call to recursive method
  24045. if (this._parseListeners !== null) {
  24046. while (this._ctx !== parentCtx) {
  24047. this.triggerExitRuleEvent();
  24048. this._ctx = this._ctx.parentCtx;
  24049. }
  24050. } else {
  24051. this._ctx = parentCtx;
  24052. }
  24053. // hook into tree
  24054. retCtx.parentCtx = parentCtx;
  24055. if (this.buildParseTrees && parentCtx !== null) {
  24056. // add return ctx into invoking rule's tree
  24057. parentCtx.addChild(retCtx);
  24058. }
  24059. };
  24060. Parser.prototype.getInvokingContext = function (ruleIndex) {
  24061. var ctx = this._ctx;
  24062. while (ctx !== null) {
  24063. if (ctx.ruleIndex === ruleIndex) {
  24064. return ctx;
  24065. }
  24066. ctx = ctx.parentCtx;
  24067. }
  24068. return null;
  24069. };
  24070. Parser.prototype.precpred = function (localctx, precedence) {
  24071. return precedence >= this._precedenceStack[this._precedenceStack.length - 1];
  24072. };
  24073. Parser.prototype.inContext = function (context) {
  24074. // TODO: useful in parser?
  24075. return false;
  24076. };
  24077. //
  24078. // Checks whether or not {@code symbol} can follow the current state in the
  24079. // ATN. The behavior of this method is equivalent to the following, but is
  24080. // implemented such that the complete context-sensitive follow set does not
  24081. // need to be explicitly constructed.
  24082. //
  24083. // <pre>
  24084. // return getExpectedTokens().contains(symbol);
  24085. // </pre>
  24086. //
  24087. // @param symbol the symbol type to check
  24088. // @return {@code true} if {@code symbol} can follow the current state in
  24089. // the ATN, otherwise {@code false}.
  24090. Parser.prototype.isExpectedToken = function (symbol) {
  24091. var atn = this._interp.atn;
  24092. var ctx = this._ctx;
  24093. var s = atn.states[this.state];
  24094. var following = atn.nextTokens(s);
  24095. if (following.contains(symbol)) {
  24096. return true;
  24097. }
  24098. if (!following.contains(Token.EPSILON)) {
  24099. return false;
  24100. }
  24101. while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
  24102. var invokingState = atn.states[ctx.invokingState];
  24103. var rt = invokingState.transitions[0];
  24104. following = atn.nextTokens(rt.followState);
  24105. if (following.contains(symbol)) {
  24106. return true;
  24107. }
  24108. ctx = ctx.parentCtx;
  24109. }
  24110. if (following.contains(Token.EPSILON) && symbol === Token.EOF) {
  24111. return true;
  24112. } else {
  24113. return false;
  24114. }
  24115. };
  24116. // Computes the set of input symbols which could follow the current parser
  24117. // state and context, as given by {@link //getState} and {@link //getContext},
  24118. // respectively.
  24119. //
  24120. // @see ATN//getExpectedTokens(int, RuleContext)
  24121. //
  24122. Parser.prototype.getExpectedTokens = function () {
  24123. return this._interp.atn.getExpectedTokens(this.state, this._ctx);
  24124. };
  24125. Parser.prototype.getExpectedTokensWithinCurrentRule = function () {
  24126. var atn = this._interp.atn;
  24127. var s = atn.states[this.state];
  24128. return atn.nextTokens(s);
  24129. };
  24130. // Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found.//
  24131. Parser.prototype.getRuleIndex = function (ruleName) {
  24132. var ruleIndex = this.getRuleIndexMap()[ruleName];
  24133. if (ruleIndex !== null) {
  24134. return ruleIndex;
  24135. } else {
  24136. return -1;
  24137. }
  24138. };
  24139. // Return List&lt;String&gt; of the rule names in your parser instance
  24140. // leading up to a call to the current rule. You could override if
  24141. // you want more details such as the file/line info of where
  24142. // in the ATN a rule is invoked.
  24143. //
  24144. // this is very useful for error messages.
  24145. //
  24146. Parser.prototype.getRuleInvocationStack = function (p) {
  24147. p = p || null;
  24148. if (p === null) {
  24149. p = this._ctx;
  24150. }
  24151. var stack = [];
  24152. while (p !== null) {
  24153. // compute what follows who invoked us
  24154. var ruleIndex = p.ruleIndex;
  24155. if (ruleIndex < 0) {
  24156. stack.push("n/a");
  24157. } else {
  24158. stack.push(this.ruleNames[ruleIndex]);
  24159. }
  24160. p = p.parentCtx;
  24161. }
  24162. return stack;
  24163. };
  24164. // For debugging and other purposes.//
  24165. Parser.prototype.getDFAStrings = function () {
  24166. return this._interp.decisionToDFA.toString();
  24167. };
  24168. // For debugging and other purposes.//
  24169. Parser.prototype.dumpDFA = function () {
  24170. var seenOne = false;
  24171. for (var i = 0; i < this._interp.decisionToDFA.length; i++) {
  24172. var dfa = this._interp.decisionToDFA[i];
  24173. if (dfa.states.length > 0) {
  24174. if (seenOne) {
  24175. console.log();
  24176. }
  24177. this.printer.println("Decision " + dfa.decision + ":");
  24178. this.printer.print(dfa.toString(this.literalNames, this.symbolicNames));
  24179. seenOne = true;
  24180. }
  24181. }
  24182. };
  24183. /*
  24184. " printer = function() {\r\n" +
  24185. " this.println = function(s) { document.getElementById('output') += s + '\\n'; }\r\n" +
  24186. " this.print = function(s) { document.getElementById('output') += s; }\r\n" +
  24187. " };\r\n" +
  24188. */
  24189. Parser.prototype.getSourceName = function () {
  24190. return this._input.sourceName;
  24191. };
  24192. // During a parse is sometimes useful to listen in on the rule entry and exit
  24193. // events as well as token matches. this is for quick and dirty debugging.
  24194. //
  24195. Parser.prototype.setTrace = function (trace) {
  24196. if (!trace) {
  24197. this.removeParseListener(this._tracer);
  24198. this._tracer = null;
  24199. } else {
  24200. if (this._tracer !== null) {
  24201. this.removeParseListener(this._tracer);
  24202. }
  24203. this._tracer = new TraceListener(this);
  24204. this.addParseListener(this._tracer);
  24205. }
  24206. };
  24207. exports.Parser = Parser;
  24208. /***/ }),
  24209. /***/ "./node_modules/antlr4/ParserRuleContext.js":
  24210. /*!**************************************************!*\
  24211. !*** ./node_modules/antlr4/ParserRuleContext.js ***!
  24212. \**************************************************/
  24213. /*! no static exports found */
  24214. /***/ (function(module, exports, __webpack_require__) {
  24215. "use strict";
  24216. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  24217. * Use of this file is governed by the BSD 3-clause license that
  24218. * can be found in the LICENSE.txt file in the project root.
  24219. */
  24220. //* A rule invocation record for parsing.
  24221. //
  24222. // Contains all of the information about the current rule not stored in the
  24223. // RuleContext. It handles parse tree children list, Any ATN state
  24224. // tracing, and the default values available for rule indications:
  24225. // start, stop, rule index, current alt number, current
  24226. // ATN state.
  24227. //
  24228. // Subclasses made for each rule and grammar track the parameters,
  24229. // return values, locals, and labels specific to that rule. These
  24230. // are the objects that are returned from rules.
  24231. //
  24232. // Note text is not an actual field of a rule return value; it is computed
  24233. // from start and stop using the input stream's toString() method. I
  24234. // could add a ctor to this so that we can pass in and store the input
  24235. // stream, but I'm not sure we want to do that. It would seem to be undefined
  24236. // to get the .text property anyway if the rule matches tokens from multiple
  24237. // input streams.
  24238. //
  24239. // I do not use getters for fields of objects that are used simply to
  24240. // group values such as this aggregate. The getters/setters are there to
  24241. // satisfy the superclass interface.
  24242. var RuleContext = __webpack_require__(/*! ./RuleContext */ "./node_modules/antlr4/RuleContext.js").RuleContext;
  24243. var Tree = __webpack_require__(/*! ./tree/Tree */ "./node_modules/antlr4/tree/Tree.js");
  24244. var INVALID_INTERVAL = Tree.INVALID_INTERVAL;
  24245. var TerminalNode = Tree.TerminalNode;
  24246. var TerminalNodeImpl = Tree.TerminalNodeImpl;
  24247. var ErrorNodeImpl = Tree.ErrorNodeImpl;
  24248. var Interval = __webpack_require__(/*! ./IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  24249. function ParserRuleContext(parent, invokingStateNumber) {
  24250. parent = parent || null;
  24251. invokingStateNumber = invokingStateNumber || null;
  24252. RuleContext.call(this, parent, invokingStateNumber);
  24253. this.ruleIndex = -1;
  24254. // * If we are debugging or building a parse tree for a visitor,
  24255. // we need to track all of the tokens and rule invocations associated
  24256. // with this rule's context. This is empty for parsing w/o tree constr.
  24257. // operation because we don't the need to track the details about
  24258. // how we parse this rule.
  24259. // /
  24260. this.children = null;
  24261. this.start = null;
  24262. this.stop = null;
  24263. // The exception that forced this rule to return. If the rule successfully
  24264. // completed, this is {@code null}.
  24265. this.exception = null;
  24266. }
  24267. ParserRuleContext.prototype = Object.create(RuleContext.prototype);
  24268. ParserRuleContext.prototype.constructor = ParserRuleContext;
  24269. // * COPY a ctx (I'm deliberately not using copy constructor)///
  24270. ParserRuleContext.prototype.copyFrom = function (ctx) {
  24271. // from RuleContext
  24272. this.parentCtx = ctx.parentCtx;
  24273. this.invokingState = ctx.invokingState;
  24274. this.children = null;
  24275. this.start = ctx.start;
  24276. this.stop = ctx.stop;
  24277. // copy any error nodes to alt label node
  24278. if (ctx.children) {
  24279. this.children = [];
  24280. // reset parent pointer for any error nodes
  24281. ctx.children.map(function (child) {
  24282. if (child instanceof ErrorNodeImpl) {
  24283. this.children.push(child);
  24284. child.parentCtx = this;
  24285. }
  24286. }, this);
  24287. }
  24288. };
  24289. // Double dispatch methods for listeners
  24290. ParserRuleContext.prototype.enterRule = function (listener) {};
  24291. ParserRuleContext.prototype.exitRule = function (listener) {};
  24292. // * Does not set parent link; other add methods do that///
  24293. ParserRuleContext.prototype.addChild = function (child) {
  24294. if (this.children === null) {
  24295. this.children = [];
  24296. }
  24297. this.children.push(child);
  24298. return child;
  24299. };
  24300. // * Used by enterOuterAlt to toss out a RuleContext previously added as
  24301. // we entered a rule. If we have // label, we will need to remove
  24302. // generic ruleContext object.
  24303. // /
  24304. ParserRuleContext.prototype.removeLastChild = function () {
  24305. if (this.children !== null) {
  24306. this.children.pop();
  24307. }
  24308. };
  24309. ParserRuleContext.prototype.addTokenNode = function (token) {
  24310. var node = new TerminalNodeImpl(token);
  24311. this.addChild(node);
  24312. node.parentCtx = this;
  24313. return node;
  24314. };
  24315. ParserRuleContext.prototype.addErrorNode = function (badToken) {
  24316. var node = new ErrorNodeImpl(badToken);
  24317. this.addChild(node);
  24318. node.parentCtx = this;
  24319. return node;
  24320. };
  24321. ParserRuleContext.prototype.getChild = function (i, type) {
  24322. type = type || null;
  24323. if (this.children === null || i < 0 || i >= this.children.length) {
  24324. return null;
  24325. }
  24326. if (type === null) {
  24327. return this.children[i];
  24328. } else {
  24329. for (var j = 0; j < this.children.length; j++) {
  24330. var child = this.children[j];
  24331. if (child instanceof type) {
  24332. if (i === 0) {
  24333. return child;
  24334. } else {
  24335. i -= 1;
  24336. }
  24337. }
  24338. }
  24339. return null;
  24340. }
  24341. };
  24342. ParserRuleContext.prototype.getToken = function (ttype, i) {
  24343. if (this.children === null || i < 0 || i >= this.children.length) {
  24344. return null;
  24345. }
  24346. for (var j = 0; j < this.children.length; j++) {
  24347. var child = this.children[j];
  24348. if (child instanceof TerminalNode) {
  24349. if (child.symbol.type === ttype) {
  24350. if (i === 0) {
  24351. return child;
  24352. } else {
  24353. i -= 1;
  24354. }
  24355. }
  24356. }
  24357. }
  24358. return null;
  24359. };
  24360. ParserRuleContext.prototype.getTokens = function (ttype) {
  24361. if (this.children === null) {
  24362. return [];
  24363. } else {
  24364. var tokens = [];
  24365. for (var j = 0; j < this.children.length; j++) {
  24366. var child = this.children[j];
  24367. if (child instanceof TerminalNode) {
  24368. if (child.symbol.type === ttype) {
  24369. tokens.push(child);
  24370. }
  24371. }
  24372. }
  24373. return tokens;
  24374. }
  24375. };
  24376. ParserRuleContext.prototype.getTypedRuleContext = function (ctxType, i) {
  24377. return this.getChild(i, ctxType);
  24378. };
  24379. ParserRuleContext.prototype.getTypedRuleContexts = function (ctxType) {
  24380. if (this.children === null) {
  24381. return [];
  24382. } else {
  24383. var contexts = [];
  24384. for (var j = 0; j < this.children.length; j++) {
  24385. var child = this.children[j];
  24386. if (child instanceof ctxType) {
  24387. contexts.push(child);
  24388. }
  24389. }
  24390. return contexts;
  24391. }
  24392. };
  24393. ParserRuleContext.prototype.getChildCount = function () {
  24394. if (this.children === null) {
  24395. return 0;
  24396. } else {
  24397. return this.children.length;
  24398. }
  24399. };
  24400. ParserRuleContext.prototype.getSourceInterval = function () {
  24401. if (this.start === null || this.stop === null) {
  24402. return INVALID_INTERVAL;
  24403. } else {
  24404. return new Interval(this.start.tokenIndex, this.stop.tokenIndex);
  24405. }
  24406. };
  24407. RuleContext.EMPTY = new ParserRuleContext();
  24408. function InterpreterRuleContext(parent, invokingStateNumber, ruleIndex) {
  24409. ParserRuleContext.call(parent, invokingStateNumber);
  24410. this.ruleIndex = ruleIndex;
  24411. return this;
  24412. }
  24413. InterpreterRuleContext.prototype = Object.create(ParserRuleContext.prototype);
  24414. InterpreterRuleContext.prototype.constructor = InterpreterRuleContext;
  24415. exports.ParserRuleContext = ParserRuleContext;
  24416. /***/ }),
  24417. /***/ "./node_modules/antlr4/PredictionContext.js":
  24418. /*!**************************************************!*\
  24419. !*** ./node_modules/antlr4/PredictionContext.js ***!
  24420. \**************************************************/
  24421. /*! no static exports found */
  24422. /***/ (function(module, exports, __webpack_require__) {
  24423. "use strict";
  24424. //
  24425. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  24426. * Use of this file is governed by the BSD 3-clause license that
  24427. * can be found in the LICENSE.txt file in the project root.
  24428. */
  24429. ///
  24430. var RuleContext = __webpack_require__(/*! ./RuleContext */ "./node_modules/antlr4/RuleContext.js").RuleContext;
  24431. var Hash = __webpack_require__(/*! ./Utils */ "./node_modules/antlr4/Utils.js").Hash;
  24432. function PredictionContext(cachedHashCode) {
  24433. this.cachedHashCode = cachedHashCode;
  24434. }
  24435. // Represents {@code $} in local context prediction, which means wildcard.
  24436. // {@code//+x =//}.
  24437. // /
  24438. PredictionContext.EMPTY = null;
  24439. // Represents {@code $} in an array in full context mode, when {@code $}
  24440. // doesn't mean wildcard: {@code $ + x = [$,x]}. Here,
  24441. // {@code $} = {@link //EMPTY_RETURN_STATE}.
  24442. // /
  24443. PredictionContext.EMPTY_RETURN_STATE = 0x7FFFFFFF;
  24444. PredictionContext.globalNodeCount = 1;
  24445. PredictionContext.id = PredictionContext.globalNodeCount;
  24446. // Stores the computed hash code of this {@link PredictionContext}. The hash
  24447. // code is computed in parts to match the following reference algorithm.
  24448. //
  24449. // <pre>
  24450. // private int referenceHashCode() {
  24451. // int hash = {@link MurmurHash//initialize MurmurHash.initialize}({@link
  24452. // //INITIAL_HASH});
  24453. //
  24454. // for (int i = 0; i &lt; {@link //size()}; i++) {
  24455. // hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link //getParent
  24456. // getParent}(i));
  24457. // }
  24458. //
  24459. // for (int i = 0; i &lt; {@link //size()}; i++) {
  24460. // hash = {@link MurmurHash//update MurmurHash.update}(hash, {@link
  24461. // //getReturnState getReturnState}(i));
  24462. // }
  24463. //
  24464. // hash = {@link MurmurHash//finish MurmurHash.finish}(hash, 2// {@link
  24465. // //size()});
  24466. // return hash;
  24467. // }
  24468. // </pre>
  24469. // /
  24470. // This means only the {@link //EMPTY} context is in set.
  24471. PredictionContext.prototype.isEmpty = function () {
  24472. return this === PredictionContext.EMPTY;
  24473. };
  24474. PredictionContext.prototype.hasEmptyPath = function () {
  24475. return this.getReturnState(this.length - 1) === PredictionContext.EMPTY_RETURN_STATE;
  24476. };
  24477. PredictionContext.prototype.hashCode = function () {
  24478. return this.cachedHashCode;
  24479. };
  24480. PredictionContext.prototype.updateHashCode = function (hash) {
  24481. hash.update(this.cachedHashCode);
  24482. };
  24483. /*
  24484. function calculateHashString(parent, returnState) {
  24485. return "" + parent + returnState;
  24486. }
  24487. */
  24488. // Used to cache {@link PredictionContext} objects. Its used for the shared
  24489. // context cash associated with contexts in DFA states. This cache
  24490. // can be used for both lexers and parsers.
  24491. function PredictionContextCache() {
  24492. this.cache = {};
  24493. return this;
  24494. }
  24495. // Add a context to the cache and return it. If the context already exists,
  24496. // return that one instead and do not add a new context to the cache.
  24497. // Protect shared cache from unsafe thread access.
  24498. //
  24499. PredictionContextCache.prototype.add = function (ctx) {
  24500. if (ctx === PredictionContext.EMPTY) {
  24501. return PredictionContext.EMPTY;
  24502. }
  24503. var existing = this.cache[ctx] || null;
  24504. if (existing !== null) {
  24505. return existing;
  24506. }
  24507. this.cache[ctx] = ctx;
  24508. return ctx;
  24509. };
  24510. PredictionContextCache.prototype.get = function (ctx) {
  24511. return this.cache[ctx] || null;
  24512. };
  24513. Object.defineProperty(PredictionContextCache.prototype, "length", {
  24514. get: function get() {
  24515. return this.cache.length;
  24516. }
  24517. });
  24518. function SingletonPredictionContext(parent, returnState) {
  24519. var hashCode = 0;
  24520. if (parent !== null) {
  24521. var hash = new Hash();
  24522. hash.update(parent, returnState);
  24523. hashCode = hash.finish();
  24524. }
  24525. PredictionContext.call(this, hashCode);
  24526. this.parentCtx = parent;
  24527. this.returnState = returnState;
  24528. }
  24529. SingletonPredictionContext.prototype = Object.create(PredictionContext.prototype);
  24530. SingletonPredictionContext.prototype.contructor = SingletonPredictionContext;
  24531. SingletonPredictionContext.create = function (parent, returnState) {
  24532. if (returnState === PredictionContext.EMPTY_RETURN_STATE && parent === null) {
  24533. // someone can pass in the bits of an array ctx that mean $
  24534. return PredictionContext.EMPTY;
  24535. } else {
  24536. return new SingletonPredictionContext(parent, returnState);
  24537. }
  24538. };
  24539. Object.defineProperty(SingletonPredictionContext.prototype, "length", {
  24540. get: function get() {
  24541. return 1;
  24542. }
  24543. });
  24544. SingletonPredictionContext.prototype.getParent = function (index) {
  24545. return this.parentCtx;
  24546. };
  24547. SingletonPredictionContext.prototype.getReturnState = function (index) {
  24548. return this.returnState;
  24549. };
  24550. SingletonPredictionContext.prototype.equals = function (other) {
  24551. if (this === other) {
  24552. return true;
  24553. } else if (!(other instanceof SingletonPredictionContext)) {
  24554. return false;
  24555. } else if (this.hashCode() !== other.hashCode()) {
  24556. return false; // can't be same if hash is different
  24557. } else {
  24558. if (this.returnState !== other.returnState) return false;else if (this.parentCtx == null) return other.parentCtx == null;else return this.parentCtx.equals(other.parentCtx);
  24559. }
  24560. };
  24561. SingletonPredictionContext.prototype.toString = function () {
  24562. var up = this.parentCtx === null ? "" : this.parentCtx.toString();
  24563. if (up.length === 0) {
  24564. if (this.returnState === PredictionContext.EMPTY_RETURN_STATE) {
  24565. return "$";
  24566. } else {
  24567. return "" + this.returnState;
  24568. }
  24569. } else {
  24570. return "" + this.returnState + " " + up;
  24571. }
  24572. };
  24573. function EmptyPredictionContext() {
  24574. SingletonPredictionContext.call(this, null, PredictionContext.EMPTY_RETURN_STATE);
  24575. return this;
  24576. }
  24577. EmptyPredictionContext.prototype = Object.create(SingletonPredictionContext.prototype);
  24578. EmptyPredictionContext.prototype.constructor = EmptyPredictionContext;
  24579. EmptyPredictionContext.prototype.isEmpty = function () {
  24580. return true;
  24581. };
  24582. EmptyPredictionContext.prototype.getParent = function (index) {
  24583. return null;
  24584. };
  24585. EmptyPredictionContext.prototype.getReturnState = function (index) {
  24586. return this.returnState;
  24587. };
  24588. EmptyPredictionContext.prototype.equals = function (other) {
  24589. return this === other;
  24590. };
  24591. EmptyPredictionContext.prototype.toString = function () {
  24592. return "$";
  24593. };
  24594. PredictionContext.EMPTY = new EmptyPredictionContext();
  24595. function ArrayPredictionContext(parents, returnStates) {
  24596. // Parent can be null only if full ctx mode and we make an array
  24597. // from {@link //EMPTY} and non-empty. We merge {@link //EMPTY} by using
  24598. // null parent and
  24599. // returnState == {@link //EMPTY_RETURN_STATE}.
  24600. var h = new Hash();
  24601. h.update(parents, returnStates);
  24602. var hashCode = h.finish();
  24603. PredictionContext.call(this, hashCode);
  24604. this.parents = parents;
  24605. this.returnStates = returnStates;
  24606. return this;
  24607. }
  24608. ArrayPredictionContext.prototype = Object.create(PredictionContext.prototype);
  24609. ArrayPredictionContext.prototype.constructor = ArrayPredictionContext;
  24610. ArrayPredictionContext.prototype.isEmpty = function () {
  24611. // since EMPTY_RETURN_STATE can only appear in the last position, we
  24612. // don't need to verify that size==1
  24613. return this.returnStates[0] === PredictionContext.EMPTY_RETURN_STATE;
  24614. };
  24615. Object.defineProperty(ArrayPredictionContext.prototype, "length", {
  24616. get: function get() {
  24617. return this.returnStates.length;
  24618. }
  24619. });
  24620. ArrayPredictionContext.prototype.getParent = function (index) {
  24621. return this.parents[index];
  24622. };
  24623. ArrayPredictionContext.prototype.getReturnState = function (index) {
  24624. return this.returnStates[index];
  24625. };
  24626. ArrayPredictionContext.prototype.equals = function (other) {
  24627. if (this === other) {
  24628. return true;
  24629. } else if (!(other instanceof ArrayPredictionContext)) {
  24630. return false;
  24631. } else if (this.hashCode() !== other.hashCode()) {
  24632. return false; // can't be same if hash is different
  24633. } else {
  24634. return this.returnStates === other.returnStates && this.parents === other.parents;
  24635. }
  24636. };
  24637. ArrayPredictionContext.prototype.toString = function () {
  24638. if (this.isEmpty()) {
  24639. return "[]";
  24640. } else {
  24641. var s = "[";
  24642. for (var i = 0; i < this.returnStates.length; i++) {
  24643. if (i > 0) {
  24644. s = s + ", ";
  24645. }
  24646. if (this.returnStates[i] === PredictionContext.EMPTY_RETURN_STATE) {
  24647. s = s + "$";
  24648. continue;
  24649. }
  24650. s = s + this.returnStates[i];
  24651. if (this.parents[i] !== null) {
  24652. s = s + " " + this.parents[i];
  24653. } else {
  24654. s = s + "null";
  24655. }
  24656. }
  24657. return s + "]";
  24658. }
  24659. };
  24660. // Convert a {@link RuleContext} tree to a {@link PredictionContext} graph.
  24661. // Return {@link //EMPTY} if {@code outerContext} is empty or null.
  24662. // /
  24663. function predictionContextFromRuleContext(atn, outerContext) {
  24664. if (outerContext === undefined || outerContext === null) {
  24665. outerContext = RuleContext.EMPTY;
  24666. }
  24667. // if we are in RuleContext of start rule, s, then PredictionContext
  24668. // is EMPTY. Nobody called us. (if we are empty, return empty)
  24669. if (outerContext.parentCtx === null || outerContext === RuleContext.EMPTY) {
  24670. return PredictionContext.EMPTY;
  24671. }
  24672. // If we have a parent, convert it to a PredictionContext graph
  24673. var parent = predictionContextFromRuleContext(atn, outerContext.parentCtx);
  24674. var state = atn.states[outerContext.invokingState];
  24675. var transition = state.transitions[0];
  24676. return SingletonPredictionContext.create(parent, transition.followState.stateNumber);
  24677. }
  24678. /*
  24679. function calculateListsHashString(parents, returnStates) {
  24680. var s = "";
  24681. parents.map(function(p) {
  24682. s = s + p;
  24683. });
  24684. returnStates.map(function(r) {
  24685. s = s + r;
  24686. });
  24687. return s;
  24688. }
  24689. */
  24690. function merge(a, b, rootIsWildcard, mergeCache) {
  24691. // share same graph if both same
  24692. if (a === b) {
  24693. return a;
  24694. }
  24695. if (a instanceof SingletonPredictionContext && b instanceof SingletonPredictionContext) {
  24696. return mergeSingletons(a, b, rootIsWildcard, mergeCache);
  24697. }
  24698. // At least one of a or b is array
  24699. // If one is $ and rootIsWildcard, return $ as// wildcard
  24700. if (rootIsWildcard) {
  24701. if (a instanceof EmptyPredictionContext) {
  24702. return a;
  24703. }
  24704. if (b instanceof EmptyPredictionContext) {
  24705. return b;
  24706. }
  24707. }
  24708. // convert singleton so both are arrays to normalize
  24709. if (a instanceof SingletonPredictionContext) {
  24710. a = new ArrayPredictionContext([a.getParent()], [a.returnState]);
  24711. }
  24712. if (b instanceof SingletonPredictionContext) {
  24713. b = new ArrayPredictionContext([b.getParent()], [b.returnState]);
  24714. }
  24715. return mergeArrays(a, b, rootIsWildcard, mergeCache);
  24716. }
  24717. //
  24718. // Merge two {@link SingletonPredictionContext} instances.
  24719. //
  24720. // <p>Stack tops equal, parents merge is same; return left graph.<br>
  24721. // <embed src="images/SingletonMerge_SameRootSamePar.svg"
  24722. // type="image/svg+xml"/></p>
  24723. //
  24724. // <p>Same stack top, parents differ; merge parents giving array node, then
  24725. // remainders of those graphs. A new root node is created to point to the
  24726. // merged parents.<br>
  24727. // <embed src="images/SingletonMerge_SameRootDiffPar.svg"
  24728. // type="image/svg+xml"/></p>
  24729. //
  24730. // <p>Different stack tops pointing to same parent. Make array node for the
  24731. // root where both element in the root point to the same (original)
  24732. // parent.<br>
  24733. // <embed src="images/SingletonMerge_DiffRootSamePar.svg"
  24734. // type="image/svg+xml"/></p>
  24735. //
  24736. // <p>Different stack tops pointing to different parents. Make array node for
  24737. // the root where each element points to the corresponding original
  24738. // parent.<br>
  24739. // <embed src="images/SingletonMerge_DiffRootDiffPar.svg"
  24740. // type="image/svg+xml"/></p>
  24741. //
  24742. // @param a the first {@link SingletonPredictionContext}
  24743. // @param b the second {@link SingletonPredictionContext}
  24744. // @param rootIsWildcard {@code true} if this is a local-context merge,
  24745. // otherwise false to indicate a full-context merge
  24746. // @param mergeCache
  24747. // /
  24748. function mergeSingletons(a, b, rootIsWildcard, mergeCache) {
  24749. if (mergeCache !== null) {
  24750. var previous = mergeCache.get(a, b);
  24751. if (previous !== null) {
  24752. return previous;
  24753. }
  24754. previous = mergeCache.get(b, a);
  24755. if (previous !== null) {
  24756. return previous;
  24757. }
  24758. }
  24759. var rootMerge = mergeRoot(a, b, rootIsWildcard);
  24760. if (rootMerge !== null) {
  24761. if (mergeCache !== null) {
  24762. mergeCache.set(a, b, rootMerge);
  24763. }
  24764. return rootMerge;
  24765. }
  24766. if (a.returnState === b.returnState) {
  24767. var parent = merge(a.parentCtx, b.parentCtx, rootIsWildcard, mergeCache);
  24768. // if parent is same as existing a or b parent or reduced to a parent,
  24769. // return it
  24770. if (parent === a.parentCtx) {
  24771. return a; // ax + bx = ax, if a=b
  24772. }
  24773. if (parent === b.parentCtx) {
  24774. return b; // ax + bx = bx, if a=b
  24775. }
  24776. // else: ax + ay = a'[x,y]
  24777. // merge parents x and y, giving array node with x,y then remainders
  24778. // of those graphs. dup a, a' points at merged array
  24779. // new joined parent so create new singleton pointing to it, a'
  24780. var spc = SingletonPredictionContext.create(parent, a.returnState);
  24781. if (mergeCache !== null) {
  24782. mergeCache.set(a, b, spc);
  24783. }
  24784. return spc;
  24785. } else {
  24786. // a != b payloads differ
  24787. // see if we can collapse parents due to $+x parents if local ctx
  24788. var singleParent = null;
  24789. if (a === b || a.parentCtx !== null && a.parentCtx === b.parentCtx) {
  24790. // ax +
  24791. // bx =
  24792. // [a,b]x
  24793. singleParent = a.parentCtx;
  24794. }
  24795. if (singleParent !== null) {
  24796. // parents are same
  24797. // sort payloads and use same parent
  24798. var payloads = [a.returnState, b.returnState];
  24799. if (a.returnState > b.returnState) {
  24800. payloads[0] = b.returnState;
  24801. payloads[1] = a.returnState;
  24802. }
  24803. var parents = [singleParent, singleParent];
  24804. var apc = new ArrayPredictionContext(parents, payloads);
  24805. if (mergeCache !== null) {
  24806. mergeCache.set(a, b, apc);
  24807. }
  24808. return apc;
  24809. }
  24810. // parents differ and can't merge them. Just pack together
  24811. // into array; can't merge.
  24812. // ax + by = [ax,by]
  24813. var payloads = [a.returnState, b.returnState];
  24814. var parents = [a.parentCtx, b.parentCtx];
  24815. if (a.returnState > b.returnState) {
  24816. // sort by payload
  24817. payloads[0] = b.returnState;
  24818. payloads[1] = a.returnState;
  24819. parents = [b.parentCtx, a.parentCtx];
  24820. }
  24821. var a_ = new ArrayPredictionContext(parents, payloads);
  24822. if (mergeCache !== null) {
  24823. mergeCache.set(a, b, a_);
  24824. }
  24825. return a_;
  24826. }
  24827. }
  24828. //
  24829. // Handle case where at least one of {@code a} or {@code b} is
  24830. // {@link //EMPTY}. In the following diagrams, the symbol {@code $} is used
  24831. // to represent {@link //EMPTY}.
  24832. //
  24833. // <h2>Local-Context Merges</h2>
  24834. //
  24835. // <p>These local-context merge operations are used when {@code rootIsWildcard}
  24836. // is true.</p>
  24837. //
  24838. // <p>{@link //EMPTY} is superset of any graph; return {@link //EMPTY}.<br>
  24839. // <embed src="images/LocalMerge_EmptyRoot.svg" type="image/svg+xml"/></p>
  24840. //
  24841. // <p>{@link //EMPTY} and anything is {@code //EMPTY}, so merged parent is
  24842. // {@code //EMPTY}; return left graph.<br>
  24843. // <embed src="images/LocalMerge_EmptyParent.svg" type="image/svg+xml"/></p>
  24844. //
  24845. // <p>Special case of last merge if local context.<br>
  24846. // <embed src="images/LocalMerge_DiffRoots.svg" type="image/svg+xml"/></p>
  24847. //
  24848. // <h2>Full-Context Merges</h2>
  24849. //
  24850. // <p>These full-context merge operations are used when {@code rootIsWildcard}
  24851. // is false.</p>
  24852. //
  24853. // <p><embed src="images/FullMerge_EmptyRoots.svg" type="image/svg+xml"/></p>
  24854. //
  24855. // <p>Must keep all contexts; {@link //EMPTY} in array is a special value (and
  24856. // null parent).<br>
  24857. // <embed src="images/FullMerge_EmptyRoot.svg" type="image/svg+xml"/></p>
  24858. //
  24859. // <p><embed src="images/FullMerge_SameRoot.svg" type="image/svg+xml"/></p>
  24860. //
  24861. // @param a the first {@link SingletonPredictionContext}
  24862. // @param b the second {@link SingletonPredictionContext}
  24863. // @param rootIsWildcard {@code true} if this is a local-context merge,
  24864. // otherwise false to indicate a full-context merge
  24865. // /
  24866. function mergeRoot(a, b, rootIsWildcard) {
  24867. if (rootIsWildcard) {
  24868. if (a === PredictionContext.EMPTY) {
  24869. return PredictionContext.EMPTY; // // + b =//
  24870. }
  24871. if (b === PredictionContext.EMPTY) {
  24872. return PredictionContext.EMPTY; // a +// =//
  24873. }
  24874. } else {
  24875. if (a === PredictionContext.EMPTY && b === PredictionContext.EMPTY) {
  24876. return PredictionContext.EMPTY; // $ + $ = $
  24877. } else if (a === PredictionContext.EMPTY) {
  24878. // $ + x = [$,x]
  24879. var payloads = [b.returnState, PredictionContext.EMPTY_RETURN_STATE];
  24880. var parents = [b.parentCtx, null];
  24881. return new ArrayPredictionContext(parents, payloads);
  24882. } else if (b === PredictionContext.EMPTY) {
  24883. // x + $ = [$,x] ($ is always first if present)
  24884. var payloads = [a.returnState, PredictionContext.EMPTY_RETURN_STATE];
  24885. var parents = [a.parentCtx, null];
  24886. return new ArrayPredictionContext(parents, payloads);
  24887. }
  24888. }
  24889. return null;
  24890. }
  24891. //
  24892. // Merge two {@link ArrayPredictionContext} instances.
  24893. //
  24894. // <p>Different tops, different parents.<br>
  24895. // <embed src="images/ArrayMerge_DiffTopDiffPar.svg" type="image/svg+xml"/></p>
  24896. //
  24897. // <p>Shared top, same parents.<br>
  24898. // <embed src="images/ArrayMerge_ShareTopSamePar.svg" type="image/svg+xml"/></p>
  24899. //
  24900. // <p>Shared top, different parents.<br>
  24901. // <embed src="images/ArrayMerge_ShareTopDiffPar.svg" type="image/svg+xml"/></p>
  24902. //
  24903. // <p>Shared top, all shared parents.<br>
  24904. // <embed src="images/ArrayMerge_ShareTopSharePar.svg"
  24905. // type="image/svg+xml"/></p>
  24906. //
  24907. // <p>Equal tops, merge parents and reduce top to
  24908. // {@link SingletonPredictionContext}.<br>
  24909. // <embed src="images/ArrayMerge_EqualTop.svg" type="image/svg+xml"/></p>
  24910. // /
  24911. function mergeArrays(a, b, rootIsWildcard, mergeCache) {
  24912. if (mergeCache !== null) {
  24913. var previous = mergeCache.get(a, b);
  24914. if (previous !== null) {
  24915. return previous;
  24916. }
  24917. previous = mergeCache.get(b, a);
  24918. if (previous !== null) {
  24919. return previous;
  24920. }
  24921. }
  24922. // merge sorted payloads a + b => M
  24923. var i = 0; // walks a
  24924. var j = 0; // walks b
  24925. var k = 0; // walks target M array
  24926. var mergedReturnStates = [];
  24927. var mergedParents = [];
  24928. // walk and merge to yield mergedParents, mergedReturnStates
  24929. while (i < a.returnStates.length && j < b.returnStates.length) {
  24930. var a_parent = a.parents[i];
  24931. var b_parent = b.parents[j];
  24932. if (a.returnStates[i] === b.returnStates[j]) {
  24933. // same payload (stack tops are equal), must yield merged singleton
  24934. var payload = a.returnStates[i];
  24935. // $+$ = $
  24936. var bothDollars = payload === PredictionContext.EMPTY_RETURN_STATE && a_parent === null && b_parent === null;
  24937. var ax_ax = a_parent !== null && b_parent !== null && a_parent === b_parent; // ax+ax
  24938. // ->
  24939. // ax
  24940. if (bothDollars || ax_ax) {
  24941. mergedParents[k] = a_parent; // choose left
  24942. mergedReturnStates[k] = payload;
  24943. } else {
  24944. // ax+ay -> a'[x,y]
  24945. var mergedParent = merge(a_parent, b_parent, rootIsWildcard, mergeCache);
  24946. mergedParents[k] = mergedParent;
  24947. mergedReturnStates[k] = payload;
  24948. }
  24949. i += 1; // hop over left one as usual
  24950. j += 1; // but also skip one in right side since we merge
  24951. } else if (a.returnStates[i] < b.returnStates[j]) {
  24952. // copy a[i] to M
  24953. mergedParents[k] = a_parent;
  24954. mergedReturnStates[k] = a.returnStates[i];
  24955. i += 1;
  24956. } else {
  24957. // b > a, copy b[j] to M
  24958. mergedParents[k] = b_parent;
  24959. mergedReturnStates[k] = b.returnStates[j];
  24960. j += 1;
  24961. }
  24962. k += 1;
  24963. }
  24964. // copy over any payloads remaining in either array
  24965. if (i < a.returnStates.length) {
  24966. for (var p = i; p < a.returnStates.length; p++) {
  24967. mergedParents[k] = a.parents[p];
  24968. mergedReturnStates[k] = a.returnStates[p];
  24969. k += 1;
  24970. }
  24971. } else {
  24972. for (var p = j; p < b.returnStates.length; p++) {
  24973. mergedParents[k] = b.parents[p];
  24974. mergedReturnStates[k] = b.returnStates[p];
  24975. k += 1;
  24976. }
  24977. }
  24978. // trim merged if we combined a few that had same stack tops
  24979. if (k < mergedParents.length) {
  24980. // write index < last position; trim
  24981. if (k === 1) {
  24982. // for just one merged element, return singleton top
  24983. var a_ = SingletonPredictionContext.create(mergedParents[0], mergedReturnStates[0]);
  24984. if (mergeCache !== null) {
  24985. mergeCache.set(a, b, a_);
  24986. }
  24987. return a_;
  24988. }
  24989. mergedParents = mergedParents.slice(0, k);
  24990. mergedReturnStates = mergedReturnStates.slice(0, k);
  24991. }
  24992. var M = new ArrayPredictionContext(mergedParents, mergedReturnStates);
  24993. // if we created same array as a or b, return that instead
  24994. // TODO: track whether this is possible above during merge sort for speed
  24995. if (M === a) {
  24996. if (mergeCache !== null) {
  24997. mergeCache.set(a, b, a);
  24998. }
  24999. return a;
  25000. }
  25001. if (M === b) {
  25002. if (mergeCache !== null) {
  25003. mergeCache.set(a, b, b);
  25004. }
  25005. return b;
  25006. }
  25007. combineCommonParents(mergedParents);
  25008. if (mergeCache !== null) {
  25009. mergeCache.set(a, b, M);
  25010. }
  25011. return M;
  25012. }
  25013. //
  25014. // Make pass over all <em>M</em> {@code parents}; merge any {@code equals()}
  25015. // ones.
  25016. // /
  25017. function combineCommonParents(parents) {
  25018. var uniqueParents = {};
  25019. for (var p = 0; p < parents.length; p++) {
  25020. var parent = parents[p];
  25021. if (!(parent in uniqueParents)) {
  25022. uniqueParents[parent] = parent;
  25023. }
  25024. }
  25025. for (var q = 0; q < parents.length; q++) {
  25026. parents[q] = uniqueParents[parents[q]];
  25027. }
  25028. }
  25029. function getCachedPredictionContext(context, contextCache, visited) {
  25030. if (context.isEmpty()) {
  25031. return context;
  25032. }
  25033. var existing = visited[context] || null;
  25034. if (existing !== null) {
  25035. return existing;
  25036. }
  25037. existing = contextCache.get(context);
  25038. if (existing !== null) {
  25039. visited[context] = existing;
  25040. return existing;
  25041. }
  25042. var changed = false;
  25043. var parents = [];
  25044. for (var i = 0; i < parents.length; i++) {
  25045. var parent = getCachedPredictionContext(context.getParent(i), contextCache, visited);
  25046. if (changed || parent !== context.getParent(i)) {
  25047. if (!changed) {
  25048. parents = [];
  25049. for (var j = 0; j < context.length; j++) {
  25050. parents[j] = context.getParent(j);
  25051. }
  25052. changed = true;
  25053. }
  25054. parents[i] = parent;
  25055. }
  25056. }
  25057. if (!changed) {
  25058. contextCache.add(context);
  25059. visited[context] = context;
  25060. return context;
  25061. }
  25062. var updated = null;
  25063. if (parents.length === 0) {
  25064. updated = PredictionContext.EMPTY;
  25065. } else if (parents.length === 1) {
  25066. updated = SingletonPredictionContext.create(parents[0], context.getReturnState(0));
  25067. } else {
  25068. updated = new ArrayPredictionContext(parents, context.returnStates);
  25069. }
  25070. contextCache.add(updated);
  25071. visited[updated] = updated;
  25072. visited[context] = updated;
  25073. return updated;
  25074. }
  25075. // ter's recursive version of Sam's getAllNodes()
  25076. function getAllContextNodes(context, nodes, visited) {
  25077. if (nodes === null) {
  25078. nodes = [];
  25079. return getAllContextNodes(context, nodes, visited);
  25080. } else if (visited === null) {
  25081. visited = {};
  25082. return getAllContextNodes(context, nodes, visited);
  25083. } else {
  25084. if (context === null || visited[context] !== null) {
  25085. return nodes;
  25086. }
  25087. visited[context] = context;
  25088. nodes.push(context);
  25089. for (var i = 0; i < context.length; i++) {
  25090. getAllContextNodes(context.getParent(i), nodes, visited);
  25091. }
  25092. return nodes;
  25093. }
  25094. }
  25095. exports.merge = merge;
  25096. exports.PredictionContext = PredictionContext;
  25097. exports.PredictionContextCache = PredictionContextCache;
  25098. exports.SingletonPredictionContext = SingletonPredictionContext;
  25099. exports.predictionContextFromRuleContext = predictionContextFromRuleContext;
  25100. exports.getCachedPredictionContext = getCachedPredictionContext;
  25101. /***/ }),
  25102. /***/ "./node_modules/antlr4/Recognizer.js":
  25103. /*!*******************************************!*\
  25104. !*** ./node_modules/antlr4/Recognizer.js ***!
  25105. \*******************************************/
  25106. /*! no static exports found */
  25107. /***/ (function(module, exports, __webpack_require__) {
  25108. "use strict";
  25109. //
  25110. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  25111. * Use of this file is governed by the BSD 3-clause license that
  25112. * can be found in the LICENSE.txt file in the project root.
  25113. */
  25114. //
  25115. var Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  25116. var ConsoleErrorListener = __webpack_require__(/*! ./error/ErrorListener */ "./node_modules/antlr4/error/ErrorListener.js").ConsoleErrorListener;
  25117. var ProxyErrorListener = __webpack_require__(/*! ./error/ErrorListener */ "./node_modules/antlr4/error/ErrorListener.js").ProxyErrorListener;
  25118. function Recognizer() {
  25119. this._listeners = [ConsoleErrorListener.INSTANCE];
  25120. this._interp = null;
  25121. this._stateNumber = -1;
  25122. return this;
  25123. }
  25124. Recognizer.tokenTypeMapCache = {};
  25125. Recognizer.ruleIndexMapCache = {};
  25126. Recognizer.prototype.checkVersion = function (toolVersion) {
  25127. var runtimeVersion = "4.7.1";
  25128. if (runtimeVersion !== toolVersion) {
  25129. console.log("ANTLR runtime and generated code versions disagree: " + runtimeVersion + "!=" + toolVersion);
  25130. }
  25131. };
  25132. Recognizer.prototype.addErrorListener = function (listener) {
  25133. this._listeners.push(listener);
  25134. };
  25135. Recognizer.prototype.removeErrorListeners = function () {
  25136. this._listeners = [];
  25137. };
  25138. Recognizer.prototype.getTokenTypeMap = function () {
  25139. var tokenNames = this.getTokenNames();
  25140. if (tokenNames === null) {
  25141. throw "The current recognizer does not provide a list of token names.";
  25142. }
  25143. var result = this.tokenTypeMapCache[tokenNames];
  25144. if (result === undefined) {
  25145. result = tokenNames.reduce(function (o, k, i) {
  25146. o[k] = i;
  25147. });
  25148. result.EOF = Token.EOF;
  25149. this.tokenTypeMapCache[tokenNames] = result;
  25150. }
  25151. return result;
  25152. };
  25153. // Get a map from rule names to rule indexes.
  25154. //
  25155. // <p>Used for XPath and tree pattern compilation.</p>
  25156. //
  25157. Recognizer.prototype.getRuleIndexMap = function () {
  25158. var ruleNames = this.ruleNames;
  25159. if (ruleNames === null) {
  25160. throw "The current recognizer does not provide a list of rule names.";
  25161. }
  25162. var result = this.ruleIndexMapCache[ruleNames];
  25163. if (result === undefined) {
  25164. result = ruleNames.reduce(function (o, k, i) {
  25165. o[k] = i;
  25166. });
  25167. this.ruleIndexMapCache[ruleNames] = result;
  25168. }
  25169. return result;
  25170. };
  25171. Recognizer.prototype.getTokenType = function (tokenName) {
  25172. var ttype = this.getTokenTypeMap()[tokenName];
  25173. if (ttype !== undefined) {
  25174. return ttype;
  25175. } else {
  25176. return Token.INVALID_TYPE;
  25177. }
  25178. };
  25179. // What is the error header, normally line/character position information?//
  25180. Recognizer.prototype.getErrorHeader = function (e) {
  25181. var line = e.getOffendingToken().line;
  25182. var column = e.getOffendingToken().column;
  25183. return "line " + line + ":" + column;
  25184. };
  25185. // How should a token be displayed in an error message? The default
  25186. // is to display just the text, but during development you might
  25187. // want to have a lot of information spit out. Override in that case
  25188. // to use t.toString() (which, for CommonToken, dumps everything about
  25189. // the token). This is better than forcing you to override a method in
  25190. // your token objects because you don't have to go modify your lexer
  25191. // so that it creates a new Java type.
  25192. //
  25193. // @deprecated This method is not called by the ANTLR 4 Runtime. Specific
  25194. // implementations of {@link ANTLRErrorStrategy} may provide a similar
  25195. // feature when necessary. For example, see
  25196. // {@link DefaultErrorStrategy//getTokenErrorDisplay}.
  25197. //
  25198. Recognizer.prototype.getTokenErrorDisplay = function (t) {
  25199. if (t === null) {
  25200. return "<no token>";
  25201. }
  25202. var s = t.text;
  25203. if (s === null) {
  25204. if (t.type === Token.EOF) {
  25205. s = "<EOF>";
  25206. } else {
  25207. s = "<" + t.type + ">";
  25208. }
  25209. }
  25210. s = s.replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t");
  25211. return "'" + s + "'";
  25212. };
  25213. Recognizer.prototype.getErrorListenerDispatch = function () {
  25214. return new ProxyErrorListener(this._listeners);
  25215. };
  25216. // subclass needs to override these if there are sempreds or actions
  25217. // that the ATN interp needs to execute
  25218. Recognizer.prototype.sempred = function (localctx, ruleIndex, actionIndex) {
  25219. return true;
  25220. };
  25221. Recognizer.prototype.precpred = function (localctx, precedence) {
  25222. return true;
  25223. };
  25224. //Indicate that the recognizer has changed internal state that is
  25225. //consistent with the ATN state passed in. This way we always know
  25226. //where we are in the ATN as the parser goes along. The rule
  25227. //context objects form a stack that lets us see the stack of
  25228. //invoking rules. Combine this and we have complete ATN
  25229. //configuration information.
  25230. Object.defineProperty(Recognizer.prototype, "state", {
  25231. get: function get() {
  25232. return this._stateNumber;
  25233. },
  25234. set: function set(state) {
  25235. this._stateNumber = state;
  25236. }
  25237. });
  25238. exports.Recognizer = Recognizer;
  25239. /***/ }),
  25240. /***/ "./node_modules/antlr4/RuleContext.js":
  25241. /*!********************************************!*\
  25242. !*** ./node_modules/antlr4/RuleContext.js ***!
  25243. \********************************************/
  25244. /*! no static exports found */
  25245. /***/ (function(module, exports, __webpack_require__) {
  25246. "use strict";
  25247. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  25248. * Use of this file is governed by the BSD 3-clause license that
  25249. * can be found in the LICENSE.txt file in the project root.
  25250. */
  25251. ///
  25252. // A rule context is a record of a single rule invocation. It knows
  25253. // which context invoked it, if any. If there is no parent context, then
  25254. // naturally the invoking state is not valid. The parent link
  25255. // provides a chain upwards from the current rule invocation to the root
  25256. // of the invocation tree, forming a stack. We actually carry no
  25257. // information about the rule associated with this context (except
  25258. // when parsing). We keep only the state number of the invoking state from
  25259. // the ATN submachine that invoked this. Contrast this with the s
  25260. // pointer inside ParserRuleContext that tracks the current state
  25261. // being "executed" for the current rule.
  25262. //
  25263. // The parent contexts are useful for computing lookahead sets and
  25264. // getting error information.
  25265. //
  25266. // These objects are used during parsing and prediction.
  25267. // For the special case of parsers, we use the subclass
  25268. // ParserRuleContext.
  25269. //
  25270. // @see ParserRuleContext
  25271. ///
  25272. var RuleNode = __webpack_require__(/*! ./tree/Tree */ "./node_modules/antlr4/tree/Tree.js").RuleNode;
  25273. var INVALID_INTERVAL = __webpack_require__(/*! ./tree/Tree */ "./node_modules/antlr4/tree/Tree.js").INVALID_INTERVAL;
  25274. var INVALID_ALT_NUMBER = __webpack_require__(/*! ./atn/ATN */ "./node_modules/antlr4/atn/ATN.js").INVALID_ALT_NUMBER;
  25275. function RuleContext(parent, invokingState) {
  25276. RuleNode.call(this);
  25277. // What context invoked this rule?
  25278. this.parentCtx = parent || null;
  25279. // What state invoked the rule associated with this context?
  25280. // The "return address" is the followState of invokingState
  25281. // If parent is null, this should be -1.
  25282. this.invokingState = invokingState || -1;
  25283. return this;
  25284. }
  25285. RuleContext.prototype = Object.create(RuleNode.prototype);
  25286. RuleContext.prototype.constructor = RuleContext;
  25287. RuleContext.prototype.depth = function () {
  25288. var n = 0;
  25289. var p = this;
  25290. while (p !== null) {
  25291. p = p.parentCtx;
  25292. n += 1;
  25293. }
  25294. return n;
  25295. };
  25296. // A context is empty if there is no invoking state; meaning nobody call
  25297. // current context.
  25298. RuleContext.prototype.isEmpty = function () {
  25299. return this.invokingState === -1;
  25300. };
  25301. // satisfy the ParseTree / SyntaxTree interface
  25302. RuleContext.prototype.getSourceInterval = function () {
  25303. return INVALID_INTERVAL;
  25304. };
  25305. RuleContext.prototype.getRuleContext = function () {
  25306. return this;
  25307. };
  25308. RuleContext.prototype.getPayload = function () {
  25309. return this;
  25310. };
  25311. // Return the combined text of all child nodes. This method only considers
  25312. // tokens which have been added to the parse tree.
  25313. // <p>
  25314. // Since tokens on hidden channels (e.g. whitespace or comments) are not
  25315. // added to the parse trees, they will not appear in the output of this
  25316. // method.
  25317. // /
  25318. RuleContext.prototype.getText = function () {
  25319. if (this.getChildCount() === 0) {
  25320. return "";
  25321. } else {
  25322. return this.children.map(function (child) {
  25323. return child.getText();
  25324. }).join("");
  25325. }
  25326. };
  25327. // For rule associated with this parse tree internal node, return
  25328. // the outer alternative number used to match the input. Default
  25329. // implementation does not compute nor store this alt num. Create
  25330. // a subclass of ParserRuleContext with backing field and set
  25331. // option contextSuperClass.
  25332. // to set it.
  25333. RuleContext.prototype.getAltNumber = function () {
  25334. return INVALID_ALT_NUMBER;
  25335. };
  25336. // Set the outer alternative number for this context node. Default
  25337. // implementation does nothing to avoid backing field overhead for
  25338. // trees that don't need it. Create
  25339. // a subclass of ParserRuleContext with backing field and set
  25340. // option contextSuperClass.
  25341. RuleContext.prototype.setAltNumber = function (altNumber) {};
  25342. RuleContext.prototype.getChild = function (i) {
  25343. return null;
  25344. };
  25345. RuleContext.prototype.getChildCount = function () {
  25346. return 0;
  25347. };
  25348. RuleContext.prototype.accept = function (visitor) {
  25349. return visitor.visitChildren(this);
  25350. };
  25351. //need to manage circular dependencies, so export now
  25352. exports.RuleContext = RuleContext;
  25353. var Trees = __webpack_require__(/*! ./tree/Trees */ "./node_modules/antlr4/tree/Trees.js").Trees;
  25354. // Print out a whole tree, not just a node, in LISP format
  25355. // (root child1 .. childN). Print just a node if this is a leaf.
  25356. //
  25357. RuleContext.prototype.toStringTree = function (ruleNames, recog) {
  25358. return Trees.toStringTree(this, ruleNames, recog);
  25359. };
  25360. RuleContext.prototype.toString = function (ruleNames, stop) {
  25361. ruleNames = ruleNames || null;
  25362. stop = stop || null;
  25363. var p = this;
  25364. var s = "[";
  25365. while (p !== null && p !== stop) {
  25366. if (ruleNames === null) {
  25367. if (!p.isEmpty()) {
  25368. s += p.invokingState;
  25369. }
  25370. } else {
  25371. var ri = p.ruleIndex;
  25372. var ruleName = ri >= 0 && ri < ruleNames.length ? ruleNames[ri] : "" + ri;
  25373. s += ruleName;
  25374. }
  25375. if (p.parentCtx !== null && (ruleNames !== null || !p.parentCtx.isEmpty())) {
  25376. s += " ";
  25377. }
  25378. p = p.parentCtx;
  25379. }
  25380. s += "]";
  25381. return s;
  25382. };
  25383. /***/ }),
  25384. /***/ "./node_modules/antlr4/Token.js":
  25385. /*!**************************************!*\
  25386. !*** ./node_modules/antlr4/Token.js ***!
  25387. \**************************************/
  25388. /*! no static exports found */
  25389. /***/ (function(module, exports, __webpack_require__) {
  25390. "use strict";
  25391. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  25392. * Use of this file is governed by the BSD 3-clause license that
  25393. * can be found in the LICENSE.txt file in the project root.
  25394. */
  25395. //
  25396. // A token has properties: text, type, line, character position in the line
  25397. // (so we can ignore tabs), token channel, index, and source from which
  25398. // we obtained this token.
  25399. function Token() {
  25400. this.source = null;
  25401. this.type = null; // token type of the token
  25402. this.channel = null; // The parser ignores everything not on DEFAULT_CHANNEL
  25403. this.start = null; // optional; return -1 if not implemented.
  25404. this.stop = null; // optional; return -1 if not implemented.
  25405. this.tokenIndex = null; // from 0..n-1 of the token object in the input stream
  25406. this.line = null; // line=1..n of the 1st character
  25407. this.column = null; // beginning of the line at which it occurs, 0..n-1
  25408. this._text = null; // text of the token.
  25409. return this;
  25410. }
  25411. Token.INVALID_TYPE = 0;
  25412. // During lookahead operations, this "token" signifies we hit rule end ATN state
  25413. // and did not follow it despite needing to.
  25414. Token.EPSILON = -2;
  25415. Token.MIN_USER_TOKEN_TYPE = 1;
  25416. Token.EOF = -1;
  25417. // All tokens go to the parser (unless skip() is called in that rule)
  25418. // on a particular "channel". The parser tunes to a particular channel
  25419. // so that whitespace etc... can go to the parser on a "hidden" channel.
  25420. Token.DEFAULT_CHANNEL = 0;
  25421. // Anything on different channel than DEFAULT_CHANNEL is not parsed
  25422. // by parser.
  25423. Token.HIDDEN_CHANNEL = 1;
  25424. // Explicitly set the text for this token. If {code text} is not
  25425. // {@code null}, then {@link //getText} will return this value rather than
  25426. // extracting the text from the input.
  25427. //
  25428. // @param text The explicit text of the token, or {@code null} if the text
  25429. // should be obtained from the input along with the start and stop indexes
  25430. // of the token.
  25431. Object.defineProperty(Token.prototype, "text", {
  25432. get: function get() {
  25433. return this._text;
  25434. },
  25435. set: function set(text) {
  25436. this._text = text;
  25437. }
  25438. });
  25439. Token.prototype.getTokenSource = function () {
  25440. return this.source[0];
  25441. };
  25442. Token.prototype.getInputStream = function () {
  25443. return this.source[1];
  25444. };
  25445. function CommonToken(source, type, channel, start, stop) {
  25446. Token.call(this);
  25447. this.source = source !== undefined ? source : CommonToken.EMPTY_SOURCE;
  25448. this.type = type !== undefined ? type : null;
  25449. this.channel = channel !== undefined ? channel : Token.DEFAULT_CHANNEL;
  25450. this.start = start !== undefined ? start : -1;
  25451. this.stop = stop !== undefined ? stop : -1;
  25452. this.tokenIndex = -1;
  25453. if (this.source[0] !== null) {
  25454. this.line = source[0].line;
  25455. this.column = source[0].column;
  25456. } else {
  25457. this.column = -1;
  25458. }
  25459. return this;
  25460. }
  25461. CommonToken.prototype = Object.create(Token.prototype);
  25462. CommonToken.prototype.constructor = CommonToken;
  25463. // An empty {@link Pair} which is used as the default value of
  25464. // {@link //source} for tokens that do not have a source.
  25465. CommonToken.EMPTY_SOURCE = [null, null];
  25466. // Constructs a new {@link CommonToken} as a copy of another {@link Token}.
  25467. //
  25468. // <p>
  25469. // If {@code oldToken} is also a {@link CommonToken} instance, the newly
  25470. // constructed token will share a reference to the {@link //text} field and
  25471. // the {@link Pair} stored in {@link //source}. Otherwise, {@link //text} will
  25472. // be assigned the result of calling {@link //getText}, and {@link //source}
  25473. // will be constructed from the result of {@link Token//getTokenSource} and
  25474. // {@link Token//getInputStream}.</p>
  25475. //
  25476. // @param oldToken The token to copy.
  25477. //
  25478. CommonToken.prototype.clone = function () {
  25479. var t = new CommonToken(this.source, this.type, this.channel, this.start, this.stop);
  25480. t.tokenIndex = this.tokenIndex;
  25481. t.line = this.line;
  25482. t.column = this.column;
  25483. t.text = this.text;
  25484. return t;
  25485. };
  25486. Object.defineProperty(CommonToken.prototype, "text", {
  25487. get: function get() {
  25488. if (this._text !== null) {
  25489. return this._text;
  25490. }
  25491. var input = this.getInputStream();
  25492. if (input === null) {
  25493. return null;
  25494. }
  25495. var n = input.size;
  25496. if (this.start < n && this.stop < n) {
  25497. return input.getText(this.start, this.stop);
  25498. } else {
  25499. return "<EOF>";
  25500. }
  25501. },
  25502. set: function set(text) {
  25503. this._text = text;
  25504. }
  25505. });
  25506. CommonToken.prototype.toString = function () {
  25507. var txt = this.text;
  25508. if (txt !== null) {
  25509. txt = txt.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
  25510. } else {
  25511. txt = "<no text>";
  25512. }
  25513. return "[@" + this.tokenIndex + "," + this.start + ":" + this.stop + "='" + txt + "',<" + this.type + ">" + (this.channel > 0 ? ",channel=" + this.channel : "") + "," + this.line + ":" + this.column + "]";
  25514. };
  25515. exports.Token = Token;
  25516. exports.CommonToken = CommonToken;
  25517. /***/ }),
  25518. /***/ "./node_modules/antlr4/Utils.js":
  25519. /*!**************************************!*\
  25520. !*** ./node_modules/antlr4/Utils.js ***!
  25521. \**************************************/
  25522. /*! no static exports found */
  25523. /***/ (function(module, exports, __webpack_require__) {
  25524. "use strict";
  25525. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  25526. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  25527. * Use of this file is governed by the BSD 3-clause license that
  25528. * can be found in the LICENSE.txt file in the project root.
  25529. */
  25530. function arrayToString(a) {
  25531. return "[" + a.join(", ") + "]";
  25532. }
  25533. String.prototype.seed = String.prototype.seed || Math.round(Math.random() * Math.pow(2, 32));
  25534. String.prototype.hashCode = function () {
  25535. var remainder,
  25536. bytes,
  25537. h1,
  25538. h1b,
  25539. c1,
  25540. c1b,
  25541. c2,
  25542. c2b,
  25543. k1,
  25544. i,
  25545. key = this.toString();
  25546. remainder = key.length & 3; // key.length % 4
  25547. bytes = key.length - remainder;
  25548. h1 = String.prototype.seed;
  25549. c1 = 0xcc9e2d51;
  25550. c2 = 0x1b873593;
  25551. i = 0;
  25552. while (i < bytes) {
  25553. k1 = key.charCodeAt(i) & 0xff | (key.charCodeAt(++i) & 0xff) << 8 | (key.charCodeAt(++i) & 0xff) << 16 | (key.charCodeAt(++i) & 0xff) << 24;
  25554. ++i;
  25555. k1 = (k1 & 0xffff) * c1 + (((k1 >>> 16) * c1 & 0xffff) << 16) & 0xffffffff;
  25556. k1 = k1 << 15 | k1 >>> 17;
  25557. k1 = (k1 & 0xffff) * c2 + (((k1 >>> 16) * c2 & 0xffff) << 16) & 0xffffffff;
  25558. h1 ^= k1;
  25559. h1 = h1 << 13 | h1 >>> 19;
  25560. h1b = (h1 & 0xffff) * 5 + (((h1 >>> 16) * 5 & 0xffff) << 16) & 0xffffffff;
  25561. h1 = (h1b & 0xffff) + 0x6b64 + (((h1b >>> 16) + 0xe654 & 0xffff) << 16);
  25562. }
  25563. k1 = 0;
  25564. switch (remainder) {
  25565. case 3:
  25566. k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;
  25567. case 2:
  25568. k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
  25569. case 1:
  25570. k1 ^= key.charCodeAt(i) & 0xff;
  25571. k1 = (k1 & 0xffff) * c1 + (((k1 >>> 16) * c1 & 0xffff) << 16) & 0xffffffff;
  25572. k1 = k1 << 15 | k1 >>> 17;
  25573. k1 = (k1 & 0xffff) * c2 + (((k1 >>> 16) * c2 & 0xffff) << 16) & 0xffffffff;
  25574. h1 ^= k1;
  25575. }
  25576. h1 ^= key.length;
  25577. h1 ^= h1 >>> 16;
  25578. h1 = (h1 & 0xffff) * 0x85ebca6b + (((h1 >>> 16) * 0x85ebca6b & 0xffff) << 16) & 0xffffffff;
  25579. h1 ^= h1 >>> 13;
  25580. h1 = (h1 & 0xffff) * 0xc2b2ae35 + (((h1 >>> 16) * 0xc2b2ae35 & 0xffff) << 16) & 0xffffffff;
  25581. h1 ^= h1 >>> 16;
  25582. return h1 >>> 0;
  25583. };
  25584. function standardEqualsFunction(a, b) {
  25585. return a.equals(b);
  25586. }
  25587. function standardHashCodeFunction(a) {
  25588. return a.hashCode();
  25589. }
  25590. function Set(hashFunction, equalsFunction) {
  25591. this.data = {};
  25592. this.hashFunction = hashFunction || standardHashCodeFunction;
  25593. this.equalsFunction = equalsFunction || standardEqualsFunction;
  25594. return this;
  25595. }
  25596. Object.defineProperty(Set.prototype, "length", {
  25597. get: function get() {
  25598. var l = 0;
  25599. for (var key in this.data) {
  25600. if (key.indexOf("hash_") === 0) {
  25601. l = l + this.data[key].length;
  25602. }
  25603. }
  25604. return l;
  25605. }
  25606. });
  25607. Set.prototype.add = function (value) {
  25608. var hash = this.hashFunction(value);
  25609. var key = "hash_" + hash;
  25610. if (key in this.data) {
  25611. var values = this.data[key];
  25612. for (var i = 0; i < values.length; i++) {
  25613. if (this.equalsFunction(value, values[i])) {
  25614. return values[i];
  25615. }
  25616. }
  25617. values.push(value);
  25618. return value;
  25619. } else {
  25620. this.data[key] = [value];
  25621. return value;
  25622. }
  25623. };
  25624. Set.prototype.contains = function (value) {
  25625. return this.get(value) != null;
  25626. };
  25627. Set.prototype.get = function (value) {
  25628. var hash = this.hashFunction(value);
  25629. var key = "hash_" + hash;
  25630. if (key in this.data) {
  25631. var values = this.data[key];
  25632. for (var i = 0; i < values.length; i++) {
  25633. if (this.equalsFunction(value, values[i])) {
  25634. return values[i];
  25635. }
  25636. }
  25637. }
  25638. return null;
  25639. };
  25640. Set.prototype.values = function () {
  25641. var l = [];
  25642. for (var key in this.data) {
  25643. if (key.indexOf("hash_") === 0) {
  25644. l = l.concat(this.data[key]);
  25645. }
  25646. }
  25647. return l;
  25648. };
  25649. Set.prototype.toString = function () {
  25650. return arrayToString(this.values());
  25651. };
  25652. function BitSet() {
  25653. this.data = [];
  25654. return this;
  25655. }
  25656. BitSet.prototype.add = function (value) {
  25657. this.data[value] = true;
  25658. };
  25659. BitSet.prototype.or = function (set) {
  25660. var bits = this;
  25661. Object.keys(set.data).map(function (alt) {
  25662. bits.add(alt);
  25663. });
  25664. };
  25665. BitSet.prototype.remove = function (value) {
  25666. delete this.data[value];
  25667. };
  25668. BitSet.prototype.contains = function (value) {
  25669. return this.data[value] === true;
  25670. };
  25671. BitSet.prototype.values = function () {
  25672. return Object.keys(this.data);
  25673. };
  25674. BitSet.prototype.minValue = function () {
  25675. return Math.min.apply(null, this.values());
  25676. };
  25677. BitSet.prototype.hashCode = function () {
  25678. var hash = new Hash();
  25679. hash.update(this.values());
  25680. return hash.finish();
  25681. };
  25682. BitSet.prototype.equals = function (other) {
  25683. if (!(other instanceof BitSet)) {
  25684. return false;
  25685. }
  25686. return this.hashCode() === other.hashCode();
  25687. };
  25688. Object.defineProperty(BitSet.prototype, "length", {
  25689. get: function get() {
  25690. return this.values().length;
  25691. }
  25692. });
  25693. BitSet.prototype.toString = function () {
  25694. return "{" + this.values().join(", ") + "}";
  25695. };
  25696. function Map(hashFunction, equalsFunction) {
  25697. this.data = {};
  25698. this.hashFunction = hashFunction || standardHashCodeFunction;
  25699. this.equalsFunction = equalsFunction || standardEqualsFunction;
  25700. return this;
  25701. }
  25702. Object.defineProperty(Map.prototype, "length", {
  25703. get: function get() {
  25704. var l = 0;
  25705. for (var hashKey in this.data) {
  25706. if (hashKey.indexOf("hash_") === 0) {
  25707. l = l + this.data[hashKey].length;
  25708. }
  25709. }
  25710. return l;
  25711. }
  25712. });
  25713. Map.prototype.put = function (key, value) {
  25714. var hashKey = "hash_" + this.hashFunction(key);
  25715. if (hashKey in this.data) {
  25716. var entries = this.data[hashKey];
  25717. for (var i = 0; i < entries.length; i++) {
  25718. var entry = entries[i];
  25719. if (this.equalsFunction(key, entry.key)) {
  25720. var oldValue = entry.value;
  25721. entry.value = value;
  25722. return oldValue;
  25723. }
  25724. }
  25725. entries.push({ key: key, value: value });
  25726. return value;
  25727. } else {
  25728. this.data[hashKey] = [{ key: key, value: value }];
  25729. return value;
  25730. }
  25731. };
  25732. Map.prototype.containsKey = function (key) {
  25733. var hashKey = "hash_" + this.hashFunction(key);
  25734. if (hashKey in this.data) {
  25735. var entries = this.data[hashKey];
  25736. for (var i = 0; i < entries.length; i++) {
  25737. var entry = entries[i];
  25738. if (this.equalsFunction(key, entry.key)) return true;
  25739. }
  25740. }
  25741. return false;
  25742. };
  25743. Map.prototype.get = function (key) {
  25744. var hashKey = "hash_" + this.hashFunction(key);
  25745. if (hashKey in this.data) {
  25746. var entries = this.data[hashKey];
  25747. for (var i = 0; i < entries.length; i++) {
  25748. var entry = entries[i];
  25749. if (this.equalsFunction(key, entry.key)) return entry.value;
  25750. }
  25751. }
  25752. return null;
  25753. };
  25754. Map.prototype.entries = function () {
  25755. var l = [];
  25756. for (var key in this.data) {
  25757. if (key.indexOf("hash_") === 0) {
  25758. l = l.concat(this.data[key]);
  25759. }
  25760. }
  25761. return l;
  25762. };
  25763. Map.prototype.getKeys = function () {
  25764. return this.entries().map(function (e) {
  25765. return e.key;
  25766. });
  25767. };
  25768. Map.prototype.getValues = function () {
  25769. return this.entries().map(function (e) {
  25770. return e.value;
  25771. });
  25772. };
  25773. Map.prototype.toString = function () {
  25774. var ss = this.entries().map(function (entry) {
  25775. return '{' + entry.key + ':' + entry.value + '}';
  25776. });
  25777. return '[' + ss.join(", ") + ']';
  25778. };
  25779. function AltDict() {
  25780. this.data = {};
  25781. return this;
  25782. }
  25783. AltDict.prototype.get = function (key) {
  25784. key = "k-" + key;
  25785. if (key in this.data) {
  25786. return this.data[key];
  25787. } else {
  25788. return null;
  25789. }
  25790. };
  25791. AltDict.prototype.put = function (key, value) {
  25792. key = "k-" + key;
  25793. this.data[key] = value;
  25794. };
  25795. AltDict.prototype.values = function () {
  25796. var data = this.data;
  25797. var keys = Object.keys(this.data);
  25798. return keys.map(function (key) {
  25799. return data[key];
  25800. });
  25801. };
  25802. function DoubleDict() {
  25803. return this;
  25804. }
  25805. function Hash() {
  25806. this.count = 0;
  25807. this.hash = 0;
  25808. return this;
  25809. }
  25810. Hash.prototype.update = function () {
  25811. for (var i = 0; i < arguments.length; i++) {
  25812. var value = arguments[i];
  25813. if (value == null) continue;
  25814. if (Array.isArray(value)) this.update.apply(value);else {
  25815. var k = 0;
  25816. switch (typeof value === "undefined" ? "undefined" : _typeof(value)) {
  25817. case 'undefined':
  25818. case 'function':
  25819. continue;
  25820. case 'number':
  25821. case 'boolean':
  25822. k = value;
  25823. break;
  25824. case 'string':
  25825. k = value.hashCode();
  25826. break;
  25827. default:
  25828. value.updateHashCode(this);
  25829. continue;
  25830. }
  25831. k = k * 0xCC9E2D51;
  25832. k = k << 15 | k >>> 32 - 15;
  25833. k = k * 0x1B873593;
  25834. this.count = this.count + 1;
  25835. var hash = this.hash ^ k;
  25836. hash = hash << 13 | hash >>> 32 - 13;
  25837. hash = hash * 5 + 0xE6546B64;
  25838. this.hash = hash;
  25839. }
  25840. }
  25841. };
  25842. Hash.prototype.finish = function () {
  25843. var hash = this.hash ^ this.count * 4;
  25844. hash = hash ^ hash >>> 16;
  25845. hash = hash * 0x85EBCA6B;
  25846. hash = hash ^ hash >>> 13;
  25847. hash = hash * 0xC2B2AE35;
  25848. hash = hash ^ hash >>> 16;
  25849. return hash;
  25850. };
  25851. function hashStuff() {
  25852. var hash = new Hash();
  25853. hash.update.apply(arguments);
  25854. return hash.finish();
  25855. }
  25856. DoubleDict.prototype.get = function (a, b) {
  25857. var d = this[a] || null;
  25858. return d === null ? null : d[b] || null;
  25859. };
  25860. DoubleDict.prototype.set = function (a, b, o) {
  25861. var d = this[a] || null;
  25862. if (d === null) {
  25863. d = {};
  25864. this[a] = d;
  25865. }
  25866. d[b] = o;
  25867. };
  25868. function escapeWhitespace(s, escapeSpaces) {
  25869. s = s.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
  25870. if (escapeSpaces) {
  25871. s = s.replace(/ /g, "\xB7");
  25872. }
  25873. return s;
  25874. }
  25875. function titleCase(str) {
  25876. return str.replace(/\w\S*/g, function (txt) {
  25877. return txt.charAt(0).toUpperCase() + txt.substr(1);
  25878. });
  25879. };
  25880. function equalArrays(a, b) {
  25881. if (!Array.isArray(a) || !Array.isArray(b)) return false;
  25882. if (a == b) return true;
  25883. if (a.length != b.length) return false;
  25884. for (var i = 0; i < a.length; i++) {
  25885. if (a[i] == b[i]) continue;
  25886. if (!a[i].equals(b[i])) return false;
  25887. }
  25888. return true;
  25889. };
  25890. exports.Hash = Hash;
  25891. exports.Set = Set;
  25892. exports.Map = Map;
  25893. exports.BitSet = BitSet;
  25894. exports.AltDict = AltDict;
  25895. exports.DoubleDict = DoubleDict;
  25896. exports.hashStuff = hashStuff;
  25897. exports.escapeWhitespace = escapeWhitespace;
  25898. exports.arrayToString = arrayToString;
  25899. exports.titleCase = titleCase;
  25900. exports.equalArrays = equalArrays;
  25901. /***/ }),
  25902. /***/ "./node_modules/antlr4/atn/ATN.js":
  25903. /*!****************************************!*\
  25904. !*** ./node_modules/antlr4/atn/ATN.js ***!
  25905. \****************************************/
  25906. /*! no static exports found */
  25907. /***/ (function(module, exports, __webpack_require__) {
  25908. "use strict";
  25909. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  25910. * Use of this file is governed by the BSD 3-clause license that
  25911. * can be found in the LICENSE.txt file in the project root.
  25912. */
  25913. var LL1Analyzer = __webpack_require__(/*! ./../LL1Analyzer */ "./node_modules/antlr4/LL1Analyzer.js").LL1Analyzer;
  25914. var IntervalSet = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").IntervalSet;
  25915. function ATN(grammarType, maxTokenType) {
  25916. // Used for runtime deserialization of ATNs from strings///
  25917. // The type of the ATN.
  25918. this.grammarType = grammarType;
  25919. // The maximum value for any symbol recognized by a transition in the ATN.
  25920. this.maxTokenType = maxTokenType;
  25921. this.states = [];
  25922. // Each subrule/rule is a decision point and we must track them so we
  25923. // can go back later and build DFA predictors for them. This includes
  25924. // all the rules, subrules, optional blocks, ()+, ()* etc...
  25925. this.decisionToState = [];
  25926. // Maps from rule index to starting state number.
  25927. this.ruleToStartState = [];
  25928. // Maps from rule index to stop state number.
  25929. this.ruleToStopState = null;
  25930. this.modeNameToStartState = {};
  25931. // For lexer ATNs, this maps the rule index to the resulting token type.
  25932. // For parser ATNs, this maps the rule index to the generated bypass token
  25933. // type if the
  25934. // {@link ATNDeserializationOptions//isGenerateRuleBypassTransitions}
  25935. // deserialization option was specified; otherwise, this is {@code null}.
  25936. this.ruleToTokenType = null;
  25937. // For lexer ATNs, this is an array of {@link LexerAction} objects which may
  25938. // be referenced by action transitions in the ATN.
  25939. this.lexerActions = null;
  25940. this.modeToStartState = [];
  25941. return this;
  25942. }
  25943. // Compute the set of valid tokens that can occur starting in state {@code s}.
  25944. // If {@code ctx} is null, the set of tokens will not include what can follow
  25945. // the rule surrounding {@code s}. In other words, the set will be
  25946. // restricted to tokens reachable staying within {@code s}'s rule.
  25947. ATN.prototype.nextTokensInContext = function (s, ctx) {
  25948. var anal = new LL1Analyzer(this);
  25949. return anal.LOOK(s, null, ctx);
  25950. };
  25951. // Compute the set of valid tokens that can occur starting in {@code s} and
  25952. // staying in same rule. {@link Token//EPSILON} is in set if we reach end of
  25953. // rule.
  25954. ATN.prototype.nextTokensNoContext = function (s) {
  25955. if (s.nextTokenWithinRule !== null) {
  25956. return s.nextTokenWithinRule;
  25957. }
  25958. s.nextTokenWithinRule = this.nextTokensInContext(s, null);
  25959. s.nextTokenWithinRule.readOnly = true;
  25960. return s.nextTokenWithinRule;
  25961. };
  25962. ATN.prototype.nextTokens = function (s, ctx) {
  25963. if (ctx === undefined) {
  25964. return this.nextTokensNoContext(s);
  25965. } else {
  25966. return this.nextTokensInContext(s, ctx);
  25967. }
  25968. };
  25969. ATN.prototype.addState = function (state) {
  25970. if (state !== null) {
  25971. state.atn = this;
  25972. state.stateNumber = this.states.length;
  25973. }
  25974. this.states.push(state);
  25975. };
  25976. ATN.prototype.removeState = function (state) {
  25977. this.states[state.stateNumber] = null; // just free mem, don't shift states in list
  25978. };
  25979. ATN.prototype.defineDecisionState = function (s) {
  25980. this.decisionToState.push(s);
  25981. s.decision = this.decisionToState.length - 1;
  25982. return s.decision;
  25983. };
  25984. ATN.prototype.getDecisionState = function (decision) {
  25985. if (this.decisionToState.length === 0) {
  25986. return null;
  25987. } else {
  25988. return this.decisionToState[decision];
  25989. }
  25990. };
  25991. // Computes the set of input symbols which could follow ATN state number
  25992. // {@code stateNumber} in the specified full {@code context}. This method
  25993. // considers the complete parser context, but does not evaluate semantic
  25994. // predicates (i.e. all predicates encountered during the calculation are
  25995. // assumed true). If a path in the ATN exists from the starting state to the
  25996. // {@link RuleStopState} of the outermost context without matching any
  25997. // symbols, {@link Token//EOF} is added to the returned set.
  25998. //
  25999. // <p>If {@code context} is {@code null}, it is treated as
  26000. // {@link ParserRuleContext//EMPTY}.</p>
  26001. //
  26002. // @param stateNumber the ATN state number
  26003. // @param context the full parse context
  26004. // @return The set of potentially valid input symbols which could follow the
  26005. // specified state in the specified context.
  26006. // @throws IllegalArgumentException if the ATN does not contain a state with
  26007. // number {@code stateNumber}
  26008. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  26009. ATN.prototype.getExpectedTokens = function (stateNumber, ctx) {
  26010. if (stateNumber < 0 || stateNumber >= this.states.length) {
  26011. throw "Invalid state number.";
  26012. }
  26013. var s = this.states[stateNumber];
  26014. var following = this.nextTokens(s);
  26015. if (!following.contains(Token.EPSILON)) {
  26016. return following;
  26017. }
  26018. var expected = new IntervalSet();
  26019. expected.addSet(following);
  26020. expected.removeOne(Token.EPSILON);
  26021. while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
  26022. var invokingState = this.states[ctx.invokingState];
  26023. var rt = invokingState.transitions[0];
  26024. following = this.nextTokens(rt.followState);
  26025. expected.addSet(following);
  26026. expected.removeOne(Token.EPSILON);
  26027. ctx = ctx.parentCtx;
  26028. }
  26029. if (following.contains(Token.EPSILON)) {
  26030. expected.addOne(Token.EOF);
  26031. }
  26032. return expected;
  26033. };
  26034. ATN.INVALID_ALT_NUMBER = 0;
  26035. exports.ATN = ATN;
  26036. /***/ }),
  26037. /***/ "./node_modules/antlr4/atn/ATNConfig.js":
  26038. /*!**********************************************!*\
  26039. !*** ./node_modules/antlr4/atn/ATNConfig.js ***!
  26040. \**********************************************/
  26041. /*! no static exports found */
  26042. /***/ (function(module, exports, __webpack_require__) {
  26043. "use strict";
  26044. //
  26045. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  26046. * Use of this file is governed by the BSD 3-clause license that
  26047. * can be found in the LICENSE.txt file in the project root.
  26048. */
  26049. ///
  26050. // A tuple: (ATN state, predicted alt, syntactic, semantic context).
  26051. // The syntactic context is a graph-structured stack node whose
  26052. // path(s) to the root is the rule invocation(s)
  26053. // chain used to arrive at the state. The semantic context is
  26054. // the tree of semantic predicates encountered before reaching
  26055. // an ATN state.
  26056. ///
  26057. var DecisionState = __webpack_require__(/*! ./ATNState */ "./node_modules/antlr4/atn/ATNState.js").DecisionState;
  26058. var SemanticContext = __webpack_require__(/*! ./SemanticContext */ "./node_modules/antlr4/atn/SemanticContext.js").SemanticContext;
  26059. var Hash = __webpack_require__(/*! ../Utils */ "./node_modules/antlr4/Utils.js").Hash;
  26060. function checkParams(params, isCfg) {
  26061. if (params === null) {
  26062. var result = { state: null, alt: null, context: null, semanticContext: null };
  26063. if (isCfg) {
  26064. result.reachesIntoOuterContext = 0;
  26065. }
  26066. return result;
  26067. } else {
  26068. var props = {};
  26069. props.state = params.state || null;
  26070. props.alt = params.alt === undefined ? null : params.alt;
  26071. props.context = params.context || null;
  26072. props.semanticContext = params.semanticContext || null;
  26073. if (isCfg) {
  26074. props.reachesIntoOuterContext = params.reachesIntoOuterContext || 0;
  26075. props.precedenceFilterSuppressed = params.precedenceFilterSuppressed || false;
  26076. }
  26077. return props;
  26078. }
  26079. }
  26080. function ATNConfig(params, config) {
  26081. this.checkContext(params, config);
  26082. params = checkParams(params);
  26083. config = checkParams(config, true);
  26084. // The ATN state associated with this configuration///
  26085. this.state = params.state !== null ? params.state : config.state;
  26086. // What alt (or lexer rule) is predicted by this configuration///
  26087. this.alt = params.alt !== null ? params.alt : config.alt;
  26088. // The stack of invoking states leading to the rule/states associated
  26089. // with this config. We track only those contexts pushed during
  26090. // execution of the ATN simulator.
  26091. this.context = params.context !== null ? params.context : config.context;
  26092. this.semanticContext = params.semanticContext !== null ? params.semanticContext : config.semanticContext !== null ? config.semanticContext : SemanticContext.NONE;
  26093. // We cannot execute predicates dependent upon local context unless
  26094. // we know for sure we are in the correct context. Because there is
  26095. // no way to do this efficiently, we simply cannot evaluate
  26096. // dependent predicates unless we are in the rule that initially
  26097. // invokes the ATN simulator.
  26098. //
  26099. // closure() tracks the depth of how far we dip into the
  26100. // outer context: depth &gt; 0. Note that it may not be totally
  26101. // accurate depth since I don't ever decrement. TODO: make it a boolean then
  26102. this.reachesIntoOuterContext = config.reachesIntoOuterContext;
  26103. this.precedenceFilterSuppressed = config.precedenceFilterSuppressed;
  26104. return this;
  26105. }
  26106. ATNConfig.prototype.checkContext = function (params, config) {
  26107. if ((params.context === null || params.context === undefined) && (config === null || config.context === null || config.context === undefined)) {
  26108. this.context = null;
  26109. }
  26110. };
  26111. ATNConfig.prototype.hashCode = function () {
  26112. var hash = new Hash();
  26113. this.updateHashCode(hash);
  26114. return hash.finish();
  26115. };
  26116. ATNConfig.prototype.updateHashCode = function (hash) {
  26117. hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext);
  26118. };
  26119. // An ATN configuration is equal to another if both have
  26120. // the same state, they predict the same alternative, and
  26121. // syntactic/semantic contexts are the same.
  26122. ATNConfig.prototype.equals = function (other) {
  26123. if (this === other) {
  26124. return true;
  26125. } else if (!(other instanceof ATNConfig)) {
  26126. return false;
  26127. } else {
  26128. return this.state.stateNumber === other.state.stateNumber && this.alt === other.alt && (this.context === null ? other.context === null : this.context.equals(other.context)) && this.semanticContext.equals(other.semanticContext) && this.precedenceFilterSuppressed === other.precedenceFilterSuppressed;
  26129. }
  26130. };
  26131. ATNConfig.prototype.hashCodeForConfigSet = function () {
  26132. var hash = new Hash();
  26133. hash.update(this.state.stateNumber, this.alt, this.semanticContext);
  26134. return hash.finish();
  26135. };
  26136. ATNConfig.prototype.equalsForConfigSet = function (other) {
  26137. if (this === other) {
  26138. return true;
  26139. } else if (!(other instanceof ATNConfig)) {
  26140. return false;
  26141. } else {
  26142. return this.state.stateNumber === other.state.stateNumber && this.alt === other.alt && this.semanticContext.equals(other.semanticContext);
  26143. }
  26144. };
  26145. ATNConfig.prototype.toString = function () {
  26146. return "(" + this.state + "," + this.alt + (this.context !== null ? ",[" + this.context.toString() + "]" : "") + (this.semanticContext !== SemanticContext.NONE ? "," + this.semanticContext.toString() : "") + (this.reachesIntoOuterContext > 0 ? ",up=" + this.reachesIntoOuterContext : "") + ")";
  26147. };
  26148. function LexerATNConfig(params, config) {
  26149. ATNConfig.call(this, params, config);
  26150. // This is the backing field for {@link //getLexerActionExecutor}.
  26151. var lexerActionExecutor = params.lexerActionExecutor || null;
  26152. this.lexerActionExecutor = lexerActionExecutor || (config !== null ? config.lexerActionExecutor : null);
  26153. this.passedThroughNonGreedyDecision = config !== null ? this.checkNonGreedyDecision(config, this.state) : false;
  26154. return this;
  26155. }
  26156. LexerATNConfig.prototype = Object.create(ATNConfig.prototype);
  26157. LexerATNConfig.prototype.constructor = LexerATNConfig;
  26158. LexerATNConfig.prototype.updateHashCode = function (hash) {
  26159. hash.update(this.state.stateNumber, this.alt, this.context, this.semanticContext, this.passedThroughNonGreedyDecision, this.lexerActionExecutor);
  26160. };
  26161. LexerATNConfig.prototype.equals = function (other) {
  26162. return this === other || other instanceof LexerATNConfig && this.passedThroughNonGreedyDecision == other.passedThroughNonGreedyDecision && (this.lexerActionExecutor ? this.lexerActionExecutor.equals(other.lexerActionExecutor) : !other.lexerActionExecutor) && ATNConfig.prototype.equals.call(this, other);
  26163. };
  26164. LexerATNConfig.prototype.hashCodeForConfigSet = LexerATNConfig.prototype.hashCode;
  26165. LexerATNConfig.prototype.equalsForConfigSet = LexerATNConfig.prototype.equals;
  26166. LexerATNConfig.prototype.checkNonGreedyDecision = function (source, target) {
  26167. return source.passedThroughNonGreedyDecision || target instanceof DecisionState && target.nonGreedy;
  26168. };
  26169. exports.ATNConfig = ATNConfig;
  26170. exports.LexerATNConfig = LexerATNConfig;
  26171. /***/ }),
  26172. /***/ "./node_modules/antlr4/atn/ATNConfigSet.js":
  26173. /*!*************************************************!*\
  26174. !*** ./node_modules/antlr4/atn/ATNConfigSet.js ***!
  26175. \*************************************************/
  26176. /*! no static exports found */
  26177. /***/ (function(module, exports, __webpack_require__) {
  26178. "use strict";
  26179. //
  26180. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  26181. * Use of this file is governed by the BSD 3-clause license that
  26182. * can be found in the LICENSE.txt file in the project root.
  26183. */
  26184. //
  26185. // Specialized {@link Set}{@code <}{@link ATNConfig}{@code >} that can track
  26186. // info about the set, with support for combining similar configurations using a
  26187. // graph-structured stack.
  26188. ///
  26189. var ATN = __webpack_require__(/*! ./ATN */ "./node_modules/antlr4/atn/ATN.js").ATN;
  26190. var Utils = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js");
  26191. var Hash = Utils.Hash;
  26192. var Set = Utils.Set;
  26193. var SemanticContext = __webpack_require__(/*! ./SemanticContext */ "./node_modules/antlr4/atn/SemanticContext.js").SemanticContext;
  26194. var merge = __webpack_require__(/*! ./../PredictionContext */ "./node_modules/antlr4/PredictionContext.js").merge;
  26195. function hashATNConfig(c) {
  26196. return c.hashCodeForConfigSet();
  26197. }
  26198. function equalATNConfigs(a, b) {
  26199. if (a === b) {
  26200. return true;
  26201. } else if (a === null || b === null) {
  26202. return false;
  26203. } else return a.equalsForConfigSet(b);
  26204. }
  26205. function ATNConfigSet(fullCtx) {
  26206. //
  26207. // The reason that we need this is because we don't want the hash map to use
  26208. // the standard hash code and equals. We need all configurations with the
  26209. // same
  26210. // {@code (s,i,_,semctx)} to be equal. Unfortunately, this key effectively
  26211. // doubles
  26212. // the number of objects associated with ATNConfigs. The other solution is
  26213. // to
  26214. // use a hash table that lets us specify the equals/hashcode operation.
  26215. // All configs but hashed by (s, i, _, pi) not including context. Wiped out
  26216. // when we go readonly as this set becomes a DFA state.
  26217. this.configLookup = new Set(hashATNConfig, equalATNConfigs);
  26218. // Indicates that this configuration set is part of a full context
  26219. // LL prediction. It will be used to determine how to merge $. With SLL
  26220. // it's a wildcard whereas it is not for LL context merge.
  26221. this.fullCtx = fullCtx === undefined ? true : fullCtx;
  26222. // Indicates that the set of configurations is read-only. Do not
  26223. // allow any code to manipulate the set; DFA states will point at
  26224. // the sets and they must not change. This does not protect the other
  26225. // fields; in particular, conflictingAlts is set after
  26226. // we've made this readonly.
  26227. this.readOnly = false;
  26228. // Track the elements as they are added to the set; supports get(i)///
  26229. this.configs = [];
  26230. // TODO: these fields make me pretty uncomfortable but nice to pack up info
  26231. // together, saves recomputation
  26232. // TODO: can we track conflicts as they are added to save scanning configs
  26233. // later?
  26234. this.uniqueAlt = 0;
  26235. this.conflictingAlts = null;
  26236. // Used in parser and lexer. In lexer, it indicates we hit a pred
  26237. // while computing a closure operation. Don't make a DFA state from this.
  26238. this.hasSemanticContext = false;
  26239. this.dipsIntoOuterContext = false;
  26240. this.cachedHashCode = -1;
  26241. return this;
  26242. }
  26243. // Adding a new config means merging contexts with existing configs for
  26244. // {@code (s, i, pi, _)}, where {@code s} is the
  26245. // {@link ATNConfig//state}, {@code i} is the {@link ATNConfig//alt}, and
  26246. // {@code pi} is the {@link ATNConfig//semanticContext}. We use
  26247. // {@code (s,i,pi)} as key.
  26248. //
  26249. // <p>This method updates {@link //dipsIntoOuterContext} and
  26250. // {@link //hasSemanticContext} when necessary.</p>
  26251. // /
  26252. ATNConfigSet.prototype.add = function (config, mergeCache) {
  26253. if (mergeCache === undefined) {
  26254. mergeCache = null;
  26255. }
  26256. if (this.readOnly) {
  26257. throw "This set is readonly";
  26258. }
  26259. if (config.semanticContext !== SemanticContext.NONE) {
  26260. this.hasSemanticContext = true;
  26261. }
  26262. if (config.reachesIntoOuterContext > 0) {
  26263. this.dipsIntoOuterContext = true;
  26264. }
  26265. var existing = this.configLookup.add(config);
  26266. if (existing === config) {
  26267. this.cachedHashCode = -1;
  26268. this.configs.push(config); // track order here
  26269. return true;
  26270. }
  26271. // a previous (s,i,pi,_), merge with it and save result
  26272. var rootIsWildcard = !this.fullCtx;
  26273. var merged = merge(existing.context, config.context, rootIsWildcard, mergeCache);
  26274. // no need to check for existing.context, config.context in cache
  26275. // since only way to create new graphs is "call rule" and here. We
  26276. // cache at both places.
  26277. existing.reachesIntoOuterContext = Math.max(existing.reachesIntoOuterContext, config.reachesIntoOuterContext);
  26278. // make sure to preserve the precedence filter suppression during the merge
  26279. if (config.precedenceFilterSuppressed) {
  26280. existing.precedenceFilterSuppressed = true;
  26281. }
  26282. existing.context = merged; // replace context; no need to alt mapping
  26283. return true;
  26284. };
  26285. ATNConfigSet.prototype.getStates = function () {
  26286. var states = new Set();
  26287. for (var i = 0; i < this.configs.length; i++) {
  26288. states.add(this.configs[i].state);
  26289. }
  26290. return states;
  26291. };
  26292. ATNConfigSet.prototype.getPredicates = function () {
  26293. var preds = [];
  26294. for (var i = 0; i < this.configs.length; i++) {
  26295. var c = this.configs[i].semanticContext;
  26296. if (c !== SemanticContext.NONE) {
  26297. preds.push(c.semanticContext);
  26298. }
  26299. }
  26300. return preds;
  26301. };
  26302. Object.defineProperty(ATNConfigSet.prototype, "items", {
  26303. get: function get() {
  26304. return this.configs;
  26305. }
  26306. });
  26307. ATNConfigSet.prototype.optimizeConfigs = function (interpreter) {
  26308. if (this.readOnly) {
  26309. throw "This set is readonly";
  26310. }
  26311. if (this.configLookup.length === 0) {
  26312. return;
  26313. }
  26314. for (var i = 0; i < this.configs.length; i++) {
  26315. var config = this.configs[i];
  26316. config.context = interpreter.getCachedContext(config.context);
  26317. }
  26318. };
  26319. ATNConfigSet.prototype.addAll = function (coll) {
  26320. for (var i = 0; i < coll.length; i++) {
  26321. this.add(coll[i]);
  26322. }
  26323. return false;
  26324. };
  26325. ATNConfigSet.prototype.equals = function (other) {
  26326. return this === other || other instanceof ATNConfigSet && Utils.equalArrays(this.configs, other.configs) && this.fullCtx === other.fullCtx && this.uniqueAlt === other.uniqueAlt && this.conflictingAlts === other.conflictingAlts && this.hasSemanticContext === other.hasSemanticContext && this.dipsIntoOuterContext === other.dipsIntoOuterContext;
  26327. };
  26328. ATNConfigSet.prototype.hashCode = function () {
  26329. var hash = new Hash();
  26330. this.updateHashCode(hash);
  26331. return hash.finish();
  26332. };
  26333. ATNConfigSet.prototype.updateHashCode = function (hash) {
  26334. if (this.readOnly) {
  26335. if (this.cachedHashCode === -1) {
  26336. var hash = new Hash();
  26337. hash.update(this.configs);
  26338. this.cachedHashCode = hash.finish();
  26339. }
  26340. hash.update(this.cachedHashCode);
  26341. } else {
  26342. hash.update(this.configs);
  26343. }
  26344. };
  26345. Object.defineProperty(ATNConfigSet.prototype, "length", {
  26346. get: function get() {
  26347. return this.configs.length;
  26348. }
  26349. });
  26350. ATNConfigSet.prototype.isEmpty = function () {
  26351. return this.configs.length === 0;
  26352. };
  26353. ATNConfigSet.prototype.contains = function (item) {
  26354. if (this.configLookup === null) {
  26355. throw "This method is not implemented for readonly sets.";
  26356. }
  26357. return this.configLookup.contains(item);
  26358. };
  26359. ATNConfigSet.prototype.containsFast = function (item) {
  26360. if (this.configLookup === null) {
  26361. throw "This method is not implemented for readonly sets.";
  26362. }
  26363. return this.configLookup.containsFast(item);
  26364. };
  26365. ATNConfigSet.prototype.clear = function () {
  26366. if (this.readOnly) {
  26367. throw "This set is readonly";
  26368. }
  26369. this.configs = [];
  26370. this.cachedHashCode = -1;
  26371. this.configLookup = new Set();
  26372. };
  26373. ATNConfigSet.prototype.setReadonly = function (readOnly) {
  26374. this.readOnly = readOnly;
  26375. if (readOnly) {
  26376. this.configLookup = null; // can't mod, no need for lookup cache
  26377. }
  26378. };
  26379. ATNConfigSet.prototype.toString = function () {
  26380. return Utils.arrayToString(this.configs) + (this.hasSemanticContext ? ",hasSemanticContext=" + this.hasSemanticContext : "") + (this.uniqueAlt !== ATN.INVALID_ALT_NUMBER ? ",uniqueAlt=" + this.uniqueAlt : "") + (this.conflictingAlts !== null ? ",conflictingAlts=" + this.conflictingAlts : "") + (this.dipsIntoOuterContext ? ",dipsIntoOuterContext" : "");
  26381. };
  26382. function OrderedATNConfigSet() {
  26383. ATNConfigSet.call(this);
  26384. this.configLookup = new Set();
  26385. return this;
  26386. }
  26387. OrderedATNConfigSet.prototype = Object.create(ATNConfigSet.prototype);
  26388. OrderedATNConfigSet.prototype.constructor = OrderedATNConfigSet;
  26389. exports.ATNConfigSet = ATNConfigSet;
  26390. exports.OrderedATNConfigSet = OrderedATNConfigSet;
  26391. /***/ }),
  26392. /***/ "./node_modules/antlr4/atn/ATNDeserializationOptions.js":
  26393. /*!**************************************************************!*\
  26394. !*** ./node_modules/antlr4/atn/ATNDeserializationOptions.js ***!
  26395. \**************************************************************/
  26396. /*! no static exports found */
  26397. /***/ (function(module, exports, __webpack_require__) {
  26398. "use strict";
  26399. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  26400. * Use of this file is governed by the BSD 3-clause license that
  26401. * can be found in the LICENSE.txt file in the project root.
  26402. */
  26403. function ATNDeserializationOptions(copyFrom) {
  26404. if (copyFrom === undefined) {
  26405. copyFrom = null;
  26406. }
  26407. this.readOnly = false;
  26408. this.verifyATN = copyFrom === null ? true : copyFrom.verifyATN;
  26409. this.generateRuleBypassTransitions = copyFrom === null ? false : copyFrom.generateRuleBypassTransitions;
  26410. return this;
  26411. }
  26412. ATNDeserializationOptions.defaultOptions = new ATNDeserializationOptions();
  26413. ATNDeserializationOptions.defaultOptions.readOnly = true;
  26414. // def __setattr__(self, key, value):
  26415. // if key!="readOnly" and self.readOnly:
  26416. // raise Exception("The object is read only.")
  26417. // super(type(self), self).__setattr__(key,value)
  26418. exports.ATNDeserializationOptions = ATNDeserializationOptions;
  26419. /***/ }),
  26420. /***/ "./node_modules/antlr4/atn/ATNDeserializer.js":
  26421. /*!****************************************************!*\
  26422. !*** ./node_modules/antlr4/atn/ATNDeserializer.js ***!
  26423. \****************************************************/
  26424. /*! no static exports found */
  26425. /***/ (function(module, exports, __webpack_require__) {
  26426. "use strict";
  26427. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  26428. * Use of this file is governed by the BSD 3-clause license that
  26429. * can be found in the LICENSE.txt file in the project root.
  26430. */
  26431. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  26432. var ATN = __webpack_require__(/*! ./ATN */ "./node_modules/antlr4/atn/ATN.js").ATN;
  26433. var ATNType = __webpack_require__(/*! ./ATNType */ "./node_modules/antlr4/atn/ATNType.js").ATNType;
  26434. var ATNStates = __webpack_require__(/*! ./ATNState */ "./node_modules/antlr4/atn/ATNState.js");
  26435. var ATNState = ATNStates.ATNState;
  26436. var BasicState = ATNStates.BasicState;
  26437. var DecisionState = ATNStates.DecisionState;
  26438. var BlockStartState = ATNStates.BlockStartState;
  26439. var BlockEndState = ATNStates.BlockEndState;
  26440. var LoopEndState = ATNStates.LoopEndState;
  26441. var RuleStartState = ATNStates.RuleStartState;
  26442. var RuleStopState = ATNStates.RuleStopState;
  26443. var TokensStartState = ATNStates.TokensStartState;
  26444. var PlusLoopbackState = ATNStates.PlusLoopbackState;
  26445. var StarLoopbackState = ATNStates.StarLoopbackState;
  26446. var StarLoopEntryState = ATNStates.StarLoopEntryState;
  26447. var PlusBlockStartState = ATNStates.PlusBlockStartState;
  26448. var StarBlockStartState = ATNStates.StarBlockStartState;
  26449. var BasicBlockStartState = ATNStates.BasicBlockStartState;
  26450. var Transitions = __webpack_require__(/*! ./Transition */ "./node_modules/antlr4/atn/Transition.js");
  26451. var Transition = Transitions.Transition;
  26452. var AtomTransition = Transitions.AtomTransition;
  26453. var SetTransition = Transitions.SetTransition;
  26454. var NotSetTransition = Transitions.NotSetTransition;
  26455. var RuleTransition = Transitions.RuleTransition;
  26456. var RangeTransition = Transitions.RangeTransition;
  26457. var ActionTransition = Transitions.ActionTransition;
  26458. var EpsilonTransition = Transitions.EpsilonTransition;
  26459. var WildcardTransition = Transitions.WildcardTransition;
  26460. var PredicateTransition = Transitions.PredicateTransition;
  26461. var PrecedencePredicateTransition = Transitions.PrecedencePredicateTransition;
  26462. var IntervalSet = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").IntervalSet;
  26463. var Interval = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  26464. var ATNDeserializationOptions = __webpack_require__(/*! ./ATNDeserializationOptions */ "./node_modules/antlr4/atn/ATNDeserializationOptions.js").ATNDeserializationOptions;
  26465. var LexerActions = __webpack_require__(/*! ./LexerAction */ "./node_modules/antlr4/atn/LexerAction.js");
  26466. var LexerActionType = LexerActions.LexerActionType;
  26467. var LexerSkipAction = LexerActions.LexerSkipAction;
  26468. var LexerChannelAction = LexerActions.LexerChannelAction;
  26469. var LexerCustomAction = LexerActions.LexerCustomAction;
  26470. var LexerMoreAction = LexerActions.LexerMoreAction;
  26471. var LexerTypeAction = LexerActions.LexerTypeAction;
  26472. var LexerPushModeAction = LexerActions.LexerPushModeAction;
  26473. var LexerPopModeAction = LexerActions.LexerPopModeAction;
  26474. var LexerModeAction = LexerActions.LexerModeAction;
  26475. // This is the earliest supported serialized UUID.
  26476. // stick to serialized version for now, we don't need a UUID instance
  26477. var BASE_SERIALIZED_UUID = "AADB8D7E-AEEF-4415-AD2B-8204D6CF042E";
  26478. //
  26479. // This UUID indicates the serialized ATN contains two sets of
  26480. // IntervalSets, where the second set's values are encoded as
  26481. // 32-bit integers to support the full Unicode SMP range up to U+10FFFF.
  26482. //
  26483. var ADDED_UNICODE_SMP = "59627784-3BE5-417A-B9EB-8131A7286089";
  26484. // This list contains all of the currently supported UUIDs, ordered by when
  26485. // the feature first appeared in this branch.
  26486. var SUPPORTED_UUIDS = [BASE_SERIALIZED_UUID, ADDED_UNICODE_SMP];
  26487. var SERIALIZED_VERSION = 3;
  26488. // This is the current serialized UUID.
  26489. var SERIALIZED_UUID = ADDED_UNICODE_SMP;
  26490. function initArray(length, value) {
  26491. var tmp = [];
  26492. tmp[length - 1] = value;
  26493. return tmp.map(function (i) {
  26494. return value;
  26495. });
  26496. }
  26497. function ATNDeserializer(options) {
  26498. if (options === undefined || options === null) {
  26499. options = ATNDeserializationOptions.defaultOptions;
  26500. }
  26501. this.deserializationOptions = options;
  26502. this.stateFactories = null;
  26503. this.actionFactories = null;
  26504. return this;
  26505. }
  26506. // Determines if a particular serialized representation of an ATN supports
  26507. // a particular feature, identified by the {@link UUID} used for serializing
  26508. // the ATN at the time the feature was first introduced.
  26509. //
  26510. // @param feature The {@link UUID} marking the first time the feature was
  26511. // supported in the serialized ATN.
  26512. // @param actualUuid The {@link UUID} of the actual serialized ATN which is
  26513. // currently being deserialized.
  26514. // @return {@code true} if the {@code actualUuid} value represents a
  26515. // serialized ATN at or after the feature identified by {@code feature} was
  26516. // introduced; otherwise, {@code false}.
  26517. ATNDeserializer.prototype.isFeatureSupported = function (feature, actualUuid) {
  26518. var idx1 = SUPPORTED_UUIDS.indexOf(feature);
  26519. if (idx1 < 0) {
  26520. return false;
  26521. }
  26522. var idx2 = SUPPORTED_UUIDS.indexOf(actualUuid);
  26523. return idx2 >= idx1;
  26524. };
  26525. ATNDeserializer.prototype.deserialize = function (data) {
  26526. this.reset(data);
  26527. this.checkVersion();
  26528. this.checkUUID();
  26529. var atn = this.readATN();
  26530. this.readStates(atn);
  26531. this.readRules(atn);
  26532. this.readModes(atn);
  26533. var sets = [];
  26534. // First, deserialize sets with 16-bit arguments <= U+FFFF.
  26535. this.readSets(atn, sets, this.readInt.bind(this));
  26536. // Next, if the ATN was serialized with the Unicode SMP feature,
  26537. // deserialize sets with 32-bit arguments <= U+10FFFF.
  26538. if (this.isFeatureSupported(ADDED_UNICODE_SMP, this.uuid)) {
  26539. this.readSets(atn, sets, this.readInt32.bind(this));
  26540. }
  26541. this.readEdges(atn, sets);
  26542. this.readDecisions(atn);
  26543. this.readLexerActions(atn);
  26544. this.markPrecedenceDecisions(atn);
  26545. this.verifyATN(atn);
  26546. if (this.deserializationOptions.generateRuleBypassTransitions && atn.grammarType === ATNType.PARSER) {
  26547. this.generateRuleBypassTransitions(atn);
  26548. // re-verify after modification
  26549. this.verifyATN(atn);
  26550. }
  26551. return atn;
  26552. };
  26553. ATNDeserializer.prototype.reset = function (data) {
  26554. var adjust = function adjust(c) {
  26555. var v = c.charCodeAt(0);
  26556. return v > 1 ? v - 2 : v + 65533;
  26557. };
  26558. var temp = data.split("").map(adjust);
  26559. // don't adjust the first value since that's the version number
  26560. temp[0] = data.charCodeAt(0);
  26561. this.data = temp;
  26562. this.pos = 0;
  26563. };
  26564. ATNDeserializer.prototype.checkVersion = function () {
  26565. var version = this.readInt();
  26566. if (version !== SERIALIZED_VERSION) {
  26567. throw "Could not deserialize ATN with version " + version + " (expected " + SERIALIZED_VERSION + ").";
  26568. }
  26569. };
  26570. ATNDeserializer.prototype.checkUUID = function () {
  26571. var uuid = this.readUUID();
  26572. if (SUPPORTED_UUIDS.indexOf(uuid) < 0) {
  26573. throw "Could not deserialize ATN with UUID: " + uuid + " (expected " + SERIALIZED_UUID + " or a legacy UUID).", uuid, SERIALIZED_UUID;
  26574. }
  26575. this.uuid = uuid;
  26576. };
  26577. ATNDeserializer.prototype.readATN = function () {
  26578. var grammarType = this.readInt();
  26579. var maxTokenType = this.readInt();
  26580. return new ATN(grammarType, maxTokenType);
  26581. };
  26582. ATNDeserializer.prototype.readStates = function (atn) {
  26583. var j, pair, stateNumber;
  26584. var loopBackStateNumbers = [];
  26585. var endStateNumbers = [];
  26586. var nstates = this.readInt();
  26587. for (var i = 0; i < nstates; i++) {
  26588. var stype = this.readInt();
  26589. // ignore bad type of states
  26590. if (stype === ATNState.INVALID_TYPE) {
  26591. atn.addState(null);
  26592. continue;
  26593. }
  26594. var ruleIndex = this.readInt();
  26595. if (ruleIndex === 0xFFFF) {
  26596. ruleIndex = -1;
  26597. }
  26598. var s = this.stateFactory(stype, ruleIndex);
  26599. if (stype === ATNState.LOOP_END) {
  26600. // special case
  26601. var loopBackStateNumber = this.readInt();
  26602. loopBackStateNumbers.push([s, loopBackStateNumber]);
  26603. } else if (s instanceof BlockStartState) {
  26604. var endStateNumber = this.readInt();
  26605. endStateNumbers.push([s, endStateNumber]);
  26606. }
  26607. atn.addState(s);
  26608. }
  26609. // delay the assignment of loop back and end states until we know all the
  26610. // state instances have been initialized
  26611. for (j = 0; j < loopBackStateNumbers.length; j++) {
  26612. pair = loopBackStateNumbers[j];
  26613. pair[0].loopBackState = atn.states[pair[1]];
  26614. }
  26615. for (j = 0; j < endStateNumbers.length; j++) {
  26616. pair = endStateNumbers[j];
  26617. pair[0].endState = atn.states[pair[1]];
  26618. }
  26619. var numNonGreedyStates = this.readInt();
  26620. for (j = 0; j < numNonGreedyStates; j++) {
  26621. stateNumber = this.readInt();
  26622. atn.states[stateNumber].nonGreedy = true;
  26623. }
  26624. var numPrecedenceStates = this.readInt();
  26625. for (j = 0; j < numPrecedenceStates; j++) {
  26626. stateNumber = this.readInt();
  26627. atn.states[stateNumber].isPrecedenceRule = true;
  26628. }
  26629. };
  26630. ATNDeserializer.prototype.readRules = function (atn) {
  26631. var i;
  26632. var nrules = this.readInt();
  26633. if (atn.grammarType === ATNType.LEXER) {
  26634. atn.ruleToTokenType = initArray(nrules, 0);
  26635. }
  26636. atn.ruleToStartState = initArray(nrules, 0);
  26637. for (i = 0; i < nrules; i++) {
  26638. var s = this.readInt();
  26639. var startState = atn.states[s];
  26640. atn.ruleToStartState[i] = startState;
  26641. if (atn.grammarType === ATNType.LEXER) {
  26642. var tokenType = this.readInt();
  26643. if (tokenType === 0xFFFF) {
  26644. tokenType = Token.EOF;
  26645. }
  26646. atn.ruleToTokenType[i] = tokenType;
  26647. }
  26648. }
  26649. atn.ruleToStopState = initArray(nrules, 0);
  26650. for (i = 0; i < atn.states.length; i++) {
  26651. var state = atn.states[i];
  26652. if (!(state instanceof RuleStopState)) {
  26653. continue;
  26654. }
  26655. atn.ruleToStopState[state.ruleIndex] = state;
  26656. atn.ruleToStartState[state.ruleIndex].stopState = state;
  26657. }
  26658. };
  26659. ATNDeserializer.prototype.readModes = function (atn) {
  26660. var nmodes = this.readInt();
  26661. for (var i = 0; i < nmodes; i++) {
  26662. var s = this.readInt();
  26663. atn.modeToStartState.push(atn.states[s]);
  26664. }
  26665. };
  26666. ATNDeserializer.prototype.readSets = function (atn, sets, readUnicode) {
  26667. var m = this.readInt();
  26668. for (var i = 0; i < m; i++) {
  26669. var iset = new IntervalSet();
  26670. sets.push(iset);
  26671. var n = this.readInt();
  26672. var containsEof = this.readInt();
  26673. if (containsEof !== 0) {
  26674. iset.addOne(-1);
  26675. }
  26676. for (var j = 0; j < n; j++) {
  26677. var i1 = readUnicode();
  26678. var i2 = readUnicode();
  26679. iset.addRange(i1, i2);
  26680. }
  26681. }
  26682. };
  26683. ATNDeserializer.prototype.readEdges = function (atn, sets) {
  26684. var i, j, state, trans, target;
  26685. var nedges = this.readInt();
  26686. for (i = 0; i < nedges; i++) {
  26687. var src = this.readInt();
  26688. var trg = this.readInt();
  26689. var ttype = this.readInt();
  26690. var arg1 = this.readInt();
  26691. var arg2 = this.readInt();
  26692. var arg3 = this.readInt();
  26693. trans = this.edgeFactory(atn, ttype, src, trg, arg1, arg2, arg3, sets);
  26694. var srcState = atn.states[src];
  26695. srcState.addTransition(trans);
  26696. }
  26697. // edges for rule stop states can be derived, so they aren't serialized
  26698. for (i = 0; i < atn.states.length; i++) {
  26699. state = atn.states[i];
  26700. for (j = 0; j < state.transitions.length; j++) {
  26701. var t = state.transitions[j];
  26702. if (!(t instanceof RuleTransition)) {
  26703. continue;
  26704. }
  26705. var outermostPrecedenceReturn = -1;
  26706. if (atn.ruleToStartState[t.target.ruleIndex].isPrecedenceRule) {
  26707. if (t.precedence === 0) {
  26708. outermostPrecedenceReturn = t.target.ruleIndex;
  26709. }
  26710. }
  26711. trans = new EpsilonTransition(t.followState, outermostPrecedenceReturn);
  26712. atn.ruleToStopState[t.target.ruleIndex].addTransition(trans);
  26713. }
  26714. }
  26715. for (i = 0; i < atn.states.length; i++) {
  26716. state = atn.states[i];
  26717. if (state instanceof BlockStartState) {
  26718. // we need to know the end state to set its start state
  26719. if (state.endState === null) {
  26720. throw "IllegalState";
  26721. }
  26722. // block end states can only be associated to a single block start
  26723. // state
  26724. if (state.endState.startState !== null) {
  26725. throw "IllegalState";
  26726. }
  26727. state.endState.startState = state;
  26728. }
  26729. if (state instanceof PlusLoopbackState) {
  26730. for (j = 0; j < state.transitions.length; j++) {
  26731. target = state.transitions[j].target;
  26732. if (target instanceof PlusBlockStartState) {
  26733. target.loopBackState = state;
  26734. }
  26735. }
  26736. } else if (state instanceof StarLoopbackState) {
  26737. for (j = 0; j < state.transitions.length; j++) {
  26738. target = state.transitions[j].target;
  26739. if (target instanceof StarLoopEntryState) {
  26740. target.loopBackState = state;
  26741. }
  26742. }
  26743. }
  26744. }
  26745. };
  26746. ATNDeserializer.prototype.readDecisions = function (atn) {
  26747. var ndecisions = this.readInt();
  26748. for (var i = 0; i < ndecisions; i++) {
  26749. var s = this.readInt();
  26750. var decState = atn.states[s];
  26751. atn.decisionToState.push(decState);
  26752. decState.decision = i;
  26753. }
  26754. };
  26755. ATNDeserializer.prototype.readLexerActions = function (atn) {
  26756. if (atn.grammarType === ATNType.LEXER) {
  26757. var count = this.readInt();
  26758. atn.lexerActions = initArray(count, null);
  26759. for (var i = 0; i < count; i++) {
  26760. var actionType = this.readInt();
  26761. var data1 = this.readInt();
  26762. if (data1 === 0xFFFF) {
  26763. data1 = -1;
  26764. }
  26765. var data2 = this.readInt();
  26766. if (data2 === 0xFFFF) {
  26767. data2 = -1;
  26768. }
  26769. var lexerAction = this.lexerActionFactory(actionType, data1, data2);
  26770. atn.lexerActions[i] = lexerAction;
  26771. }
  26772. }
  26773. };
  26774. ATNDeserializer.prototype.generateRuleBypassTransitions = function (atn) {
  26775. var i;
  26776. var count = atn.ruleToStartState.length;
  26777. for (i = 0; i < count; i++) {
  26778. atn.ruleToTokenType[i] = atn.maxTokenType + i + 1;
  26779. }
  26780. for (i = 0; i < count; i++) {
  26781. this.generateRuleBypassTransition(atn, i);
  26782. }
  26783. };
  26784. ATNDeserializer.prototype.generateRuleBypassTransition = function (atn, idx) {
  26785. var i, state;
  26786. var bypassStart = new BasicBlockStartState();
  26787. bypassStart.ruleIndex = idx;
  26788. atn.addState(bypassStart);
  26789. var bypassStop = new BlockEndState();
  26790. bypassStop.ruleIndex = idx;
  26791. atn.addState(bypassStop);
  26792. bypassStart.endState = bypassStop;
  26793. atn.defineDecisionState(bypassStart);
  26794. bypassStop.startState = bypassStart;
  26795. var excludeTransition = null;
  26796. var endState = null;
  26797. if (atn.ruleToStartState[idx].isPrecedenceRule) {
  26798. // wrap from the beginning of the rule to the StarLoopEntryState
  26799. endState = null;
  26800. for (i = 0; i < atn.states.length; i++) {
  26801. state = atn.states[i];
  26802. if (this.stateIsEndStateFor(state, idx)) {
  26803. endState = state;
  26804. excludeTransition = state.loopBackState.transitions[0];
  26805. break;
  26806. }
  26807. }
  26808. if (excludeTransition === null) {
  26809. throw "Couldn't identify final state of the precedence rule prefix section.";
  26810. }
  26811. } else {
  26812. endState = atn.ruleToStopState[idx];
  26813. }
  26814. // all non-excluded transitions that currently target end state need to
  26815. // target blockEnd instead
  26816. for (i = 0; i < atn.states.length; i++) {
  26817. state = atn.states[i];
  26818. for (var j = 0; j < state.transitions.length; j++) {
  26819. var transition = state.transitions[j];
  26820. if (transition === excludeTransition) {
  26821. continue;
  26822. }
  26823. if (transition.target === endState) {
  26824. transition.target = bypassStop;
  26825. }
  26826. }
  26827. }
  26828. // all transitions leaving the rule start state need to leave blockStart
  26829. // instead
  26830. var ruleToStartState = atn.ruleToStartState[idx];
  26831. var count = ruleToStartState.transitions.length;
  26832. while (count > 0) {
  26833. bypassStart.addTransition(ruleToStartState.transitions[count - 1]);
  26834. ruleToStartState.transitions = ruleToStartState.transitions.slice(-1);
  26835. }
  26836. // link the new states
  26837. atn.ruleToStartState[idx].addTransition(new EpsilonTransition(bypassStart));
  26838. bypassStop.addTransition(new EpsilonTransition(endState));
  26839. var matchState = new BasicState();
  26840. atn.addState(matchState);
  26841. matchState.addTransition(new AtomTransition(bypassStop, atn.ruleToTokenType[idx]));
  26842. bypassStart.addTransition(new EpsilonTransition(matchState));
  26843. };
  26844. ATNDeserializer.prototype.stateIsEndStateFor = function (state, idx) {
  26845. if (state.ruleIndex !== idx) {
  26846. return null;
  26847. }
  26848. if (!(state instanceof StarLoopEntryState)) {
  26849. return null;
  26850. }
  26851. var maybeLoopEndState = state.transitions[state.transitions.length - 1].target;
  26852. if (!(maybeLoopEndState instanceof LoopEndState)) {
  26853. return null;
  26854. }
  26855. if (maybeLoopEndState.epsilonOnlyTransitions && maybeLoopEndState.transitions[0].target instanceof RuleStopState) {
  26856. return state;
  26857. } else {
  26858. return null;
  26859. }
  26860. };
  26861. //
  26862. // Analyze the {@link StarLoopEntryState} states in the specified ATN to set
  26863. // the {@link StarLoopEntryState//isPrecedenceDecision} field to the
  26864. // correct value.
  26865. //
  26866. // @param atn The ATN.
  26867. //
  26868. ATNDeserializer.prototype.markPrecedenceDecisions = function (atn) {
  26869. for (var i = 0; i < atn.states.length; i++) {
  26870. var state = atn.states[i];
  26871. if (!(state instanceof StarLoopEntryState)) {
  26872. continue;
  26873. }
  26874. // We analyze the ATN to determine if this ATN decision state is the
  26875. // decision for the closure block that determines whether a
  26876. // precedence rule should continue or complete.
  26877. //
  26878. if (atn.ruleToStartState[state.ruleIndex].isPrecedenceRule) {
  26879. var maybeLoopEndState = state.transitions[state.transitions.length - 1].target;
  26880. if (maybeLoopEndState instanceof LoopEndState) {
  26881. if (maybeLoopEndState.epsilonOnlyTransitions && maybeLoopEndState.transitions[0].target instanceof RuleStopState) {
  26882. state.isPrecedenceDecision = true;
  26883. }
  26884. }
  26885. }
  26886. }
  26887. };
  26888. ATNDeserializer.prototype.verifyATN = function (atn) {
  26889. if (!this.deserializationOptions.verifyATN) {
  26890. return;
  26891. }
  26892. // verify assumptions
  26893. for (var i = 0; i < atn.states.length; i++) {
  26894. var state = atn.states[i];
  26895. if (state === null) {
  26896. continue;
  26897. }
  26898. this.checkCondition(state.epsilonOnlyTransitions || state.transitions.length <= 1);
  26899. if (state instanceof PlusBlockStartState) {
  26900. this.checkCondition(state.loopBackState !== null);
  26901. } else if (state instanceof StarLoopEntryState) {
  26902. this.checkCondition(state.loopBackState !== null);
  26903. this.checkCondition(state.transitions.length === 2);
  26904. if (state.transitions[0].target instanceof StarBlockStartState) {
  26905. this.checkCondition(state.transitions[1].target instanceof LoopEndState);
  26906. this.checkCondition(!state.nonGreedy);
  26907. } else if (state.transitions[0].target instanceof LoopEndState) {
  26908. this.checkCondition(state.transitions[1].target instanceof StarBlockStartState);
  26909. this.checkCondition(state.nonGreedy);
  26910. } else {
  26911. throw "IllegalState";
  26912. }
  26913. } else if (state instanceof StarLoopbackState) {
  26914. this.checkCondition(state.transitions.length === 1);
  26915. this.checkCondition(state.transitions[0].target instanceof StarLoopEntryState);
  26916. } else if (state instanceof LoopEndState) {
  26917. this.checkCondition(state.loopBackState !== null);
  26918. } else if (state instanceof RuleStartState) {
  26919. this.checkCondition(state.stopState !== null);
  26920. } else if (state instanceof BlockStartState) {
  26921. this.checkCondition(state.endState !== null);
  26922. } else if (state instanceof BlockEndState) {
  26923. this.checkCondition(state.startState !== null);
  26924. } else if (state instanceof DecisionState) {
  26925. this.checkCondition(state.transitions.length <= 1 || state.decision >= 0);
  26926. } else {
  26927. this.checkCondition(state.transitions.length <= 1 || state instanceof RuleStopState);
  26928. }
  26929. }
  26930. };
  26931. ATNDeserializer.prototype.checkCondition = function (condition, message) {
  26932. if (!condition) {
  26933. if (message === undefined || message === null) {
  26934. message = "IllegalState";
  26935. }
  26936. throw message;
  26937. }
  26938. };
  26939. ATNDeserializer.prototype.readInt = function () {
  26940. return this.data[this.pos++];
  26941. };
  26942. ATNDeserializer.prototype.readInt32 = function () {
  26943. var low = this.readInt();
  26944. var high = this.readInt();
  26945. return low | high << 16;
  26946. };
  26947. ATNDeserializer.prototype.readLong = function () {
  26948. var low = this.readInt32();
  26949. var high = this.readInt32();
  26950. return low & 0x00000000FFFFFFFF | high << 32;
  26951. };
  26952. function createByteToHex() {
  26953. var bth = [];
  26954. for (var i = 0; i < 256; i++) {
  26955. bth[i] = (i + 0x100).toString(16).substr(1).toUpperCase();
  26956. }
  26957. return bth;
  26958. }
  26959. var byteToHex = createByteToHex();
  26960. ATNDeserializer.prototype.readUUID = function () {
  26961. var bb = [];
  26962. for (var i = 7; i >= 0; i--) {
  26963. var int = this.readInt();
  26964. /* jshint bitwise: false */
  26965. bb[2 * i + 1] = int & 0xFF;
  26966. bb[2 * i] = int >> 8 & 0xFF;
  26967. }
  26968. return byteToHex[bb[0]] + byteToHex[bb[1]] + byteToHex[bb[2]] + byteToHex[bb[3]] + '-' + byteToHex[bb[4]] + byteToHex[bb[5]] + '-' + byteToHex[bb[6]] + byteToHex[bb[7]] + '-' + byteToHex[bb[8]] + byteToHex[bb[9]] + '-' + byteToHex[bb[10]] + byteToHex[bb[11]] + byteToHex[bb[12]] + byteToHex[bb[13]] + byteToHex[bb[14]] + byteToHex[bb[15]];
  26969. };
  26970. ATNDeserializer.prototype.edgeFactory = function (atn, type, src, trg, arg1, arg2, arg3, sets) {
  26971. var target = atn.states[trg];
  26972. switch (type) {
  26973. case Transition.EPSILON:
  26974. return new EpsilonTransition(target);
  26975. case Transition.RANGE:
  26976. return arg3 !== 0 ? new RangeTransition(target, Token.EOF, arg2) : new RangeTransition(target, arg1, arg2);
  26977. case Transition.RULE:
  26978. return new RuleTransition(atn.states[arg1], arg2, arg3, target);
  26979. case Transition.PREDICATE:
  26980. return new PredicateTransition(target, arg1, arg2, arg3 !== 0);
  26981. case Transition.PRECEDENCE:
  26982. return new PrecedencePredicateTransition(target, arg1);
  26983. case Transition.ATOM:
  26984. return arg3 !== 0 ? new AtomTransition(target, Token.EOF) : new AtomTransition(target, arg1);
  26985. case Transition.ACTION:
  26986. return new ActionTransition(target, arg1, arg2, arg3 !== 0);
  26987. case Transition.SET:
  26988. return new SetTransition(target, sets[arg1]);
  26989. case Transition.NOT_SET:
  26990. return new NotSetTransition(target, sets[arg1]);
  26991. case Transition.WILDCARD:
  26992. return new WildcardTransition(target);
  26993. default:
  26994. throw "The specified transition type: " + type + " is not valid.";
  26995. }
  26996. };
  26997. ATNDeserializer.prototype.stateFactory = function (type, ruleIndex) {
  26998. if (this.stateFactories === null) {
  26999. var sf = [];
  27000. sf[ATNState.INVALID_TYPE] = null;
  27001. sf[ATNState.BASIC] = function () {
  27002. return new BasicState();
  27003. };
  27004. sf[ATNState.RULE_START] = function () {
  27005. return new RuleStartState();
  27006. };
  27007. sf[ATNState.BLOCK_START] = function () {
  27008. return new BasicBlockStartState();
  27009. };
  27010. sf[ATNState.PLUS_BLOCK_START] = function () {
  27011. return new PlusBlockStartState();
  27012. };
  27013. sf[ATNState.STAR_BLOCK_START] = function () {
  27014. return new StarBlockStartState();
  27015. };
  27016. sf[ATNState.TOKEN_START] = function () {
  27017. return new TokensStartState();
  27018. };
  27019. sf[ATNState.RULE_STOP] = function () {
  27020. return new RuleStopState();
  27021. };
  27022. sf[ATNState.BLOCK_END] = function () {
  27023. return new BlockEndState();
  27024. };
  27025. sf[ATNState.STAR_LOOP_BACK] = function () {
  27026. return new StarLoopbackState();
  27027. };
  27028. sf[ATNState.STAR_LOOP_ENTRY] = function () {
  27029. return new StarLoopEntryState();
  27030. };
  27031. sf[ATNState.PLUS_LOOP_BACK] = function () {
  27032. return new PlusLoopbackState();
  27033. };
  27034. sf[ATNState.LOOP_END] = function () {
  27035. return new LoopEndState();
  27036. };
  27037. this.stateFactories = sf;
  27038. }
  27039. if (type > this.stateFactories.length || this.stateFactories[type] === null) {
  27040. throw "The specified state type " + type + " is not valid.";
  27041. } else {
  27042. var s = this.stateFactories[type]();
  27043. if (s !== null) {
  27044. s.ruleIndex = ruleIndex;
  27045. return s;
  27046. }
  27047. }
  27048. };
  27049. ATNDeserializer.prototype.lexerActionFactory = function (type, data1, data2) {
  27050. if (this.actionFactories === null) {
  27051. var af = [];
  27052. af[LexerActionType.CHANNEL] = function (data1, data2) {
  27053. return new LexerChannelAction(data1);
  27054. };
  27055. af[LexerActionType.CUSTOM] = function (data1, data2) {
  27056. return new LexerCustomAction(data1, data2);
  27057. };
  27058. af[LexerActionType.MODE] = function (data1, data2) {
  27059. return new LexerModeAction(data1);
  27060. };
  27061. af[LexerActionType.MORE] = function (data1, data2) {
  27062. return LexerMoreAction.INSTANCE;
  27063. };
  27064. af[LexerActionType.POP_MODE] = function (data1, data2) {
  27065. return LexerPopModeAction.INSTANCE;
  27066. };
  27067. af[LexerActionType.PUSH_MODE] = function (data1, data2) {
  27068. return new LexerPushModeAction(data1);
  27069. };
  27070. af[LexerActionType.SKIP] = function (data1, data2) {
  27071. return LexerSkipAction.INSTANCE;
  27072. };
  27073. af[LexerActionType.TYPE] = function (data1, data2) {
  27074. return new LexerTypeAction(data1);
  27075. };
  27076. this.actionFactories = af;
  27077. }
  27078. if (type > this.actionFactories.length || this.actionFactories[type] === null) {
  27079. throw "The specified lexer action type " + type + " is not valid.";
  27080. } else {
  27081. return this.actionFactories[type](data1, data2);
  27082. }
  27083. };
  27084. exports.ATNDeserializer = ATNDeserializer;
  27085. /***/ }),
  27086. /***/ "./node_modules/antlr4/atn/ATNSimulator.js":
  27087. /*!*************************************************!*\
  27088. !*** ./node_modules/antlr4/atn/ATNSimulator.js ***!
  27089. \*************************************************/
  27090. /*! no static exports found */
  27091. /***/ (function(module, exports, __webpack_require__) {
  27092. "use strict";
  27093. //
  27094. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  27095. * Use of this file is governed by the BSD 3-clause license that
  27096. * can be found in the LICENSE.txt file in the project root.
  27097. */
  27098. ///
  27099. var DFAState = __webpack_require__(/*! ./../dfa/DFAState */ "./node_modules/antlr4/dfa/DFAState.js").DFAState;
  27100. var ATNConfigSet = __webpack_require__(/*! ./ATNConfigSet */ "./node_modules/antlr4/atn/ATNConfigSet.js").ATNConfigSet;
  27101. var getCachedPredictionContext = __webpack_require__(/*! ./../PredictionContext */ "./node_modules/antlr4/PredictionContext.js").getCachedPredictionContext;
  27102. function ATNSimulator(atn, sharedContextCache) {
  27103. // The context cache maps all PredictionContext objects that are ==
  27104. // to a single cached copy. This cache is shared across all contexts
  27105. // in all ATNConfigs in all DFA states. We rebuild each ATNConfigSet
  27106. // to use only cached nodes/graphs in addDFAState(). We don't want to
  27107. // fill this during closure() since there are lots of contexts that
  27108. // pop up but are not used ever again. It also greatly slows down closure().
  27109. //
  27110. // <p>This cache makes a huge difference in memory and a little bit in speed.
  27111. // For the Java grammar on java.*, it dropped the memory requirements
  27112. // at the end from 25M to 16M. We don't store any of the full context
  27113. // graphs in the DFA because they are limited to local context only,
  27114. // but apparently there's a lot of repetition there as well. We optimize
  27115. // the config contexts before storing the config set in the DFA states
  27116. // by literally rebuilding them with cached subgraphs only.</p>
  27117. //
  27118. // <p>I tried a cache for use during closure operations, that was
  27119. // whacked after each adaptivePredict(). It cost a little bit
  27120. // more time I think and doesn't save on the overall footprint
  27121. // so it's not worth the complexity.</p>
  27122. ///
  27123. this.atn = atn;
  27124. this.sharedContextCache = sharedContextCache;
  27125. return this;
  27126. }
  27127. // Must distinguish between missing edge and edge we know leads nowhere///
  27128. ATNSimulator.ERROR = new DFAState(0x7FFFFFFF, new ATNConfigSet());
  27129. ATNSimulator.prototype.getCachedContext = function (context) {
  27130. if (this.sharedContextCache === null) {
  27131. return context;
  27132. }
  27133. var visited = {};
  27134. return getCachedPredictionContext(context, this.sharedContextCache, visited);
  27135. };
  27136. exports.ATNSimulator = ATNSimulator;
  27137. /***/ }),
  27138. /***/ "./node_modules/antlr4/atn/ATNState.js":
  27139. /*!*********************************************!*\
  27140. !*** ./node_modules/antlr4/atn/ATNState.js ***!
  27141. \*********************************************/
  27142. /*! no static exports found */
  27143. /***/ (function(module, exports, __webpack_require__) {
  27144. "use strict";
  27145. //
  27146. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  27147. * Use of this file is governed by the BSD 3-clause license that
  27148. * can be found in the LICENSE.txt file in the project root.
  27149. */
  27150. //
  27151. // The following images show the relation of states and
  27152. // {@link ATNState//transitions} for various grammar constructs.
  27153. //
  27154. // <ul>
  27155. //
  27156. // <li>Solid edges marked with an &//0949; indicate a required
  27157. // {@link EpsilonTransition}.</li>
  27158. //
  27159. // <li>Dashed edges indicate locations where any transition derived from
  27160. // {@link Transition} might appear.</li>
  27161. //
  27162. // <li>Dashed nodes are place holders for either a sequence of linked
  27163. // {@link BasicState} states or the inclusion of a block representing a nested
  27164. // construct in one of the forms below.</li>
  27165. //
  27166. // <li>Nodes showing multiple outgoing alternatives with a {@code ...} support
  27167. // any number of alternatives (one or more). Nodes without the {@code ...} only
  27168. // support the exact number of alternatives shown in the diagram.</li>
  27169. //
  27170. // </ul>
  27171. //
  27172. // <h2>Basic Blocks</h2>
  27173. //
  27174. // <h3>Rule</h3>
  27175. //
  27176. // <embed src="images/Rule.svg" type="image/svg+xml"/>
  27177. //
  27178. // <h3>Block of 1 or more alternatives</h3>
  27179. //
  27180. // <embed src="images/Block.svg" type="image/svg+xml"/>
  27181. //
  27182. // <h2>Greedy Loops</h2>
  27183. //
  27184. // <h3>Greedy Closure: {@code (...)*}</h3>
  27185. //
  27186. // <embed src="images/ClosureGreedy.svg" type="image/svg+xml"/>
  27187. //
  27188. // <h3>Greedy Positive Closure: {@code (...)+}</h3>
  27189. //
  27190. // <embed src="images/PositiveClosureGreedy.svg" type="image/svg+xml"/>
  27191. //
  27192. // <h3>Greedy Optional: {@code (...)?}</h3>
  27193. //
  27194. // <embed src="images/OptionalGreedy.svg" type="image/svg+xml"/>
  27195. //
  27196. // <h2>Non-Greedy Loops</h2>
  27197. //
  27198. // <h3>Non-Greedy Closure: {@code (...)*?}</h3>
  27199. //
  27200. // <embed src="images/ClosureNonGreedy.svg" type="image/svg+xml"/>
  27201. //
  27202. // <h3>Non-Greedy Positive Closure: {@code (...)+?}</h3>
  27203. //
  27204. // <embed src="images/PositiveClosureNonGreedy.svg" type="image/svg+xml"/>
  27205. //
  27206. // <h3>Non-Greedy Optional: {@code (...)??}</h3>
  27207. //
  27208. // <embed src="images/OptionalNonGreedy.svg" type="image/svg+xml"/>
  27209. //
  27210. var INITIAL_NUM_TRANSITIONS = 4;
  27211. function ATNState() {
  27212. // Which ATN are we in?
  27213. this.atn = null;
  27214. this.stateNumber = ATNState.INVALID_STATE_NUMBER;
  27215. this.stateType = null;
  27216. this.ruleIndex = 0; // at runtime, we don't have Rule objects
  27217. this.epsilonOnlyTransitions = false;
  27218. // Track the transitions emanating from this ATN state.
  27219. this.transitions = [];
  27220. // Used to cache lookahead during parsing, not used during construction
  27221. this.nextTokenWithinRule = null;
  27222. return this;
  27223. }
  27224. // constants for serialization
  27225. ATNState.INVALID_TYPE = 0;
  27226. ATNState.BASIC = 1;
  27227. ATNState.RULE_START = 2;
  27228. ATNState.BLOCK_START = 3;
  27229. ATNState.PLUS_BLOCK_START = 4;
  27230. ATNState.STAR_BLOCK_START = 5;
  27231. ATNState.TOKEN_START = 6;
  27232. ATNState.RULE_STOP = 7;
  27233. ATNState.BLOCK_END = 8;
  27234. ATNState.STAR_LOOP_BACK = 9;
  27235. ATNState.STAR_LOOP_ENTRY = 10;
  27236. ATNState.PLUS_LOOP_BACK = 11;
  27237. ATNState.LOOP_END = 12;
  27238. ATNState.serializationNames = ["INVALID", "BASIC", "RULE_START", "BLOCK_START", "PLUS_BLOCK_START", "STAR_BLOCK_START", "TOKEN_START", "RULE_STOP", "BLOCK_END", "STAR_LOOP_BACK", "STAR_LOOP_ENTRY", "PLUS_LOOP_BACK", "LOOP_END"];
  27239. ATNState.INVALID_STATE_NUMBER = -1;
  27240. ATNState.prototype.toString = function () {
  27241. return this.stateNumber;
  27242. };
  27243. ATNState.prototype.equals = function (other) {
  27244. if (other instanceof ATNState) {
  27245. return this.stateNumber === other.stateNumber;
  27246. } else {
  27247. return false;
  27248. }
  27249. };
  27250. ATNState.prototype.isNonGreedyExitState = function () {
  27251. return false;
  27252. };
  27253. ATNState.prototype.addTransition = function (trans, index) {
  27254. if (index === undefined) {
  27255. index = -1;
  27256. }
  27257. if (this.transitions.length === 0) {
  27258. this.epsilonOnlyTransitions = trans.isEpsilon;
  27259. } else if (this.epsilonOnlyTransitions !== trans.isEpsilon) {
  27260. this.epsilonOnlyTransitions = false;
  27261. }
  27262. if (index === -1) {
  27263. this.transitions.push(trans);
  27264. } else {
  27265. this.transitions.splice(index, 1, trans);
  27266. }
  27267. };
  27268. function BasicState() {
  27269. ATNState.call(this);
  27270. this.stateType = ATNState.BASIC;
  27271. return this;
  27272. }
  27273. BasicState.prototype = Object.create(ATNState.prototype);
  27274. BasicState.prototype.constructor = BasicState;
  27275. function DecisionState() {
  27276. ATNState.call(this);
  27277. this.decision = -1;
  27278. this.nonGreedy = false;
  27279. return this;
  27280. }
  27281. DecisionState.prototype = Object.create(ATNState.prototype);
  27282. DecisionState.prototype.constructor = DecisionState;
  27283. // The start of a regular {@code (...)} block.
  27284. function BlockStartState() {
  27285. DecisionState.call(this);
  27286. this.endState = null;
  27287. return this;
  27288. }
  27289. BlockStartState.prototype = Object.create(DecisionState.prototype);
  27290. BlockStartState.prototype.constructor = BlockStartState;
  27291. function BasicBlockStartState() {
  27292. BlockStartState.call(this);
  27293. this.stateType = ATNState.BLOCK_START;
  27294. return this;
  27295. }
  27296. BasicBlockStartState.prototype = Object.create(BlockStartState.prototype);
  27297. BasicBlockStartState.prototype.constructor = BasicBlockStartState;
  27298. // Terminal node of a simple {@code (a|b|c)} block.
  27299. function BlockEndState() {
  27300. ATNState.call(this);
  27301. this.stateType = ATNState.BLOCK_END;
  27302. this.startState = null;
  27303. return this;
  27304. }
  27305. BlockEndState.prototype = Object.create(ATNState.prototype);
  27306. BlockEndState.prototype.constructor = BlockEndState;
  27307. // The last node in the ATN for a rule, unless that rule is the start symbol.
  27308. // In that case, there is one transition to EOF. Later, we might encode
  27309. // references to all calls to this rule to compute FOLLOW sets for
  27310. // error handling.
  27311. //
  27312. function RuleStopState() {
  27313. ATNState.call(this);
  27314. this.stateType = ATNState.RULE_STOP;
  27315. return this;
  27316. }
  27317. RuleStopState.prototype = Object.create(ATNState.prototype);
  27318. RuleStopState.prototype.constructor = RuleStopState;
  27319. function RuleStartState() {
  27320. ATNState.call(this);
  27321. this.stateType = ATNState.RULE_START;
  27322. this.stopState = null;
  27323. this.isPrecedenceRule = false;
  27324. return this;
  27325. }
  27326. RuleStartState.prototype = Object.create(ATNState.prototype);
  27327. RuleStartState.prototype.constructor = RuleStartState;
  27328. // Decision state for {@code A+} and {@code (A|B)+}. It has two transitions:
  27329. // one to the loop back to start of the block and one to exit.
  27330. //
  27331. function PlusLoopbackState() {
  27332. DecisionState.call(this);
  27333. this.stateType = ATNState.PLUS_LOOP_BACK;
  27334. return this;
  27335. }
  27336. PlusLoopbackState.prototype = Object.create(DecisionState.prototype);
  27337. PlusLoopbackState.prototype.constructor = PlusLoopbackState;
  27338. // Start of {@code (A|B|...)+} loop. Technically a decision state, but
  27339. // we don't use for code generation; somebody might need it, so I'm defining
  27340. // it for completeness. In reality, the {@link PlusLoopbackState} node is the
  27341. // real decision-making note for {@code A+}.
  27342. //
  27343. function PlusBlockStartState() {
  27344. BlockStartState.call(this);
  27345. this.stateType = ATNState.PLUS_BLOCK_START;
  27346. this.loopBackState = null;
  27347. return this;
  27348. }
  27349. PlusBlockStartState.prototype = Object.create(BlockStartState.prototype);
  27350. PlusBlockStartState.prototype.constructor = PlusBlockStartState;
  27351. // The block that begins a closure loop.
  27352. function StarBlockStartState() {
  27353. BlockStartState.call(this);
  27354. this.stateType = ATNState.STAR_BLOCK_START;
  27355. return this;
  27356. }
  27357. StarBlockStartState.prototype = Object.create(BlockStartState.prototype);
  27358. StarBlockStartState.prototype.constructor = StarBlockStartState;
  27359. function StarLoopbackState() {
  27360. ATNState.call(this);
  27361. this.stateType = ATNState.STAR_LOOP_BACK;
  27362. return this;
  27363. }
  27364. StarLoopbackState.prototype = Object.create(ATNState.prototype);
  27365. StarLoopbackState.prototype.constructor = StarLoopbackState;
  27366. function StarLoopEntryState() {
  27367. DecisionState.call(this);
  27368. this.stateType = ATNState.STAR_LOOP_ENTRY;
  27369. this.loopBackState = null;
  27370. // Indicates whether this state can benefit from a precedence DFA during SLL decision making.
  27371. this.isPrecedenceDecision = null;
  27372. return this;
  27373. }
  27374. StarLoopEntryState.prototype = Object.create(DecisionState.prototype);
  27375. StarLoopEntryState.prototype.constructor = StarLoopEntryState;
  27376. // Mark the end of a * or + loop.
  27377. function LoopEndState() {
  27378. ATNState.call(this);
  27379. this.stateType = ATNState.LOOP_END;
  27380. this.loopBackState = null;
  27381. return this;
  27382. }
  27383. LoopEndState.prototype = Object.create(ATNState.prototype);
  27384. LoopEndState.prototype.constructor = LoopEndState;
  27385. // The Tokens rule start state linking to each lexer rule start state */
  27386. function TokensStartState() {
  27387. DecisionState.call(this);
  27388. this.stateType = ATNState.TOKEN_START;
  27389. return this;
  27390. }
  27391. TokensStartState.prototype = Object.create(DecisionState.prototype);
  27392. TokensStartState.prototype.constructor = TokensStartState;
  27393. exports.ATNState = ATNState;
  27394. exports.BasicState = BasicState;
  27395. exports.DecisionState = DecisionState;
  27396. exports.BlockStartState = BlockStartState;
  27397. exports.BlockEndState = BlockEndState;
  27398. exports.LoopEndState = LoopEndState;
  27399. exports.RuleStartState = RuleStartState;
  27400. exports.RuleStopState = RuleStopState;
  27401. exports.TokensStartState = TokensStartState;
  27402. exports.PlusLoopbackState = PlusLoopbackState;
  27403. exports.StarLoopbackState = StarLoopbackState;
  27404. exports.StarLoopEntryState = StarLoopEntryState;
  27405. exports.PlusBlockStartState = PlusBlockStartState;
  27406. exports.StarBlockStartState = StarBlockStartState;
  27407. exports.BasicBlockStartState = BasicBlockStartState;
  27408. /***/ }),
  27409. /***/ "./node_modules/antlr4/atn/ATNType.js":
  27410. /*!********************************************!*\
  27411. !*** ./node_modules/antlr4/atn/ATNType.js ***!
  27412. \********************************************/
  27413. /*! no static exports found */
  27414. /***/ (function(module, exports, __webpack_require__) {
  27415. "use strict";
  27416. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  27417. * Use of this file is governed by the BSD 3-clause license that
  27418. * can be found in the LICENSE.txt file in the project root.
  27419. */
  27420. ///
  27421. // Represents the type of recognizer an ATN applies to.
  27422. function ATNType() {}
  27423. ATNType.LEXER = 0;
  27424. ATNType.PARSER = 1;
  27425. exports.ATNType = ATNType;
  27426. /***/ }),
  27427. /***/ "./node_modules/antlr4/atn/LexerATNSimulator.js":
  27428. /*!******************************************************!*\
  27429. !*** ./node_modules/antlr4/atn/LexerATNSimulator.js ***!
  27430. \******************************************************/
  27431. /*! no static exports found */
  27432. /***/ (function(module, exports, __webpack_require__) {
  27433. "use strict";
  27434. //
  27435. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  27436. * Use of this file is governed by the BSD 3-clause license that
  27437. * can be found in the LICENSE.txt file in the project root.
  27438. */
  27439. ///
  27440. // When we hit an accept state in either the DFA or the ATN, we
  27441. // have to notify the character stream to start buffering characters
  27442. // via {@link IntStream//mark} and record the current state. The current sim state
  27443. // includes the current index into the input, the current line,
  27444. // and current character position in that line. Note that the Lexer is
  27445. // tracking the starting line and characterization of the token. These
  27446. // variables track the "state" of the simulator when it hits an accept state.
  27447. //
  27448. // <p>We track these variables separately for the DFA and ATN simulation
  27449. // because the DFA simulation often has to fail over to the ATN
  27450. // simulation. If the ATN simulation fails, we need the DFA to fall
  27451. // back to its previously accepted state, if any. If the ATN succeeds,
  27452. // then the ATN does the accept and the DFA simulator that invoked it
  27453. // can simply return the predicted token type.</p>
  27454. ///
  27455. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  27456. var Lexer = __webpack_require__(/*! ./../Lexer */ "./node_modules/antlr4/Lexer.js").Lexer;
  27457. var ATN = __webpack_require__(/*! ./ATN */ "./node_modules/antlr4/atn/ATN.js").ATN;
  27458. var ATNSimulator = __webpack_require__(/*! ./ATNSimulator */ "./node_modules/antlr4/atn/ATNSimulator.js").ATNSimulator;
  27459. var DFAState = __webpack_require__(/*! ./../dfa/DFAState */ "./node_modules/antlr4/dfa/DFAState.js").DFAState;
  27460. var ATNConfigSet = __webpack_require__(/*! ./ATNConfigSet */ "./node_modules/antlr4/atn/ATNConfigSet.js").ATNConfigSet;
  27461. var OrderedATNConfigSet = __webpack_require__(/*! ./ATNConfigSet */ "./node_modules/antlr4/atn/ATNConfigSet.js").OrderedATNConfigSet;
  27462. var PredictionContext = __webpack_require__(/*! ./../PredictionContext */ "./node_modules/antlr4/PredictionContext.js").PredictionContext;
  27463. var SingletonPredictionContext = __webpack_require__(/*! ./../PredictionContext */ "./node_modules/antlr4/PredictionContext.js").SingletonPredictionContext;
  27464. var RuleStopState = __webpack_require__(/*! ./ATNState */ "./node_modules/antlr4/atn/ATNState.js").RuleStopState;
  27465. var LexerATNConfig = __webpack_require__(/*! ./ATNConfig */ "./node_modules/antlr4/atn/ATNConfig.js").LexerATNConfig;
  27466. var Transition = __webpack_require__(/*! ./Transition */ "./node_modules/antlr4/atn/Transition.js").Transition;
  27467. var LexerActionExecutor = __webpack_require__(/*! ./LexerActionExecutor */ "./node_modules/antlr4/atn/LexerActionExecutor.js").LexerActionExecutor;
  27468. var LexerNoViableAltException = __webpack_require__(/*! ./../error/Errors */ "./node_modules/antlr4/error/Errors.js").LexerNoViableAltException;
  27469. function resetSimState(sim) {
  27470. sim.index = -1;
  27471. sim.line = 0;
  27472. sim.column = -1;
  27473. sim.dfaState = null;
  27474. }
  27475. function SimState() {
  27476. resetSimState(this);
  27477. return this;
  27478. }
  27479. SimState.prototype.reset = function () {
  27480. resetSimState(this);
  27481. };
  27482. function LexerATNSimulator(recog, atn, decisionToDFA, sharedContextCache) {
  27483. ATNSimulator.call(this, atn, sharedContextCache);
  27484. this.decisionToDFA = decisionToDFA;
  27485. this.recog = recog;
  27486. // The current token's starting index into the character stream.
  27487. // Shared across DFA to ATN simulation in case the ATN fails and the
  27488. // DFA did not have a previous accept state. In this case, we use the
  27489. // ATN-generated exception object.
  27490. this.startIndex = -1;
  27491. // line number 1..n within the input///
  27492. this.line = 1;
  27493. // The index of the character relative to the beginning of the line
  27494. // 0..n-1///
  27495. this.column = 0;
  27496. this.mode = Lexer.DEFAULT_MODE;
  27497. // Used during DFA/ATN exec to record the most recent accept configuration
  27498. // info
  27499. this.prevAccept = new SimState();
  27500. // done
  27501. return this;
  27502. }
  27503. LexerATNSimulator.prototype = Object.create(ATNSimulator.prototype);
  27504. LexerATNSimulator.prototype.constructor = LexerATNSimulator;
  27505. LexerATNSimulator.debug = false;
  27506. LexerATNSimulator.dfa_debug = false;
  27507. LexerATNSimulator.MIN_DFA_EDGE = 0;
  27508. LexerATNSimulator.MAX_DFA_EDGE = 127; // forces unicode to stay in ATN
  27509. LexerATNSimulator.match_calls = 0;
  27510. LexerATNSimulator.prototype.copyState = function (simulator) {
  27511. this.column = simulator.column;
  27512. this.line = simulator.line;
  27513. this.mode = simulator.mode;
  27514. this.startIndex = simulator.startIndex;
  27515. };
  27516. LexerATNSimulator.prototype.match = function (input, mode) {
  27517. this.match_calls += 1;
  27518. this.mode = mode;
  27519. var mark = input.mark();
  27520. try {
  27521. this.startIndex = input.index;
  27522. this.prevAccept.reset();
  27523. var dfa = this.decisionToDFA[mode];
  27524. if (dfa.s0 === null) {
  27525. return this.matchATN(input);
  27526. } else {
  27527. return this.execATN(input, dfa.s0);
  27528. }
  27529. } finally {
  27530. input.release(mark);
  27531. }
  27532. };
  27533. LexerATNSimulator.prototype.reset = function () {
  27534. this.prevAccept.reset();
  27535. this.startIndex = -1;
  27536. this.line = 1;
  27537. this.column = 0;
  27538. this.mode = Lexer.DEFAULT_MODE;
  27539. };
  27540. LexerATNSimulator.prototype.matchATN = function (input) {
  27541. var startState = this.atn.modeToStartState[this.mode];
  27542. if (LexerATNSimulator.debug) {
  27543. console.log("matchATN mode " + this.mode + " start: " + startState);
  27544. }
  27545. var old_mode = this.mode;
  27546. var s0_closure = this.computeStartState(input, startState);
  27547. var suppressEdge = s0_closure.hasSemanticContext;
  27548. s0_closure.hasSemanticContext = false;
  27549. var next = this.addDFAState(s0_closure);
  27550. if (!suppressEdge) {
  27551. this.decisionToDFA[this.mode].s0 = next;
  27552. }
  27553. var predict = this.execATN(input, next);
  27554. if (LexerATNSimulator.debug) {
  27555. console.log("DFA after matchATN: " + this.decisionToDFA[old_mode].toLexerString());
  27556. }
  27557. return predict;
  27558. };
  27559. LexerATNSimulator.prototype.execATN = function (input, ds0) {
  27560. if (LexerATNSimulator.debug) {
  27561. console.log("start state closure=" + ds0.configs);
  27562. }
  27563. if (ds0.isAcceptState) {
  27564. // allow zero-length tokens
  27565. this.captureSimState(this.prevAccept, input, ds0);
  27566. }
  27567. var t = input.LA(1);
  27568. var s = ds0; // s is current/from DFA state
  27569. while (true) {
  27570. // while more work
  27571. if (LexerATNSimulator.debug) {
  27572. console.log("execATN loop starting closure: " + s.configs);
  27573. }
  27574. // As we move src->trg, src->trg, we keep track of the previous trg to
  27575. // avoid looking up the DFA state again, which is expensive.
  27576. // If the previous target was already part of the DFA, we might
  27577. // be able to avoid doing a reach operation upon t. If s!=null,
  27578. // it means that semantic predicates didn't prevent us from
  27579. // creating a DFA state. Once we know s!=null, we check to see if
  27580. // the DFA state has an edge already for t. If so, we can just reuse
  27581. // it's configuration set; there's no point in re-computing it.
  27582. // This is kind of like doing DFA simulation within the ATN
  27583. // simulation because DFA simulation is really just a way to avoid
  27584. // computing reach/closure sets. Technically, once we know that
  27585. // we have a previously added DFA state, we could jump over to
  27586. // the DFA simulator. But, that would mean popping back and forth
  27587. // a lot and making things more complicated algorithmically.
  27588. // This optimization makes a lot of sense for loops within DFA.
  27589. // A character will take us back to an existing DFA state
  27590. // that already has lots of edges out of it. e.g., .* in comments.
  27591. // print("Target for:" + str(s) + " and:" + str(t))
  27592. var target = this.getExistingTargetState(s, t);
  27593. // print("Existing:" + str(target))
  27594. if (target === null) {
  27595. target = this.computeTargetState(input, s, t);
  27596. // print("Computed:" + str(target))
  27597. }
  27598. if (target === ATNSimulator.ERROR) {
  27599. break;
  27600. }
  27601. // If this is a consumable input element, make sure to consume before
  27602. // capturing the accept state so the input index, line, and char
  27603. // position accurately reflect the state of the interpreter at the
  27604. // end of the token.
  27605. if (t !== Token.EOF) {
  27606. this.consume(input);
  27607. }
  27608. if (target.isAcceptState) {
  27609. this.captureSimState(this.prevAccept, input, target);
  27610. if (t === Token.EOF) {
  27611. break;
  27612. }
  27613. }
  27614. t = input.LA(1);
  27615. s = target; // flip; current DFA target becomes new src/from state
  27616. }
  27617. return this.failOrAccept(this.prevAccept, input, s.configs, t);
  27618. };
  27619. // Get an existing target state for an edge in the DFA. If the target state
  27620. // for the edge has not yet been computed or is otherwise not available,
  27621. // this method returns {@code null}.
  27622. //
  27623. // @param s The current DFA state
  27624. // @param t The next input symbol
  27625. // @return The existing target DFA state for the given input symbol
  27626. // {@code t}, or {@code null} if the target state for this edge is not
  27627. // already cached
  27628. LexerATNSimulator.prototype.getExistingTargetState = function (s, t) {
  27629. if (s.edges === null || t < LexerATNSimulator.MIN_DFA_EDGE || t > LexerATNSimulator.MAX_DFA_EDGE) {
  27630. return null;
  27631. }
  27632. var target = s.edges[t - LexerATNSimulator.MIN_DFA_EDGE];
  27633. if (target === undefined) {
  27634. target = null;
  27635. }
  27636. if (LexerATNSimulator.debug && target !== null) {
  27637. console.log("reuse state " + s.stateNumber + " edge to " + target.stateNumber);
  27638. }
  27639. return target;
  27640. };
  27641. // Compute a target state for an edge in the DFA, and attempt to add the
  27642. // computed state and corresponding edge to the DFA.
  27643. //
  27644. // @param input The input stream
  27645. // @param s The current DFA state
  27646. // @param t The next input symbol
  27647. //
  27648. // @return The computed target DFA state for the given input symbol
  27649. // {@code t}. If {@code t} does not lead to a valid DFA state, this method
  27650. // returns {@link //ERROR}.
  27651. LexerATNSimulator.prototype.computeTargetState = function (input, s, t) {
  27652. var reach = new OrderedATNConfigSet();
  27653. // if we don't find an existing DFA state
  27654. // Fill reach starting from closure, following t transitions
  27655. this.getReachableConfigSet(input, s.configs, reach, t);
  27656. if (reach.items.length === 0) {
  27657. // we got nowhere on t from s
  27658. if (!reach.hasSemanticContext) {
  27659. // we got nowhere on t, don't throw out this knowledge; it'd
  27660. // cause a failover from DFA later.
  27661. this.addDFAEdge(s, t, ATNSimulator.ERROR);
  27662. }
  27663. // stop when we can't match any more char
  27664. return ATNSimulator.ERROR;
  27665. }
  27666. // Add an edge from s to target DFA found/created for reach
  27667. return this.addDFAEdge(s, t, null, reach);
  27668. };
  27669. LexerATNSimulator.prototype.failOrAccept = function (prevAccept, input, reach, t) {
  27670. if (this.prevAccept.dfaState !== null) {
  27671. var lexerActionExecutor = prevAccept.dfaState.lexerActionExecutor;
  27672. this.accept(input, lexerActionExecutor, this.startIndex, prevAccept.index, prevAccept.line, prevAccept.column);
  27673. return prevAccept.dfaState.prediction;
  27674. } else {
  27675. // if no accept and EOF is first char, return EOF
  27676. if (t === Token.EOF && input.index === this.startIndex) {
  27677. return Token.EOF;
  27678. }
  27679. throw new LexerNoViableAltException(this.recog, input, this.startIndex, reach);
  27680. }
  27681. };
  27682. // Given a starting configuration set, figure out all ATN configurations
  27683. // we can reach upon input {@code t}. Parameter {@code reach} is a return
  27684. // parameter.
  27685. LexerATNSimulator.prototype.getReachableConfigSet = function (input, closure, reach, t) {
  27686. // this is used to skip processing for configs which have a lower priority
  27687. // than a config that already reached an accept state for the same rule
  27688. var skipAlt = ATN.INVALID_ALT_NUMBER;
  27689. for (var i = 0; i < closure.items.length; i++) {
  27690. var cfg = closure.items[i];
  27691. var currentAltReachedAcceptState = cfg.alt === skipAlt;
  27692. if (currentAltReachedAcceptState && cfg.passedThroughNonGreedyDecision) {
  27693. continue;
  27694. }
  27695. if (LexerATNSimulator.debug) {
  27696. console.log("testing %s at %s\n", this.getTokenName(t), cfg.toString(this.recog, true));
  27697. }
  27698. for (var j = 0; j < cfg.state.transitions.length; j++) {
  27699. var trans = cfg.state.transitions[j]; // for each transition
  27700. var target = this.getReachableTarget(trans, t);
  27701. if (target !== null) {
  27702. var lexerActionExecutor = cfg.lexerActionExecutor;
  27703. if (lexerActionExecutor !== null) {
  27704. lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.index - this.startIndex);
  27705. }
  27706. var treatEofAsEpsilon = t === Token.EOF;
  27707. var config = new LexerATNConfig({ state: target, lexerActionExecutor: lexerActionExecutor }, cfg);
  27708. if (this.closure(input, config, reach, currentAltReachedAcceptState, true, treatEofAsEpsilon)) {
  27709. // any remaining configs for this alt have a lower priority
  27710. // than the one that just reached an accept state.
  27711. skipAlt = cfg.alt;
  27712. }
  27713. }
  27714. }
  27715. }
  27716. };
  27717. LexerATNSimulator.prototype.accept = function (input, lexerActionExecutor, startIndex, index, line, charPos) {
  27718. if (LexerATNSimulator.debug) {
  27719. console.log("ACTION %s\n", lexerActionExecutor);
  27720. }
  27721. // seek to after last char in token
  27722. input.seek(index);
  27723. this.line = line;
  27724. this.column = charPos;
  27725. if (lexerActionExecutor !== null && this.recog !== null) {
  27726. lexerActionExecutor.execute(this.recog, input, startIndex);
  27727. }
  27728. };
  27729. LexerATNSimulator.prototype.getReachableTarget = function (trans, t) {
  27730. if (trans.matches(t, 0, Lexer.MAX_CHAR_VALUE)) {
  27731. return trans.target;
  27732. } else {
  27733. return null;
  27734. }
  27735. };
  27736. LexerATNSimulator.prototype.computeStartState = function (input, p) {
  27737. var initialContext = PredictionContext.EMPTY;
  27738. var configs = new OrderedATNConfigSet();
  27739. for (var i = 0; i < p.transitions.length; i++) {
  27740. var target = p.transitions[i].target;
  27741. var cfg = new LexerATNConfig({ state: target, alt: i + 1, context: initialContext }, null);
  27742. this.closure(input, cfg, configs, false, false, false);
  27743. }
  27744. return configs;
  27745. };
  27746. // Since the alternatives within any lexer decision are ordered by
  27747. // preference, this method stops pursuing the closure as soon as an accept
  27748. // state is reached. After the first accept state is reached by depth-first
  27749. // search from {@code config}, all other (potentially reachable) states for
  27750. // this rule would have a lower priority.
  27751. //
  27752. // @return {@code true} if an accept state is reached, otherwise
  27753. // {@code false}.
  27754. LexerATNSimulator.prototype.closure = function (input, config, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon) {
  27755. var cfg = null;
  27756. if (LexerATNSimulator.debug) {
  27757. console.log("closure(" + config.toString(this.recog, true) + ")");
  27758. }
  27759. if (config.state instanceof RuleStopState) {
  27760. if (LexerATNSimulator.debug) {
  27761. if (this.recog !== null) {
  27762. console.log("closure at %s rule stop %s\n", this.recog.ruleNames[config.state.ruleIndex], config);
  27763. } else {
  27764. console.log("closure at rule stop %s\n", config);
  27765. }
  27766. }
  27767. if (config.context === null || config.context.hasEmptyPath()) {
  27768. if (config.context === null || config.context.isEmpty()) {
  27769. configs.add(config);
  27770. return true;
  27771. } else {
  27772. configs.add(new LexerATNConfig({ state: config.state, context: PredictionContext.EMPTY }, config));
  27773. currentAltReachedAcceptState = true;
  27774. }
  27775. }
  27776. if (config.context !== null && !config.context.isEmpty()) {
  27777. for (var i = 0; i < config.context.length; i++) {
  27778. if (config.context.getReturnState(i) !== PredictionContext.EMPTY_RETURN_STATE) {
  27779. var newContext = config.context.getParent(i); // "pop" return state
  27780. var returnState = this.atn.states[config.context.getReturnState(i)];
  27781. cfg = new LexerATNConfig({ state: returnState, context: newContext }, config);
  27782. currentAltReachedAcceptState = this.closure(input, cfg, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
  27783. }
  27784. }
  27785. }
  27786. return currentAltReachedAcceptState;
  27787. }
  27788. // optimization
  27789. if (!config.state.epsilonOnlyTransitions) {
  27790. if (!currentAltReachedAcceptState || !config.passedThroughNonGreedyDecision) {
  27791. configs.add(config);
  27792. }
  27793. }
  27794. for (var j = 0; j < config.state.transitions.length; j++) {
  27795. var trans = config.state.transitions[j];
  27796. cfg = this.getEpsilonTarget(input, config, trans, configs, speculative, treatEofAsEpsilon);
  27797. if (cfg !== null) {
  27798. currentAltReachedAcceptState = this.closure(input, cfg, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
  27799. }
  27800. }
  27801. return currentAltReachedAcceptState;
  27802. };
  27803. // side-effect: can alter configs.hasSemanticContext
  27804. LexerATNSimulator.prototype.getEpsilonTarget = function (input, config, trans, configs, speculative, treatEofAsEpsilon) {
  27805. var cfg = null;
  27806. if (trans.serializationType === Transition.RULE) {
  27807. var newContext = SingletonPredictionContext.create(config.context, trans.followState.stateNumber);
  27808. cfg = new LexerATNConfig({ state: trans.target, context: newContext }, config);
  27809. } else if (trans.serializationType === Transition.PRECEDENCE) {
  27810. throw "Precedence predicates are not supported in lexers.";
  27811. } else if (trans.serializationType === Transition.PREDICATE) {
  27812. // Track traversing semantic predicates. If we traverse,
  27813. // we cannot add a DFA state for this "reach" computation
  27814. // because the DFA would not test the predicate again in the
  27815. // future. Rather than creating collections of semantic predicates
  27816. // like v3 and testing them on prediction, v4 will test them on the
  27817. // fly all the time using the ATN not the DFA. This is slower but
  27818. // semantically it's not used that often. One of the key elements to
  27819. // this predicate mechanism is not adding DFA states that see
  27820. // predicates immediately afterwards in the ATN. For example,
  27821. // a : ID {p1}? | ID {p2}? ;
  27822. // should create the start state for rule 'a' (to save start state
  27823. // competition), but should not create target of ID state. The
  27824. // collection of ATN states the following ID references includes
  27825. // states reached by traversing predicates. Since this is when we
  27826. // test them, we cannot cash the DFA state target of ID.
  27827. if (LexerATNSimulator.debug) {
  27828. console.log("EVAL rule " + trans.ruleIndex + ":" + trans.predIndex);
  27829. }
  27830. configs.hasSemanticContext = true;
  27831. if (this.evaluatePredicate(input, trans.ruleIndex, trans.predIndex, speculative)) {
  27832. cfg = new LexerATNConfig({ state: trans.target }, config);
  27833. }
  27834. } else if (trans.serializationType === Transition.ACTION) {
  27835. if (config.context === null || config.context.hasEmptyPath()) {
  27836. // execute actions anywhere in the start rule for a token.
  27837. //
  27838. // TODO: if the entry rule is invoked recursively, some
  27839. // actions may be executed during the recursive call. The
  27840. // problem can appear when hasEmptyPath() is true but
  27841. // isEmpty() is false. In this case, the config needs to be
  27842. // split into two contexts - one with just the empty path
  27843. // and another with everything but the empty path.
  27844. // Unfortunately, the current algorithm does not allow
  27845. // getEpsilonTarget to return two configurations, so
  27846. // additional modifications are needed before we can support
  27847. // the split operation.
  27848. var lexerActionExecutor = LexerActionExecutor.append(config.lexerActionExecutor, this.atn.lexerActions[trans.actionIndex]);
  27849. cfg = new LexerATNConfig({ state: trans.target, lexerActionExecutor: lexerActionExecutor }, config);
  27850. } else {
  27851. // ignore actions in referenced rules
  27852. cfg = new LexerATNConfig({ state: trans.target }, config);
  27853. }
  27854. } else if (trans.serializationType === Transition.EPSILON) {
  27855. cfg = new LexerATNConfig({ state: trans.target }, config);
  27856. } else if (trans.serializationType === Transition.ATOM || trans.serializationType === Transition.RANGE || trans.serializationType === Transition.SET) {
  27857. if (treatEofAsEpsilon) {
  27858. if (trans.matches(Token.EOF, 0, Lexer.MAX_CHAR_VALUE)) {
  27859. cfg = new LexerATNConfig({ state: trans.target }, config);
  27860. }
  27861. }
  27862. }
  27863. return cfg;
  27864. };
  27865. // Evaluate a predicate specified in the lexer.
  27866. //
  27867. // <p>If {@code speculative} is {@code true}, this method was called before
  27868. // {@link //consume} for the matched character. This method should call
  27869. // {@link //consume} before evaluating the predicate to ensure position
  27870. // sensitive values, including {@link Lexer//getText}, {@link Lexer//getLine},
  27871. // and {@link Lexer//getcolumn}, properly reflect the current
  27872. // lexer state. This method should restore {@code input} and the simulator
  27873. // to the original state before returning (i.e. undo the actions made by the
  27874. // call to {@link //consume}.</p>
  27875. //
  27876. // @param input The input stream.
  27877. // @param ruleIndex The rule containing the predicate.
  27878. // @param predIndex The index of the predicate within the rule.
  27879. // @param speculative {@code true} if the current index in {@code input} is
  27880. // one character before the predicate's location.
  27881. //
  27882. // @return {@code true} if the specified predicate evaluates to
  27883. // {@code true}.
  27884. // /
  27885. LexerATNSimulator.prototype.evaluatePredicate = function (input, ruleIndex, predIndex, speculative) {
  27886. // assume true if no recognizer was provided
  27887. if (this.recog === null) {
  27888. return true;
  27889. }
  27890. if (!speculative) {
  27891. return this.recog.sempred(null, ruleIndex, predIndex);
  27892. }
  27893. var savedcolumn = this.column;
  27894. var savedLine = this.line;
  27895. var index = input.index;
  27896. var marker = input.mark();
  27897. try {
  27898. this.consume(input);
  27899. return this.recog.sempred(null, ruleIndex, predIndex);
  27900. } finally {
  27901. this.column = savedcolumn;
  27902. this.line = savedLine;
  27903. input.seek(index);
  27904. input.release(marker);
  27905. }
  27906. };
  27907. LexerATNSimulator.prototype.captureSimState = function (settings, input, dfaState) {
  27908. settings.index = input.index;
  27909. settings.line = this.line;
  27910. settings.column = this.column;
  27911. settings.dfaState = dfaState;
  27912. };
  27913. LexerATNSimulator.prototype.addDFAEdge = function (from_, tk, to, cfgs) {
  27914. if (to === undefined) {
  27915. to = null;
  27916. }
  27917. if (cfgs === undefined) {
  27918. cfgs = null;
  27919. }
  27920. if (to === null && cfgs !== null) {
  27921. // leading to this call, ATNConfigSet.hasSemanticContext is used as a
  27922. // marker indicating dynamic predicate evaluation makes this edge
  27923. // dependent on the specific input sequence, so the static edge in the
  27924. // DFA should be omitted. The target DFAState is still created since
  27925. // execATN has the ability to resynchronize with the DFA state cache
  27926. // following the predicate evaluation step.
  27927. //
  27928. // TJP notes: next time through the DFA, we see a pred again and eval.
  27929. // If that gets us to a previously created (but dangling) DFA
  27930. // state, we can continue in pure DFA mode from there.
  27931. // /
  27932. var suppressEdge = cfgs.hasSemanticContext;
  27933. cfgs.hasSemanticContext = false;
  27934. to = this.addDFAState(cfgs);
  27935. if (suppressEdge) {
  27936. return to;
  27937. }
  27938. }
  27939. // add the edge
  27940. if (tk < LexerATNSimulator.MIN_DFA_EDGE || tk > LexerATNSimulator.MAX_DFA_EDGE) {
  27941. // Only track edges within the DFA bounds
  27942. return to;
  27943. }
  27944. if (LexerATNSimulator.debug) {
  27945. console.log("EDGE " + from_ + " -> " + to + " upon " + tk);
  27946. }
  27947. if (from_.edges === null) {
  27948. // make room for tokens 1..n and -1 masquerading as index 0
  27949. from_.edges = [];
  27950. }
  27951. from_.edges[tk - LexerATNSimulator.MIN_DFA_EDGE] = to; // connect
  27952. return to;
  27953. };
  27954. // Add a new DFA state if there isn't one with this set of
  27955. // configurations already. This method also detects the first
  27956. // configuration containing an ATN rule stop state. Later, when
  27957. // traversing the DFA, we will know which rule to accept.
  27958. LexerATNSimulator.prototype.addDFAState = function (configs) {
  27959. var proposed = new DFAState(null, configs);
  27960. var firstConfigWithRuleStopState = null;
  27961. for (var i = 0; i < configs.items.length; i++) {
  27962. var cfg = configs.items[i];
  27963. if (cfg.state instanceof RuleStopState) {
  27964. firstConfigWithRuleStopState = cfg;
  27965. break;
  27966. }
  27967. }
  27968. if (firstConfigWithRuleStopState !== null) {
  27969. proposed.isAcceptState = true;
  27970. proposed.lexerActionExecutor = firstConfigWithRuleStopState.lexerActionExecutor;
  27971. proposed.prediction = this.atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex];
  27972. }
  27973. var dfa = this.decisionToDFA[this.mode];
  27974. var existing = dfa.states.get(proposed);
  27975. if (existing !== null) {
  27976. return existing;
  27977. }
  27978. var newState = proposed;
  27979. newState.stateNumber = dfa.states.length;
  27980. configs.setReadonly(true);
  27981. newState.configs = configs;
  27982. dfa.states.add(newState);
  27983. return newState;
  27984. };
  27985. LexerATNSimulator.prototype.getDFA = function (mode) {
  27986. return this.decisionToDFA[mode];
  27987. };
  27988. // Get the text matched so far for the current token.
  27989. LexerATNSimulator.prototype.getText = function (input) {
  27990. // index is first lookahead char, don't include.
  27991. return input.getText(this.startIndex, input.index - 1);
  27992. };
  27993. LexerATNSimulator.prototype.consume = function (input) {
  27994. var curChar = input.LA(1);
  27995. if (curChar === "\n".charCodeAt(0)) {
  27996. this.line += 1;
  27997. this.column = 0;
  27998. } else {
  27999. this.column += 1;
  28000. }
  28001. input.consume();
  28002. };
  28003. LexerATNSimulator.prototype.getTokenName = function (tt) {
  28004. if (tt === -1) {
  28005. return "EOF";
  28006. } else {
  28007. return "'" + String.fromCharCode(tt) + "'";
  28008. }
  28009. };
  28010. exports.LexerATNSimulator = LexerATNSimulator;
  28011. /***/ }),
  28012. /***/ "./node_modules/antlr4/atn/LexerAction.js":
  28013. /*!************************************************!*\
  28014. !*** ./node_modules/antlr4/atn/LexerAction.js ***!
  28015. \************************************************/
  28016. /*! no static exports found */
  28017. /***/ (function(module, exports, __webpack_require__) {
  28018. "use strict";
  28019. //
  28020. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  28021. * Use of this file is governed by the BSD 3-clause license that
  28022. * can be found in the LICENSE.txt file in the project root.
  28023. */
  28024. //
  28025. function LexerActionType() {}
  28026. LexerActionType.CHANNEL = 0; //The type of a {@link LexerChannelAction} action.
  28027. LexerActionType.CUSTOM = 1; //The type of a {@link LexerCustomAction} action.
  28028. LexerActionType.MODE = 2; //The type of a {@link LexerModeAction} action.
  28029. LexerActionType.MORE = 3; //The type of a {@link LexerMoreAction} action.
  28030. LexerActionType.POP_MODE = 4; //The type of a {@link LexerPopModeAction} action.
  28031. LexerActionType.PUSH_MODE = 5; //The type of a {@link LexerPushModeAction} action.
  28032. LexerActionType.SKIP = 6; //The type of a {@link LexerSkipAction} action.
  28033. LexerActionType.TYPE = 7; //The type of a {@link LexerTypeAction} action.
  28034. function LexerAction(action) {
  28035. this.actionType = action;
  28036. this.isPositionDependent = false;
  28037. return this;
  28038. }
  28039. LexerAction.prototype.hashCode = function () {
  28040. var hash = new Hash();
  28041. this.updateHashCode(hash);
  28042. return hash.finish();
  28043. };
  28044. LexerAction.prototype.updateHashCode = function (hash) {
  28045. hash.update(this.actionType);
  28046. };
  28047. LexerAction.prototype.equals = function (other) {
  28048. return this === other;
  28049. };
  28050. //
  28051. // Implements the {@code skip} lexer action by calling {@link Lexer//skip}.
  28052. //
  28053. // <p>The {@code skip} command does not have any parameters, so this action is
  28054. // implemented as a singleton instance exposed by {@link //INSTANCE}.</p>
  28055. function LexerSkipAction() {
  28056. LexerAction.call(this, LexerActionType.SKIP);
  28057. return this;
  28058. }
  28059. LexerSkipAction.prototype = Object.create(LexerAction.prototype);
  28060. LexerSkipAction.prototype.constructor = LexerSkipAction;
  28061. // Provides a singleton instance of this parameterless lexer action.
  28062. LexerSkipAction.INSTANCE = new LexerSkipAction();
  28063. LexerSkipAction.prototype.execute = function (lexer) {
  28064. lexer.skip();
  28065. };
  28066. LexerSkipAction.prototype.toString = function () {
  28067. return "skip";
  28068. };
  28069. // Implements the {@code type} lexer action by calling {@link Lexer//setType}
  28070. // with the assigned type.
  28071. function LexerTypeAction(type) {
  28072. LexerAction.call(this, LexerActionType.TYPE);
  28073. this.type = type;
  28074. return this;
  28075. }
  28076. LexerTypeAction.prototype = Object.create(LexerAction.prototype);
  28077. LexerTypeAction.prototype.constructor = LexerTypeAction;
  28078. LexerTypeAction.prototype.execute = function (lexer) {
  28079. lexer.type = this.type;
  28080. };
  28081. LexerTypeAction.prototype.updateHashCode = function (hash) {
  28082. hash.update(this.actionType, this.type);
  28083. };
  28084. LexerTypeAction.prototype.equals = function (other) {
  28085. if (this === other) {
  28086. return true;
  28087. } else if (!(other instanceof LexerTypeAction)) {
  28088. return false;
  28089. } else {
  28090. return this.type === other.type;
  28091. }
  28092. };
  28093. LexerTypeAction.prototype.toString = function () {
  28094. return "type(" + this.type + ")";
  28095. };
  28096. // Implements the {@code pushMode} lexer action by calling
  28097. // {@link Lexer//pushMode} with the assigned mode.
  28098. function LexerPushModeAction(mode) {
  28099. LexerAction.call(this, LexerActionType.PUSH_MODE);
  28100. this.mode = mode;
  28101. return this;
  28102. }
  28103. LexerPushModeAction.prototype = Object.create(LexerAction.prototype);
  28104. LexerPushModeAction.prototype.constructor = LexerPushModeAction;
  28105. // <p>This action is implemented by calling {@link Lexer//pushMode} with the
  28106. // value provided by {@link //getMode}.</p>
  28107. LexerPushModeAction.prototype.execute = function (lexer) {
  28108. lexer.pushMode(this.mode);
  28109. };
  28110. LexerPushModeAction.prototype.updateHashCode = function (hash) {
  28111. hash.update(this.actionType, this.mode);
  28112. };
  28113. LexerPushModeAction.prototype.equals = function (other) {
  28114. if (this === other) {
  28115. return true;
  28116. } else if (!(other instanceof LexerPushModeAction)) {
  28117. return false;
  28118. } else {
  28119. return this.mode === other.mode;
  28120. }
  28121. };
  28122. LexerPushModeAction.prototype.toString = function () {
  28123. return "pushMode(" + this.mode + ")";
  28124. };
  28125. // Implements the {@code popMode} lexer action by calling {@link Lexer//popMode}.
  28126. //
  28127. // <p>The {@code popMode} command does not have any parameters, so this action is
  28128. // implemented as a singleton instance exposed by {@link //INSTANCE}.</p>
  28129. function LexerPopModeAction() {
  28130. LexerAction.call(this, LexerActionType.POP_MODE);
  28131. return this;
  28132. }
  28133. LexerPopModeAction.prototype = Object.create(LexerAction.prototype);
  28134. LexerPopModeAction.prototype.constructor = LexerPopModeAction;
  28135. LexerPopModeAction.INSTANCE = new LexerPopModeAction();
  28136. // <p>This action is implemented by calling {@link Lexer//popMode}.</p>
  28137. LexerPopModeAction.prototype.execute = function (lexer) {
  28138. lexer.popMode();
  28139. };
  28140. LexerPopModeAction.prototype.toString = function () {
  28141. return "popMode";
  28142. };
  28143. // Implements the {@code more} lexer action by calling {@link Lexer//more}.
  28144. //
  28145. // <p>The {@code more} command does not have any parameters, so this action is
  28146. // implemented as a singleton instance exposed by {@link //INSTANCE}.</p>
  28147. function LexerMoreAction() {
  28148. LexerAction.call(this, LexerActionType.MORE);
  28149. return this;
  28150. }
  28151. LexerMoreAction.prototype = Object.create(LexerAction.prototype);
  28152. LexerMoreAction.prototype.constructor = LexerMoreAction;
  28153. LexerMoreAction.INSTANCE = new LexerMoreAction();
  28154. // <p>This action is implemented by calling {@link Lexer//popMode}.</p>
  28155. LexerMoreAction.prototype.execute = function (lexer) {
  28156. lexer.more();
  28157. };
  28158. LexerMoreAction.prototype.toString = function () {
  28159. return "more";
  28160. };
  28161. // Implements the {@code mode} lexer action by calling {@link Lexer//mode} with
  28162. // the assigned mode.
  28163. function LexerModeAction(mode) {
  28164. LexerAction.call(this, LexerActionType.MODE);
  28165. this.mode = mode;
  28166. return this;
  28167. }
  28168. LexerModeAction.prototype = Object.create(LexerAction.prototype);
  28169. LexerModeAction.prototype.constructor = LexerModeAction;
  28170. // <p>This action is implemented by calling {@link Lexer//mode} with the
  28171. // value provided by {@link //getMode}.</p>
  28172. LexerModeAction.prototype.execute = function (lexer) {
  28173. lexer.mode(this.mode);
  28174. };
  28175. LexerModeAction.prototype.updateHashCode = function (hash) {
  28176. hash.update(this.actionType, this.mode);
  28177. };
  28178. LexerModeAction.prototype.equals = function (other) {
  28179. if (this === other) {
  28180. return true;
  28181. } else if (!(other instanceof LexerModeAction)) {
  28182. return false;
  28183. } else {
  28184. return this.mode === other.mode;
  28185. }
  28186. };
  28187. LexerModeAction.prototype.toString = function () {
  28188. return "mode(" + this.mode + ")";
  28189. };
  28190. // Executes a custom lexer action by calling {@link Recognizer//action} with the
  28191. // rule and action indexes assigned to the custom action. The implementation of
  28192. // a custom action is added to the generated code for the lexer in an override
  28193. // of {@link Recognizer//action} when the grammar is compiled.
  28194. //
  28195. // <p>This class may represent embedded actions created with the <code>{...}</code>
  28196. // syntax in ANTLR 4, as well as actions created for lexer commands where the
  28197. // command argument could not be evaluated when the grammar was compiled.</p>
  28198. // Constructs a custom lexer action with the specified rule and action
  28199. // indexes.
  28200. //
  28201. // @param ruleIndex The rule index to use for calls to
  28202. // {@link Recognizer//action}.
  28203. // @param actionIndex The action index to use for calls to
  28204. // {@link Recognizer//action}.
  28205. function LexerCustomAction(ruleIndex, actionIndex) {
  28206. LexerAction.call(this, LexerActionType.CUSTOM);
  28207. this.ruleIndex = ruleIndex;
  28208. this.actionIndex = actionIndex;
  28209. this.isPositionDependent = true;
  28210. return this;
  28211. }
  28212. LexerCustomAction.prototype = Object.create(LexerAction.prototype);
  28213. LexerCustomAction.prototype.constructor = LexerCustomAction;
  28214. // <p>Custom actions are implemented by calling {@link Lexer//action} with the
  28215. // appropriate rule and action indexes.</p>
  28216. LexerCustomAction.prototype.execute = function (lexer) {
  28217. lexer.action(null, this.ruleIndex, this.actionIndex);
  28218. };
  28219. LexerCustomAction.prototype.updateHashCode = function (hash) {
  28220. hash.update(this.actionType, this.ruleIndex, this.actionIndex);
  28221. };
  28222. LexerCustomAction.prototype.equals = function (other) {
  28223. if (this === other) {
  28224. return true;
  28225. } else if (!(other instanceof LexerCustomAction)) {
  28226. return false;
  28227. } else {
  28228. return this.ruleIndex === other.ruleIndex && this.actionIndex === other.actionIndex;
  28229. }
  28230. };
  28231. // Implements the {@code channel} lexer action by calling
  28232. // {@link Lexer//setChannel} with the assigned channel.
  28233. // Constructs a new {@code channel} action with the specified channel value.
  28234. // @param channel The channel value to pass to {@link Lexer//setChannel}.
  28235. function LexerChannelAction(channel) {
  28236. LexerAction.call(this, LexerActionType.CHANNEL);
  28237. this.channel = channel;
  28238. return this;
  28239. }
  28240. LexerChannelAction.prototype = Object.create(LexerAction.prototype);
  28241. LexerChannelAction.prototype.constructor = LexerChannelAction;
  28242. // <p>This action is implemented by calling {@link Lexer//setChannel} with the
  28243. // value provided by {@link //getChannel}.</p>
  28244. LexerChannelAction.prototype.execute = function (lexer) {
  28245. lexer._channel = this.channel;
  28246. };
  28247. LexerChannelAction.prototype.updateHashCode = function (hash) {
  28248. hash.update(this.actionType, this.channel);
  28249. };
  28250. LexerChannelAction.prototype.equals = function (other) {
  28251. if (this === other) {
  28252. return true;
  28253. } else if (!(other instanceof LexerChannelAction)) {
  28254. return false;
  28255. } else {
  28256. return this.channel === other.channel;
  28257. }
  28258. };
  28259. LexerChannelAction.prototype.toString = function () {
  28260. return "channel(" + this.channel + ")";
  28261. };
  28262. // This implementation of {@link LexerAction} is used for tracking input offsets
  28263. // for position-dependent actions within a {@link LexerActionExecutor}.
  28264. //
  28265. // <p>This action is not serialized as part of the ATN, and is only required for
  28266. // position-dependent lexer actions which appear at a location other than the
  28267. // end of a rule. For more information about DFA optimizations employed for
  28268. // lexer actions, see {@link LexerActionExecutor//append} and
  28269. // {@link LexerActionExecutor//fixOffsetBeforeMatch}.</p>
  28270. // Constructs a new indexed custom action by associating a character offset
  28271. // with a {@link LexerAction}.
  28272. //
  28273. // <p>Note: This class is only required for lexer actions for which
  28274. // {@link LexerAction//isPositionDependent} returns {@code true}.</p>
  28275. //
  28276. // @param offset The offset into the input {@link CharStream}, relative to
  28277. // the token start index, at which the specified lexer action should be
  28278. // executed.
  28279. // @param action The lexer action to execute at a particular offset in the
  28280. // input {@link CharStream}.
  28281. function LexerIndexedCustomAction(offset, action) {
  28282. LexerAction.call(this, action.actionType);
  28283. this.offset = offset;
  28284. this.action = action;
  28285. this.isPositionDependent = true;
  28286. return this;
  28287. }
  28288. LexerIndexedCustomAction.prototype = Object.create(LexerAction.prototype);
  28289. LexerIndexedCustomAction.prototype.constructor = LexerIndexedCustomAction;
  28290. // <p>This method calls {@link //execute} on the result of {@link //getAction}
  28291. // using the provided {@code lexer}.</p>
  28292. LexerIndexedCustomAction.prototype.execute = function (lexer) {
  28293. // assume the input stream position was properly set by the calling code
  28294. this.action.execute(lexer);
  28295. };
  28296. LexerIndexedCustomAction.prototype.updateHashCode = function (hash) {
  28297. hash.update(this.actionType, this.offset, this.action);
  28298. };
  28299. LexerIndexedCustomAction.prototype.equals = function (other) {
  28300. if (this === other) {
  28301. return true;
  28302. } else if (!(other instanceof LexerIndexedCustomAction)) {
  28303. return false;
  28304. } else {
  28305. return this.offset === other.offset && this.action === other.action;
  28306. }
  28307. };
  28308. exports.LexerActionType = LexerActionType;
  28309. exports.LexerSkipAction = LexerSkipAction;
  28310. exports.LexerChannelAction = LexerChannelAction;
  28311. exports.LexerCustomAction = LexerCustomAction;
  28312. exports.LexerIndexedCustomAction = LexerIndexedCustomAction;
  28313. exports.LexerMoreAction = LexerMoreAction;
  28314. exports.LexerTypeAction = LexerTypeAction;
  28315. exports.LexerPushModeAction = LexerPushModeAction;
  28316. exports.LexerPopModeAction = LexerPopModeAction;
  28317. exports.LexerModeAction = LexerModeAction;
  28318. /***/ }),
  28319. /***/ "./node_modules/antlr4/atn/LexerActionExecutor.js":
  28320. /*!********************************************************!*\
  28321. !*** ./node_modules/antlr4/atn/LexerActionExecutor.js ***!
  28322. \********************************************************/
  28323. /*! no static exports found */
  28324. /***/ (function(module, exports, __webpack_require__) {
  28325. "use strict";
  28326. //
  28327. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  28328. * Use of this file is governed by the BSD 3-clause license that
  28329. * can be found in the LICENSE.txt file in the project root.
  28330. */
  28331. ///
  28332. // Represents an executor for a sequence of lexer actions which traversed during
  28333. // the matching operation of a lexer rule (token).
  28334. //
  28335. // <p>The executor tracks position information for position-dependent lexer actions
  28336. // efficiently, ensuring that actions appearing only at the end of the rule do
  28337. // not cause bloating of the {@link DFA} created for the lexer.</p>
  28338. var hashStuff = __webpack_require__(/*! ../Utils */ "./node_modules/antlr4/Utils.js").hashStuff;
  28339. var LexerIndexedCustomAction = __webpack_require__(/*! ./LexerAction */ "./node_modules/antlr4/atn/LexerAction.js").LexerIndexedCustomAction;
  28340. function LexerActionExecutor(lexerActions) {
  28341. this.lexerActions = lexerActions === null ? [] : lexerActions;
  28342. // Caches the result of {@link //hashCode} since the hash code is an element
  28343. // of the performance-critical {@link LexerATNConfig//hashCode} operation.
  28344. this.cachedHashCode = hashStuff(lexerActions); // "".join([str(la) for la in
  28345. // lexerActions]))
  28346. return this;
  28347. }
  28348. // Creates a {@link LexerActionExecutor} which executes the actions for
  28349. // the input {@code lexerActionExecutor} followed by a specified
  28350. // {@code lexerAction}.
  28351. //
  28352. // @param lexerActionExecutor The executor for actions already traversed by
  28353. // the lexer while matching a token within a particular
  28354. // {@link LexerATNConfig}. If this is {@code null}, the method behaves as
  28355. // though it were an empty executor.
  28356. // @param lexerAction The lexer action to execute after the actions
  28357. // specified in {@code lexerActionExecutor}.
  28358. //
  28359. // @return A {@link LexerActionExecutor} for executing the combine actions
  28360. // of {@code lexerActionExecutor} and {@code lexerAction}.
  28361. LexerActionExecutor.append = function (lexerActionExecutor, lexerAction) {
  28362. if (lexerActionExecutor === null) {
  28363. return new LexerActionExecutor([lexerAction]);
  28364. }
  28365. var lexerActions = lexerActionExecutor.lexerActions.concat([lexerAction]);
  28366. return new LexerActionExecutor(lexerActions);
  28367. };
  28368. // Creates a {@link LexerActionExecutor} which encodes the current offset
  28369. // for position-dependent lexer actions.
  28370. //
  28371. // <p>Normally, when the executor encounters lexer actions where
  28372. // {@link LexerAction//isPositionDependent} returns {@code true}, it calls
  28373. // {@link IntStream//seek} on the input {@link CharStream} to set the input
  28374. // position to the <em>end</em> of the current token. This behavior provides
  28375. // for efficient DFA representation of lexer actions which appear at the end
  28376. // of a lexer rule, even when the lexer rule matches a variable number of
  28377. // characters.</p>
  28378. //
  28379. // <p>Prior to traversing a match transition in the ATN, the current offset
  28380. // from the token start index is assigned to all position-dependent lexer
  28381. // actions which have not already been assigned a fixed offset. By storing
  28382. // the offsets relative to the token start index, the DFA representation of
  28383. // lexer actions which appear in the middle of tokens remains efficient due
  28384. // to sharing among tokens of the same length, regardless of their absolute
  28385. // position in the input stream.</p>
  28386. //
  28387. // <p>If the current executor already has offsets assigned to all
  28388. // position-dependent lexer actions, the method returns {@code this}.</p>
  28389. //
  28390. // @param offset The current offset to assign to all position-dependent
  28391. // lexer actions which do not already have offsets assigned.
  28392. //
  28393. // @return A {@link LexerActionExecutor} which stores input stream offsets
  28394. // for all position-dependent lexer actions.
  28395. // /
  28396. LexerActionExecutor.prototype.fixOffsetBeforeMatch = function (offset) {
  28397. var updatedLexerActions = null;
  28398. for (var i = 0; i < this.lexerActions.length; i++) {
  28399. if (this.lexerActions[i].isPositionDependent && !(this.lexerActions[i] instanceof LexerIndexedCustomAction)) {
  28400. if (updatedLexerActions === null) {
  28401. updatedLexerActions = this.lexerActions.concat([]);
  28402. }
  28403. updatedLexerActions[i] = new LexerIndexedCustomAction(offset, this.lexerActions[i]);
  28404. }
  28405. }
  28406. if (updatedLexerActions === null) {
  28407. return this;
  28408. } else {
  28409. return new LexerActionExecutor(updatedLexerActions);
  28410. }
  28411. };
  28412. // Execute the actions encapsulated by this executor within the context of a
  28413. // particular {@link Lexer}.
  28414. //
  28415. // <p>This method calls {@link IntStream//seek} to set the position of the
  28416. // {@code input} {@link CharStream} prior to calling
  28417. // {@link LexerAction//execute} on a position-dependent action. Before the
  28418. // method returns, the input position will be restored to the same position
  28419. // it was in when the method was invoked.</p>
  28420. //
  28421. // @param lexer The lexer instance.
  28422. // @param input The input stream which is the source for the current token.
  28423. // When this method is called, the current {@link IntStream//index} for
  28424. // {@code input} should be the start of the following token, i.e. 1
  28425. // character past the end of the current token.
  28426. // @param startIndex The token start index. This value may be passed to
  28427. // {@link IntStream//seek} to set the {@code input} position to the beginning
  28428. // of the token.
  28429. // /
  28430. LexerActionExecutor.prototype.execute = function (lexer, input, startIndex) {
  28431. var requiresSeek = false;
  28432. var stopIndex = input.index;
  28433. try {
  28434. for (var i = 0; i < this.lexerActions.length; i++) {
  28435. var lexerAction = this.lexerActions[i];
  28436. if (lexerAction instanceof LexerIndexedCustomAction) {
  28437. var offset = lexerAction.offset;
  28438. input.seek(startIndex + offset);
  28439. lexerAction = lexerAction.action;
  28440. requiresSeek = startIndex + offset !== stopIndex;
  28441. } else if (lexerAction.isPositionDependent) {
  28442. input.seek(stopIndex);
  28443. requiresSeek = false;
  28444. }
  28445. lexerAction.execute(lexer);
  28446. }
  28447. } finally {
  28448. if (requiresSeek) {
  28449. input.seek(stopIndex);
  28450. }
  28451. }
  28452. };
  28453. LexerActionExecutor.prototype.hashCode = function () {
  28454. return this.cachedHashCode;
  28455. };
  28456. LexerActionExecutor.prototype.updateHashCode = function (hash) {
  28457. hash.update(this.cachedHashCode);
  28458. };
  28459. LexerActionExecutor.prototype.equals = function (other) {
  28460. if (this === other) {
  28461. return true;
  28462. } else if (!(other instanceof LexerActionExecutor)) {
  28463. return false;
  28464. } else if (this.cachedHashCode != other.cachedHashCode) {
  28465. return false;
  28466. } else if (this.lexerActions.length != other.lexerActions.length) {
  28467. return false;
  28468. } else {
  28469. var numActions = this.lexerActions.length;
  28470. for (var idx = 0; idx < numActions; ++idx) {
  28471. if (!this.lexerActions[idx].equals(other.lexerActions[idx])) {
  28472. return false;
  28473. }
  28474. }
  28475. return true;
  28476. }
  28477. };
  28478. exports.LexerActionExecutor = LexerActionExecutor;
  28479. /***/ }),
  28480. /***/ "./node_modules/antlr4/atn/ParserATNSimulator.js":
  28481. /*!*******************************************************!*\
  28482. !*** ./node_modules/antlr4/atn/ParserATNSimulator.js ***!
  28483. \*******************************************************/
  28484. /*! no static exports found */
  28485. /***/ (function(module, exports, __webpack_require__) {
  28486. "use strict";
  28487. //
  28488. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  28489. * Use of this file is governed by the BSD 3-clause license that
  28490. * can be found in the LICENSE.txt file in the project root.
  28491. */
  28492. //
  28493. //
  28494. // The embodiment of the adaptive LL(*), ALL(*), parsing strategy.
  28495. //
  28496. // <p>
  28497. // The basic complexity of the adaptive strategy makes it harder to understand.
  28498. // We begin with ATN simulation to build paths in a DFA. Subsequent prediction
  28499. // requests go through the DFA first. If they reach a state without an edge for
  28500. // the current symbol, the algorithm fails over to the ATN simulation to
  28501. // complete the DFA path for the current input (until it finds a conflict state
  28502. // or uniquely predicting state).</p>
  28503. //
  28504. // <p>
  28505. // All of that is done without using the outer context because we want to create
  28506. // a DFA that is not dependent upon the rule invocation stack when we do a
  28507. // prediction. One DFA works in all contexts. We avoid using context not
  28508. // necessarily because it's slower, although it can be, but because of the DFA
  28509. // caching problem. The closure routine only considers the rule invocation stack
  28510. // created during prediction beginning in the decision rule. For example, if
  28511. // prediction occurs without invoking another rule's ATN, there are no context
  28512. // stacks in the configurations. When lack of context leads to a conflict, we
  28513. // don't know if it's an ambiguity or a weakness in the strong LL(*) parsing
  28514. // strategy (versus full LL(*)).</p>
  28515. //
  28516. // <p>
  28517. // When SLL yields a configuration set with conflict, we rewind the input and
  28518. // retry the ATN simulation, this time using full outer context without adding
  28519. // to the DFA. Configuration context stacks will be the full invocation stacks
  28520. // from the start rule. If we get a conflict using full context, then we can
  28521. // definitively say we have a true ambiguity for that input sequence. If we
  28522. // don't get a conflict, it implies that the decision is sensitive to the outer
  28523. // context. (It is not context-sensitive in the sense of context-sensitive
  28524. // grammars.)</p>
  28525. //
  28526. // <p>
  28527. // The next time we reach this DFA state with an SLL conflict, through DFA
  28528. // simulation, we will again retry the ATN simulation using full context mode.
  28529. // This is slow because we can't save the results and have to "interpret" the
  28530. // ATN each time we get that input.</p>
  28531. //
  28532. // <p>
  28533. // <strong>CACHING FULL CONTEXT PREDICTIONS</strong></p>
  28534. //
  28535. // <p>
  28536. // We could cache results from full context to predicted alternative easily and
  28537. // that saves a lot of time but doesn't work in presence of predicates. The set
  28538. // of visible predicates from the ATN start state changes depending on the
  28539. // context, because closure can fall off the end of a rule. I tried to cache
  28540. // tuples (stack context, semantic context, predicted alt) but it was slower
  28541. // than interpreting and much more complicated. Also required a huge amount of
  28542. // memory. The goal is not to create the world's fastest parser anyway. I'd like
  28543. // to keep this algorithm simple. By launching multiple threads, we can improve
  28544. // the speed of parsing across a large number of files.</p>
  28545. //
  28546. // <p>
  28547. // There is no strict ordering between the amount of input used by SLL vs LL,
  28548. // which makes it really hard to build a cache for full context. Let's say that
  28549. // we have input A B C that leads to an SLL conflict with full context X. That
  28550. // implies that using X we might only use A B but we could also use A B C D to
  28551. // resolve conflict. Input A B C D could predict alternative 1 in one position
  28552. // in the input and A B C E could predict alternative 2 in another position in
  28553. // input. The conflicting SLL configurations could still be non-unique in the
  28554. // full context prediction, which would lead us to requiring more input than the
  28555. // original A B C. To make a prediction cache work, we have to track the exact
  28556. // input used during the previous prediction. That amounts to a cache that maps
  28557. // X to a specific DFA for that context.</p>
  28558. //
  28559. // <p>
  28560. // Something should be done for left-recursive expression predictions. They are
  28561. // likely LL(1) + pred eval. Easier to do the whole SLL unless error and retry
  28562. // with full LL thing Sam does.</p>
  28563. //
  28564. // <p>
  28565. // <strong>AVOIDING FULL CONTEXT PREDICTION</strong></p>
  28566. //
  28567. // <p>
  28568. // We avoid doing full context retry when the outer context is empty, we did not
  28569. // dip into the outer context by falling off the end of the decision state rule,
  28570. // or when we force SLL mode.</p>
  28571. //
  28572. // <p>
  28573. // As an example of the not dip into outer context case, consider as super
  28574. // constructor calls versus function calls. One grammar might look like
  28575. // this:</p>
  28576. //
  28577. // <pre>
  28578. // ctorBody
  28579. // : '{' superCall? stat* '}'
  28580. // ;
  28581. // </pre>
  28582. //
  28583. // <p>
  28584. // Or, you might see something like</p>
  28585. //
  28586. // <pre>
  28587. // stat
  28588. // : superCall ';'
  28589. // | expression ';'
  28590. // | ...
  28591. // ;
  28592. // </pre>
  28593. //
  28594. // <p>
  28595. // In both cases I believe that no closure operations will dip into the outer
  28596. // context. In the first case ctorBody in the worst case will stop at the '}'.
  28597. // In the 2nd case it should stop at the ';'. Both cases should stay within the
  28598. // entry rule and not dip into the outer context.</p>
  28599. //
  28600. // <p>
  28601. // <strong>PREDICATES</strong></p>
  28602. //
  28603. // <p>
  28604. // Predicates are always evaluated if present in either SLL or LL both. SLL and
  28605. // LL simulation deals with predicates differently. SLL collects predicates as
  28606. // it performs closure operations like ANTLR v3 did. It delays predicate
  28607. // evaluation until it reaches and accept state. This allows us to cache the SLL
  28608. // ATN simulation whereas, if we had evaluated predicates on-the-fly during
  28609. // closure, the DFA state configuration sets would be different and we couldn't
  28610. // build up a suitable DFA.</p>
  28611. //
  28612. // <p>
  28613. // When building a DFA accept state during ATN simulation, we evaluate any
  28614. // predicates and return the sole semantically valid alternative. If there is
  28615. // more than 1 alternative, we report an ambiguity. If there are 0 alternatives,
  28616. // we throw an exception. Alternatives without predicates act like they have
  28617. // true predicates. The simple way to think about it is to strip away all
  28618. // alternatives with false predicates and choose the minimum alternative that
  28619. // remains.</p>
  28620. //
  28621. // <p>
  28622. // When we start in the DFA and reach an accept state that's predicated, we test
  28623. // those and return the minimum semantically viable alternative. If no
  28624. // alternatives are viable, we throw an exception.</p>
  28625. //
  28626. // <p>
  28627. // During full LL ATN simulation, closure always evaluates predicates and
  28628. // on-the-fly. This is crucial to reducing the configuration set size during
  28629. // closure. It hits a landmine when parsing with the Java grammar, for example,
  28630. // without this on-the-fly evaluation.</p>
  28631. //
  28632. // <p>
  28633. // <strong>SHARING DFA</strong></p>
  28634. //
  28635. // <p>
  28636. // All instances of the same parser share the same decision DFAs through a
  28637. // static field. Each instance gets its own ATN simulator but they share the
  28638. // same {@link //decisionToDFA} field. They also share a
  28639. // {@link PredictionContextCache} object that makes sure that all
  28640. // {@link PredictionContext} objects are shared among the DFA states. This makes
  28641. // a big size difference.</p>
  28642. //
  28643. // <p>
  28644. // <strong>THREAD SAFETY</strong></p>
  28645. //
  28646. // <p>
  28647. // The {@link ParserATNSimulator} locks on the {@link //decisionToDFA} field when
  28648. // it adds a new DFA object to that array. {@link //addDFAEdge}
  28649. // locks on the DFA for the current decision when setting the
  28650. // {@link DFAState//edges} field. {@link //addDFAState} locks on
  28651. // the DFA for the current decision when looking up a DFA state to see if it
  28652. // already exists. We must make sure that all requests to add DFA states that
  28653. // are equivalent result in the same shared DFA object. This is because lots of
  28654. // threads will be trying to update the DFA at once. The
  28655. // {@link //addDFAState} method also locks inside the DFA lock
  28656. // but this time on the shared context cache when it rebuilds the
  28657. // configurations' {@link PredictionContext} objects using cached
  28658. // subgraphs/nodes. No other locking occurs, even during DFA simulation. This is
  28659. // safe as long as we can guarantee that all threads referencing
  28660. // {@code s.edge[t]} get the same physical target {@link DFAState}, or
  28661. // {@code null}. Once into the DFA, the DFA simulation does not reference the
  28662. // {@link DFA//states} map. It follows the {@link DFAState//edges} field to new
  28663. // targets. The DFA simulator will either find {@link DFAState//edges} to be
  28664. // {@code null}, to be non-{@code null} and {@code dfa.edges[t]} null, or
  28665. // {@code dfa.edges[t]} to be non-null. The
  28666. // {@link //addDFAEdge} method could be racing to set the field
  28667. // but in either case the DFA simulator works; if {@code null}, and requests ATN
  28668. // simulation. It could also race trying to get {@code dfa.edges[t]}, but either
  28669. // way it will work because it's not doing a test and set operation.</p>
  28670. //
  28671. // <p>
  28672. // <strong>Starting with SLL then failing to combined SLL/LL (Two-Stage
  28673. // Parsing)</strong></p>
  28674. //
  28675. // <p>
  28676. // Sam pointed out that if SLL does not give a syntax error, then there is no
  28677. // point in doing full LL, which is slower. We only have to try LL if we get a
  28678. // syntax error. For maximum speed, Sam starts the parser set to pure SLL
  28679. // mode with the {@link BailErrorStrategy}:</p>
  28680. //
  28681. // <pre>
  28682. // parser.{@link Parser//getInterpreter() getInterpreter()}.{@link //setPredictionMode setPredictionMode}{@code (}{@link PredictionMode//SLL}{@code )};
  28683. // parser.{@link Parser//setErrorHandler setErrorHandler}(new {@link BailErrorStrategy}());
  28684. // </pre>
  28685. //
  28686. // <p>
  28687. // If it does not get a syntax error, then we're done. If it does get a syntax
  28688. // error, we need to retry with the combined SLL/LL strategy.</p>
  28689. //
  28690. // <p>
  28691. // The reason this works is as follows. If there are no SLL conflicts, then the
  28692. // grammar is SLL (at least for that input set). If there is an SLL conflict,
  28693. // the full LL analysis must yield a set of viable alternatives which is a
  28694. // subset of the alternatives reported by SLL. If the LL set is a singleton,
  28695. // then the grammar is LL but not SLL. If the LL set is the same size as the SLL
  28696. // set, the decision is SLL. If the LL set has size &gt; 1, then that decision
  28697. // is truly ambiguous on the current input. If the LL set is smaller, then the
  28698. // SLL conflict resolution might choose an alternative that the full LL would
  28699. // rule out as a possibility based upon better context information. If that's
  28700. // the case, then the SLL parse will definitely get an error because the full LL
  28701. // analysis says it's not viable. If SLL conflict resolution chooses an
  28702. // alternative within the LL set, them both SLL and LL would choose the same
  28703. // alternative because they both choose the minimum of multiple conflicting
  28704. // alternatives.</p>
  28705. //
  28706. // <p>
  28707. // Let's say we have a set of SLL conflicting alternatives {@code {1, 2, 3}} and
  28708. // a smaller LL set called <em>s</em>. If <em>s</em> is {@code {2, 3}}, then SLL
  28709. // parsing will get an error because SLL will pursue alternative 1. If
  28710. // <em>s</em> is {@code {1, 2}} or {@code {1, 3}} then both SLL and LL will
  28711. // choose the same alternative because alternative one is the minimum of either
  28712. // set. If <em>s</em> is {@code {2}} or {@code {3}} then SLL will get a syntax
  28713. // error. If <em>s</em> is {@code {1}} then SLL will succeed.</p>
  28714. //
  28715. // <p>
  28716. // Of course, if the input is invalid, then we will get an error for sure in
  28717. // both SLL and LL parsing. Erroneous input will therefore require 2 passes over
  28718. // the input.</p>
  28719. //
  28720. var Utils = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js");
  28721. var Set = Utils.Set;
  28722. var BitSet = Utils.BitSet;
  28723. var DoubleDict = Utils.DoubleDict;
  28724. var ATN = __webpack_require__(/*! ./ATN */ "./node_modules/antlr4/atn/ATN.js").ATN;
  28725. var ATNState = __webpack_require__(/*! ./ATNState */ "./node_modules/antlr4/atn/ATNState.js").ATNState;
  28726. var ATNConfig = __webpack_require__(/*! ./ATNConfig */ "./node_modules/antlr4/atn/ATNConfig.js").ATNConfig;
  28727. var ATNConfigSet = __webpack_require__(/*! ./ATNConfigSet */ "./node_modules/antlr4/atn/ATNConfigSet.js").ATNConfigSet;
  28728. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  28729. var DFAState = __webpack_require__(/*! ./../dfa/DFAState */ "./node_modules/antlr4/dfa/DFAState.js").DFAState;
  28730. var PredPrediction = __webpack_require__(/*! ./../dfa/DFAState */ "./node_modules/antlr4/dfa/DFAState.js").PredPrediction;
  28731. var ATNSimulator = __webpack_require__(/*! ./ATNSimulator */ "./node_modules/antlr4/atn/ATNSimulator.js").ATNSimulator;
  28732. var PredictionMode = __webpack_require__(/*! ./PredictionMode */ "./node_modules/antlr4/atn/PredictionMode.js").PredictionMode;
  28733. var RuleContext = __webpack_require__(/*! ./../RuleContext */ "./node_modules/antlr4/RuleContext.js").RuleContext;
  28734. var ParserRuleContext = __webpack_require__(/*! ./../ParserRuleContext */ "./node_modules/antlr4/ParserRuleContext.js").ParserRuleContext;
  28735. var SemanticContext = __webpack_require__(/*! ./SemanticContext */ "./node_modules/antlr4/atn/SemanticContext.js").SemanticContext;
  28736. var StarLoopEntryState = __webpack_require__(/*! ./ATNState */ "./node_modules/antlr4/atn/ATNState.js").StarLoopEntryState;
  28737. var RuleStopState = __webpack_require__(/*! ./ATNState */ "./node_modules/antlr4/atn/ATNState.js").RuleStopState;
  28738. var PredictionContext = __webpack_require__(/*! ./../PredictionContext */ "./node_modules/antlr4/PredictionContext.js").PredictionContext;
  28739. var Interval = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  28740. var Transitions = __webpack_require__(/*! ./Transition */ "./node_modules/antlr4/atn/Transition.js");
  28741. var Transition = Transitions.Transition;
  28742. var SetTransition = Transitions.SetTransition;
  28743. var NotSetTransition = Transitions.NotSetTransition;
  28744. var RuleTransition = Transitions.RuleTransition;
  28745. var ActionTransition = Transitions.ActionTransition;
  28746. var NoViableAltException = __webpack_require__(/*! ./../error/Errors */ "./node_modules/antlr4/error/Errors.js").NoViableAltException;
  28747. var SingletonPredictionContext = __webpack_require__(/*! ./../PredictionContext */ "./node_modules/antlr4/PredictionContext.js").SingletonPredictionContext;
  28748. var predictionContextFromRuleContext = __webpack_require__(/*! ./../PredictionContext */ "./node_modules/antlr4/PredictionContext.js").predictionContextFromRuleContext;
  28749. function ParserATNSimulator(parser, atn, decisionToDFA, sharedContextCache) {
  28750. ATNSimulator.call(this, atn, sharedContextCache);
  28751. this.parser = parser;
  28752. this.decisionToDFA = decisionToDFA;
  28753. // SLL, LL, or LL + exact ambig detection?//
  28754. this.predictionMode = PredictionMode.LL;
  28755. // LAME globals to avoid parameters!!!!! I need these down deep in predTransition
  28756. this._input = null;
  28757. this._startIndex = 0;
  28758. this._outerContext = null;
  28759. this._dfa = null;
  28760. // Each prediction operation uses a cache for merge of prediction contexts.
  28761. // Don't keep around as it wastes huge amounts of memory. DoubleKeyMap
  28762. // isn't synchronized but we're ok since two threads shouldn't reuse same
  28763. // parser/atnsim object because it can only handle one input at a time.
  28764. // This maps graphs a and b to merged result c. (a,b)&rarr;c. We can avoid
  28765. // the merge if we ever see a and b again. Note that (b,a)&rarr;c should
  28766. // also be examined during cache lookup.
  28767. //
  28768. this.mergeCache = null;
  28769. return this;
  28770. }
  28771. ParserATNSimulator.prototype = Object.create(ATNSimulator.prototype);
  28772. ParserATNSimulator.prototype.constructor = ParserATNSimulator;
  28773. ParserATNSimulator.prototype.debug = false;
  28774. ParserATNSimulator.prototype.debug_closure = false;
  28775. ParserATNSimulator.prototype.debug_add = false;
  28776. ParserATNSimulator.prototype.debug_list_atn_decisions = false;
  28777. ParserATNSimulator.prototype.dfa_debug = false;
  28778. ParserATNSimulator.prototype.retry_debug = false;
  28779. ParserATNSimulator.prototype.reset = function () {};
  28780. ParserATNSimulator.prototype.adaptivePredict = function (input, decision, outerContext) {
  28781. if (this.debug || this.debug_list_atn_decisions) {
  28782. console.log("adaptivePredict decision " + decision + " exec LA(1)==" + this.getLookaheadName(input) + " line " + input.LT(1).line + ":" + input.LT(1).column);
  28783. }
  28784. this._input = input;
  28785. this._startIndex = input.index;
  28786. this._outerContext = outerContext;
  28787. var dfa = this.decisionToDFA[decision];
  28788. this._dfa = dfa;
  28789. var m = input.mark();
  28790. var index = input.index;
  28791. // Now we are certain to have a specific decision's DFA
  28792. // But, do we still need an initial state?
  28793. try {
  28794. var s0;
  28795. if (dfa.precedenceDfa) {
  28796. // the start state for a precedence DFA depends on the current
  28797. // parser precedence, and is provided by a DFA method.
  28798. s0 = dfa.getPrecedenceStartState(this.parser.getPrecedence());
  28799. } else {
  28800. // the start state for a "regular" DFA is just s0
  28801. s0 = dfa.s0;
  28802. }
  28803. if (s0 === null) {
  28804. if (outerContext === null) {
  28805. outerContext = RuleContext.EMPTY;
  28806. }
  28807. if (this.debug || this.debug_list_atn_decisions) {
  28808. console.log("predictATN decision " + dfa.decision + " exec LA(1)==" + this.getLookaheadName(input) + ", outerContext=" + outerContext.toString(this.parser.ruleNames));
  28809. }
  28810. var fullCtx = false;
  28811. var s0_closure = this.computeStartState(dfa.atnStartState, RuleContext.EMPTY, fullCtx);
  28812. if (dfa.precedenceDfa) {
  28813. // If this is a precedence DFA, we use applyPrecedenceFilter
  28814. // to convert the computed start state to a precedence start
  28815. // state. We then use DFA.setPrecedenceStartState to set the
  28816. // appropriate start state for the precedence level rather
  28817. // than simply setting DFA.s0.
  28818. //
  28819. dfa.s0.configs = s0_closure; // not used for prediction but useful to know start configs anyway
  28820. s0_closure = this.applyPrecedenceFilter(s0_closure);
  28821. s0 = this.addDFAState(dfa, new DFAState(null, s0_closure));
  28822. dfa.setPrecedenceStartState(this.parser.getPrecedence(), s0);
  28823. } else {
  28824. s0 = this.addDFAState(dfa, new DFAState(null, s0_closure));
  28825. dfa.s0 = s0;
  28826. }
  28827. }
  28828. var alt = this.execATN(dfa, s0, input, index, outerContext);
  28829. if (this.debug) {
  28830. console.log("DFA after predictATN: " + dfa.toString(this.parser.literalNames));
  28831. }
  28832. return alt;
  28833. } finally {
  28834. this._dfa = null;
  28835. this.mergeCache = null; // wack cache after each prediction
  28836. input.seek(index);
  28837. input.release(m);
  28838. }
  28839. };
  28840. // Performs ATN simulation to compute a predicted alternative based
  28841. // upon the remaining input, but also updates the DFA cache to avoid
  28842. // having to traverse the ATN again for the same input sequence.
  28843. // There are some key conditions we're looking for after computing a new
  28844. // set of ATN configs (proposed DFA state):
  28845. // if the set is empty, there is no viable alternative for current symbol
  28846. // does the state uniquely predict an alternative?
  28847. // does the state have a conflict that would prevent us from
  28848. // putting it on the work list?
  28849. // We also have some key operations to do:
  28850. // add an edge from previous DFA state to potentially new DFA state, D,
  28851. // upon current symbol but only if adding to work list, which means in all
  28852. // cases except no viable alternative (and possibly non-greedy decisions?)
  28853. // collecting predicates and adding semantic context to DFA accept states
  28854. // adding rule context to context-sensitive DFA accept states
  28855. // consuming an input symbol
  28856. // reporting a conflict
  28857. // reporting an ambiguity
  28858. // reporting a context sensitivity
  28859. // reporting insufficient predicates
  28860. // cover these cases:
  28861. // dead end
  28862. // single alt
  28863. // single alt + preds
  28864. // conflict
  28865. // conflict + preds
  28866. //
  28867. ParserATNSimulator.prototype.execATN = function (dfa, s0, input, startIndex, outerContext) {
  28868. if (this.debug || this.debug_list_atn_decisions) {
  28869. console.log("execATN decision " + dfa.decision + " exec LA(1)==" + this.getLookaheadName(input) + " line " + input.LT(1).line + ":" + input.LT(1).column);
  28870. }
  28871. var alt;
  28872. var previousD = s0;
  28873. if (this.debug) {
  28874. console.log("s0 = " + s0);
  28875. }
  28876. var t = input.LA(1);
  28877. while (true) {
  28878. // while more work
  28879. var D = this.getExistingTargetState(previousD, t);
  28880. if (D === null) {
  28881. D = this.computeTargetState(dfa, previousD, t);
  28882. }
  28883. if (D === ATNSimulator.ERROR) {
  28884. // if any configs in previous dipped into outer context, that
  28885. // means that input up to t actually finished entry rule
  28886. // at least for SLL decision. Full LL doesn't dip into outer
  28887. // so don't need special case.
  28888. // We will get an error no matter what so delay until after
  28889. // decision; better error message. Also, no reachable target
  28890. // ATN states in SLL implies LL will also get nowhere.
  28891. // If conflict in states that dip out, choose min since we
  28892. // will get error no matter what.
  28893. var e = this.noViableAlt(input, outerContext, previousD.configs, startIndex);
  28894. input.seek(startIndex);
  28895. alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previousD.configs, outerContext);
  28896. if (alt !== ATN.INVALID_ALT_NUMBER) {
  28897. return alt;
  28898. } else {
  28899. throw e;
  28900. }
  28901. }
  28902. if (D.requiresFullContext && this.predictionMode !== PredictionMode.SLL) {
  28903. // IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error)
  28904. var conflictingAlts = null;
  28905. if (D.predicates !== null) {
  28906. if (this.debug) {
  28907. console.log("DFA state has preds in DFA sim LL failover");
  28908. }
  28909. var conflictIndex = input.index;
  28910. if (conflictIndex !== startIndex) {
  28911. input.seek(startIndex);
  28912. }
  28913. conflictingAlts = this.evalSemanticContext(D.predicates, outerContext, true);
  28914. if (conflictingAlts.length === 1) {
  28915. if (this.debug) {
  28916. console.log("Full LL avoided");
  28917. }
  28918. return conflictingAlts.minValue();
  28919. }
  28920. if (conflictIndex !== startIndex) {
  28921. // restore the index so reporting the fallback to full
  28922. // context occurs with the index at the correct spot
  28923. input.seek(conflictIndex);
  28924. }
  28925. }
  28926. if (this.dfa_debug) {
  28927. console.log("ctx sensitive state " + outerContext + " in " + D);
  28928. }
  28929. var fullCtx = true;
  28930. var s0_closure = this.computeStartState(dfa.atnStartState, outerContext, fullCtx);
  28931. this.reportAttemptingFullContext(dfa, conflictingAlts, D.configs, startIndex, input.index);
  28932. alt = this.execATNWithFullContext(dfa, D, s0_closure, input, startIndex, outerContext);
  28933. return alt;
  28934. }
  28935. if (D.isAcceptState) {
  28936. if (D.predicates === null) {
  28937. return D.prediction;
  28938. }
  28939. var stopIndex = input.index;
  28940. input.seek(startIndex);
  28941. var alts = this.evalSemanticContext(D.predicates, outerContext, true);
  28942. if (alts.length === 0) {
  28943. throw this.noViableAlt(input, outerContext, D.configs, startIndex);
  28944. } else if (alts.length === 1) {
  28945. return alts.minValue();
  28946. } else {
  28947. // report ambiguity after predicate evaluation to make sure the correct set of ambig alts is reported.
  28948. this.reportAmbiguity(dfa, D, startIndex, stopIndex, false, alts, D.configs);
  28949. return alts.minValue();
  28950. }
  28951. }
  28952. previousD = D;
  28953. if (t !== Token.EOF) {
  28954. input.consume();
  28955. t = input.LA(1);
  28956. }
  28957. }
  28958. };
  28959. //
  28960. // Get an existing target state for an edge in the DFA. If the target state
  28961. // for the edge has not yet been computed or is otherwise not available,
  28962. // this method returns {@code null}.
  28963. //
  28964. // @param previousD The current DFA state
  28965. // @param t The next input symbol
  28966. // @return The existing target DFA state for the given input symbol
  28967. // {@code t}, or {@code null} if the target state for this edge is not
  28968. // already cached
  28969. //
  28970. ParserATNSimulator.prototype.getExistingTargetState = function (previousD, t) {
  28971. var edges = previousD.edges;
  28972. if (edges === null) {
  28973. return null;
  28974. } else {
  28975. return edges[t + 1] || null;
  28976. }
  28977. };
  28978. //
  28979. // Compute a target state for an edge in the DFA, and attempt to add the
  28980. // computed state and corresponding edge to the DFA.
  28981. //
  28982. // @param dfa The DFA
  28983. // @param previousD The current DFA state
  28984. // @param t The next input symbol
  28985. //
  28986. // @return The computed target DFA state for the given input symbol
  28987. // {@code t}. If {@code t} does not lead to a valid DFA state, this method
  28988. // returns {@link //ERROR}.
  28989. //
  28990. ParserATNSimulator.prototype.computeTargetState = function (dfa, previousD, t) {
  28991. var reach = this.computeReachSet(previousD.configs, t, false);
  28992. if (reach === null) {
  28993. this.addDFAEdge(dfa, previousD, t, ATNSimulator.ERROR);
  28994. return ATNSimulator.ERROR;
  28995. }
  28996. // create new target state; we'll add to DFA after it's complete
  28997. var D = new DFAState(null, reach);
  28998. var predictedAlt = this.getUniqueAlt(reach);
  28999. if (this.debug) {
  29000. var altSubSets = PredictionMode.getConflictingAltSubsets(reach);
  29001. console.log("SLL altSubSets=" + Utils.arrayToString(altSubSets) + ", previous=" + previousD.configs + ", configs=" + reach + ", predict=" + predictedAlt + ", allSubsetsConflict=" + PredictionMode.allSubsetsConflict(altSubSets) + ", conflictingAlts=" + this.getConflictingAlts(reach));
  29002. }
  29003. if (predictedAlt !== ATN.INVALID_ALT_NUMBER) {
  29004. // NO CONFLICT, UNIQUELY PREDICTED ALT
  29005. D.isAcceptState = true;
  29006. D.configs.uniqueAlt = predictedAlt;
  29007. D.prediction = predictedAlt;
  29008. } else if (PredictionMode.hasSLLConflictTerminatingPrediction(this.predictionMode, reach)) {
  29009. // MORE THAN ONE VIABLE ALTERNATIVE
  29010. D.configs.conflictingAlts = this.getConflictingAlts(reach);
  29011. D.requiresFullContext = true;
  29012. // in SLL-only mode, we will stop at this state and return the minimum alt
  29013. D.isAcceptState = true;
  29014. D.prediction = D.configs.conflictingAlts.minValue();
  29015. }
  29016. if (D.isAcceptState && D.configs.hasSemanticContext) {
  29017. this.predicateDFAState(D, this.atn.getDecisionState(dfa.decision));
  29018. if (D.predicates !== null) {
  29019. D.prediction = ATN.INVALID_ALT_NUMBER;
  29020. }
  29021. }
  29022. // all adds to dfa are done after we've created full D state
  29023. D = this.addDFAEdge(dfa, previousD, t, D);
  29024. return D;
  29025. };
  29026. ParserATNSimulator.prototype.predicateDFAState = function (dfaState, decisionState) {
  29027. // We need to test all predicates, even in DFA states that
  29028. // uniquely predict alternative.
  29029. var nalts = decisionState.transitions.length;
  29030. // Update DFA so reach becomes accept state with (predicate,alt)
  29031. // pairs if preds found for conflicting alts
  29032. var altsToCollectPredsFrom = this.getConflictingAltsOrUniqueAlt(dfaState.configs);
  29033. var altToPred = this.getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts);
  29034. if (altToPred !== null) {
  29035. dfaState.predicates = this.getPredicatePredictions(altsToCollectPredsFrom, altToPred);
  29036. dfaState.prediction = ATN.INVALID_ALT_NUMBER; // make sure we use preds
  29037. } else {
  29038. // There are preds in configs but they might go away
  29039. // when OR'd together like {p}? || NONE == NONE. If neither
  29040. // alt has preds, resolve to min alt
  29041. dfaState.prediction = altsToCollectPredsFrom.minValue();
  29042. }
  29043. };
  29044. // comes back with reach.uniqueAlt set to a valid alt
  29045. ParserATNSimulator.prototype.execATNWithFullContext = function (dfa, D, // how far we got before failing over
  29046. s0, input, startIndex, outerContext) {
  29047. if (this.debug || this.debug_list_atn_decisions) {
  29048. console.log("execATNWithFullContext " + s0);
  29049. }
  29050. var fullCtx = true;
  29051. var foundExactAmbig = false;
  29052. var reach = null;
  29053. var previous = s0;
  29054. input.seek(startIndex);
  29055. var t = input.LA(1);
  29056. var predictedAlt = -1;
  29057. while (true) {
  29058. // while more work
  29059. reach = this.computeReachSet(previous, t, fullCtx);
  29060. if (reach === null) {
  29061. // if any configs in previous dipped into outer context, that
  29062. // means that input up to t actually finished entry rule
  29063. // at least for LL decision. Full LL doesn't dip into outer
  29064. // so don't need special case.
  29065. // We will get an error no matter what so delay until after
  29066. // decision; better error message. Also, no reachable target
  29067. // ATN states in SLL implies LL will also get nowhere.
  29068. // If conflict in states that dip out, choose min since we
  29069. // will get error no matter what.
  29070. var e = this.noViableAlt(input, outerContext, previous, startIndex);
  29071. input.seek(startIndex);
  29072. var alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previous, outerContext);
  29073. if (alt !== ATN.INVALID_ALT_NUMBER) {
  29074. return alt;
  29075. } else {
  29076. throw e;
  29077. }
  29078. }
  29079. var altSubSets = PredictionMode.getConflictingAltSubsets(reach);
  29080. if (this.debug) {
  29081. console.log("LL altSubSets=" + altSubSets + ", predict=" + PredictionMode.getUniqueAlt(altSubSets) + ", resolvesToJustOneViableAlt=" + PredictionMode.resolvesToJustOneViableAlt(altSubSets));
  29082. }
  29083. reach.uniqueAlt = this.getUniqueAlt(reach);
  29084. // unique prediction?
  29085. if (reach.uniqueAlt !== ATN.INVALID_ALT_NUMBER) {
  29086. predictedAlt = reach.uniqueAlt;
  29087. break;
  29088. } else if (this.predictionMode !== PredictionMode.LL_EXACT_AMBIG_DETECTION) {
  29089. predictedAlt = PredictionMode.resolvesToJustOneViableAlt(altSubSets);
  29090. if (predictedAlt !== ATN.INVALID_ALT_NUMBER) {
  29091. break;
  29092. }
  29093. } else {
  29094. // In exact ambiguity mode, we never try to terminate early.
  29095. // Just keeps scarfing until we know what the conflict is
  29096. if (PredictionMode.allSubsetsConflict(altSubSets) && PredictionMode.allSubsetsEqual(altSubSets)) {
  29097. foundExactAmbig = true;
  29098. predictedAlt = PredictionMode.getSingleViableAlt(altSubSets);
  29099. break;
  29100. }
  29101. // else there are multiple non-conflicting subsets or
  29102. // we're not sure what the ambiguity is yet.
  29103. // So, keep going.
  29104. }
  29105. previous = reach;
  29106. if (t !== Token.EOF) {
  29107. input.consume();
  29108. t = input.LA(1);
  29109. }
  29110. }
  29111. // If the configuration set uniquely predicts an alternative,
  29112. // without conflict, then we know that it's a full LL decision
  29113. // not SLL.
  29114. if (reach.uniqueAlt !== ATN.INVALID_ALT_NUMBER) {
  29115. this.reportContextSensitivity(dfa, predictedAlt, reach, startIndex, input.index);
  29116. return predictedAlt;
  29117. }
  29118. // We do not check predicates here because we have checked them
  29119. // on-the-fly when doing full context prediction.
  29120. //
  29121. // In non-exact ambiguity detection mode, we might actually be able to
  29122. // detect an exact ambiguity, but I'm not going to spend the cycles
  29123. // needed to check. We only emit ambiguity warnings in exact ambiguity
  29124. // mode.
  29125. //
  29126. // For example, we might know that we have conflicting configurations.
  29127. // But, that does not mean that there is no way forward without a
  29128. // conflict. It's possible to have nonconflicting alt subsets as in:
  29129. // altSubSets=[{1, 2}, {1, 2}, {1}, {1, 2}]
  29130. // from
  29131. //
  29132. // [(17,1,[5 $]), (13,1,[5 10 $]), (21,1,[5 10 $]), (11,1,[$]),
  29133. // (13,2,[5 10 $]), (21,2,[5 10 $]), (11,2,[$])]
  29134. //
  29135. // In this case, (17,1,[5 $]) indicates there is some next sequence that
  29136. // would resolve this without conflict to alternative 1. Any other viable
  29137. // next sequence, however, is associated with a conflict. We stop
  29138. // looking for input because no amount of further lookahead will alter
  29139. // the fact that we should predict alternative 1. We just can't say for
  29140. // sure that there is an ambiguity without looking further.
  29141. this.reportAmbiguity(dfa, D, startIndex, input.index, foundExactAmbig, null, reach);
  29142. return predictedAlt;
  29143. };
  29144. ParserATNSimulator.prototype.computeReachSet = function (closure, t, fullCtx) {
  29145. if (this.debug) {
  29146. console.log("in computeReachSet, starting closure: " + closure);
  29147. }
  29148. if (this.mergeCache === null) {
  29149. this.mergeCache = new DoubleDict();
  29150. }
  29151. var intermediate = new ATNConfigSet(fullCtx);
  29152. // Configurations already in a rule stop state indicate reaching the end
  29153. // of the decision rule (local context) or end of the start rule (full
  29154. // context). Once reached, these configurations are never updated by a
  29155. // closure operation, so they are handled separately for the performance
  29156. // advantage of having a smaller intermediate set when calling closure.
  29157. //
  29158. // For full-context reach operations, separate handling is required to
  29159. // ensure that the alternative matching the longest overall sequence is
  29160. // chosen when multiple such configurations can match the input.
  29161. var skippedStopStates = null;
  29162. // First figure out where we can reach on input t
  29163. for (var i = 0; i < closure.items.length; i++) {
  29164. var c = closure.items[i];
  29165. if (this.debug_add) {
  29166. console.log("testing " + this.getTokenName(t) + " at " + c);
  29167. }
  29168. if (c.state instanceof RuleStopState) {
  29169. if (fullCtx || t === Token.EOF) {
  29170. if (skippedStopStates === null) {
  29171. skippedStopStates = [];
  29172. }
  29173. skippedStopStates.push(c);
  29174. if (this.debug_add) {
  29175. console.log("added " + c + " to skippedStopStates");
  29176. }
  29177. }
  29178. continue;
  29179. }
  29180. for (var j = 0; j < c.state.transitions.length; j++) {
  29181. var trans = c.state.transitions[j];
  29182. var target = this.getReachableTarget(trans, t);
  29183. if (target !== null) {
  29184. var cfg = new ATNConfig({ state: target }, c);
  29185. intermediate.add(cfg, this.mergeCache);
  29186. if (this.debug_add) {
  29187. console.log("added " + cfg + " to intermediate");
  29188. }
  29189. }
  29190. }
  29191. }
  29192. // Now figure out where the reach operation can take us...
  29193. var reach = null;
  29194. // This block optimizes the reach operation for intermediate sets which
  29195. // trivially indicate a termination state for the overall
  29196. // adaptivePredict operation.
  29197. //
  29198. // The conditions assume that intermediate
  29199. // contains all configurations relevant to the reach set, but this
  29200. // condition is not true when one or more configurations have been
  29201. // withheld in skippedStopStates, or when the current symbol is EOF.
  29202. //
  29203. if (skippedStopStates === null && t !== Token.EOF) {
  29204. if (intermediate.items.length === 1) {
  29205. // Don't pursue the closure if there is just one state.
  29206. // It can only have one alternative; just add to result
  29207. // Also don't pursue the closure if there is unique alternative
  29208. // among the configurations.
  29209. reach = intermediate;
  29210. } else if (this.getUniqueAlt(intermediate) !== ATN.INVALID_ALT_NUMBER) {
  29211. // Also don't pursue the closure if there is unique alternative
  29212. // among the configurations.
  29213. reach = intermediate;
  29214. }
  29215. }
  29216. // If the reach set could not be trivially determined, perform a closure
  29217. // operation on the intermediate set to compute its initial value.
  29218. //
  29219. if (reach === null) {
  29220. reach = new ATNConfigSet(fullCtx);
  29221. var closureBusy = new Set();
  29222. var treatEofAsEpsilon = t === Token.EOF;
  29223. for (var k = 0; k < intermediate.items.length; k++) {
  29224. this.closure(intermediate.items[k], reach, closureBusy, false, fullCtx, treatEofAsEpsilon);
  29225. }
  29226. }
  29227. if (t === Token.EOF) {
  29228. // After consuming EOF no additional input is possible, so we are
  29229. // only interested in configurations which reached the end of the
  29230. // decision rule (local context) or end of the start rule (full
  29231. // context). Update reach to contain only these configurations. This
  29232. // handles both explicit EOF transitions in the grammar and implicit
  29233. // EOF transitions following the end of the decision or start rule.
  29234. //
  29235. // When reach==intermediate, no closure operation was performed. In
  29236. // this case, removeAllConfigsNotInRuleStopState needs to check for
  29237. // reachable rule stop states as well as configurations already in
  29238. // a rule stop state.
  29239. //
  29240. // This is handled before the configurations in skippedStopStates,
  29241. // because any configurations potentially added from that list are
  29242. // already guaranteed to meet this condition whether or not it's
  29243. // required.
  29244. //
  29245. reach = this.removeAllConfigsNotInRuleStopState(reach, reach === intermediate);
  29246. }
  29247. // If skippedStopStates!==null, then it contains at least one
  29248. // configuration. For full-context reach operations, these
  29249. // configurations reached the end of the start rule, in which case we
  29250. // only add them back to reach if no configuration during the current
  29251. // closure operation reached such a state. This ensures adaptivePredict
  29252. // chooses an alternative matching the longest overall sequence when
  29253. // multiple alternatives are viable.
  29254. //
  29255. if (skippedStopStates !== null && (!fullCtx || !PredictionMode.hasConfigInRuleStopState(reach))) {
  29256. for (var l = 0; l < skippedStopStates.length; l++) {
  29257. reach.add(skippedStopStates[l], this.mergeCache);
  29258. }
  29259. }
  29260. if (reach.items.length === 0) {
  29261. return null;
  29262. } else {
  29263. return reach;
  29264. }
  29265. };
  29266. //
  29267. // Return a configuration set containing only the configurations from
  29268. // {@code configs} which are in a {@link RuleStopState}. If all
  29269. // configurations in {@code configs} are already in a rule stop state, this
  29270. // method simply returns {@code configs}.
  29271. //
  29272. // <p>When {@code lookToEndOfRule} is true, this method uses
  29273. // {@link ATN//nextTokens} for each configuration in {@code configs} which is
  29274. // not already in a rule stop state to see if a rule stop state is reachable
  29275. // from the configuration via epsilon-only transitions.</p>
  29276. //
  29277. // @param configs the configuration set to update
  29278. // @param lookToEndOfRule when true, this method checks for rule stop states
  29279. // reachable by epsilon-only transitions from each configuration in
  29280. // {@code configs}.
  29281. //
  29282. // @return {@code configs} if all configurations in {@code configs} are in a
  29283. // rule stop state, otherwise return a new configuration set containing only
  29284. // the configurations from {@code configs} which are in a rule stop state
  29285. //
  29286. ParserATNSimulator.prototype.removeAllConfigsNotInRuleStopState = function (configs, lookToEndOfRule) {
  29287. if (PredictionMode.allConfigsInRuleStopStates(configs)) {
  29288. return configs;
  29289. }
  29290. var result = new ATNConfigSet(configs.fullCtx);
  29291. for (var i = 0; i < configs.items.length; i++) {
  29292. var config = configs.items[i];
  29293. if (config.state instanceof RuleStopState) {
  29294. result.add(config, this.mergeCache);
  29295. continue;
  29296. }
  29297. if (lookToEndOfRule && config.state.epsilonOnlyTransitions) {
  29298. var nextTokens = this.atn.nextTokens(config.state);
  29299. if (nextTokens.contains(Token.EPSILON)) {
  29300. var endOfRuleState = this.atn.ruleToStopState[config.state.ruleIndex];
  29301. result.add(new ATNConfig({ state: endOfRuleState }, config), this.mergeCache);
  29302. }
  29303. }
  29304. }
  29305. return result;
  29306. };
  29307. ParserATNSimulator.prototype.computeStartState = function (p, ctx, fullCtx) {
  29308. // always at least the implicit call to start rule
  29309. var initialContext = predictionContextFromRuleContext(this.atn, ctx);
  29310. var configs = new ATNConfigSet(fullCtx);
  29311. for (var i = 0; i < p.transitions.length; i++) {
  29312. var target = p.transitions[i].target;
  29313. var c = new ATNConfig({ state: target, alt: i + 1, context: initialContext }, null);
  29314. var closureBusy = new Set();
  29315. this.closure(c, configs, closureBusy, true, fullCtx, false);
  29316. }
  29317. return configs;
  29318. };
  29319. //
  29320. // This method transforms the start state computed by
  29321. // {@link //computeStartState} to the special start state used by a
  29322. // precedence DFA for a particular precedence value. The transformation
  29323. // process applies the following changes to the start state's configuration
  29324. // set.
  29325. //
  29326. // <ol>
  29327. // <li>Evaluate the precedence predicates for each configuration using
  29328. // {@link SemanticContext//evalPrecedence}.</li>
  29329. // <li>Remove all configurations which predict an alternative greater than
  29330. // 1, for which another configuration that predicts alternative 1 is in the
  29331. // same ATN state with the same prediction context. This transformation is
  29332. // valid for the following reasons:
  29333. // <ul>
  29334. // <li>The closure block cannot contain any epsilon transitions which bypass
  29335. // the body of the closure, so all states reachable via alternative 1 are
  29336. // part of the precedence alternatives of the transformed left-recursive
  29337. // rule.</li>
  29338. // <li>The "primary" portion of a left recursive rule cannot contain an
  29339. // epsilon transition, so the only way an alternative other than 1 can exist
  29340. // in a state that is also reachable via alternative 1 is by nesting calls
  29341. // to the left-recursive rule, with the outer calls not being at the
  29342. // preferred precedence level.</li>
  29343. // </ul>
  29344. // </li>
  29345. // </ol>
  29346. //
  29347. // <p>
  29348. // The prediction context must be considered by this filter to address
  29349. // situations like the following.
  29350. // </p>
  29351. // <code>
  29352. // <pre>
  29353. // grammar TA;
  29354. // prog: statement* EOF;
  29355. // statement: letterA | statement letterA 'b' ;
  29356. // letterA: 'a';
  29357. // </pre>
  29358. // </code>
  29359. // <p>
  29360. // If the above grammar, the ATN state immediately before the token
  29361. // reference {@code 'a'} in {@code letterA} is reachable from the left edge
  29362. // of both the primary and closure blocks of the left-recursive rule
  29363. // {@code statement}. The prediction context associated with each of these
  29364. // configurations distinguishes between them, and prevents the alternative
  29365. // which stepped out to {@code prog} (and then back in to {@code statement}
  29366. // from being eliminated by the filter.
  29367. // </p>
  29368. //
  29369. // @param configs The configuration set computed by
  29370. // {@link //computeStartState} as the start state for the DFA.
  29371. // @return The transformed configuration set representing the start state
  29372. // for a precedence DFA at a particular precedence level (determined by
  29373. // calling {@link Parser//getPrecedence}).
  29374. //
  29375. ParserATNSimulator.prototype.applyPrecedenceFilter = function (configs) {
  29376. var config;
  29377. var statesFromAlt1 = [];
  29378. var configSet = new ATNConfigSet(configs.fullCtx);
  29379. for (var i = 0; i < configs.items.length; i++) {
  29380. config = configs.items[i];
  29381. // handle alt 1 first
  29382. if (config.alt !== 1) {
  29383. continue;
  29384. }
  29385. var updatedContext = config.semanticContext.evalPrecedence(this.parser, this._outerContext);
  29386. if (updatedContext === null) {
  29387. // the configuration was eliminated
  29388. continue;
  29389. }
  29390. statesFromAlt1[config.state.stateNumber] = config.context;
  29391. if (updatedContext !== config.semanticContext) {
  29392. configSet.add(new ATNConfig({ semanticContext: updatedContext }, config), this.mergeCache);
  29393. } else {
  29394. configSet.add(config, this.mergeCache);
  29395. }
  29396. }
  29397. for (i = 0; i < configs.items.length; i++) {
  29398. config = configs.items[i];
  29399. if (config.alt === 1) {
  29400. // already handled
  29401. continue;
  29402. }
  29403. // In the future, this elimination step could be updated to also
  29404. // filter the prediction context for alternatives predicting alt>1
  29405. // (basically a graph subtraction algorithm).
  29406. if (!config.precedenceFilterSuppressed) {
  29407. var context = statesFromAlt1[config.state.stateNumber] || null;
  29408. if (context !== null && context.equals(config.context)) {
  29409. // eliminated
  29410. continue;
  29411. }
  29412. }
  29413. configSet.add(config, this.mergeCache);
  29414. }
  29415. return configSet;
  29416. };
  29417. ParserATNSimulator.prototype.getReachableTarget = function (trans, ttype) {
  29418. if (trans.matches(ttype, 0, this.atn.maxTokenType)) {
  29419. return trans.target;
  29420. } else {
  29421. return null;
  29422. }
  29423. };
  29424. ParserATNSimulator.prototype.getPredsForAmbigAlts = function (ambigAlts, configs, nalts) {
  29425. // REACH=[1|1|[]|0:0, 1|2|[]|0:1]
  29426. // altToPred starts as an array of all null contexts. The entry at index i
  29427. // corresponds to alternative i. altToPred[i] may have one of three values:
  29428. // 1. null: no ATNConfig c is found such that c.alt==i
  29429. // 2. SemanticContext.NONE: At least one ATNConfig c exists such that
  29430. // c.alt==i and c.semanticContext==SemanticContext.NONE. In other words,
  29431. // alt i has at least one unpredicated config.
  29432. // 3. Non-NONE Semantic Context: There exists at least one, and for all
  29433. // ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE.
  29434. //
  29435. // From this, it is clear that NONE||anything==NONE.
  29436. //
  29437. var altToPred = [];
  29438. for (var i = 0; i < configs.items.length; i++) {
  29439. var c = configs.items[i];
  29440. if (ambigAlts.contains(c.alt)) {
  29441. altToPred[c.alt] = SemanticContext.orContext(altToPred[c.alt] || null, c.semanticContext);
  29442. }
  29443. }
  29444. var nPredAlts = 0;
  29445. for (i = 1; i < nalts + 1; i++) {
  29446. var pred = altToPred[i] || null;
  29447. if (pred === null) {
  29448. altToPred[i] = SemanticContext.NONE;
  29449. } else if (pred !== SemanticContext.NONE) {
  29450. nPredAlts += 1;
  29451. }
  29452. }
  29453. // nonambig alts are null in altToPred
  29454. if (nPredAlts === 0) {
  29455. altToPred = null;
  29456. }
  29457. if (this.debug) {
  29458. console.log("getPredsForAmbigAlts result " + Utils.arrayToString(altToPred));
  29459. }
  29460. return altToPred;
  29461. };
  29462. ParserATNSimulator.prototype.getPredicatePredictions = function (ambigAlts, altToPred) {
  29463. var pairs = [];
  29464. var containsPredicate = false;
  29465. for (var i = 1; i < altToPred.length; i++) {
  29466. var pred = altToPred[i];
  29467. // unpredicated is indicated by SemanticContext.NONE
  29468. if (ambigAlts !== null && ambigAlts.contains(i)) {
  29469. pairs.push(new PredPrediction(pred, i));
  29470. }
  29471. if (pred !== SemanticContext.NONE) {
  29472. containsPredicate = true;
  29473. }
  29474. }
  29475. if (!containsPredicate) {
  29476. return null;
  29477. }
  29478. return pairs;
  29479. };
  29480. //
  29481. // This method is used to improve the localization of error messages by
  29482. // choosing an alternative rather than throwing a
  29483. // {@link NoViableAltException} in particular prediction scenarios where the
  29484. // {@link //ERROR} state was reached during ATN simulation.
  29485. //
  29486. // <p>
  29487. // The default implementation of this method uses the following
  29488. // algorithm to identify an ATN configuration which successfully parsed the
  29489. // decision entry rule. Choosing such an alternative ensures that the
  29490. // {@link ParserRuleContext} returned by the calling rule will be complete
  29491. // and valid, and the syntax error will be reported later at a more
  29492. // localized location.</p>
  29493. //
  29494. // <ul>
  29495. // <li>If a syntactically valid path or paths reach the end of the decision rule and
  29496. // they are semantically valid if predicated, return the min associated alt.</li>
  29497. // <li>Else, if a semantically invalid but syntactically valid path exist
  29498. // or paths exist, return the minimum associated alt.
  29499. // </li>
  29500. // <li>Otherwise, return {@link ATN//INVALID_ALT_NUMBER}.</li>
  29501. // </ul>
  29502. //
  29503. // <p>
  29504. // In some scenarios, the algorithm described above could predict an
  29505. // alternative which will result in a {@link FailedPredicateException} in
  29506. // the parser. Specifically, this could occur if the <em>only</em> configuration
  29507. // capable of successfully parsing to the end of the decision rule is
  29508. // blocked by a semantic predicate. By choosing this alternative within
  29509. // {@link //adaptivePredict} instead of throwing a
  29510. // {@link NoViableAltException}, the resulting
  29511. // {@link FailedPredicateException} in the parser will identify the specific
  29512. // predicate which is preventing the parser from successfully parsing the
  29513. // decision rule, which helps developers identify and correct logic errors
  29514. // in semantic predicates.
  29515. // </p>
  29516. //
  29517. // @param configs The ATN configurations which were valid immediately before
  29518. // the {@link //ERROR} state was reached
  29519. // @param outerContext The is the \gamma_0 initial parser context from the paper
  29520. // or the parser stack at the instant before prediction commences.
  29521. //
  29522. // @return The value to return from {@link //adaptivePredict}, or
  29523. // {@link ATN//INVALID_ALT_NUMBER} if a suitable alternative was not
  29524. // identified and {@link //adaptivePredict} should report an error instead.
  29525. //
  29526. ParserATNSimulator.prototype.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule = function (configs, outerContext) {
  29527. var cfgs = this.splitAccordingToSemanticValidity(configs, outerContext);
  29528. var semValidConfigs = cfgs[0];
  29529. var semInvalidConfigs = cfgs[1];
  29530. var alt = this.getAltThatFinishedDecisionEntryRule(semValidConfigs);
  29531. if (alt !== ATN.INVALID_ALT_NUMBER) {
  29532. // semantically/syntactically viable path exists
  29533. return alt;
  29534. }
  29535. // Is there a syntactically valid path with a failed pred?
  29536. if (semInvalidConfigs.items.length > 0) {
  29537. alt = this.getAltThatFinishedDecisionEntryRule(semInvalidConfigs);
  29538. if (alt !== ATN.INVALID_ALT_NUMBER) {
  29539. // syntactically viable path exists
  29540. return alt;
  29541. }
  29542. }
  29543. return ATN.INVALID_ALT_NUMBER;
  29544. };
  29545. ParserATNSimulator.prototype.getAltThatFinishedDecisionEntryRule = function (configs) {
  29546. var alts = [];
  29547. for (var i = 0; i < configs.items.length; i++) {
  29548. var c = configs.items[i];
  29549. if (c.reachesIntoOuterContext > 0 || c.state instanceof RuleStopState && c.context.hasEmptyPath()) {
  29550. if (alts.indexOf(c.alt) < 0) {
  29551. alts.push(c.alt);
  29552. }
  29553. }
  29554. }
  29555. if (alts.length === 0) {
  29556. return ATN.INVALID_ALT_NUMBER;
  29557. } else {
  29558. return Math.min.apply(null, alts);
  29559. }
  29560. };
  29561. // Walk the list of configurations and split them according to
  29562. // those that have preds evaluating to true/false. If no pred, assume
  29563. // true pred and include in succeeded set. Returns Pair of sets.
  29564. //
  29565. // Create a new set so as not to alter the incoming parameter.
  29566. //
  29567. // Assumption: the input stream has been restored to the starting point
  29568. // prediction, which is where predicates need to evaluate.
  29569. //
  29570. ParserATNSimulator.prototype.splitAccordingToSemanticValidity = function (configs, outerContext) {
  29571. var succeeded = new ATNConfigSet(configs.fullCtx);
  29572. var failed = new ATNConfigSet(configs.fullCtx);
  29573. for (var i = 0; i < configs.items.length; i++) {
  29574. var c = configs.items[i];
  29575. if (c.semanticContext !== SemanticContext.NONE) {
  29576. var predicateEvaluationResult = c.semanticContext.evaluate(this.parser, outerContext);
  29577. if (predicateEvaluationResult) {
  29578. succeeded.add(c);
  29579. } else {
  29580. failed.add(c);
  29581. }
  29582. } else {
  29583. succeeded.add(c);
  29584. }
  29585. }
  29586. return [succeeded, failed];
  29587. };
  29588. // Look through a list of predicate/alt pairs, returning alts for the
  29589. // pairs that win. A {@code NONE} predicate indicates an alt containing an
  29590. // unpredicated config which behaves as "always true." If !complete
  29591. // then we stop at the first predicate that evaluates to true. This
  29592. // includes pairs with null predicates.
  29593. //
  29594. ParserATNSimulator.prototype.evalSemanticContext = function (predPredictions, outerContext, complete) {
  29595. var predictions = new BitSet();
  29596. for (var i = 0; i < predPredictions.length; i++) {
  29597. var pair = predPredictions[i];
  29598. if (pair.pred === SemanticContext.NONE) {
  29599. predictions.add(pair.alt);
  29600. if (!complete) {
  29601. break;
  29602. }
  29603. continue;
  29604. }
  29605. var predicateEvaluationResult = pair.pred.evaluate(this.parser, outerContext);
  29606. if (this.debug || this.dfa_debug) {
  29607. console.log("eval pred " + pair + "=" + predicateEvaluationResult);
  29608. }
  29609. if (predicateEvaluationResult) {
  29610. if (this.debug || this.dfa_debug) {
  29611. console.log("PREDICT " + pair.alt);
  29612. }
  29613. predictions.add(pair.alt);
  29614. if (!complete) {
  29615. break;
  29616. }
  29617. }
  29618. }
  29619. return predictions;
  29620. };
  29621. // TODO: If we are doing predicates, there is no point in pursuing
  29622. // closure operations if we reach a DFA state that uniquely predicts
  29623. // alternative. We will not be caching that DFA state and it is a
  29624. // waste to pursue the closure. Might have to advance when we do
  29625. // ambig detection thought :(
  29626. //
  29627. ParserATNSimulator.prototype.closure = function (config, configs, closureBusy, collectPredicates, fullCtx, treatEofAsEpsilon) {
  29628. var initialDepth = 0;
  29629. this.closureCheckingStopState(config, configs, closureBusy, collectPredicates, fullCtx, initialDepth, treatEofAsEpsilon);
  29630. };
  29631. ParserATNSimulator.prototype.closureCheckingStopState = function (config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEofAsEpsilon) {
  29632. if (this.debug || this.debug_closure) {
  29633. console.log("closure(" + config.toString(this.parser, true) + ")");
  29634. // console.log("configs(" + configs.toString() + ")");
  29635. if (config.reachesIntoOuterContext > 50) {
  29636. throw "problem";
  29637. }
  29638. }
  29639. if (config.state instanceof RuleStopState) {
  29640. // We hit rule end. If we have context info, use it
  29641. // run thru all possible stack tops in ctx
  29642. if (!config.context.isEmpty()) {
  29643. for (var i = 0; i < config.context.length; i++) {
  29644. if (config.context.getReturnState(i) === PredictionContext.EMPTY_RETURN_STATE) {
  29645. if (fullCtx) {
  29646. configs.add(new ATNConfig({ state: config.state, context: PredictionContext.EMPTY }, config), this.mergeCache);
  29647. continue;
  29648. } else {
  29649. // we have no context info, just chase follow links (if greedy)
  29650. if (this.debug) {
  29651. console.log("FALLING off rule " + this.getRuleName(config.state.ruleIndex));
  29652. }
  29653. this.closure_(config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEofAsEpsilon);
  29654. }
  29655. continue;
  29656. }
  29657. var returnState = this.atn.states[config.context.getReturnState(i)];
  29658. var newContext = config.context.getParent(i); // "pop" return state
  29659. var parms = { state: returnState, alt: config.alt, context: newContext, semanticContext: config.semanticContext };
  29660. var c = new ATNConfig(parms, null);
  29661. // While we have context to pop back from, we may have
  29662. // gotten that context AFTER having falling off a rule.
  29663. // Make sure we track that we are now out of context.
  29664. c.reachesIntoOuterContext = config.reachesIntoOuterContext;
  29665. this.closureCheckingStopState(c, configs, closureBusy, collectPredicates, fullCtx, depth - 1, treatEofAsEpsilon);
  29666. }
  29667. return;
  29668. } else if (fullCtx) {
  29669. // reached end of start rule
  29670. configs.add(config, this.mergeCache);
  29671. return;
  29672. } else {
  29673. // else if we have no context info, just chase follow links (if greedy)
  29674. if (this.debug) {
  29675. console.log("FALLING off rule " + this.getRuleName(config.state.ruleIndex));
  29676. }
  29677. }
  29678. }
  29679. this.closure_(config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEofAsEpsilon);
  29680. };
  29681. // Do the actual work of walking epsilon edges//
  29682. ParserATNSimulator.prototype.closure_ = function (config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEofAsEpsilon) {
  29683. var p = config.state;
  29684. // optimization
  29685. if (!p.epsilonOnlyTransitions) {
  29686. configs.add(config, this.mergeCache);
  29687. // make sure to not return here, because EOF transitions can act as
  29688. // both epsilon transitions and non-epsilon transitions.
  29689. }
  29690. for (var i = 0; i < p.transitions.length; i++) {
  29691. if (i == 0 && this.canDropLoopEntryEdgeInLeftRecursiveRule(config)) continue;
  29692. var t = p.transitions[i];
  29693. var continueCollecting = collectPredicates && !(t instanceof ActionTransition);
  29694. var c = this.getEpsilonTarget(config, t, continueCollecting, depth === 0, fullCtx, treatEofAsEpsilon);
  29695. if (c !== null) {
  29696. if (!t.isEpsilon && closureBusy.add(c) !== c) {
  29697. // avoid infinite recursion for EOF* and EOF+
  29698. continue;
  29699. }
  29700. var newDepth = depth;
  29701. if (config.state instanceof RuleStopState) {
  29702. // target fell off end of rule; mark resulting c as having dipped into outer context
  29703. // We can't get here if incoming config was rule stop and we had context
  29704. // track how far we dip into outer context. Might
  29705. // come in handy and we avoid evaluating context dependent
  29706. // preds if this is > 0.
  29707. if (closureBusy.add(c) !== c) {
  29708. // avoid infinite recursion for right-recursive rules
  29709. continue;
  29710. }
  29711. if (this._dfa !== null && this._dfa.precedenceDfa) {
  29712. if (t.outermostPrecedenceReturn === this._dfa.atnStartState.ruleIndex) {
  29713. c.precedenceFilterSuppressed = true;
  29714. }
  29715. }
  29716. c.reachesIntoOuterContext += 1;
  29717. configs.dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method
  29718. newDepth -= 1;
  29719. if (this.debug) {
  29720. console.log("dips into outer ctx: " + c);
  29721. }
  29722. } else if (t instanceof RuleTransition) {
  29723. // latch when newDepth goes negative - once we step out of the entry context we can't return
  29724. if (newDepth >= 0) {
  29725. newDepth += 1;
  29726. }
  29727. }
  29728. this.closureCheckingStopState(c, configs, closureBusy, continueCollecting, fullCtx, newDepth, treatEofAsEpsilon);
  29729. }
  29730. }
  29731. };
  29732. ParserATNSimulator.prototype.canDropLoopEntryEdgeInLeftRecursiveRule = function (config) {
  29733. // return False
  29734. var p = config.state;
  29735. // First check to see if we are in StarLoopEntryState generated during
  29736. // left-recursion elimination. For efficiency, also check if
  29737. // the context has an empty stack case. If so, it would mean
  29738. // global FOLLOW so we can't perform optimization
  29739. // Are we the special loop entry/exit state? or SLL wildcard
  29740. if (p.stateType != ATNState.STAR_LOOP_ENTRY) return false;
  29741. if (p.stateType != ATNState.STAR_LOOP_ENTRY || !p.isPrecedenceDecision || config.context.isEmpty() || config.context.hasEmptyPath()) return false;
  29742. // Require all return states to return back to the same rule that p is in.
  29743. var numCtxs = config.context.length;
  29744. for (var i = 0; i < numCtxs; i++) {
  29745. // for each stack context
  29746. var returnState = this.atn.states[config.context.getReturnState(i)];
  29747. if (returnState.ruleIndex != p.ruleIndex) return false;
  29748. }
  29749. var decisionStartState = p.transitions[0].target;
  29750. var blockEndStateNum = decisionStartState.endState.stateNumber;
  29751. var blockEndState = this.atn.states[blockEndStateNum];
  29752. // Verify that the top of each stack context leads to loop entry/exit
  29753. // state through epsilon edges and w/o leaving rule.
  29754. for (var i = 0; i < numCtxs; i++) {
  29755. // for each stack context
  29756. var returnStateNumber = config.context.getReturnState(i);
  29757. var returnState = this.atn.states[returnStateNumber];
  29758. // all states must have single outgoing epsilon edge
  29759. if (returnState.transitions.length != 1 || !returnState.transitions[0].isEpsilon) return false;
  29760. // Look for prefix op case like 'not expr', (' type ')' expr
  29761. var returnStateTarget = returnState.transitions[0].target;
  29762. if (returnState.stateType == ATNState.BLOCK_END && returnStateTarget == p) continue;
  29763. // Look for 'expr op expr' or case where expr's return state is block end
  29764. // of (...)* internal block; the block end points to loop back
  29765. // which points to p but we don't need to check that
  29766. if (returnState == blockEndState) continue;
  29767. // Look for ternary expr ? expr : expr. The return state points at block end,
  29768. // which points at loop entry state
  29769. if (returnStateTarget == blockEndState) continue;
  29770. // Look for complex prefix 'between expr and expr' case where 2nd expr's
  29771. // return state points at block end state of (...)* internal block
  29772. if (returnStateTarget.stateType == ATNState.BLOCK_END && returnStateTarget.transitions.length == 1 && returnStateTarget.transitions[0].isEpsilon && returnStateTarget.transitions[0].target == p) continue;
  29773. // anything else ain't conforming
  29774. return false;
  29775. }
  29776. return true;
  29777. };
  29778. ParserATNSimulator.prototype.getRuleName = function (index) {
  29779. if (this.parser !== null && index >= 0) {
  29780. return this.parser.ruleNames[index];
  29781. } else {
  29782. return "<rule " + index + ">";
  29783. }
  29784. };
  29785. ParserATNSimulator.prototype.getEpsilonTarget = function (config, t, collectPredicates, inContext, fullCtx, treatEofAsEpsilon) {
  29786. switch (t.serializationType) {
  29787. case Transition.RULE:
  29788. return this.ruleTransition(config, t);
  29789. case Transition.PRECEDENCE:
  29790. return this.precedenceTransition(config, t, collectPredicates, inContext, fullCtx);
  29791. case Transition.PREDICATE:
  29792. return this.predTransition(config, t, collectPredicates, inContext, fullCtx);
  29793. case Transition.ACTION:
  29794. return this.actionTransition(config, t);
  29795. case Transition.EPSILON:
  29796. return new ATNConfig({ state: t.target }, config);
  29797. case Transition.ATOM:
  29798. case Transition.RANGE:
  29799. case Transition.SET:
  29800. // EOF transitions act like epsilon transitions after the first EOF
  29801. // transition is traversed
  29802. if (treatEofAsEpsilon) {
  29803. if (t.matches(Token.EOF, 0, 1)) {
  29804. return new ATNConfig({ state: t.target }, config);
  29805. }
  29806. }
  29807. return null;
  29808. default:
  29809. return null;
  29810. }
  29811. };
  29812. ParserATNSimulator.prototype.actionTransition = function (config, t) {
  29813. if (this.debug) {
  29814. var index = t.actionIndex == -1 ? 65535 : t.actionIndex;
  29815. console.log("ACTION edge " + t.ruleIndex + ":" + index);
  29816. }
  29817. return new ATNConfig({ state: t.target }, config);
  29818. };
  29819. ParserATNSimulator.prototype.precedenceTransition = function (config, pt, collectPredicates, inContext, fullCtx) {
  29820. if (this.debug) {
  29821. console.log("PRED (collectPredicates=" + collectPredicates + ") " + pt.precedence + ">=_p, ctx dependent=true");
  29822. if (this.parser !== null) {
  29823. console.log("context surrounding pred is " + Utils.arrayToString(this.parser.getRuleInvocationStack()));
  29824. }
  29825. }
  29826. var c = null;
  29827. if (collectPredicates && inContext) {
  29828. if (fullCtx) {
  29829. // In full context mode, we can evaluate predicates on-the-fly
  29830. // during closure, which dramatically reduces the size of
  29831. // the config sets. It also obviates the need to test predicates
  29832. // later during conflict resolution.
  29833. var currentPosition = this._input.index;
  29834. this._input.seek(this._startIndex);
  29835. var predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext);
  29836. this._input.seek(currentPosition);
  29837. if (predSucceeds) {
  29838. c = new ATNConfig({ state: pt.target }, config); // no pred context
  29839. }
  29840. } else {
  29841. var newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate());
  29842. c = new ATNConfig({ state: pt.target, semanticContext: newSemCtx }, config);
  29843. }
  29844. } else {
  29845. c = new ATNConfig({ state: pt.target }, config);
  29846. }
  29847. if (this.debug) {
  29848. console.log("config from pred transition=" + c);
  29849. }
  29850. return c;
  29851. };
  29852. ParserATNSimulator.prototype.predTransition = function (config, pt, collectPredicates, inContext, fullCtx) {
  29853. if (this.debug) {
  29854. console.log("PRED (collectPredicates=" + collectPredicates + ") " + pt.ruleIndex + ":" + pt.predIndex + ", ctx dependent=" + pt.isCtxDependent);
  29855. if (this.parser !== null) {
  29856. console.log("context surrounding pred is " + Utils.arrayToString(this.parser.getRuleInvocationStack()));
  29857. }
  29858. }
  29859. var c = null;
  29860. if (collectPredicates && (pt.isCtxDependent && inContext || !pt.isCtxDependent)) {
  29861. if (fullCtx) {
  29862. // In full context mode, we can evaluate predicates on-the-fly
  29863. // during closure, which dramatically reduces the size of
  29864. // the config sets. It also obviates the need to test predicates
  29865. // later during conflict resolution.
  29866. var currentPosition = this._input.index;
  29867. this._input.seek(this._startIndex);
  29868. var predSucceeds = pt.getPredicate().evaluate(this.parser, this._outerContext);
  29869. this._input.seek(currentPosition);
  29870. if (predSucceeds) {
  29871. c = new ATNConfig({ state: pt.target }, config); // no pred context
  29872. }
  29873. } else {
  29874. var newSemCtx = SemanticContext.andContext(config.semanticContext, pt.getPredicate());
  29875. c = new ATNConfig({ state: pt.target, semanticContext: newSemCtx }, config);
  29876. }
  29877. } else {
  29878. c = new ATNConfig({ state: pt.target }, config);
  29879. }
  29880. if (this.debug) {
  29881. console.log("config from pred transition=" + c);
  29882. }
  29883. return c;
  29884. };
  29885. ParserATNSimulator.prototype.ruleTransition = function (config, t) {
  29886. if (this.debug) {
  29887. console.log("CALL rule " + this.getRuleName(t.target.ruleIndex) + ", ctx=" + config.context);
  29888. }
  29889. var returnState = t.followState;
  29890. var newContext = SingletonPredictionContext.create(config.context, returnState.stateNumber);
  29891. return new ATNConfig({ state: t.target, context: newContext }, config);
  29892. };
  29893. ParserATNSimulator.prototype.getConflictingAlts = function (configs) {
  29894. var altsets = PredictionMode.getConflictingAltSubsets(configs);
  29895. return PredictionMode.getAlts(altsets);
  29896. };
  29897. // Sam pointed out a problem with the previous definition, v3, of
  29898. // ambiguous states. If we have another state associated with conflicting
  29899. // alternatives, we should keep going. For example, the following grammar
  29900. //
  29901. // s : (ID | ID ID?) ';' ;
  29902. //
  29903. // When the ATN simulation reaches the state before ';', it has a DFA
  29904. // state that looks like: [12|1|[], 6|2|[], 12|2|[]]. Naturally
  29905. // 12|1|[] and 12|2|[] conflict, but we cannot stop processing this node
  29906. // because alternative to has another way to continue, via [6|2|[]].
  29907. // The key is that we have a single state that has config's only associated
  29908. // with a single alternative, 2, and crucially the state transitions
  29909. // among the configurations are all non-epsilon transitions. That means
  29910. // we don't consider any conflicts that include alternative 2. So, we
  29911. // ignore the conflict between alts 1 and 2. We ignore a set of
  29912. // conflicting alts when there is an intersection with an alternative
  29913. // associated with a single alt state in the state&rarr;config-list map.
  29914. //
  29915. // It's also the case that we might have two conflicting configurations but
  29916. // also a 3rd nonconflicting configuration for a different alternative:
  29917. // [1|1|[], 1|2|[], 8|3|[]]. This can come about from grammar:
  29918. //
  29919. // a : A | A | A B ;
  29920. //
  29921. // After matching input A, we reach the stop state for rule A, state 1.
  29922. // State 8 is the state right before B. Clearly alternatives 1 and 2
  29923. // conflict and no amount of further lookahead will separate the two.
  29924. // However, alternative 3 will be able to continue and so we do not
  29925. // stop working on this state. In the previous example, we're concerned
  29926. // with states associated with the conflicting alternatives. Here alt
  29927. // 3 is not associated with the conflicting configs, but since we can continue
  29928. // looking for input reasonably, I don't declare the state done. We
  29929. // ignore a set of conflicting alts when we have an alternative
  29930. // that we still need to pursue.
  29931. //
  29932. ParserATNSimulator.prototype.getConflictingAltsOrUniqueAlt = function (configs) {
  29933. var conflictingAlts = null;
  29934. if (configs.uniqueAlt !== ATN.INVALID_ALT_NUMBER) {
  29935. conflictingAlts = new BitSet();
  29936. conflictingAlts.add(configs.uniqueAlt);
  29937. } else {
  29938. conflictingAlts = configs.conflictingAlts;
  29939. }
  29940. return conflictingAlts;
  29941. };
  29942. ParserATNSimulator.prototype.getTokenName = function (t) {
  29943. if (t === Token.EOF) {
  29944. return "EOF";
  29945. }
  29946. if (this.parser !== null && this.parser.literalNames !== null) {
  29947. if (t >= this.parser.literalNames.length && t >= this.parser.symbolicNames.length) {
  29948. console.log("" + t + " ttype out of range: " + this.parser.literalNames);
  29949. console.log("" + this.parser.getInputStream().getTokens());
  29950. } else {
  29951. var name = this.parser.literalNames[t] || this.parser.symbolicNames[t];
  29952. return name + "<" + t + ">";
  29953. }
  29954. }
  29955. return "" + t;
  29956. };
  29957. ParserATNSimulator.prototype.getLookaheadName = function (input) {
  29958. return this.getTokenName(input.LA(1));
  29959. };
  29960. // Used for debugging in adaptivePredict around execATN but I cut
  29961. // it out for clarity now that alg. works well. We can leave this
  29962. // "dead" code for a bit.
  29963. //
  29964. ParserATNSimulator.prototype.dumpDeadEndConfigs = function (nvae) {
  29965. console.log("dead end configs: ");
  29966. var decs = nvae.getDeadEndConfigs();
  29967. for (var i = 0; i < decs.length; i++) {
  29968. var c = decs[i];
  29969. var trans = "no edges";
  29970. if (c.state.transitions.length > 0) {
  29971. var t = c.state.transitions[0];
  29972. if (t instanceof AtomTransition) {
  29973. trans = "Atom " + this.getTokenName(t.label);
  29974. } else if (t instanceof SetTransition) {
  29975. var neg = t instanceof NotSetTransition;
  29976. trans = (neg ? "~" : "") + "Set " + t.set;
  29977. }
  29978. }
  29979. console.error(c.toString(this.parser, true) + ":" + trans);
  29980. }
  29981. };
  29982. ParserATNSimulator.prototype.noViableAlt = function (input, outerContext, configs, startIndex) {
  29983. return new NoViableAltException(this.parser, input, input.get(startIndex), input.LT(1), configs, outerContext);
  29984. };
  29985. ParserATNSimulator.prototype.getUniqueAlt = function (configs) {
  29986. var alt = ATN.INVALID_ALT_NUMBER;
  29987. for (var i = 0; i < configs.items.length; i++) {
  29988. var c = configs.items[i];
  29989. if (alt === ATN.INVALID_ALT_NUMBER) {
  29990. alt = c.alt; // found first alt
  29991. } else if (c.alt !== alt) {
  29992. return ATN.INVALID_ALT_NUMBER;
  29993. }
  29994. }
  29995. return alt;
  29996. };
  29997. //
  29998. // Add an edge to the DFA, if possible. This method calls
  29999. // {@link //addDFAState} to ensure the {@code to} state is present in the
  30000. // DFA. If {@code from} is {@code null}, or if {@code t} is outside the
  30001. // range of edges that can be represented in the DFA tables, this method
  30002. // returns without adding the edge to the DFA.
  30003. //
  30004. // <p>If {@code to} is {@code null}, this method returns {@code null}.
  30005. // Otherwise, this method returns the {@link DFAState} returned by calling
  30006. // {@link //addDFAState} for the {@code to} state.</p>
  30007. //
  30008. // @param dfa The DFA
  30009. // @param from The source state for the edge
  30010. // @param t The input symbol
  30011. // @param to The target state for the edge
  30012. //
  30013. // @return If {@code to} is {@code null}, this method returns {@code null};
  30014. // otherwise this method returns the result of calling {@link //addDFAState}
  30015. // on {@code to}
  30016. //
  30017. ParserATNSimulator.prototype.addDFAEdge = function (dfa, from_, t, to) {
  30018. if (this.debug) {
  30019. console.log("EDGE " + from_ + " -> " + to + " upon " + this.getTokenName(t));
  30020. }
  30021. if (to === null) {
  30022. return null;
  30023. }
  30024. to = this.addDFAState(dfa, to); // used existing if possible not incoming
  30025. if (from_ === null || t < -1 || t > this.atn.maxTokenType) {
  30026. return to;
  30027. }
  30028. if (from_.edges === null) {
  30029. from_.edges = [];
  30030. }
  30031. from_.edges[t + 1] = to; // connect
  30032. if (this.debug) {
  30033. var literalNames = this.parser === null ? null : this.parser.literalNames;
  30034. var symbolicNames = this.parser === null ? null : this.parser.symbolicNames;
  30035. console.log("DFA=\n" + dfa.toString(literalNames, symbolicNames));
  30036. }
  30037. return to;
  30038. };
  30039. //
  30040. // Add state {@code D} to the DFA if it is not already present, and return
  30041. // the actual instance stored in the DFA. If a state equivalent to {@code D}
  30042. // is already in the DFA, the existing state is returned. Otherwise this
  30043. // method returns {@code D} after adding it to the DFA.
  30044. //
  30045. // <p>If {@code D} is {@link //ERROR}, this method returns {@link //ERROR} and
  30046. // does not change the DFA.</p>
  30047. //
  30048. // @param dfa The dfa
  30049. // @param D The DFA state to add
  30050. // @return The state stored in the DFA. This will be either the existing
  30051. // state if {@code D} is already in the DFA, or {@code D} itself if the
  30052. // state was not already present.
  30053. //
  30054. ParserATNSimulator.prototype.addDFAState = function (dfa, D) {
  30055. if (D == ATNSimulator.ERROR) {
  30056. return D;
  30057. }
  30058. var existing = dfa.states.get(D);
  30059. if (existing !== null) {
  30060. return existing;
  30061. }
  30062. D.stateNumber = dfa.states.length;
  30063. if (!D.configs.readOnly) {
  30064. D.configs.optimizeConfigs(this);
  30065. D.configs.setReadonly(true);
  30066. }
  30067. dfa.states.add(D);
  30068. if (this.debug) {
  30069. console.log("adding new DFA state: " + D);
  30070. }
  30071. return D;
  30072. };
  30073. ParserATNSimulator.prototype.reportAttemptingFullContext = function (dfa, conflictingAlts, configs, startIndex, stopIndex) {
  30074. if (this.debug || this.retry_debug) {
  30075. var interval = new Interval(startIndex, stopIndex + 1);
  30076. console.log("reportAttemptingFullContext decision=" + dfa.decision + ":" + configs + ", input=" + this.parser.getTokenStream().getText(interval));
  30077. }
  30078. if (this.parser !== null) {
  30079. this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
  30080. }
  30081. };
  30082. ParserATNSimulator.prototype.reportContextSensitivity = function (dfa, prediction, configs, startIndex, stopIndex) {
  30083. if (this.debug || this.retry_debug) {
  30084. var interval = new Interval(startIndex, stopIndex + 1);
  30085. console.log("reportContextSensitivity decision=" + dfa.decision + ":" + configs + ", input=" + this.parser.getTokenStream().getText(interval));
  30086. }
  30087. if (this.parser !== null) {
  30088. this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser, dfa, startIndex, stopIndex, prediction, configs);
  30089. }
  30090. };
  30091. // If context sensitive parsing, we know it's ambiguity not conflict//
  30092. ParserATNSimulator.prototype.reportAmbiguity = function (dfa, D, startIndex, stopIndex, exact, ambigAlts, configs) {
  30093. if (this.debug || this.retry_debug) {
  30094. var interval = new Interval(startIndex, stopIndex + 1);
  30095. console.log("reportAmbiguity " + ambigAlts + ":" + configs + ", input=" + this.parser.getTokenStream().getText(interval));
  30096. }
  30097. if (this.parser !== null) {
  30098. this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
  30099. }
  30100. };
  30101. exports.ParserATNSimulator = ParserATNSimulator;
  30102. /***/ }),
  30103. /***/ "./node_modules/antlr4/atn/PredictionMode.js":
  30104. /*!***************************************************!*\
  30105. !*** ./node_modules/antlr4/atn/PredictionMode.js ***!
  30106. \***************************************************/
  30107. /*! no static exports found */
  30108. /***/ (function(module, exports, __webpack_require__) {
  30109. "use strict";
  30110. //
  30111. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  30112. * Use of this file is governed by the BSD 3-clause license that
  30113. * can be found in the LICENSE.txt file in the project root.
  30114. */
  30115. //
  30116. //
  30117. // This enumeration defines the prediction modes available in ANTLR 4 along with
  30118. // utility methods for analyzing configuration sets for conflicts and/or
  30119. // ambiguities.
  30120. var Set = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").Set;
  30121. var Map = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").Map;
  30122. var BitSet = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").BitSet;
  30123. var AltDict = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").AltDict;
  30124. var ATN = __webpack_require__(/*! ./ATN */ "./node_modules/antlr4/atn/ATN.js").ATN;
  30125. var RuleStopState = __webpack_require__(/*! ./ATNState */ "./node_modules/antlr4/atn/ATNState.js").RuleStopState;
  30126. var ATNConfigSet = __webpack_require__(/*! ./ATNConfigSet */ "./node_modules/antlr4/atn/ATNConfigSet.js").ATNConfigSet;
  30127. var ATNConfig = __webpack_require__(/*! ./ATNConfig */ "./node_modules/antlr4/atn/ATNConfig.js").ATNConfig;
  30128. var SemanticContext = __webpack_require__(/*! ./SemanticContext */ "./node_modules/antlr4/atn/SemanticContext.js").SemanticContext;
  30129. var Hash = __webpack_require__(/*! ../Utils */ "./node_modules/antlr4/Utils.js").Hash;
  30130. var hashStuff = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").hashStuff;
  30131. var equalArrays = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").equalArrays;
  30132. function PredictionMode() {
  30133. return this;
  30134. }
  30135. //
  30136. // The SLL(*) prediction mode. This prediction mode ignores the current
  30137. // parser context when making predictions. This is the fastest prediction
  30138. // mode, and provides correct results for many grammars. This prediction
  30139. // mode is more powerful than the prediction mode provided by ANTLR 3, but
  30140. // may result in syntax errors for grammar and input combinations which are
  30141. // not SLL.
  30142. //
  30143. // <p>
  30144. // When using this prediction mode, the parser will either return a correct
  30145. // parse tree (i.e. the same parse tree that would be returned with the
  30146. // {@link //LL} prediction mode), or it will report a syntax error. If a
  30147. // syntax error is encountered when using the {@link //SLL} prediction mode,
  30148. // it may be due to either an actual syntax error in the input or indicate
  30149. // that the particular combination of grammar and input requires the more
  30150. // powerful {@link //LL} prediction abilities to complete successfully.</p>
  30151. //
  30152. // <p>
  30153. // This prediction mode does not provide any guarantees for prediction
  30154. // behavior for syntactically-incorrect inputs.</p>
  30155. //
  30156. PredictionMode.SLL = 0;
  30157. //
  30158. // The LL(*) prediction mode. This prediction mode allows the current parser
  30159. // context to be used for resolving SLL conflicts that occur during
  30160. // prediction. This is the fastest prediction mode that guarantees correct
  30161. // parse results for all combinations of grammars with syntactically correct
  30162. // inputs.
  30163. //
  30164. // <p>
  30165. // When using this prediction mode, the parser will make correct decisions
  30166. // for all syntactically-correct grammar and input combinations. However, in
  30167. // cases where the grammar is truly ambiguous this prediction mode might not
  30168. // report a precise answer for <em>exactly which</em> alternatives are
  30169. // ambiguous.</p>
  30170. //
  30171. // <p>
  30172. // This prediction mode does not provide any guarantees for prediction
  30173. // behavior for syntactically-incorrect inputs.</p>
  30174. //
  30175. PredictionMode.LL = 1;
  30176. //
  30177. // The LL(*) prediction mode with exact ambiguity detection. In addition to
  30178. // the correctness guarantees provided by the {@link //LL} prediction mode,
  30179. // this prediction mode instructs the prediction algorithm to determine the
  30180. // complete and exact set of ambiguous alternatives for every ambiguous
  30181. // decision encountered while parsing.
  30182. //
  30183. // <p>
  30184. // This prediction mode may be used for diagnosing ambiguities during
  30185. // grammar development. Due to the performance overhead of calculating sets
  30186. // of ambiguous alternatives, this prediction mode should be avoided when
  30187. // the exact results are not necessary.</p>
  30188. //
  30189. // <p>
  30190. // This prediction mode does not provide any guarantees for prediction
  30191. // behavior for syntactically-incorrect inputs.</p>
  30192. //
  30193. PredictionMode.LL_EXACT_AMBIG_DETECTION = 2;
  30194. //
  30195. // Computes the SLL prediction termination condition.
  30196. //
  30197. // <p>
  30198. // This method computes the SLL prediction termination condition for both of
  30199. // the following cases.</p>
  30200. //
  30201. // <ul>
  30202. // <li>The usual SLL+LL fallback upon SLL conflict</li>
  30203. // <li>Pure SLL without LL fallback</li>
  30204. // </ul>
  30205. //
  30206. // <p><strong>COMBINED SLL+LL PARSING</strong></p>
  30207. //
  30208. // <p>When LL-fallback is enabled upon SLL conflict, correct predictions are
  30209. // ensured regardless of how the termination condition is computed by this
  30210. // method. Due to the substantially higher cost of LL prediction, the
  30211. // prediction should only fall back to LL when the additional lookahead
  30212. // cannot lead to a unique SLL prediction.</p>
  30213. //
  30214. // <p>Assuming combined SLL+LL parsing, an SLL configuration set with only
  30215. // conflicting subsets should fall back to full LL, even if the
  30216. // configuration sets don't resolve to the same alternative (e.g.
  30217. // {@code {1,2}} and {@code {3,4}}. If there is at least one non-conflicting
  30218. // configuration, SLL could continue with the hopes that more lookahead will
  30219. // resolve via one of those non-conflicting configurations.</p>
  30220. //
  30221. // <p>Here's the prediction termination rule them: SLL (for SLL+LL parsing)
  30222. // stops when it sees only conflicting configuration subsets. In contrast,
  30223. // full LL keeps going when there is uncertainty.</p>
  30224. //
  30225. // <p><strong>HEURISTIC</strong></p>
  30226. //
  30227. // <p>As a heuristic, we stop prediction when we see any conflicting subset
  30228. // unless we see a state that only has one alternative associated with it.
  30229. // The single-alt-state thing lets prediction continue upon rules like
  30230. // (otherwise, it would admit defeat too soon):</p>
  30231. //
  30232. // <p>{@code [12|1|[], 6|2|[], 12|2|[]]. s : (ID | ID ID?) ';' ;}</p>
  30233. //
  30234. // <p>When the ATN simulation reaches the state before {@code ';'}, it has a
  30235. // DFA state that looks like: {@code [12|1|[], 6|2|[], 12|2|[]]}. Naturally
  30236. // {@code 12|1|[]} and {@code 12|2|[]} conflict, but we cannot stop
  30237. // processing this node because alternative to has another way to continue,
  30238. // via {@code [6|2|[]]}.</p>
  30239. //
  30240. // <p>It also let's us continue for this rule:</p>
  30241. //
  30242. // <p>{@code [1|1|[], 1|2|[], 8|3|[]] a : A | A | A B ;}</p>
  30243. //
  30244. // <p>After matching input A, we reach the stop state for rule A, state 1.
  30245. // State 8 is the state right before B. Clearly alternatives 1 and 2
  30246. // conflict and no amount of further lookahead will separate the two.
  30247. // However, alternative 3 will be able to continue and so we do not stop
  30248. // working on this state. In the previous example, we're concerned with
  30249. // states associated with the conflicting alternatives. Here alt 3 is not
  30250. // associated with the conflicting configs, but since we can continue
  30251. // looking for input reasonably, don't declare the state done.</p>
  30252. //
  30253. // <p><strong>PURE SLL PARSING</strong></p>
  30254. //
  30255. // <p>To handle pure SLL parsing, all we have to do is make sure that we
  30256. // combine stack contexts for configurations that differ only by semantic
  30257. // predicate. From there, we can do the usual SLL termination heuristic.</p>
  30258. //
  30259. // <p><strong>PREDICATES IN SLL+LL PARSING</strong></p>
  30260. //
  30261. // <p>SLL decisions don't evaluate predicates until after they reach DFA stop
  30262. // states because they need to create the DFA cache that works in all
  30263. // semantic situations. In contrast, full LL evaluates predicates collected
  30264. // during start state computation so it can ignore predicates thereafter.
  30265. // This means that SLL termination detection can totally ignore semantic
  30266. // predicates.</p>
  30267. //
  30268. // <p>Implementation-wise, {@link ATNConfigSet} combines stack contexts but not
  30269. // semantic predicate contexts so we might see two configurations like the
  30270. // following.</p>
  30271. //
  30272. // <p>{@code (s, 1, x, {}), (s, 1, x', {p})}</p>
  30273. //
  30274. // <p>Before testing these configurations against others, we have to merge
  30275. // {@code x} and {@code x'} (without modifying the existing configurations).
  30276. // For example, we test {@code (x+x')==x''} when looking for conflicts in
  30277. // the following configurations.</p>
  30278. //
  30279. // <p>{@code (s, 1, x, {}), (s, 1, x', {p}), (s, 2, x'', {})}</p>
  30280. //
  30281. // <p>If the configuration set has predicates (as indicated by
  30282. // {@link ATNConfigSet//hasSemanticContext}), this algorithm makes a copy of
  30283. // the configurations to strip out all of the predicates so that a standard
  30284. // {@link ATNConfigSet} will merge everything ignoring predicates.</p>
  30285. //
  30286. PredictionMode.hasSLLConflictTerminatingPrediction = function (mode, configs) {
  30287. // Configs in rule stop states indicate reaching the end of the decision
  30288. // rule (local context) or end of start rule (full context). If all
  30289. // configs meet this condition, then none of the configurations is able
  30290. // to match additional input so we terminate prediction.
  30291. //
  30292. if (PredictionMode.allConfigsInRuleStopStates(configs)) {
  30293. return true;
  30294. }
  30295. // pure SLL mode parsing
  30296. if (mode === PredictionMode.SLL) {
  30297. // Don't bother with combining configs from different semantic
  30298. // contexts if we can fail over to full LL; costs more time
  30299. // since we'll often fail over anyway.
  30300. if (configs.hasSemanticContext) {
  30301. // dup configs, tossing out semantic predicates
  30302. var dup = new ATNConfigSet();
  30303. for (var i = 0; i < configs.items.length; i++) {
  30304. var c = configs.items[i];
  30305. c = new ATNConfig({ semanticContext: SemanticContext.NONE }, c);
  30306. dup.add(c);
  30307. }
  30308. configs = dup;
  30309. }
  30310. // now we have combined contexts for configs with dissimilar preds
  30311. }
  30312. // pure SLL or combined SLL+LL mode parsing
  30313. var altsets = PredictionMode.getConflictingAltSubsets(configs);
  30314. return PredictionMode.hasConflictingAltSet(altsets) && !PredictionMode.hasStateAssociatedWithOneAlt(configs);
  30315. };
  30316. // Checks if any configuration in {@code configs} is in a
  30317. // {@link RuleStopState}. Configurations meeting this condition have reached
  30318. // the end of the decision rule (local context) or end of start rule (full
  30319. // context).
  30320. //
  30321. // @param configs the configuration set to test
  30322. // @return {@code true} if any configuration in {@code configs} is in a
  30323. // {@link RuleStopState}, otherwise {@code false}
  30324. PredictionMode.hasConfigInRuleStopState = function (configs) {
  30325. for (var i = 0; i < configs.items.length; i++) {
  30326. var c = configs.items[i];
  30327. if (c.state instanceof RuleStopState) {
  30328. return true;
  30329. }
  30330. }
  30331. return false;
  30332. };
  30333. // Checks if all configurations in {@code configs} are in a
  30334. // {@link RuleStopState}. Configurations meeting this condition have reached
  30335. // the end of the decision rule (local context) or end of start rule (full
  30336. // context).
  30337. //
  30338. // @param configs the configuration set to test
  30339. // @return {@code true} if all configurations in {@code configs} are in a
  30340. // {@link RuleStopState}, otherwise {@code false}
  30341. PredictionMode.allConfigsInRuleStopStates = function (configs) {
  30342. for (var i = 0; i < configs.items.length; i++) {
  30343. var c = configs.items[i];
  30344. if (!(c.state instanceof RuleStopState)) {
  30345. return false;
  30346. }
  30347. }
  30348. return true;
  30349. };
  30350. //
  30351. // Full LL prediction termination.
  30352. //
  30353. // <p>Can we stop looking ahead during ATN simulation or is there some
  30354. // uncertainty as to which alternative we will ultimately pick, after
  30355. // consuming more input? Even if there are partial conflicts, we might know
  30356. // that everything is going to resolve to the same minimum alternative. That
  30357. // means we can stop since no more lookahead will change that fact. On the
  30358. // other hand, there might be multiple conflicts that resolve to different
  30359. // minimums. That means we need more look ahead to decide which of those
  30360. // alternatives we should predict.</p>
  30361. //
  30362. // <p>The basic idea is to split the set of configurations {@code C}, into
  30363. // conflicting subsets {@code (s, _, ctx, _)} and singleton subsets with
  30364. // non-conflicting configurations. Two configurations conflict if they have
  30365. // identical {@link ATNConfig//state} and {@link ATNConfig//context} values
  30366. // but different {@link ATNConfig//alt} value, e.g. {@code (s, i, ctx, _)}
  30367. // and {@code (s, j, ctx, _)} for {@code i!=j}.</p>
  30368. //
  30369. // <p>Reduce these configuration subsets to the set of possible alternatives.
  30370. // You can compute the alternative subsets in one pass as follows:</p>
  30371. //
  30372. // <p>{@code A_s,ctx = {i | (s, i, ctx, _)}} for each configuration in
  30373. // {@code C} holding {@code s} and {@code ctx} fixed.</p>
  30374. //
  30375. // <p>Or in pseudo-code, for each configuration {@code c} in {@code C}:</p>
  30376. //
  30377. // <pre>
  30378. // map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not
  30379. // alt and not pred
  30380. // </pre>
  30381. //
  30382. // <p>The values in {@code map} are the set of {@code A_s,ctx} sets.</p>
  30383. //
  30384. // <p>If {@code |A_s,ctx|=1} then there is no conflict associated with
  30385. // {@code s} and {@code ctx}.</p>
  30386. //
  30387. // <p>Reduce the subsets to singletons by choosing a minimum of each subset. If
  30388. // the union of these alternative subsets is a singleton, then no amount of
  30389. // more lookahead will help us. We will always pick that alternative. If,
  30390. // however, there is more than one alternative, then we are uncertain which
  30391. // alternative to predict and must continue looking for resolution. We may
  30392. // or may not discover an ambiguity in the future, even if there are no
  30393. // conflicting subsets this round.</p>
  30394. //
  30395. // <p>The biggest sin is to terminate early because it means we've made a
  30396. // decision but were uncertain as to the eventual outcome. We haven't used
  30397. // enough lookahead. On the other hand, announcing a conflict too late is no
  30398. // big deal; you will still have the conflict. It's just inefficient. It
  30399. // might even look until the end of file.</p>
  30400. //
  30401. // <p>No special consideration for semantic predicates is required because
  30402. // predicates are evaluated on-the-fly for full LL prediction, ensuring that
  30403. // no configuration contains a semantic context during the termination
  30404. // check.</p>
  30405. //
  30406. // <p><strong>CONFLICTING CONFIGS</strong></p>
  30407. //
  30408. // <p>Two configurations {@code (s, i, x)} and {@code (s, j, x')}, conflict
  30409. // when {@code i!=j} but {@code x=x'}. Because we merge all
  30410. // {@code (s, i, _)} configurations together, that means that there are at
  30411. // most {@code n} configurations associated with state {@code s} for
  30412. // {@code n} possible alternatives in the decision. The merged stacks
  30413. // complicate the comparison of configuration contexts {@code x} and
  30414. // {@code x'}. Sam checks to see if one is a subset of the other by calling
  30415. // merge and checking to see if the merged result is either {@code x} or
  30416. // {@code x'}. If the {@code x} associated with lowest alternative {@code i}
  30417. // is the superset, then {@code i} is the only possible prediction since the
  30418. // others resolve to {@code min(i)} as well. However, if {@code x} is
  30419. // associated with {@code j>i} then at least one stack configuration for
  30420. // {@code j} is not in conflict with alternative {@code i}. The algorithm
  30421. // should keep going, looking for more lookahead due to the uncertainty.</p>
  30422. //
  30423. // <p>For simplicity, I'm doing a equality check between {@code x} and
  30424. // {@code x'} that lets the algorithm continue to consume lookahead longer
  30425. // than necessary. The reason I like the equality is of course the
  30426. // simplicity but also because that is the test you need to detect the
  30427. // alternatives that are actually in conflict.</p>
  30428. //
  30429. // <p><strong>CONTINUE/STOP RULE</strong></p>
  30430. //
  30431. // <p>Continue if union of resolved alternative sets from non-conflicting and
  30432. // conflicting alternative subsets has more than one alternative. We are
  30433. // uncertain about which alternative to predict.</p>
  30434. //
  30435. // <p>The complete set of alternatives, {@code [i for (_,i,_)]}, tells us which
  30436. // alternatives are still in the running for the amount of input we've
  30437. // consumed at this point. The conflicting sets let us to strip away
  30438. // configurations that won't lead to more states because we resolve
  30439. // conflicts to the configuration with a minimum alternate for the
  30440. // conflicting set.</p>
  30441. //
  30442. // <p><strong>CASES</strong></p>
  30443. //
  30444. // <ul>
  30445. //
  30446. // <li>no conflicts and more than 1 alternative in set =&gt; continue</li>
  30447. //
  30448. // <li> {@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s, 3, z)},
  30449. // {@code (s', 1, y)}, {@code (s', 2, y)} yields non-conflicting set
  30450. // {@code {3}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} =
  30451. // {@code {1,3}} =&gt; continue
  30452. // </li>
  30453. //
  30454. // <li>{@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)},
  30455. // {@code (s', 2, y)}, {@code (s'', 1, z)} yields non-conflicting set
  30456. // {@code {1}} U conflicting sets {@code min({1,2})} U {@code min({1,2})} =
  30457. // {@code {1}} =&gt; stop and predict 1</li>
  30458. //
  30459. // <li>{@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 1, y)},
  30460. // {@code (s', 2, y)} yields conflicting, reduced sets {@code {1}} U
  30461. // {@code {1}} = {@code {1}} =&gt; stop and predict 1, can announce
  30462. // ambiguity {@code {1,2}}</li>
  30463. //
  30464. // <li>{@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 2, y)},
  30465. // {@code (s', 3, y)} yields conflicting, reduced sets {@code {1}} U
  30466. // {@code {2}} = {@code {1,2}} =&gt; continue</li>
  30467. //
  30468. // <li>{@code (s, 1, x)}, {@code (s, 2, x)}, {@code (s', 3, y)},
  30469. // {@code (s', 4, y)} yields conflicting, reduced sets {@code {1}} U
  30470. // {@code {3}} = {@code {1,3}} =&gt; continue</li>
  30471. //
  30472. // </ul>
  30473. //
  30474. // <p><strong>EXACT AMBIGUITY DETECTION</strong></p>
  30475. //
  30476. // <p>If all states report the same conflicting set of alternatives, then we
  30477. // know we have the exact ambiguity set.</p>
  30478. //
  30479. // <p><code>|A_<em>i</em>|&gt;1</code> and
  30480. // <code>A_<em>i</em> = A_<em>j</em></code> for all <em>i</em>, <em>j</em>.</p>
  30481. //
  30482. // <p>In other words, we continue examining lookahead until all {@code A_i}
  30483. // have more than one alternative and all {@code A_i} are the same. If
  30484. // {@code A={{1,2}, {1,3}}}, then regular LL prediction would terminate
  30485. // because the resolved set is {@code {1}}. To determine what the real
  30486. // ambiguity is, we have to know whether the ambiguity is between one and
  30487. // two or one and three so we keep going. We can only stop prediction when
  30488. // we need exact ambiguity detection when the sets look like
  30489. // {@code A={{1,2}}} or {@code {{1,2},{1,2}}}, etc...</p>
  30490. //
  30491. PredictionMode.resolvesToJustOneViableAlt = function (altsets) {
  30492. return PredictionMode.getSingleViableAlt(altsets);
  30493. };
  30494. //
  30495. // Determines if every alternative subset in {@code altsets} contains more
  30496. // than one alternative.
  30497. //
  30498. // @param altsets a collection of alternative subsets
  30499. // @return {@code true} if every {@link BitSet} in {@code altsets} has
  30500. // {@link BitSet//cardinality cardinality} &gt; 1, otherwise {@code false}
  30501. //
  30502. PredictionMode.allSubsetsConflict = function (altsets) {
  30503. return !PredictionMode.hasNonConflictingAltSet(altsets);
  30504. };
  30505. //
  30506. // Determines if any single alternative subset in {@code altsets} contains
  30507. // exactly one alternative.
  30508. //
  30509. // @param altsets a collection of alternative subsets
  30510. // @return {@code true} if {@code altsets} contains a {@link BitSet} with
  30511. // {@link BitSet//cardinality cardinality} 1, otherwise {@code false}
  30512. //
  30513. PredictionMode.hasNonConflictingAltSet = function (altsets) {
  30514. for (var i = 0; i < altsets.length; i++) {
  30515. var alts = altsets[i];
  30516. if (alts.length === 1) {
  30517. return true;
  30518. }
  30519. }
  30520. return false;
  30521. };
  30522. //
  30523. // Determines if any single alternative subset in {@code altsets} contains
  30524. // more than one alternative.
  30525. //
  30526. // @param altsets a collection of alternative subsets
  30527. // @return {@code true} if {@code altsets} contains a {@link BitSet} with
  30528. // {@link BitSet//cardinality cardinality} &gt; 1, otherwise {@code false}
  30529. //
  30530. PredictionMode.hasConflictingAltSet = function (altsets) {
  30531. for (var i = 0; i < altsets.length; i++) {
  30532. var alts = altsets[i];
  30533. if (alts.length > 1) {
  30534. return true;
  30535. }
  30536. }
  30537. return false;
  30538. };
  30539. //
  30540. // Determines if every alternative subset in {@code altsets} is equivalent.
  30541. //
  30542. // @param altsets a collection of alternative subsets
  30543. // @return {@code true} if every member of {@code altsets} is equal to the
  30544. // others, otherwise {@code false}
  30545. //
  30546. PredictionMode.allSubsetsEqual = function (altsets) {
  30547. var first = null;
  30548. for (var i = 0; i < altsets.length; i++) {
  30549. var alts = altsets[i];
  30550. if (first === null) {
  30551. first = alts;
  30552. } else if (alts !== first) {
  30553. return false;
  30554. }
  30555. }
  30556. return true;
  30557. };
  30558. //
  30559. // Returns the unique alternative predicted by all alternative subsets in
  30560. // {@code altsets}. If no such alternative exists, this method returns
  30561. // {@link ATN//INVALID_ALT_NUMBER}.
  30562. //
  30563. // @param altsets a collection of alternative subsets
  30564. //
  30565. PredictionMode.getUniqueAlt = function (altsets) {
  30566. var all = PredictionMode.getAlts(altsets);
  30567. if (all.length === 1) {
  30568. return all.minValue();
  30569. } else {
  30570. return ATN.INVALID_ALT_NUMBER;
  30571. }
  30572. };
  30573. // Gets the complete set of represented alternatives for a collection of
  30574. // alternative subsets. This method returns the union of each {@link BitSet}
  30575. // in {@code altsets}.
  30576. //
  30577. // @param altsets a collection of alternative subsets
  30578. // @return the set of represented alternatives in {@code altsets}
  30579. //
  30580. PredictionMode.getAlts = function (altsets) {
  30581. var all = new BitSet();
  30582. altsets.map(function (alts) {
  30583. all.or(alts);
  30584. });
  30585. return all;
  30586. };
  30587. //
  30588. // This function gets the conflicting alt subsets from a configuration set.
  30589. // For each configuration {@code c} in {@code configs}:
  30590. //
  30591. // <pre>
  30592. // map[c] U= c.{@link ATNConfig//alt alt} // map hash/equals uses s and x, not
  30593. // alt and not pred
  30594. // </pre>
  30595. PredictionMode.getConflictingAltSubsets = function (configs) {
  30596. var configToAlts = new Map();
  30597. configToAlts.hashFunction = function (cfg) {
  30598. hashStuff(cfg.state.stateNumber, cfg.context);
  30599. };
  30600. configToAlts.equalsFunction = function (c1, c2) {
  30601. return c1.state.stateNumber == c2.state.stateNumber && c1.context.equals(c2.context);
  30602. };
  30603. configs.items.map(function (cfg) {
  30604. var alts = configToAlts.get(cfg);
  30605. if (alts === null) {
  30606. alts = new BitSet();
  30607. configToAlts.put(cfg, alts);
  30608. }
  30609. alts.add(cfg.alt);
  30610. });
  30611. return configToAlts.getValues();
  30612. };
  30613. //
  30614. // Get a map from state to alt subset from a configuration set. For each
  30615. // configuration {@code c} in {@code configs}:
  30616. //
  30617. // <pre>
  30618. // map[c.{@link ATNConfig//state state}] U= c.{@link ATNConfig//alt alt}
  30619. // </pre>
  30620. //
  30621. PredictionMode.getStateToAltMap = function (configs) {
  30622. var m = new AltDict();
  30623. configs.items.map(function (c) {
  30624. var alts = m.get(c.state);
  30625. if (alts === null) {
  30626. alts = new BitSet();
  30627. m.put(c.state, alts);
  30628. }
  30629. alts.add(c.alt);
  30630. });
  30631. return m;
  30632. };
  30633. PredictionMode.hasStateAssociatedWithOneAlt = function (configs) {
  30634. var values = PredictionMode.getStateToAltMap(configs).values();
  30635. for (var i = 0; i < values.length; i++) {
  30636. if (values[i].length === 1) {
  30637. return true;
  30638. }
  30639. }
  30640. return false;
  30641. };
  30642. PredictionMode.getSingleViableAlt = function (altsets) {
  30643. var result = null;
  30644. for (var i = 0; i < altsets.length; i++) {
  30645. var alts = altsets[i];
  30646. var minAlt = alts.minValue();
  30647. if (result === null) {
  30648. result = minAlt;
  30649. } else if (result !== minAlt) {
  30650. // more than 1 viable alt
  30651. return ATN.INVALID_ALT_NUMBER;
  30652. }
  30653. }
  30654. return result;
  30655. };
  30656. exports.PredictionMode = PredictionMode;
  30657. /***/ }),
  30658. /***/ "./node_modules/antlr4/atn/SemanticContext.js":
  30659. /*!****************************************************!*\
  30660. !*** ./node_modules/antlr4/atn/SemanticContext.js ***!
  30661. \****************************************************/
  30662. /*! no static exports found */
  30663. /***/ (function(module, exports, __webpack_require__) {
  30664. "use strict";
  30665. //
  30666. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  30667. * Use of this file is governed by the BSD 3-clause license that
  30668. * can be found in the LICENSE.txt file in the project root.
  30669. */
  30670. //
  30671. // A tree structure used to record the semantic context in which
  30672. // an ATN configuration is valid. It's either a single predicate,
  30673. // a conjunction {@code p1&&p2}, or a sum of products {@code p1||p2}.
  30674. //
  30675. // <p>I have scoped the {@link AND}, {@link OR}, and {@link Predicate} subclasses of
  30676. // {@link SemanticContext} within the scope of this outer class.</p>
  30677. //
  30678. var Set = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").Set;
  30679. var Hash = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").Hash;
  30680. function SemanticContext() {
  30681. return this;
  30682. }
  30683. SemanticContext.prototype.hashCode = function () {
  30684. var hash = new Hash();
  30685. this.updateHashCode(hash);
  30686. return hash.finish();
  30687. };
  30688. // For context independent predicates, we evaluate them without a local
  30689. // context (i.e., null context). That way, we can evaluate them without
  30690. // having to create proper rule-specific context during prediction (as
  30691. // opposed to the parser, which creates them naturally). In a practical
  30692. // sense, this avoids a cast exception from RuleContext to myruleContext.
  30693. //
  30694. // <p>For context dependent predicates, we must pass in a local context so that
  30695. // references such as $arg evaluate properly as _localctx.arg. We only
  30696. // capture context dependent predicates in the context in which we begin
  30697. // prediction, so we passed in the outer context here in case of context
  30698. // dependent predicate evaluation.</p>
  30699. //
  30700. SemanticContext.prototype.evaluate = function (parser, outerContext) {};
  30701. //
  30702. // Evaluate the precedence predicates for the context and reduce the result.
  30703. //
  30704. // @param parser The parser instance.
  30705. // @param outerContext The current parser context object.
  30706. // @return The simplified semantic context after precedence predicates are
  30707. // evaluated, which will be one of the following values.
  30708. // <ul>
  30709. // <li>{@link //NONE}: if the predicate simplifies to {@code true} after
  30710. // precedence predicates are evaluated.</li>
  30711. // <li>{@code null}: if the predicate simplifies to {@code false} after
  30712. // precedence predicates are evaluated.</li>
  30713. // <li>{@code this}: if the semantic context is not changed as a result of
  30714. // precedence predicate evaluation.</li>
  30715. // <li>A non-{@code null} {@link SemanticContext}: the new simplified
  30716. // semantic context after precedence predicates are evaluated.</li>
  30717. // </ul>
  30718. //
  30719. SemanticContext.prototype.evalPrecedence = function (parser, outerContext) {
  30720. return this;
  30721. };
  30722. SemanticContext.andContext = function (a, b) {
  30723. if (a === null || a === SemanticContext.NONE) {
  30724. return b;
  30725. }
  30726. if (b === null || b === SemanticContext.NONE) {
  30727. return a;
  30728. }
  30729. var result = new AND(a, b);
  30730. if (result.opnds.length === 1) {
  30731. return result.opnds[0];
  30732. } else {
  30733. return result;
  30734. }
  30735. };
  30736. SemanticContext.orContext = function (a, b) {
  30737. if (a === null) {
  30738. return b;
  30739. }
  30740. if (b === null) {
  30741. return a;
  30742. }
  30743. if (a === SemanticContext.NONE || b === SemanticContext.NONE) {
  30744. return SemanticContext.NONE;
  30745. }
  30746. var result = new OR(a, b);
  30747. if (result.opnds.length === 1) {
  30748. return result.opnds[0];
  30749. } else {
  30750. return result;
  30751. }
  30752. };
  30753. function Predicate(ruleIndex, predIndex, isCtxDependent) {
  30754. SemanticContext.call(this);
  30755. this.ruleIndex = ruleIndex === undefined ? -1 : ruleIndex;
  30756. this.predIndex = predIndex === undefined ? -1 : predIndex;
  30757. this.isCtxDependent = isCtxDependent === undefined ? false : isCtxDependent; // e.g., $i ref in pred
  30758. return this;
  30759. }
  30760. Predicate.prototype = Object.create(SemanticContext.prototype);
  30761. Predicate.prototype.constructor = Predicate;
  30762. //The default {@link SemanticContext}, which is semantically equivalent to
  30763. //a predicate of the form {@code {true}?}.
  30764. //
  30765. SemanticContext.NONE = new Predicate();
  30766. Predicate.prototype.evaluate = function (parser, outerContext) {
  30767. var localctx = this.isCtxDependent ? outerContext : null;
  30768. return parser.sempred(localctx, this.ruleIndex, this.predIndex);
  30769. };
  30770. Predicate.prototype.updateHashCode = function (hash) {
  30771. hash.update(this.ruleIndex, this.predIndex, this.isCtxDependent);
  30772. };
  30773. Predicate.prototype.equals = function (other) {
  30774. if (this === other) {
  30775. return true;
  30776. } else if (!(other instanceof Predicate)) {
  30777. return false;
  30778. } else {
  30779. return this.ruleIndex === other.ruleIndex && this.predIndex === other.predIndex && this.isCtxDependent === other.isCtxDependent;
  30780. }
  30781. };
  30782. Predicate.prototype.toString = function () {
  30783. return "{" + this.ruleIndex + ":" + this.predIndex + "}?";
  30784. };
  30785. function PrecedencePredicate(precedence) {
  30786. SemanticContext.call(this);
  30787. this.precedence = precedence === undefined ? 0 : precedence;
  30788. }
  30789. PrecedencePredicate.prototype = Object.create(SemanticContext.prototype);
  30790. PrecedencePredicate.prototype.constructor = PrecedencePredicate;
  30791. PrecedencePredicate.prototype.evaluate = function (parser, outerContext) {
  30792. return parser.precpred(outerContext, this.precedence);
  30793. };
  30794. PrecedencePredicate.prototype.evalPrecedence = function (parser, outerContext) {
  30795. if (parser.precpred(outerContext, this.precedence)) {
  30796. return SemanticContext.NONE;
  30797. } else {
  30798. return null;
  30799. }
  30800. };
  30801. PrecedencePredicate.prototype.compareTo = function (other) {
  30802. return this.precedence - other.precedence;
  30803. };
  30804. PrecedencePredicate.prototype.updateHashCode = function (hash) {
  30805. hash.update(31);
  30806. };
  30807. PrecedencePredicate.prototype.equals = function (other) {
  30808. if (this === other) {
  30809. return true;
  30810. } else if (!(other instanceof PrecedencePredicate)) {
  30811. return false;
  30812. } else {
  30813. return this.precedence === other.precedence;
  30814. }
  30815. };
  30816. PrecedencePredicate.prototype.toString = function () {
  30817. return "{" + this.precedence + ">=prec}?";
  30818. };
  30819. PrecedencePredicate.filterPrecedencePredicates = function (set) {
  30820. var result = [];
  30821. set.values().map(function (context) {
  30822. if (context instanceof PrecedencePredicate) {
  30823. result.push(context);
  30824. }
  30825. });
  30826. return result;
  30827. };
  30828. // A semantic context which is true whenever none of the contained contexts
  30829. // is false.
  30830. //
  30831. function AND(a, b) {
  30832. SemanticContext.call(this);
  30833. var operands = new Set();
  30834. if (a instanceof AND) {
  30835. a.opnds.map(function (o) {
  30836. operands.add(o);
  30837. });
  30838. } else {
  30839. operands.add(a);
  30840. }
  30841. if (b instanceof AND) {
  30842. b.opnds.map(function (o) {
  30843. operands.add(o);
  30844. });
  30845. } else {
  30846. operands.add(b);
  30847. }
  30848. var precedencePredicates = PrecedencePredicate.filterPrecedencePredicates(operands);
  30849. if (precedencePredicates.length > 0) {
  30850. // interested in the transition with the lowest precedence
  30851. var reduced = null;
  30852. precedencePredicates.map(function (p) {
  30853. if (reduced === null || p.precedence < reduced.precedence) {
  30854. reduced = p;
  30855. }
  30856. });
  30857. operands.add(reduced);
  30858. }
  30859. this.opnds = operands.values();
  30860. return this;
  30861. }
  30862. AND.prototype = Object.create(SemanticContext.prototype);
  30863. AND.prototype.constructor = AND;
  30864. AND.prototype.equals = function (other) {
  30865. if (this === other) {
  30866. return true;
  30867. } else if (!(other instanceof AND)) {
  30868. return false;
  30869. } else {
  30870. return this.opnds === other.opnds;
  30871. }
  30872. };
  30873. AND.prototype.updateHashCode = function (hash) {
  30874. hash.update(this.opnds, "AND");
  30875. };
  30876. //
  30877. // {@inheritDoc}
  30878. //
  30879. // <p>
  30880. // The evaluation of predicates by this context is short-circuiting, but
  30881. // unordered.</p>
  30882. //
  30883. AND.prototype.evaluate = function (parser, outerContext) {
  30884. for (var i = 0; i < this.opnds.length; i++) {
  30885. if (!this.opnds[i].evaluate(parser, outerContext)) {
  30886. return false;
  30887. }
  30888. }
  30889. return true;
  30890. };
  30891. AND.prototype.evalPrecedence = function (parser, outerContext) {
  30892. var differs = false;
  30893. var operands = [];
  30894. for (var i = 0; i < this.opnds.length; i++) {
  30895. var context = this.opnds[i];
  30896. var evaluated = context.evalPrecedence(parser, outerContext);
  30897. differs |= evaluated !== context;
  30898. if (evaluated === null) {
  30899. // The AND context is false if any element is false
  30900. return null;
  30901. } else if (evaluated !== SemanticContext.NONE) {
  30902. // Reduce the result by skipping true elements
  30903. operands.push(evaluated);
  30904. }
  30905. }
  30906. if (!differs) {
  30907. return this;
  30908. }
  30909. if (operands.length === 0) {
  30910. // all elements were true, so the AND context is true
  30911. return SemanticContext.NONE;
  30912. }
  30913. var result = null;
  30914. operands.map(function (o) {
  30915. result = result === null ? o : SemanticContext.andContext(result, o);
  30916. });
  30917. return result;
  30918. };
  30919. AND.prototype.toString = function () {
  30920. var s = "";
  30921. this.opnds.map(function (o) {
  30922. s += "&& " + o.toString();
  30923. });
  30924. return s.length > 3 ? s.slice(3) : s;
  30925. };
  30926. //
  30927. // A semantic context which is true whenever at least one of the contained
  30928. // contexts is true.
  30929. //
  30930. function OR(a, b) {
  30931. SemanticContext.call(this);
  30932. var operands = new Set();
  30933. if (a instanceof OR) {
  30934. a.opnds.map(function (o) {
  30935. operands.add(o);
  30936. });
  30937. } else {
  30938. operands.add(a);
  30939. }
  30940. if (b instanceof OR) {
  30941. b.opnds.map(function (o) {
  30942. operands.add(o);
  30943. });
  30944. } else {
  30945. operands.add(b);
  30946. }
  30947. var precedencePredicates = PrecedencePredicate.filterPrecedencePredicates(operands);
  30948. if (precedencePredicates.length > 0) {
  30949. // interested in the transition with the highest precedence
  30950. var s = precedencePredicates.sort(function (a, b) {
  30951. return a.compareTo(b);
  30952. });
  30953. var reduced = s[s.length - 1];
  30954. operands.add(reduced);
  30955. }
  30956. this.opnds = operands.values();
  30957. return this;
  30958. }
  30959. OR.prototype = Object.create(SemanticContext.prototype);
  30960. OR.prototype.constructor = OR;
  30961. OR.prototype.constructor = function (other) {
  30962. if (this === other) {
  30963. return true;
  30964. } else if (!(other instanceof OR)) {
  30965. return false;
  30966. } else {
  30967. return this.opnds === other.opnds;
  30968. }
  30969. };
  30970. OR.prototype.updateHashCode = function (hash) {
  30971. hash.update(this.opnds, "OR");
  30972. };
  30973. // <p>
  30974. // The evaluation of predicates by this context is short-circuiting, but
  30975. // unordered.</p>
  30976. //
  30977. OR.prototype.evaluate = function (parser, outerContext) {
  30978. for (var i = 0; i < this.opnds.length; i++) {
  30979. if (this.opnds[i].evaluate(parser, outerContext)) {
  30980. return true;
  30981. }
  30982. }
  30983. return false;
  30984. };
  30985. OR.prototype.evalPrecedence = function (parser, outerContext) {
  30986. var differs = false;
  30987. var operands = [];
  30988. for (var i = 0; i < this.opnds.length; i++) {
  30989. var context = this.opnds[i];
  30990. var evaluated = context.evalPrecedence(parser, outerContext);
  30991. differs |= evaluated !== context;
  30992. if (evaluated === SemanticContext.NONE) {
  30993. // The OR context is true if any element is true
  30994. return SemanticContext.NONE;
  30995. } else if (evaluated !== null) {
  30996. // Reduce the result by skipping false elements
  30997. operands.push(evaluated);
  30998. }
  30999. }
  31000. if (!differs) {
  31001. return this;
  31002. }
  31003. if (operands.length === 0) {
  31004. // all elements were false, so the OR context is false
  31005. return null;
  31006. }
  31007. var result = null;
  31008. operands.map(function (o) {
  31009. return result === null ? o : SemanticContext.orContext(result, o);
  31010. });
  31011. return result;
  31012. };
  31013. OR.prototype.toString = function () {
  31014. var s = "";
  31015. this.opnds.map(function (o) {
  31016. s += "|| " + o.toString();
  31017. });
  31018. return s.length > 3 ? s.slice(3) : s;
  31019. };
  31020. exports.SemanticContext = SemanticContext;
  31021. exports.PrecedencePredicate = PrecedencePredicate;
  31022. exports.Predicate = Predicate;
  31023. /***/ }),
  31024. /***/ "./node_modules/antlr4/atn/Transition.js":
  31025. /*!***********************************************!*\
  31026. !*** ./node_modules/antlr4/atn/Transition.js ***!
  31027. \***********************************************/
  31028. /*! no static exports found */
  31029. /***/ (function(module, exports, __webpack_require__) {
  31030. "use strict";
  31031. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31032. * Use of this file is governed by the BSD 3-clause license that
  31033. * can be found in the LICENSE.txt file in the project root.
  31034. */
  31035. //
  31036. // An ATN transition between any two ATN states. Subclasses define
  31037. // atom, set, epsilon, action, predicate, rule transitions.
  31038. //
  31039. // <p>This is a one way link. It emanates from a state (usually via a list of
  31040. // transitions) and has a target state.</p>
  31041. //
  31042. // <p>Since we never have to change the ATN transitions once we construct it,
  31043. // we can fix these transitions as specific classes. The DFA transitions
  31044. // on the other hand need to update the labels as it adds transitions to
  31045. // the states. We'll use the term Edge for the DFA to distinguish them from
  31046. // ATN transitions.</p>
  31047. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  31048. var Interval = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  31049. var IntervalSet = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").IntervalSet;
  31050. var Predicate = __webpack_require__(/*! ./SemanticContext */ "./node_modules/antlr4/atn/SemanticContext.js").Predicate;
  31051. var PrecedencePredicate = __webpack_require__(/*! ./SemanticContext */ "./node_modules/antlr4/atn/SemanticContext.js").PrecedencePredicate;
  31052. function Transition(target) {
  31053. // The target of this transition.
  31054. if (target === undefined || target === null) {
  31055. throw "target cannot be null.";
  31056. }
  31057. this.target = target;
  31058. // Are we epsilon, action, sempred?
  31059. this.isEpsilon = false;
  31060. this.label = null;
  31061. return this;
  31062. }
  31063. // constants for serialization
  31064. Transition.EPSILON = 1;
  31065. Transition.RANGE = 2;
  31066. Transition.RULE = 3;
  31067. Transition.PREDICATE = 4; // e.g., {isType(input.LT(1))}?
  31068. Transition.ATOM = 5;
  31069. Transition.ACTION = 6;
  31070. Transition.SET = 7; // ~(A|B) or ~atom, wildcard, which convert to next 2
  31071. Transition.NOT_SET = 8;
  31072. Transition.WILDCARD = 9;
  31073. Transition.PRECEDENCE = 10;
  31074. Transition.serializationNames = ["INVALID", "EPSILON", "RANGE", "RULE", "PREDICATE", "ATOM", "ACTION", "SET", "NOT_SET", "WILDCARD", "PRECEDENCE"];
  31075. Transition.serializationTypes = {
  31076. EpsilonTransition: Transition.EPSILON,
  31077. RangeTransition: Transition.RANGE,
  31078. RuleTransition: Transition.RULE,
  31079. PredicateTransition: Transition.PREDICATE,
  31080. AtomTransition: Transition.ATOM,
  31081. ActionTransition: Transition.ACTION,
  31082. SetTransition: Transition.SET,
  31083. NotSetTransition: Transition.NOT_SET,
  31084. WildcardTransition: Transition.WILDCARD,
  31085. PrecedencePredicateTransition: Transition.PRECEDENCE
  31086. };
  31087. // TODO: make all transitions sets? no, should remove set edges
  31088. function AtomTransition(target, label) {
  31089. Transition.call(this, target);
  31090. this.label_ = label; // The token type or character value; or, signifies special label.
  31091. this.label = this.makeLabel();
  31092. this.serializationType = Transition.ATOM;
  31093. return this;
  31094. }
  31095. AtomTransition.prototype = Object.create(Transition.prototype);
  31096. AtomTransition.prototype.constructor = AtomTransition;
  31097. AtomTransition.prototype.makeLabel = function () {
  31098. var s = new IntervalSet();
  31099. s.addOne(this.label_);
  31100. return s;
  31101. };
  31102. AtomTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31103. return this.label_ === symbol;
  31104. };
  31105. AtomTransition.prototype.toString = function () {
  31106. return this.label_;
  31107. };
  31108. function RuleTransition(ruleStart, ruleIndex, precedence, followState) {
  31109. Transition.call(this, ruleStart);
  31110. this.ruleIndex = ruleIndex; // ptr to the rule definition object for this rule ref
  31111. this.precedence = precedence;
  31112. this.followState = followState; // what node to begin computations following ref to rule
  31113. this.serializationType = Transition.RULE;
  31114. this.isEpsilon = true;
  31115. return this;
  31116. }
  31117. RuleTransition.prototype = Object.create(Transition.prototype);
  31118. RuleTransition.prototype.constructor = RuleTransition;
  31119. RuleTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31120. return false;
  31121. };
  31122. function EpsilonTransition(target, outermostPrecedenceReturn) {
  31123. Transition.call(this, target);
  31124. this.serializationType = Transition.EPSILON;
  31125. this.isEpsilon = true;
  31126. this.outermostPrecedenceReturn = outermostPrecedenceReturn;
  31127. return this;
  31128. }
  31129. EpsilonTransition.prototype = Object.create(Transition.prototype);
  31130. EpsilonTransition.prototype.constructor = EpsilonTransition;
  31131. EpsilonTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31132. return false;
  31133. };
  31134. EpsilonTransition.prototype.toString = function () {
  31135. return "epsilon";
  31136. };
  31137. function RangeTransition(target, start, stop) {
  31138. Transition.call(this, target);
  31139. this.serializationType = Transition.RANGE;
  31140. this.start = start;
  31141. this.stop = stop;
  31142. this.label = this.makeLabel();
  31143. return this;
  31144. }
  31145. RangeTransition.prototype = Object.create(Transition.prototype);
  31146. RangeTransition.prototype.constructor = RangeTransition;
  31147. RangeTransition.prototype.makeLabel = function () {
  31148. var s = new IntervalSet();
  31149. s.addRange(this.start, this.stop);
  31150. return s;
  31151. };
  31152. RangeTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31153. return symbol >= this.start && symbol <= this.stop;
  31154. };
  31155. RangeTransition.prototype.toString = function () {
  31156. return "'" + String.fromCharCode(this.start) + "'..'" + String.fromCharCode(this.stop) + "'";
  31157. };
  31158. function AbstractPredicateTransition(target) {
  31159. Transition.call(this, target);
  31160. return this;
  31161. }
  31162. AbstractPredicateTransition.prototype = Object.create(Transition.prototype);
  31163. AbstractPredicateTransition.prototype.constructor = AbstractPredicateTransition;
  31164. function PredicateTransition(target, ruleIndex, predIndex, isCtxDependent) {
  31165. AbstractPredicateTransition.call(this, target);
  31166. this.serializationType = Transition.PREDICATE;
  31167. this.ruleIndex = ruleIndex;
  31168. this.predIndex = predIndex;
  31169. this.isCtxDependent = isCtxDependent; // e.g., $i ref in pred
  31170. this.isEpsilon = true;
  31171. return this;
  31172. }
  31173. PredicateTransition.prototype = Object.create(AbstractPredicateTransition.prototype);
  31174. PredicateTransition.prototype.constructor = PredicateTransition;
  31175. PredicateTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31176. return false;
  31177. };
  31178. PredicateTransition.prototype.getPredicate = function () {
  31179. return new Predicate(this.ruleIndex, this.predIndex, this.isCtxDependent);
  31180. };
  31181. PredicateTransition.prototype.toString = function () {
  31182. return "pred_" + this.ruleIndex + ":" + this.predIndex;
  31183. };
  31184. function ActionTransition(target, ruleIndex, actionIndex, isCtxDependent) {
  31185. Transition.call(this, target);
  31186. this.serializationType = Transition.ACTION;
  31187. this.ruleIndex = ruleIndex;
  31188. this.actionIndex = actionIndex === undefined ? -1 : actionIndex;
  31189. this.isCtxDependent = isCtxDependent === undefined ? false : isCtxDependent; // e.g., $i ref in pred
  31190. this.isEpsilon = true;
  31191. return this;
  31192. }
  31193. ActionTransition.prototype = Object.create(Transition.prototype);
  31194. ActionTransition.prototype.constructor = ActionTransition;
  31195. ActionTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31196. return false;
  31197. };
  31198. ActionTransition.prototype.toString = function () {
  31199. return "action_" + this.ruleIndex + ":" + this.actionIndex;
  31200. };
  31201. // A transition containing a set of values.
  31202. function SetTransition(target, set) {
  31203. Transition.call(this, target);
  31204. this.serializationType = Transition.SET;
  31205. if (set !== undefined && set !== null) {
  31206. this.label = set;
  31207. } else {
  31208. this.label = new IntervalSet();
  31209. this.label.addOne(Token.INVALID_TYPE);
  31210. }
  31211. return this;
  31212. }
  31213. SetTransition.prototype = Object.create(Transition.prototype);
  31214. SetTransition.prototype.constructor = SetTransition;
  31215. SetTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31216. return this.label.contains(symbol);
  31217. };
  31218. SetTransition.prototype.toString = function () {
  31219. return this.label.toString();
  31220. };
  31221. function NotSetTransition(target, set) {
  31222. SetTransition.call(this, target, set);
  31223. this.serializationType = Transition.NOT_SET;
  31224. return this;
  31225. }
  31226. NotSetTransition.prototype = Object.create(SetTransition.prototype);
  31227. NotSetTransition.prototype.constructor = NotSetTransition;
  31228. NotSetTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31229. return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && !SetTransition.prototype.matches.call(this, symbol, minVocabSymbol, maxVocabSymbol);
  31230. };
  31231. NotSetTransition.prototype.toString = function () {
  31232. return '~' + SetTransition.prototype.toString.call(this);
  31233. };
  31234. function WildcardTransition(target) {
  31235. Transition.call(this, target);
  31236. this.serializationType = Transition.WILDCARD;
  31237. return this;
  31238. }
  31239. WildcardTransition.prototype = Object.create(Transition.prototype);
  31240. WildcardTransition.prototype.constructor = WildcardTransition;
  31241. WildcardTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31242. return symbol >= minVocabSymbol && symbol <= maxVocabSymbol;
  31243. };
  31244. WildcardTransition.prototype.toString = function () {
  31245. return ".";
  31246. };
  31247. function PrecedencePredicateTransition(target, precedence) {
  31248. AbstractPredicateTransition.call(this, target);
  31249. this.serializationType = Transition.PRECEDENCE;
  31250. this.precedence = precedence;
  31251. this.isEpsilon = true;
  31252. return this;
  31253. }
  31254. PrecedencePredicateTransition.prototype = Object.create(AbstractPredicateTransition.prototype);
  31255. PrecedencePredicateTransition.prototype.constructor = PrecedencePredicateTransition;
  31256. PrecedencePredicateTransition.prototype.matches = function (symbol, minVocabSymbol, maxVocabSymbol) {
  31257. return false;
  31258. };
  31259. PrecedencePredicateTransition.prototype.getPredicate = function () {
  31260. return new PrecedencePredicate(this.precedence);
  31261. };
  31262. PrecedencePredicateTransition.prototype.toString = function () {
  31263. return this.precedence + " >= _p";
  31264. };
  31265. exports.Transition = Transition;
  31266. exports.AtomTransition = AtomTransition;
  31267. exports.SetTransition = SetTransition;
  31268. exports.NotSetTransition = NotSetTransition;
  31269. exports.RuleTransition = RuleTransition;
  31270. exports.ActionTransition = ActionTransition;
  31271. exports.EpsilonTransition = EpsilonTransition;
  31272. exports.RangeTransition = RangeTransition;
  31273. exports.WildcardTransition = WildcardTransition;
  31274. exports.PredicateTransition = PredicateTransition;
  31275. exports.PrecedencePredicateTransition = PrecedencePredicateTransition;
  31276. exports.AbstractPredicateTransition = AbstractPredicateTransition;
  31277. /***/ }),
  31278. /***/ "./node_modules/antlr4/atn/index.js":
  31279. /*!******************************************!*\
  31280. !*** ./node_modules/antlr4/atn/index.js ***!
  31281. \******************************************/
  31282. /*! no static exports found */
  31283. /***/ (function(module, exports, __webpack_require__) {
  31284. "use strict";
  31285. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31286. * Use of this file is governed by the BSD 3-clause license that
  31287. * can be found in the LICENSE.txt file in the project root.
  31288. */
  31289. exports.ATN = __webpack_require__(/*! ./ATN */ "./node_modules/antlr4/atn/ATN.js").ATN;
  31290. exports.ATNDeserializer = __webpack_require__(/*! ./ATNDeserializer */ "./node_modules/antlr4/atn/ATNDeserializer.js").ATNDeserializer;
  31291. exports.LexerATNSimulator = __webpack_require__(/*! ./LexerATNSimulator */ "./node_modules/antlr4/atn/LexerATNSimulator.js").LexerATNSimulator;
  31292. exports.ParserATNSimulator = __webpack_require__(/*! ./ParserATNSimulator */ "./node_modules/antlr4/atn/ParserATNSimulator.js").ParserATNSimulator;
  31293. exports.PredictionMode = __webpack_require__(/*! ./PredictionMode */ "./node_modules/antlr4/atn/PredictionMode.js").PredictionMode;
  31294. /***/ }),
  31295. /***/ "./node_modules/antlr4/dfa/DFA.js":
  31296. /*!****************************************!*\
  31297. !*** ./node_modules/antlr4/dfa/DFA.js ***!
  31298. \****************************************/
  31299. /*! no static exports found */
  31300. /***/ (function(module, exports, __webpack_require__) {
  31301. "use strict";
  31302. //
  31303. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31304. * Use of this file is governed by the BSD 3-clause license that
  31305. * can be found in the LICENSE.txt file in the project root.
  31306. */
  31307. var Set = __webpack_require__(/*! ../Utils */ "./node_modules/antlr4/Utils.js").Set;
  31308. var DFAState = __webpack_require__(/*! ./DFAState */ "./node_modules/antlr4/dfa/DFAState.js").DFAState;
  31309. var StarLoopEntryState = __webpack_require__(/*! ../atn/ATNState */ "./node_modules/antlr4/atn/ATNState.js").StarLoopEntryState;
  31310. var ATNConfigSet = __webpack_require__(/*! ./../atn/ATNConfigSet */ "./node_modules/antlr4/atn/ATNConfigSet.js").ATNConfigSet;
  31311. var DFASerializer = __webpack_require__(/*! ./DFASerializer */ "./node_modules/antlr4/dfa/DFASerializer.js").DFASerializer;
  31312. var LexerDFASerializer = __webpack_require__(/*! ./DFASerializer */ "./node_modules/antlr4/dfa/DFASerializer.js").LexerDFASerializer;
  31313. function DFA(atnStartState, decision) {
  31314. if (decision === undefined) {
  31315. decision = 0;
  31316. }
  31317. // From which ATN state did we create this DFA?
  31318. this.atnStartState = atnStartState;
  31319. this.decision = decision;
  31320. // A set of all DFA states. Use {@link Map} so we can get old state back
  31321. // ({@link Set} only allows you to see if it's there).
  31322. this._states = new Set();
  31323. this.s0 = null;
  31324. // {@code true} if this DFA is for a precedence decision; otherwise,
  31325. // {@code false}. This is the backing field for {@link //isPrecedenceDfa},
  31326. // {@link //setPrecedenceDfa}.
  31327. this.precedenceDfa = false;
  31328. if (atnStartState instanceof StarLoopEntryState) {
  31329. if (atnStartState.isPrecedenceDecision) {
  31330. this.precedenceDfa = true;
  31331. var precedenceState = new DFAState(null, new ATNConfigSet());
  31332. precedenceState.edges = [];
  31333. precedenceState.isAcceptState = false;
  31334. precedenceState.requiresFullContext = false;
  31335. this.s0 = precedenceState;
  31336. }
  31337. }
  31338. return this;
  31339. }
  31340. // Get the start state for a specific precedence value.
  31341. //
  31342. // @param precedence The current precedence.
  31343. // @return The start state corresponding to the specified precedence, or
  31344. // {@code null} if no start state exists for the specified precedence.
  31345. //
  31346. // @throws IllegalStateException if this is not a precedence DFA.
  31347. // @see //isPrecedenceDfa()
  31348. DFA.prototype.getPrecedenceStartState = function (precedence) {
  31349. if (!this.precedenceDfa) {
  31350. throw "Only precedence DFAs may contain a precedence start state.";
  31351. }
  31352. // s0.edges is never null for a precedence DFA
  31353. if (precedence < 0 || precedence >= this.s0.edges.length) {
  31354. return null;
  31355. }
  31356. return this.s0.edges[precedence] || null;
  31357. };
  31358. // Set the start state for a specific precedence value.
  31359. //
  31360. // @param precedence The current precedence.
  31361. // @param startState The start state corresponding to the specified
  31362. // precedence.
  31363. //
  31364. // @throws IllegalStateException if this is not a precedence DFA.
  31365. // @see //isPrecedenceDfa()
  31366. //
  31367. DFA.prototype.setPrecedenceStartState = function (precedence, startState) {
  31368. if (!this.precedenceDfa) {
  31369. throw "Only precedence DFAs may contain a precedence start state.";
  31370. }
  31371. if (precedence < 0) {
  31372. return;
  31373. }
  31374. // synchronization on s0 here is ok. when the DFA is turned into a
  31375. // precedence DFA, s0 will be initialized once and not updated again
  31376. // s0.edges is never null for a precedence DFA
  31377. this.s0.edges[precedence] = startState;
  31378. };
  31379. //
  31380. // Sets whether this is a precedence DFA. If the specified value differs
  31381. // from the current DFA configuration, the following actions are taken;
  31382. // otherwise no changes are made to the current DFA.
  31383. //
  31384. // <ul>
  31385. // <li>The {@link //states} map is cleared</li>
  31386. // <li>If {@code precedenceDfa} is {@code false}, the initial state
  31387. // {@link //s0} is set to {@code null}; otherwise, it is initialized to a new
  31388. // {@link DFAState} with an empty outgoing {@link DFAState//edges} array to
  31389. // store the start states for individual precedence values.</li>
  31390. // <li>The {@link //precedenceDfa} field is updated</li>
  31391. // </ul>
  31392. //
  31393. // @param precedenceDfa {@code true} if this is a precedence DFA; otherwise,
  31394. // {@code false}
  31395. DFA.prototype.setPrecedenceDfa = function (precedenceDfa) {
  31396. if (this.precedenceDfa !== precedenceDfa) {
  31397. this._states = new DFAStatesSet();
  31398. if (precedenceDfa) {
  31399. var precedenceState = new DFAState(null, new ATNConfigSet());
  31400. precedenceState.edges = [];
  31401. precedenceState.isAcceptState = false;
  31402. precedenceState.requiresFullContext = false;
  31403. this.s0 = precedenceState;
  31404. } else {
  31405. this.s0 = null;
  31406. }
  31407. this.precedenceDfa = precedenceDfa;
  31408. }
  31409. };
  31410. Object.defineProperty(DFA.prototype, "states", {
  31411. get: function get() {
  31412. return this._states;
  31413. }
  31414. });
  31415. // Return a list of all states in this DFA, ordered by state number.
  31416. DFA.prototype.sortedStates = function () {
  31417. var list = this._states.values();
  31418. return list.sort(function (a, b) {
  31419. return a.stateNumber - b.stateNumber;
  31420. });
  31421. };
  31422. DFA.prototype.toString = function (literalNames, symbolicNames) {
  31423. literalNames = literalNames || null;
  31424. symbolicNames = symbolicNames || null;
  31425. if (this.s0 === null) {
  31426. return "";
  31427. }
  31428. var serializer = new DFASerializer(this, literalNames, symbolicNames);
  31429. return serializer.toString();
  31430. };
  31431. DFA.prototype.toLexerString = function () {
  31432. if (this.s0 === null) {
  31433. return "";
  31434. }
  31435. var serializer = new LexerDFASerializer(this);
  31436. return serializer.toString();
  31437. };
  31438. exports.DFA = DFA;
  31439. /***/ }),
  31440. /***/ "./node_modules/antlr4/dfa/DFASerializer.js":
  31441. /*!**************************************************!*\
  31442. !*** ./node_modules/antlr4/dfa/DFASerializer.js ***!
  31443. \**************************************************/
  31444. /*! no static exports found */
  31445. /***/ (function(module, exports, __webpack_require__) {
  31446. "use strict";
  31447. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31448. * Use of this file is governed by the BSD 3-clause license that
  31449. * can be found in the LICENSE.txt file in the project root.
  31450. */
  31451. // A DFA walker that knows how to dump them to serialized strings.#/
  31452. function DFASerializer(dfa, literalNames, symbolicNames) {
  31453. this.dfa = dfa;
  31454. this.literalNames = literalNames || [];
  31455. this.symbolicNames = symbolicNames || [];
  31456. return this;
  31457. }
  31458. DFASerializer.prototype.toString = function () {
  31459. if (this.dfa.s0 === null) {
  31460. return null;
  31461. }
  31462. var buf = "";
  31463. var states = this.dfa.sortedStates();
  31464. for (var i = 0; i < states.length; i++) {
  31465. var s = states[i];
  31466. if (s.edges !== null) {
  31467. var n = s.edges.length;
  31468. for (var j = 0; j < n; j++) {
  31469. var t = s.edges[j] || null;
  31470. if (t !== null && t.stateNumber !== 0x7FFFFFFF) {
  31471. buf = buf.concat(this.getStateString(s));
  31472. buf = buf.concat("-");
  31473. buf = buf.concat(this.getEdgeLabel(j));
  31474. buf = buf.concat("->");
  31475. buf = buf.concat(this.getStateString(t));
  31476. buf = buf.concat('\n');
  31477. }
  31478. }
  31479. }
  31480. }
  31481. return buf.length === 0 ? null : buf;
  31482. };
  31483. DFASerializer.prototype.getEdgeLabel = function (i) {
  31484. if (i === 0) {
  31485. return "EOF";
  31486. } else if (this.literalNames !== null || this.symbolicNames !== null) {
  31487. return this.literalNames[i - 1] || this.symbolicNames[i - 1];
  31488. } else {
  31489. return String.fromCharCode(i - 1);
  31490. }
  31491. };
  31492. DFASerializer.prototype.getStateString = function (s) {
  31493. var baseStateStr = (s.isAcceptState ? ":" : "") + "s" + s.stateNumber + (s.requiresFullContext ? "^" : "");
  31494. if (s.isAcceptState) {
  31495. if (s.predicates !== null) {
  31496. return baseStateStr + "=>" + s.predicates.toString();
  31497. } else {
  31498. return baseStateStr + "=>" + s.prediction.toString();
  31499. }
  31500. } else {
  31501. return baseStateStr;
  31502. }
  31503. };
  31504. function LexerDFASerializer(dfa) {
  31505. DFASerializer.call(this, dfa, null);
  31506. return this;
  31507. }
  31508. LexerDFASerializer.prototype = Object.create(DFASerializer.prototype);
  31509. LexerDFASerializer.prototype.constructor = LexerDFASerializer;
  31510. LexerDFASerializer.prototype.getEdgeLabel = function (i) {
  31511. return "'" + String.fromCharCode(i) + "'";
  31512. };
  31513. exports.DFASerializer = DFASerializer;
  31514. exports.LexerDFASerializer = LexerDFASerializer;
  31515. /***/ }),
  31516. /***/ "./node_modules/antlr4/dfa/DFAState.js":
  31517. /*!*********************************************!*\
  31518. !*** ./node_modules/antlr4/dfa/DFAState.js ***!
  31519. \*********************************************/
  31520. /*! no static exports found */
  31521. /***/ (function(module, exports, __webpack_require__) {
  31522. "use strict";
  31523. //
  31524. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31525. * Use of this file is governed by the BSD 3-clause license that
  31526. * can be found in the LICENSE.txt file in the project root.
  31527. */
  31528. ///
  31529. var ATNConfigSet = __webpack_require__(/*! ./../atn/ATNConfigSet */ "./node_modules/antlr4/atn/ATNConfigSet.js").ATNConfigSet;
  31530. var Utils = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js");
  31531. var Hash = Utils.Hash;
  31532. var Set = Utils.Set;
  31533. // Map a predicate to a predicted alternative.///
  31534. function PredPrediction(pred, alt) {
  31535. this.alt = alt;
  31536. this.pred = pred;
  31537. return this;
  31538. }
  31539. PredPrediction.prototype.toString = function () {
  31540. return "(" + this.pred + ", " + this.alt + ")";
  31541. };
  31542. // A DFA state represents a set of possible ATN configurations.
  31543. // As Aho, Sethi, Ullman p. 117 says "The DFA uses its state
  31544. // to keep track of all possible states the ATN can be in after
  31545. // reading each input symbol. That is to say, after reading
  31546. // input a1a2..an, the DFA is in a state that represents the
  31547. // subset T of the states of the ATN that are reachable from the
  31548. // ATN's start state along some path labeled a1a2..an."
  31549. // In conventional NFA&rarr;DFA conversion, therefore, the subset T
  31550. // would be a bitset representing the set of states the
  31551. // ATN could be in. We need to track the alt predicted by each
  31552. // state as well, however. More importantly, we need to maintain
  31553. // a stack of states, tracking the closure operations as they
  31554. // jump from rule to rule, emulating rule invocations (method calls).
  31555. // I have to add a stack to simulate the proper lookahead sequences for
  31556. // the underlying LL grammar from which the ATN was derived.
  31557. //
  31558. // <p>I use a set of ATNConfig objects not simple states. An ATNConfig
  31559. // is both a state (ala normal conversion) and a RuleContext describing
  31560. // the chain of rules (if any) followed to arrive at that state.</p>
  31561. //
  31562. // <p>A DFA state may have multiple references to a particular state,
  31563. // but with different ATN contexts (with same or different alts)
  31564. // meaning that state was reached via a different set of rule invocations.</p>
  31565. // /
  31566. function DFAState(stateNumber, configs) {
  31567. if (stateNumber === null) {
  31568. stateNumber = -1;
  31569. }
  31570. if (configs === null) {
  31571. configs = new ATNConfigSet();
  31572. }
  31573. this.stateNumber = stateNumber;
  31574. this.configs = configs;
  31575. // {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1)
  31576. // {@link Token//EOF} maps to {@code edges[0]}.
  31577. this.edges = null;
  31578. this.isAcceptState = false;
  31579. // if accept state, what ttype do we match or alt do we predict?
  31580. // This is set to {@link ATN//INVALID_ALT_NUMBER} when {@link
  31581. // //predicates}{@code !=null} or
  31582. // {@link //requiresFullContext}.
  31583. this.prediction = 0;
  31584. this.lexerActionExecutor = null;
  31585. // Indicates that this state was created during SLL prediction that
  31586. // discovered a conflict between the configurations in the state. Future
  31587. // {@link ParserATNSimulator//execATN} invocations immediately jumped doing
  31588. // full context prediction if this field is true.
  31589. this.requiresFullContext = false;
  31590. // During SLL parsing, this is a list of predicates associated with the
  31591. // ATN configurations of the DFA state. When we have predicates,
  31592. // {@link //requiresFullContext} is {@code false} since full context
  31593. // prediction evaluates predicates
  31594. // on-the-fly. If this is not null, then {@link //prediction} is
  31595. // {@link ATN//INVALID_ALT_NUMBER}.
  31596. //
  31597. // <p>We only use these for non-{@link //requiresFullContext} but
  31598. // conflicting states. That
  31599. // means we know from the context (it's $ or we don't dip into outer
  31600. // context) that it's an ambiguity not a conflict.</p>
  31601. //
  31602. // <p>This list is computed by {@link
  31603. // ParserATNSimulator//predicateDFAState}.</p>
  31604. this.predicates = null;
  31605. return this;
  31606. }
  31607. // Get the set of all alts mentioned by all ATN configurations in this
  31608. // DFA state.
  31609. DFAState.prototype.getAltSet = function () {
  31610. var alts = new Set();
  31611. if (this.configs !== null) {
  31612. for (var i = 0; i < this.configs.length; i++) {
  31613. var c = this.configs[i];
  31614. alts.add(c.alt);
  31615. }
  31616. }
  31617. if (alts.length === 0) {
  31618. return null;
  31619. } else {
  31620. return alts;
  31621. }
  31622. };
  31623. // Two {@link DFAState} instances are equal if their ATN configuration sets
  31624. // are the same. This method is used to see if a state already exists.
  31625. //
  31626. // <p>Because the number of alternatives and number of ATN configurations are
  31627. // finite, there is a finite number of DFA states that can be processed.
  31628. // This is necessary to show that the algorithm terminates.</p>
  31629. //
  31630. // <p>Cannot test the DFA state numbers here because in
  31631. // {@link ParserATNSimulator//addDFAState} we need to know if any other state
  31632. // exists that has this exact set of ATN configurations. The
  31633. // {@link //stateNumber} is irrelevant.</p>
  31634. DFAState.prototype.equals = function (other) {
  31635. // compare set of ATN configurations in this set with other
  31636. return this === other || other instanceof DFAState && this.configs.equals(other.configs);
  31637. };
  31638. DFAState.prototype.toString = function () {
  31639. var s = "" + this.stateNumber + ":" + this.configs;
  31640. if (this.isAcceptState) {
  31641. s = s + "=>";
  31642. if (this.predicates !== null) s = s + this.predicates;else s = s + this.prediction;
  31643. }
  31644. return s;
  31645. };
  31646. DFAState.prototype.hashCode = function () {
  31647. var hash = new Hash();
  31648. hash.update(this.configs);
  31649. if (this.isAcceptState) {
  31650. if (this.predicates !== null) hash.update(this.predicates);else hash.update(this.prediction);
  31651. }
  31652. return hash.finish();
  31653. };
  31654. exports.DFAState = DFAState;
  31655. exports.PredPrediction = PredPrediction;
  31656. /***/ }),
  31657. /***/ "./node_modules/antlr4/dfa/index.js":
  31658. /*!******************************************!*\
  31659. !*** ./node_modules/antlr4/dfa/index.js ***!
  31660. \******************************************/
  31661. /*! no static exports found */
  31662. /***/ (function(module, exports, __webpack_require__) {
  31663. "use strict";
  31664. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31665. * Use of this file is governed by the BSD 3-clause license that
  31666. * can be found in the LICENSE.txt file in the project root.
  31667. */
  31668. exports.DFA = __webpack_require__(/*! ./DFA */ "./node_modules/antlr4/dfa/DFA.js").DFA;
  31669. exports.DFASerializer = __webpack_require__(/*! ./DFASerializer */ "./node_modules/antlr4/dfa/DFASerializer.js").DFASerializer;
  31670. exports.LexerDFASerializer = __webpack_require__(/*! ./DFASerializer */ "./node_modules/antlr4/dfa/DFASerializer.js").LexerDFASerializer;
  31671. exports.PredPrediction = __webpack_require__(/*! ./DFAState */ "./node_modules/antlr4/dfa/DFAState.js").PredPrediction;
  31672. /***/ }),
  31673. /***/ "./node_modules/antlr4/error/DiagnosticErrorListener.js":
  31674. /*!**************************************************************!*\
  31675. !*** ./node_modules/antlr4/error/DiagnosticErrorListener.js ***!
  31676. \**************************************************************/
  31677. /*! no static exports found */
  31678. /***/ (function(module, exports, __webpack_require__) {
  31679. "use strict";
  31680. //
  31681. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31682. * Use of this file is governed by the BSD 3-clause license that
  31683. * can be found in the LICENSE.txt file in the project root.
  31684. */
  31685. //
  31686. //
  31687. // This implementation of {@link ANTLRErrorListener} can be used to identify
  31688. // certain potential correctness and performance problems in grammars. "Reports"
  31689. // are made by calling {@link Parser//notifyErrorListeners} with the appropriate
  31690. // message.
  31691. //
  31692. // <ul>
  31693. // <li><b>Ambiguities</b>: These are cases where more than one path through the
  31694. // grammar can match the input.</li>
  31695. // <li><b>Weak context sensitivity</b>: These are cases where full-context
  31696. // prediction resolved an SLL conflict to a unique alternative which equaled the
  31697. // minimum alternative of the SLL conflict.</li>
  31698. // <li><b>Strong (forced) context sensitivity</b>: These are cases where the
  31699. // full-context prediction resolved an SLL conflict to a unique alternative,
  31700. // <em>and</em> the minimum alternative of the SLL conflict was found to not be
  31701. // a truly viable alternative. Two-stage parsing cannot be used for inputs where
  31702. // this situation occurs.</li>
  31703. // </ul>
  31704. var BitSet = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js").BitSet;
  31705. var ErrorListener = __webpack_require__(/*! ./ErrorListener */ "./node_modules/antlr4/error/ErrorListener.js").ErrorListener;
  31706. var Interval = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  31707. function DiagnosticErrorListener(exactOnly) {
  31708. ErrorListener.call(this);
  31709. exactOnly = exactOnly || true;
  31710. // whether all ambiguities or only exact ambiguities are reported.
  31711. this.exactOnly = exactOnly;
  31712. return this;
  31713. }
  31714. DiagnosticErrorListener.prototype = Object.create(ErrorListener.prototype);
  31715. DiagnosticErrorListener.prototype.constructor = DiagnosticErrorListener;
  31716. DiagnosticErrorListener.prototype.reportAmbiguity = function (recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) {
  31717. if (this.exactOnly && !exact) {
  31718. return;
  31719. }
  31720. var msg = "reportAmbiguity d=" + this.getDecisionDescription(recognizer, dfa) + ": ambigAlts=" + this.getConflictingAlts(ambigAlts, configs) + ", input='" + recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'";
  31721. recognizer.notifyErrorListeners(msg);
  31722. };
  31723. DiagnosticErrorListener.prototype.reportAttemptingFullContext = function (recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) {
  31724. var msg = "reportAttemptingFullContext d=" + this.getDecisionDescription(recognizer, dfa) + ", input='" + recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'";
  31725. recognizer.notifyErrorListeners(msg);
  31726. };
  31727. DiagnosticErrorListener.prototype.reportContextSensitivity = function (recognizer, dfa, startIndex, stopIndex, prediction, configs) {
  31728. var msg = "reportContextSensitivity d=" + this.getDecisionDescription(recognizer, dfa) + ", input='" + recognizer.getTokenStream().getText(new Interval(startIndex, stopIndex)) + "'";
  31729. recognizer.notifyErrorListeners(msg);
  31730. };
  31731. DiagnosticErrorListener.prototype.getDecisionDescription = function (recognizer, dfa) {
  31732. var decision = dfa.decision;
  31733. var ruleIndex = dfa.atnStartState.ruleIndex;
  31734. var ruleNames = recognizer.ruleNames;
  31735. if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
  31736. return "" + decision;
  31737. }
  31738. var ruleName = ruleNames[ruleIndex] || null;
  31739. if (ruleName === null || ruleName.length === 0) {
  31740. return "" + decision;
  31741. }
  31742. return "" + decision + " (" + ruleName + ")";
  31743. };
  31744. //
  31745. // Computes the set of conflicting or ambiguous alternatives from a
  31746. // configuration set, if that information was not already provided by the
  31747. // parser.
  31748. //
  31749. // @param reportedAlts The set of conflicting or ambiguous alternatives, as
  31750. // reported by the parser.
  31751. // @param configs The conflicting or ambiguous configuration set.
  31752. // @return Returns {@code reportedAlts} if it is not {@code null}, otherwise
  31753. // returns the set of alternatives represented in {@code configs}.
  31754. //
  31755. DiagnosticErrorListener.prototype.getConflictingAlts = function (reportedAlts, configs) {
  31756. if (reportedAlts !== null) {
  31757. return reportedAlts;
  31758. }
  31759. var result = new BitSet();
  31760. for (var i = 0; i < configs.items.length; i++) {
  31761. result.add(configs.items[i].alt);
  31762. }
  31763. return "{" + result.values().join(", ") + "}";
  31764. };
  31765. exports.DiagnosticErrorListener = DiagnosticErrorListener;
  31766. /***/ }),
  31767. /***/ "./node_modules/antlr4/error/ErrorListener.js":
  31768. /*!****************************************************!*\
  31769. !*** ./node_modules/antlr4/error/ErrorListener.js ***!
  31770. \****************************************************/
  31771. /*! no static exports found */
  31772. /***/ (function(module, exports, __webpack_require__) {
  31773. "use strict";
  31774. //
  31775. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31776. * Use of this file is governed by the BSD 3-clause license that
  31777. * can be found in the LICENSE.txt file in the project root.
  31778. */
  31779. // Provides an empty default implementation of {@link ANTLRErrorListener}. The
  31780. // default implementation of each method does nothing, but can be overridden as
  31781. // necessary.
  31782. function ErrorListener() {
  31783. return this;
  31784. }
  31785. ErrorListener.prototype.syntaxError = function (recognizer, offendingSymbol, line, column, msg, e) {};
  31786. ErrorListener.prototype.reportAmbiguity = function (recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) {};
  31787. ErrorListener.prototype.reportAttemptingFullContext = function (recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) {};
  31788. ErrorListener.prototype.reportContextSensitivity = function (recognizer, dfa, startIndex, stopIndex, prediction, configs) {};
  31789. function ConsoleErrorListener() {
  31790. ErrorListener.call(this);
  31791. return this;
  31792. }
  31793. ConsoleErrorListener.prototype = Object.create(ErrorListener.prototype);
  31794. ConsoleErrorListener.prototype.constructor = ConsoleErrorListener;
  31795. //
  31796. // Provides a default instance of {@link ConsoleErrorListener}.
  31797. //
  31798. ConsoleErrorListener.INSTANCE = new ConsoleErrorListener();
  31799. //
  31800. // {@inheritDoc}
  31801. //
  31802. // <p>
  31803. // This implementation prints messages to {@link System//err} containing the
  31804. // values of {@code line}, {@code charPositionInLine}, and {@code msg} using
  31805. // the following format.</p>
  31806. //
  31807. // <pre>
  31808. // line <em>line</em>:<em>charPositionInLine</em> <em>msg</em>
  31809. // </pre>
  31810. //
  31811. ConsoleErrorListener.prototype.syntaxError = function (recognizer, offendingSymbol, line, column, msg, e) {
  31812. console.error("line " + line + ":" + column + " " + msg);
  31813. };
  31814. function ProxyErrorListener(delegates) {
  31815. ErrorListener.call(this);
  31816. if (delegates === null) {
  31817. throw "delegates";
  31818. }
  31819. this.delegates = delegates;
  31820. return this;
  31821. }
  31822. ProxyErrorListener.prototype = Object.create(ErrorListener.prototype);
  31823. ProxyErrorListener.prototype.constructor = ProxyErrorListener;
  31824. ProxyErrorListener.prototype.syntaxError = function (recognizer, offendingSymbol, line, column, msg, e) {
  31825. this.delegates.map(function (d) {
  31826. d.syntaxError(recognizer, offendingSymbol, line, column, msg, e);
  31827. });
  31828. };
  31829. ProxyErrorListener.prototype.reportAmbiguity = function (recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) {
  31830. this.delegates.map(function (d) {
  31831. d.reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
  31832. });
  31833. };
  31834. ProxyErrorListener.prototype.reportAttemptingFullContext = function (recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) {
  31835. this.delegates.map(function (d) {
  31836. d.reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
  31837. });
  31838. };
  31839. ProxyErrorListener.prototype.reportContextSensitivity = function (recognizer, dfa, startIndex, stopIndex, prediction, configs) {
  31840. this.delegates.map(function (d) {
  31841. d.reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
  31842. });
  31843. };
  31844. exports.ErrorListener = ErrorListener;
  31845. exports.ConsoleErrorListener = ConsoleErrorListener;
  31846. exports.ProxyErrorListener = ProxyErrorListener;
  31847. /***/ }),
  31848. /***/ "./node_modules/antlr4/error/ErrorStrategy.js":
  31849. /*!****************************************************!*\
  31850. !*** ./node_modules/antlr4/error/ErrorStrategy.js ***!
  31851. \****************************************************/
  31852. /*! no static exports found */
  31853. /***/ (function(module, exports, __webpack_require__) {
  31854. "use strict";
  31855. //
  31856. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  31857. * Use of this file is governed by the BSD 3-clause license that
  31858. * can be found in the LICENSE.txt file in the project root.
  31859. */
  31860. //
  31861. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  31862. var Errors = __webpack_require__(/*! ./Errors */ "./node_modules/antlr4/error/Errors.js");
  31863. var NoViableAltException = Errors.NoViableAltException;
  31864. var InputMismatchException = Errors.InputMismatchException;
  31865. var FailedPredicateException = Errors.FailedPredicateException;
  31866. var ParseCancellationException = Errors.ParseCancellationException;
  31867. var ATNState = __webpack_require__(/*! ./../atn/ATNState */ "./node_modules/antlr4/atn/ATNState.js").ATNState;
  31868. var Interval = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  31869. var IntervalSet = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").IntervalSet;
  31870. function ErrorStrategy() {}
  31871. ErrorStrategy.prototype.reset = function (recognizer) {};
  31872. ErrorStrategy.prototype.recoverInline = function (recognizer) {};
  31873. ErrorStrategy.prototype.recover = function (recognizer, e) {};
  31874. ErrorStrategy.prototype.sync = function (recognizer) {};
  31875. ErrorStrategy.prototype.inErrorRecoveryMode = function (recognizer) {};
  31876. ErrorStrategy.prototype.reportError = function (recognizer) {};
  31877. // This is the default implementation of {@link ANTLRErrorStrategy} used for
  31878. // error reporting and recovery in ANTLR parsers.
  31879. //
  31880. function DefaultErrorStrategy() {
  31881. ErrorStrategy.call(this);
  31882. // Indicates whether the error strategy is currently "recovering from an
  31883. // error". This is used to suppress reporting multiple error messages while
  31884. // attempting to recover from a detected syntax error.
  31885. //
  31886. // @see //inErrorRecoveryMode
  31887. //
  31888. this.errorRecoveryMode = false;
  31889. // The index into the input stream where the last error occurred.
  31890. // This is used to prevent infinite loops where an error is found
  31891. // but no token is consumed during recovery...another error is found,
  31892. // ad nauseum. This is a failsafe mechanism to guarantee that at least
  31893. // one token/tree node is consumed for two errors.
  31894. //
  31895. this.lastErrorIndex = -1;
  31896. this.lastErrorStates = null;
  31897. return this;
  31898. }
  31899. DefaultErrorStrategy.prototype = Object.create(ErrorStrategy.prototype);
  31900. DefaultErrorStrategy.prototype.constructor = DefaultErrorStrategy;
  31901. // <p>The default implementation simply calls {@link //endErrorCondition} to
  31902. // ensure that the handler is not in error recovery mode.</p>
  31903. DefaultErrorStrategy.prototype.reset = function (recognizer) {
  31904. this.endErrorCondition(recognizer);
  31905. };
  31906. //
  31907. // This method is called to enter error recovery mode when a recognition
  31908. // exception is reported.
  31909. //
  31910. // @param recognizer the parser instance
  31911. //
  31912. DefaultErrorStrategy.prototype.beginErrorCondition = function (recognizer) {
  31913. this.errorRecoveryMode = true;
  31914. };
  31915. DefaultErrorStrategy.prototype.inErrorRecoveryMode = function (recognizer) {
  31916. return this.errorRecoveryMode;
  31917. };
  31918. //
  31919. // This method is called to leave error recovery mode after recovering from
  31920. // a recognition exception.
  31921. //
  31922. // @param recognizer
  31923. //
  31924. DefaultErrorStrategy.prototype.endErrorCondition = function (recognizer) {
  31925. this.errorRecoveryMode = false;
  31926. this.lastErrorStates = null;
  31927. this.lastErrorIndex = -1;
  31928. };
  31929. //
  31930. // {@inheritDoc}
  31931. //
  31932. // <p>The default implementation simply calls {@link //endErrorCondition}.</p>
  31933. //
  31934. DefaultErrorStrategy.prototype.reportMatch = function (recognizer) {
  31935. this.endErrorCondition(recognizer);
  31936. };
  31937. //
  31938. // {@inheritDoc}
  31939. //
  31940. // <p>The default implementation returns immediately if the handler is already
  31941. // in error recovery mode. Otherwise, it calls {@link //beginErrorCondition}
  31942. // and dispatches the reporting task based on the runtime type of {@code e}
  31943. // according to the following table.</p>
  31944. //
  31945. // <ul>
  31946. // <li>{@link NoViableAltException}: Dispatches the call to
  31947. // {@link //reportNoViableAlternative}</li>
  31948. // <li>{@link InputMismatchException}: Dispatches the call to
  31949. // {@link //reportInputMismatch}</li>
  31950. // <li>{@link FailedPredicateException}: Dispatches the call to
  31951. // {@link //reportFailedPredicate}</li>
  31952. // <li>All other types: calls {@link Parser//notifyErrorListeners} to report
  31953. // the exception</li>
  31954. // </ul>
  31955. //
  31956. DefaultErrorStrategy.prototype.reportError = function (recognizer, e) {
  31957. // if we've already reported an error and have not matched a token
  31958. // yet successfully, don't report any errors.
  31959. if (this.inErrorRecoveryMode(recognizer)) {
  31960. return; // don't report spurious errors
  31961. }
  31962. this.beginErrorCondition(recognizer);
  31963. if (e instanceof NoViableAltException) {
  31964. this.reportNoViableAlternative(recognizer, e);
  31965. } else if (e instanceof InputMismatchException) {
  31966. this.reportInputMismatch(recognizer, e);
  31967. } else if (e instanceof FailedPredicateException) {
  31968. this.reportFailedPredicate(recognizer, e);
  31969. } else {
  31970. console.log("unknown recognition error type: " + e.constructor.name);
  31971. console.log(e.stack);
  31972. recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e);
  31973. }
  31974. };
  31975. //
  31976. // {@inheritDoc}
  31977. //
  31978. // <p>The default implementation resynchronizes the parser by consuming tokens
  31979. // until we find one in the resynchronization set--loosely the set of tokens
  31980. // that can follow the current rule.</p>
  31981. //
  31982. DefaultErrorStrategy.prototype.recover = function (recognizer, e) {
  31983. if (this.lastErrorIndex === recognizer.getInputStream().index && this.lastErrorStates !== null && this.lastErrorStates.indexOf(recognizer.state) >= 0) {
  31984. // uh oh, another error at same token index and previously-visited
  31985. // state in ATN; must be a case where LT(1) is in the recovery
  31986. // token set so nothing got consumed. Consume a single token
  31987. // at least to prevent an infinite loop; this is a failsafe.
  31988. recognizer.consume();
  31989. }
  31990. this.lastErrorIndex = recognizer._input.index;
  31991. if (this.lastErrorStates === null) {
  31992. this.lastErrorStates = [];
  31993. }
  31994. this.lastErrorStates.push(recognizer.state);
  31995. var followSet = this.getErrorRecoverySet(recognizer);
  31996. this.consumeUntil(recognizer, followSet);
  31997. };
  31998. // The default implementation of {@link ANTLRErrorStrategy//sync} makes sure
  31999. // that the current lookahead symbol is consistent with what were expecting
  32000. // at this point in the ATN. You can call this anytime but ANTLR only
  32001. // generates code to check before subrules/loops and each iteration.
  32002. //
  32003. // <p>Implements Jim Idle's magic sync mechanism in closures and optional
  32004. // subrules. E.g.,</p>
  32005. //
  32006. // <pre>
  32007. // a : sync ( stuff sync )* ;
  32008. // sync : {consume to what can follow sync} ;
  32009. // </pre>
  32010. //
  32011. // At the start of a sub rule upon error, {@link //sync} performs single
  32012. // token deletion, if possible. If it can't do that, it bails on the current
  32013. // rule and uses the default error recovery, which consumes until the
  32014. // resynchronization set of the current rule.
  32015. //
  32016. // <p>If the sub rule is optional ({@code (...)?}, {@code (...)*}, or block
  32017. // with an empty alternative), then the expected set includes what follows
  32018. // the subrule.</p>
  32019. //
  32020. // <p>During loop iteration, it consumes until it sees a token that can start a
  32021. // sub rule or what follows loop. Yes, that is pretty aggressive. We opt to
  32022. // stay in the loop as long as possible.</p>
  32023. //
  32024. // <p><strong>ORIGINS</strong></p>
  32025. //
  32026. // <p>Previous versions of ANTLR did a poor job of their recovery within loops.
  32027. // A single mismatch token or missing token would force the parser to bail
  32028. // out of the entire rules surrounding the loop. So, for rule</p>
  32029. //
  32030. // <pre>
  32031. // classDef : 'class' ID '{' member* '}'
  32032. // </pre>
  32033. //
  32034. // input with an extra token between members would force the parser to
  32035. // consume until it found the next class definition rather than the next
  32036. // member definition of the current class.
  32037. //
  32038. // <p>This functionality cost a little bit of effort because the parser has to
  32039. // compare token set at the start of the loop and at each iteration. If for
  32040. // some reason speed is suffering for you, you can turn off this
  32041. // functionality by simply overriding this method as a blank { }.</p>
  32042. //
  32043. DefaultErrorStrategy.prototype.sync = function (recognizer) {
  32044. // If already recovering, don't try to sync
  32045. if (this.inErrorRecoveryMode(recognizer)) {
  32046. return;
  32047. }
  32048. var s = recognizer._interp.atn.states[recognizer.state];
  32049. var la = recognizer.getTokenStream().LA(1);
  32050. // try cheaper subset first; might get lucky. seems to shave a wee bit off
  32051. var nextTokens = recognizer.atn.nextTokens(s);
  32052. if (nextTokens.contains(Token.EPSILON) || nextTokens.contains(la)) {
  32053. return;
  32054. }
  32055. switch (s.stateType) {
  32056. case ATNState.BLOCK_START:
  32057. case ATNState.STAR_BLOCK_START:
  32058. case ATNState.PLUS_BLOCK_START:
  32059. case ATNState.STAR_LOOP_ENTRY:
  32060. // report error and recover if possible
  32061. if (this.singleTokenDeletion(recognizer) !== null) {
  32062. return;
  32063. } else {
  32064. throw new InputMismatchException(recognizer);
  32065. }
  32066. break;
  32067. case ATNState.PLUS_LOOP_BACK:
  32068. case ATNState.STAR_LOOP_BACK:
  32069. this.reportUnwantedToken(recognizer);
  32070. var expecting = new IntervalSet();
  32071. expecting.addSet(recognizer.getExpectedTokens());
  32072. var whatFollowsLoopIterationOrRule = expecting.addSet(this.getErrorRecoverySet(recognizer));
  32073. this.consumeUntil(recognizer, whatFollowsLoopIterationOrRule);
  32074. break;
  32075. default:
  32076. // do nothing if we can't identify the exact kind of ATN state
  32077. }
  32078. };
  32079. // This is called by {@link //reportError} when the exception is a
  32080. // {@link NoViableAltException}.
  32081. //
  32082. // @see //reportError
  32083. //
  32084. // @param recognizer the parser instance
  32085. // @param e the recognition exception
  32086. //
  32087. DefaultErrorStrategy.prototype.reportNoViableAlternative = function (recognizer, e) {
  32088. var tokens = recognizer.getTokenStream();
  32089. var input;
  32090. if (tokens !== null) {
  32091. if (e.startToken.type === Token.EOF) {
  32092. input = "<EOF>";
  32093. } else {
  32094. input = tokens.getText(new Interval(e.startToken.tokenIndex, e.offendingToken.tokenIndex));
  32095. }
  32096. } else {
  32097. input = "<unknown input>";
  32098. }
  32099. var msg = "no viable alternative at input " + this.escapeWSAndQuote(input);
  32100. recognizer.notifyErrorListeners(msg, e.offendingToken, e);
  32101. };
  32102. //
  32103. // This is called by {@link //reportError} when the exception is an
  32104. // {@link InputMismatchException}.
  32105. //
  32106. // @see //reportError
  32107. //
  32108. // @param recognizer the parser instance
  32109. // @param e the recognition exception
  32110. //
  32111. DefaultErrorStrategy.prototype.reportInputMismatch = function (recognizer, e) {
  32112. var msg = "mismatched input " + this.getTokenErrorDisplay(e.offendingToken) + " expecting " + e.getExpectedTokens().toString(recognizer.literalNames, recognizer.symbolicNames);
  32113. recognizer.notifyErrorListeners(msg, e.offendingToken, e);
  32114. };
  32115. //
  32116. // This is called by {@link //reportError} when the exception is a
  32117. // {@link FailedPredicateException}.
  32118. //
  32119. // @see //reportError
  32120. //
  32121. // @param recognizer the parser instance
  32122. // @param e the recognition exception
  32123. //
  32124. DefaultErrorStrategy.prototype.reportFailedPredicate = function (recognizer, e) {
  32125. var ruleName = recognizer.ruleNames[recognizer._ctx.ruleIndex];
  32126. var msg = "rule " + ruleName + " " + e.message;
  32127. recognizer.notifyErrorListeners(msg, e.offendingToken, e);
  32128. };
  32129. // This method is called to report a syntax error which requires the removal
  32130. // of a token from the input stream. At the time this method is called, the
  32131. // erroneous symbol is current {@code LT(1)} symbol and has not yet been
  32132. // removed from the input stream. When this method returns,
  32133. // {@code recognizer} is in error recovery mode.
  32134. //
  32135. // <p>This method is called when {@link //singleTokenDeletion} identifies
  32136. // single-token deletion as a viable recovery strategy for a mismatched
  32137. // input error.</p>
  32138. //
  32139. // <p>The default implementation simply returns if the handler is already in
  32140. // error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to
  32141. // enter error recovery mode, followed by calling
  32142. // {@link Parser//notifyErrorListeners}.</p>
  32143. //
  32144. // @param recognizer the parser instance
  32145. //
  32146. DefaultErrorStrategy.prototype.reportUnwantedToken = function (recognizer) {
  32147. if (this.inErrorRecoveryMode(recognizer)) {
  32148. return;
  32149. }
  32150. this.beginErrorCondition(recognizer);
  32151. var t = recognizer.getCurrentToken();
  32152. var tokenName = this.getTokenErrorDisplay(t);
  32153. var expecting = this.getExpectedTokens(recognizer);
  32154. var msg = "extraneous input " + tokenName + " expecting " + expecting.toString(recognizer.literalNames, recognizer.symbolicNames);
  32155. recognizer.notifyErrorListeners(msg, t, null);
  32156. };
  32157. // This method is called to report a syntax error which requires the
  32158. // insertion of a missing token into the input stream. At the time this
  32159. // method is called, the missing token has not yet been inserted. When this
  32160. // method returns, {@code recognizer} is in error recovery mode.
  32161. //
  32162. // <p>This method is called when {@link //singleTokenInsertion} identifies
  32163. // single-token insertion as a viable recovery strategy for a mismatched
  32164. // input error.</p>
  32165. //
  32166. // <p>The default implementation simply returns if the handler is already in
  32167. // error recovery mode. Otherwise, it calls {@link //beginErrorCondition} to
  32168. // enter error recovery mode, followed by calling
  32169. // {@link Parser//notifyErrorListeners}.</p>
  32170. //
  32171. // @param recognizer the parser instance
  32172. //
  32173. DefaultErrorStrategy.prototype.reportMissingToken = function (recognizer) {
  32174. if (this.inErrorRecoveryMode(recognizer)) {
  32175. return;
  32176. }
  32177. this.beginErrorCondition(recognizer);
  32178. var t = recognizer.getCurrentToken();
  32179. var expecting = this.getExpectedTokens(recognizer);
  32180. var msg = "missing " + expecting.toString(recognizer.literalNames, recognizer.symbolicNames) + " at " + this.getTokenErrorDisplay(t);
  32181. recognizer.notifyErrorListeners(msg, t, null);
  32182. };
  32183. // <p>The default implementation attempts to recover from the mismatched input
  32184. // by using single token insertion and deletion as described below. If the
  32185. // recovery attempt fails, this method throws an
  32186. // {@link InputMismatchException}.</p>
  32187. //
  32188. // <p><strong>EXTRA TOKEN</strong> (single token deletion)</p>
  32189. //
  32190. // <p>{@code LA(1)} is not what we are looking for. If {@code LA(2)} has the
  32191. // right token, however, then assume {@code LA(1)} is some extra spurious
  32192. // token and delete it. Then consume and return the next token (which was
  32193. // the {@code LA(2)} token) as the successful result of the match operation.</p>
  32194. //
  32195. // <p>This recovery strategy is implemented by {@link
  32196. // //singleTokenDeletion}.</p>
  32197. //
  32198. // <p><strong>MISSING TOKEN</strong> (single token insertion)</p>
  32199. //
  32200. // <p>If current token (at {@code LA(1)}) is consistent with what could come
  32201. // after the expected {@code LA(1)} token, then assume the token is missing
  32202. // and use the parser's {@link TokenFactory} to create it on the fly. The
  32203. // "insertion" is performed by returning the created token as the successful
  32204. // result of the match operation.</p>
  32205. //
  32206. // <p>This recovery strategy is implemented by {@link
  32207. // //singleTokenInsertion}.</p>
  32208. //
  32209. // <p><strong>EXAMPLE</strong></p>
  32210. //
  32211. // <p>For example, Input {@code i=(3;} is clearly missing the {@code ')'}. When
  32212. // the parser returns from the nested call to {@code expr}, it will have
  32213. // call chain:</p>
  32214. //
  32215. // <pre>
  32216. // stat &rarr; expr &rarr; atom
  32217. // </pre>
  32218. //
  32219. // and it will be trying to match the {@code ')'} at this point in the
  32220. // derivation:
  32221. //
  32222. // <pre>
  32223. // =&gt; ID '=' '(' INT ')' ('+' atom)* ';'
  32224. // ^
  32225. // </pre>
  32226. //
  32227. // The attempt to match {@code ')'} will fail when it sees {@code ';'} and
  32228. // call {@link //recoverInline}. To recover, it sees that {@code LA(1)==';'}
  32229. // is in the set of tokens that can follow the {@code ')'} token reference
  32230. // in rule {@code atom}. It can assume that you forgot the {@code ')'}.
  32231. //
  32232. DefaultErrorStrategy.prototype.recoverInline = function (recognizer) {
  32233. // SINGLE TOKEN DELETION
  32234. var matchedSymbol = this.singleTokenDeletion(recognizer);
  32235. if (matchedSymbol !== null) {
  32236. // we have deleted the extra token.
  32237. // now, move past ttype token as if all were ok
  32238. recognizer.consume();
  32239. return matchedSymbol;
  32240. }
  32241. // SINGLE TOKEN INSERTION
  32242. if (this.singleTokenInsertion(recognizer)) {
  32243. return this.getMissingSymbol(recognizer);
  32244. }
  32245. // even that didn't work; must throw the exception
  32246. throw new InputMismatchException(recognizer);
  32247. };
  32248. //
  32249. // This method implements the single-token insertion inline error recovery
  32250. // strategy. It is called by {@link //recoverInline} if the single-token
  32251. // deletion strategy fails to recover from the mismatched input. If this
  32252. // method returns {@code true}, {@code recognizer} will be in error recovery
  32253. // mode.
  32254. //
  32255. // <p>This method determines whether or not single-token insertion is viable by
  32256. // checking if the {@code LA(1)} input symbol could be successfully matched
  32257. // if it were instead the {@code LA(2)} symbol. If this method returns
  32258. // {@code true}, the caller is responsible for creating and inserting a
  32259. // token with the correct type to produce this behavior.</p>
  32260. //
  32261. // @param recognizer the parser instance
  32262. // @return {@code true} if single-token insertion is a viable recovery
  32263. // strategy for the current mismatched input, otherwise {@code false}
  32264. //
  32265. DefaultErrorStrategy.prototype.singleTokenInsertion = function (recognizer) {
  32266. var currentSymbolType = recognizer.getTokenStream().LA(1);
  32267. // if current token is consistent with what could come after current
  32268. // ATN state, then we know we're missing a token; error recovery
  32269. // is free to conjure up and insert the missing token
  32270. var atn = recognizer._interp.atn;
  32271. var currentState = atn.states[recognizer.state];
  32272. var next = currentState.transitions[0].target;
  32273. var expectingAtLL2 = atn.nextTokens(next, recognizer._ctx);
  32274. if (expectingAtLL2.contains(currentSymbolType)) {
  32275. this.reportMissingToken(recognizer);
  32276. return true;
  32277. } else {
  32278. return false;
  32279. }
  32280. };
  32281. // This method implements the single-token deletion inline error recovery
  32282. // strategy. It is called by {@link //recoverInline} to attempt to recover
  32283. // from mismatched input. If this method returns null, the parser and error
  32284. // handler state will not have changed. If this method returns non-null,
  32285. // {@code recognizer} will <em>not</em> be in error recovery mode since the
  32286. // returned token was a successful match.
  32287. //
  32288. // <p>If the single-token deletion is successful, this method calls
  32289. // {@link //reportUnwantedToken} to report the error, followed by
  32290. // {@link Parser//consume} to actually "delete" the extraneous token. Then,
  32291. // before returning {@link //reportMatch} is called to signal a successful
  32292. // match.</p>
  32293. //
  32294. // @param recognizer the parser instance
  32295. // @return the successfully matched {@link Token} instance if single-token
  32296. // deletion successfully recovers from the mismatched input, otherwise
  32297. // {@code null}
  32298. //
  32299. DefaultErrorStrategy.prototype.singleTokenDeletion = function (recognizer) {
  32300. var nextTokenType = recognizer.getTokenStream().LA(2);
  32301. var expecting = this.getExpectedTokens(recognizer);
  32302. if (expecting.contains(nextTokenType)) {
  32303. this.reportUnwantedToken(recognizer);
  32304. // print("recoverFromMismatchedToken deleting " \
  32305. // + str(recognizer.getTokenStream().LT(1)) \
  32306. // + " since " + str(recognizer.getTokenStream().LT(2)) \
  32307. // + " is what we want", file=sys.stderr)
  32308. recognizer.consume(); // simply delete extra token
  32309. // we want to return the token we're actually matching
  32310. var matchedSymbol = recognizer.getCurrentToken();
  32311. this.reportMatch(recognizer); // we know current token is correct
  32312. return matchedSymbol;
  32313. } else {
  32314. return null;
  32315. }
  32316. };
  32317. // Conjure up a missing token during error recovery.
  32318. //
  32319. // The recognizer attempts to recover from single missing
  32320. // symbols. But, actions might refer to that missing symbol.
  32321. // For example, x=ID {f($x);}. The action clearly assumes
  32322. // that there has been an identifier matched previously and that
  32323. // $x points at that token. If that token is missing, but
  32324. // the next token in the stream is what we want we assume that
  32325. // this token is missing and we keep going. Because we
  32326. // have to return some token to replace the missing token,
  32327. // we have to conjure one up. This method gives the user control
  32328. // over the tokens returned for missing tokens. Mostly,
  32329. // you will want to create something special for identifier
  32330. // tokens. For literals such as '{' and ',', the default
  32331. // action in the parser or tree parser works. It simply creates
  32332. // a CommonToken of the appropriate type. The text will be the token.
  32333. // If you change what tokens must be created by the lexer,
  32334. // override this method to create the appropriate tokens.
  32335. //
  32336. DefaultErrorStrategy.prototype.getMissingSymbol = function (recognizer) {
  32337. var currentSymbol = recognizer.getCurrentToken();
  32338. var expecting = this.getExpectedTokens(recognizer);
  32339. var expectedTokenType = expecting.first(); // get any element
  32340. var tokenText;
  32341. if (expectedTokenType === Token.EOF) {
  32342. tokenText = "<missing EOF>";
  32343. } else {
  32344. tokenText = "<missing " + recognizer.literalNames[expectedTokenType] + ">";
  32345. }
  32346. var current = currentSymbol;
  32347. var lookback = recognizer.getTokenStream().LT(-1);
  32348. if (current.type === Token.EOF && lookback !== null) {
  32349. current = lookback;
  32350. }
  32351. return recognizer.getTokenFactory().create(current.source, expectedTokenType, tokenText, Token.DEFAULT_CHANNEL, -1, -1, current.line, current.column);
  32352. };
  32353. DefaultErrorStrategy.prototype.getExpectedTokens = function (recognizer) {
  32354. return recognizer.getExpectedTokens();
  32355. };
  32356. // How should a token be displayed in an error message? The default
  32357. // is to display just the text, but during development you might
  32358. // want to have a lot of information spit out. Override in that case
  32359. // to use t.toString() (which, for CommonToken, dumps everything about
  32360. // the token). This is better than forcing you to override a method in
  32361. // your token objects because you don't have to go modify your lexer
  32362. // so that it creates a new Java type.
  32363. //
  32364. DefaultErrorStrategy.prototype.getTokenErrorDisplay = function (t) {
  32365. if (t === null) {
  32366. return "<no token>";
  32367. }
  32368. var s = t.text;
  32369. if (s === null) {
  32370. if (t.type === Token.EOF) {
  32371. s = "<EOF>";
  32372. } else {
  32373. s = "<" + t.type + ">";
  32374. }
  32375. }
  32376. return this.escapeWSAndQuote(s);
  32377. };
  32378. DefaultErrorStrategy.prototype.escapeWSAndQuote = function (s) {
  32379. s = s.replace(/\n/g, "\\n");
  32380. s = s.replace(/\r/g, "\\r");
  32381. s = s.replace(/\t/g, "\\t");
  32382. return "'" + s + "'";
  32383. };
  32384. // Compute the error recovery set for the current rule. During
  32385. // rule invocation, the parser pushes the set of tokens that can
  32386. // follow that rule reference on the stack; this amounts to
  32387. // computing FIRST of what follows the rule reference in the
  32388. // enclosing rule. See LinearApproximator.FIRST().
  32389. // This local follow set only includes tokens
  32390. // from within the rule; i.e., the FIRST computation done by
  32391. // ANTLR stops at the end of a rule.
  32392. //
  32393. // EXAMPLE
  32394. //
  32395. // When you find a "no viable alt exception", the input is not
  32396. // consistent with any of the alternatives for rule r. The best
  32397. // thing to do is to consume tokens until you see something that
  32398. // can legally follow a call to r//or* any rule that called r.
  32399. // You don't want the exact set of viable next tokens because the
  32400. // input might just be missing a token--you might consume the
  32401. // rest of the input looking for one of the missing tokens.
  32402. //
  32403. // Consider grammar:
  32404. //
  32405. // a : '[' b ']'
  32406. // | '(' b ')'
  32407. // ;
  32408. // b : c '^' INT ;
  32409. // c : ID
  32410. // | INT
  32411. // ;
  32412. //
  32413. // At each rule invocation, the set of tokens that could follow
  32414. // that rule is pushed on a stack. Here are the various
  32415. // context-sensitive follow sets:
  32416. //
  32417. // FOLLOW(b1_in_a) = FIRST(']') = ']'
  32418. // FOLLOW(b2_in_a) = FIRST(')') = ')'
  32419. // FOLLOW(c_in_b) = FIRST('^') = '^'
  32420. //
  32421. // Upon erroneous input "[]", the call chain is
  32422. //
  32423. // a -> b -> c
  32424. //
  32425. // and, hence, the follow context stack is:
  32426. //
  32427. // depth follow set start of rule execution
  32428. // 0 <EOF> a (from main())
  32429. // 1 ']' b
  32430. // 2 '^' c
  32431. //
  32432. // Notice that ')' is not included, because b would have to have
  32433. // been called from a different context in rule a for ')' to be
  32434. // included.
  32435. //
  32436. // For error recovery, we cannot consider FOLLOW(c)
  32437. // (context-sensitive or otherwise). We need the combined set of
  32438. // all context-sensitive FOLLOW sets--the set of all tokens that
  32439. // could follow any reference in the call chain. We need to
  32440. // resync to one of those tokens. Note that FOLLOW(c)='^' and if
  32441. // we resync'd to that token, we'd consume until EOF. We need to
  32442. // sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}.
  32443. // In this case, for input "[]", LA(1) is ']' and in the set, so we would
  32444. // not consume anything. After printing an error, rule c would
  32445. // return normally. Rule b would not find the required '^' though.
  32446. // At this point, it gets a mismatched token error and throws an
  32447. // exception (since LA(1) is not in the viable following token
  32448. // set). The rule exception handler tries to recover, but finds
  32449. // the same recovery set and doesn't consume anything. Rule b
  32450. // exits normally returning to rule a. Now it finds the ']' (and
  32451. // with the successful match exits errorRecovery mode).
  32452. //
  32453. // So, you can see that the parser walks up the call chain looking
  32454. // for the token that was a member of the recovery set.
  32455. //
  32456. // Errors are not generated in errorRecovery mode.
  32457. //
  32458. // ANTLR's error recovery mechanism is based upon original ideas:
  32459. //
  32460. // "Algorithms + Data Structures = Programs" by Niklaus Wirth
  32461. //
  32462. // and
  32463. //
  32464. // "A note on error recovery in recursive descent parsers":
  32465. // http://portal.acm.org/citation.cfm?id=947902.947905
  32466. //
  32467. // Later, Josef Grosch had some good ideas:
  32468. //
  32469. // "Efficient and Comfortable Error Recovery in Recursive Descent
  32470. // Parsers":
  32471. // ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip
  32472. //
  32473. // Like Grosch I implement context-sensitive FOLLOW sets that are combined
  32474. // at run-time upon error to avoid overhead during parsing.
  32475. //
  32476. DefaultErrorStrategy.prototype.getErrorRecoverySet = function (recognizer) {
  32477. var atn = recognizer._interp.atn;
  32478. var ctx = recognizer._ctx;
  32479. var recoverSet = new IntervalSet();
  32480. while (ctx !== null && ctx.invokingState >= 0) {
  32481. // compute what follows who invoked us
  32482. var invokingState = atn.states[ctx.invokingState];
  32483. var rt = invokingState.transitions[0];
  32484. var follow = atn.nextTokens(rt.followState);
  32485. recoverSet.addSet(follow);
  32486. ctx = ctx.parentCtx;
  32487. }
  32488. recoverSet.removeOne(Token.EPSILON);
  32489. return recoverSet;
  32490. };
  32491. // Consume tokens until one matches the given token set.//
  32492. DefaultErrorStrategy.prototype.consumeUntil = function (recognizer, set) {
  32493. var ttype = recognizer.getTokenStream().LA(1);
  32494. while (ttype !== Token.EOF && !set.contains(ttype)) {
  32495. recognizer.consume();
  32496. ttype = recognizer.getTokenStream().LA(1);
  32497. }
  32498. };
  32499. //
  32500. // This implementation of {@link ANTLRErrorStrategy} responds to syntax errors
  32501. // by immediately canceling the parse operation with a
  32502. // {@link ParseCancellationException}. The implementation ensures that the
  32503. // {@link ParserRuleContext//exception} field is set for all parse tree nodes
  32504. // that were not completed prior to encountering the error.
  32505. //
  32506. // <p>
  32507. // This error strategy is useful in the following scenarios.</p>
  32508. //
  32509. // <ul>
  32510. // <li><strong>Two-stage parsing:</strong> This error strategy allows the first
  32511. // stage of two-stage parsing to immediately terminate if an error is
  32512. // encountered, and immediately fall back to the second stage. In addition to
  32513. // avoiding wasted work by attempting to recover from errors here, the empty
  32514. // implementation of {@link BailErrorStrategy//sync} improves the performance of
  32515. // the first stage.</li>
  32516. // <li><strong>Silent validation:</strong> When syntax errors are not being
  32517. // reported or logged, and the parse result is simply ignored if errors occur,
  32518. // the {@link BailErrorStrategy} avoids wasting work on recovering from errors
  32519. // when the result will be ignored either way.</li>
  32520. // </ul>
  32521. //
  32522. // <p>
  32523. // {@code myparser.setErrorHandler(new BailErrorStrategy());}</p>
  32524. //
  32525. // @see Parser//setErrorHandler(ANTLRErrorStrategy)
  32526. //
  32527. function BailErrorStrategy() {
  32528. DefaultErrorStrategy.call(this);
  32529. return this;
  32530. }
  32531. BailErrorStrategy.prototype = Object.create(DefaultErrorStrategy.prototype);
  32532. BailErrorStrategy.prototype.constructor = BailErrorStrategy;
  32533. // Instead of recovering from exception {@code e}, re-throw it wrapped
  32534. // in a {@link ParseCancellationException} so it is not caught by the
  32535. // rule function catches. Use {@link Exception//getCause()} to get the
  32536. // original {@link RecognitionException}.
  32537. //
  32538. BailErrorStrategy.prototype.recover = function (recognizer, e) {
  32539. var context = recognizer._ctx;
  32540. while (context !== null) {
  32541. context.exception = e;
  32542. context = context.parentCtx;
  32543. }
  32544. throw new ParseCancellationException(e);
  32545. };
  32546. // Make sure we don't attempt to recover inline; if the parser
  32547. // successfully recovers, it won't throw an exception.
  32548. //
  32549. BailErrorStrategy.prototype.recoverInline = function (recognizer) {
  32550. this.recover(recognizer, new InputMismatchException(recognizer));
  32551. };
  32552. // Make sure we don't attempt to recover from problems in subrules.//
  32553. BailErrorStrategy.prototype.sync = function (recognizer) {
  32554. // pass
  32555. };
  32556. exports.BailErrorStrategy = BailErrorStrategy;
  32557. exports.DefaultErrorStrategy = DefaultErrorStrategy;
  32558. /***/ }),
  32559. /***/ "./node_modules/antlr4/error/Errors.js":
  32560. /*!*********************************************!*\
  32561. !*** ./node_modules/antlr4/error/Errors.js ***!
  32562. \*********************************************/
  32563. /*! no static exports found */
  32564. /***/ (function(module, exports, __webpack_require__) {
  32565. "use strict";
  32566. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  32567. * Use of this file is governed by the BSD 3-clause license that
  32568. * can be found in the LICENSE.txt file in the project root.
  32569. */
  32570. // The root of the ANTLR exception hierarchy. In general, ANTLR tracks just
  32571. // 3 kinds of errors: prediction errors, failed predicate errors, and
  32572. // mismatched input errors. In each case, the parser knows where it is
  32573. // in the input, where it is in the ATN, the rule invocation stack,
  32574. // and what kind of problem occurred.
  32575. var PredicateTransition = __webpack_require__(/*! ./../atn/Transition */ "./node_modules/antlr4/atn/Transition.js").PredicateTransition;
  32576. function RecognitionException(params) {
  32577. Error.call(this);
  32578. if (!!Error.captureStackTrace) {
  32579. Error.captureStackTrace(this, RecognitionException);
  32580. } else {
  32581. var stack = new Error().stack;
  32582. }
  32583. this.message = params.message;
  32584. this.recognizer = params.recognizer;
  32585. this.input = params.input;
  32586. this.ctx = params.ctx;
  32587. // The current {@link Token} when an error occurred. Since not all streams
  32588. // support accessing symbols by index, we have to track the {@link Token}
  32589. // instance itself.
  32590. this.offendingToken = null;
  32591. // Get the ATN state number the parser was in at the time the error
  32592. // occurred. For {@link NoViableAltException} and
  32593. // {@link LexerNoViableAltException} exceptions, this is the
  32594. // {@link DecisionState} number. For others, it is the state whose outgoing
  32595. // edge we couldn't match.
  32596. this.offendingState = -1;
  32597. if (this.recognizer !== null) {
  32598. this.offendingState = this.recognizer.state;
  32599. }
  32600. return this;
  32601. }
  32602. RecognitionException.prototype = Object.create(Error.prototype);
  32603. RecognitionException.prototype.constructor = RecognitionException;
  32604. // <p>If the state number is not known, this method returns -1.</p>
  32605. //
  32606. // Gets the set of input symbols which could potentially follow the
  32607. // previously matched symbol at the time this exception was thrown.
  32608. //
  32609. // <p>If the set of expected tokens is not known and could not be computed,
  32610. // this method returns {@code null}.</p>
  32611. //
  32612. // @return The set of token types that could potentially follow the current
  32613. // state in the ATN, or {@code null} if the information is not available.
  32614. // /
  32615. RecognitionException.prototype.getExpectedTokens = function () {
  32616. if (this.recognizer !== null) {
  32617. return this.recognizer.atn.getExpectedTokens(this.offendingState, this.ctx);
  32618. } else {
  32619. return null;
  32620. }
  32621. };
  32622. RecognitionException.prototype.toString = function () {
  32623. return this.message;
  32624. };
  32625. function LexerNoViableAltException(lexer, input, startIndex, deadEndConfigs) {
  32626. RecognitionException.call(this, { message: "", recognizer: lexer, input: input, ctx: null });
  32627. this.startIndex = startIndex;
  32628. this.deadEndConfigs = deadEndConfigs;
  32629. return this;
  32630. }
  32631. LexerNoViableAltException.prototype = Object.create(RecognitionException.prototype);
  32632. LexerNoViableAltException.prototype.constructor = LexerNoViableAltException;
  32633. LexerNoViableAltException.prototype.toString = function () {
  32634. var symbol = "";
  32635. if (this.startIndex >= 0 && this.startIndex < this.input.size) {
  32636. symbol = this.input.getText((this.startIndex, this.startIndex));
  32637. }
  32638. return "LexerNoViableAltException" + symbol;
  32639. };
  32640. // Indicates that the parser could not decide which of two or more paths
  32641. // to take based upon the remaining input. It tracks the starting token
  32642. // of the offending input and also knows where the parser was
  32643. // in the various paths when the error. Reported by reportNoViableAlternative()
  32644. //
  32645. function NoViableAltException(recognizer, input, startToken, offendingToken, deadEndConfigs, ctx) {
  32646. ctx = ctx || recognizer._ctx;
  32647. offendingToken = offendingToken || recognizer.getCurrentToken();
  32648. startToken = startToken || recognizer.getCurrentToken();
  32649. input = input || recognizer.getInputStream();
  32650. RecognitionException.call(this, { message: "", recognizer: recognizer, input: input, ctx: ctx });
  32651. // Which configurations did we try at input.index() that couldn't match
  32652. // input.LT(1)?//
  32653. this.deadEndConfigs = deadEndConfigs;
  32654. // The token object at the start index; the input stream might
  32655. // not be buffering tokens so get a reference to it. (At the
  32656. // time the error occurred, of course the stream needs to keep a
  32657. // buffer all of the tokens but later we might not have access to those.)
  32658. this.startToken = startToken;
  32659. this.offendingToken = offendingToken;
  32660. }
  32661. NoViableAltException.prototype = Object.create(RecognitionException.prototype);
  32662. NoViableAltException.prototype.constructor = NoViableAltException;
  32663. // This signifies any kind of mismatched input exceptions such as
  32664. // when the current input does not match the expected token.
  32665. //
  32666. function InputMismatchException(recognizer) {
  32667. RecognitionException.call(this, { message: "", recognizer: recognizer, input: recognizer.getInputStream(), ctx: recognizer._ctx });
  32668. this.offendingToken = recognizer.getCurrentToken();
  32669. }
  32670. InputMismatchException.prototype = Object.create(RecognitionException.prototype);
  32671. InputMismatchException.prototype.constructor = InputMismatchException;
  32672. // A semantic predicate failed during validation. Validation of predicates
  32673. // occurs when normally parsing the alternative just like matching a token.
  32674. // Disambiguating predicate evaluation occurs when we test a predicate during
  32675. // prediction.
  32676. function FailedPredicateException(recognizer, predicate, message) {
  32677. RecognitionException.call(this, { message: this.formatMessage(predicate, message || null), recognizer: recognizer,
  32678. input: recognizer.getInputStream(), ctx: recognizer._ctx });
  32679. var s = recognizer._interp.atn.states[recognizer.state];
  32680. var trans = s.transitions[0];
  32681. if (trans instanceof PredicateTransition) {
  32682. this.ruleIndex = trans.ruleIndex;
  32683. this.predicateIndex = trans.predIndex;
  32684. } else {
  32685. this.ruleIndex = 0;
  32686. this.predicateIndex = 0;
  32687. }
  32688. this.predicate = predicate;
  32689. this.offendingToken = recognizer.getCurrentToken();
  32690. return this;
  32691. }
  32692. FailedPredicateException.prototype = Object.create(RecognitionException.prototype);
  32693. FailedPredicateException.prototype.constructor = FailedPredicateException;
  32694. FailedPredicateException.prototype.formatMessage = function (predicate, message) {
  32695. if (message !== null) {
  32696. return message;
  32697. } else {
  32698. return "failed predicate: {" + predicate + "}?";
  32699. }
  32700. };
  32701. function ParseCancellationException() {
  32702. Error.call(this);
  32703. Error.captureStackTrace(this, ParseCancellationException);
  32704. return this;
  32705. }
  32706. ParseCancellationException.prototype = Object.create(Error.prototype);
  32707. ParseCancellationException.prototype.constructor = ParseCancellationException;
  32708. exports.RecognitionException = RecognitionException;
  32709. exports.NoViableAltException = NoViableAltException;
  32710. exports.LexerNoViableAltException = LexerNoViableAltException;
  32711. exports.InputMismatchException = InputMismatchException;
  32712. exports.FailedPredicateException = FailedPredicateException;
  32713. exports.ParseCancellationException = ParseCancellationException;
  32714. /***/ }),
  32715. /***/ "./node_modules/antlr4/error/index.js":
  32716. /*!********************************************!*\
  32717. !*** ./node_modules/antlr4/error/index.js ***!
  32718. \********************************************/
  32719. /*! no static exports found */
  32720. /***/ (function(module, exports, __webpack_require__) {
  32721. "use strict";
  32722. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  32723. * Use of this file is governed by the BSD 3-clause license that
  32724. * can be found in the LICENSE.txt file in the project root.
  32725. */
  32726. exports.RecognitionException = __webpack_require__(/*! ./Errors */ "./node_modules/antlr4/error/Errors.js").RecognitionException;
  32727. exports.NoViableAltException = __webpack_require__(/*! ./Errors */ "./node_modules/antlr4/error/Errors.js").NoViableAltException;
  32728. exports.LexerNoViableAltException = __webpack_require__(/*! ./Errors */ "./node_modules/antlr4/error/Errors.js").LexerNoViableAltException;
  32729. exports.InputMismatchException = __webpack_require__(/*! ./Errors */ "./node_modules/antlr4/error/Errors.js").InputMismatchException;
  32730. exports.FailedPredicateException = __webpack_require__(/*! ./Errors */ "./node_modules/antlr4/error/Errors.js").FailedPredicateException;
  32731. exports.DiagnosticErrorListener = __webpack_require__(/*! ./DiagnosticErrorListener */ "./node_modules/antlr4/error/DiagnosticErrorListener.js").DiagnosticErrorListener;
  32732. exports.BailErrorStrategy = __webpack_require__(/*! ./ErrorStrategy */ "./node_modules/antlr4/error/ErrorStrategy.js").BailErrorStrategy;
  32733. exports.ErrorListener = __webpack_require__(/*! ./ErrorListener */ "./node_modules/antlr4/error/ErrorListener.js").ErrorListener;
  32734. /***/ }),
  32735. /***/ "./node_modules/antlr4/index.js":
  32736. /*!**************************************!*\
  32737. !*** ./node_modules/antlr4/index.js ***!
  32738. \**************************************/
  32739. /*! no static exports found */
  32740. /***/ (function(module, exports, __webpack_require__) {
  32741. "use strict";
  32742. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  32743. * Use of this file is governed by the BSD 3-clause license that
  32744. * can be found in the LICENSE.txt file in the project root.
  32745. */
  32746. exports.atn = __webpack_require__(/*! ./atn/index */ "./node_modules/antlr4/atn/index.js");
  32747. exports.codepointat = __webpack_require__(/*! ./polyfills/codepointat */ "./node_modules/antlr4/polyfills/codepointat.js");
  32748. exports.dfa = __webpack_require__(/*! ./dfa/index */ "./node_modules/antlr4/dfa/index.js");
  32749. exports.fromcodepoint = __webpack_require__(/*! ./polyfills/fromcodepoint */ "./node_modules/antlr4/polyfills/fromcodepoint.js");
  32750. exports.tree = __webpack_require__(/*! ./tree/index */ "./node_modules/antlr4/tree/index.js");
  32751. exports.error = __webpack_require__(/*! ./error/index */ "./node_modules/antlr4/error/index.js");
  32752. exports.Token = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").Token;
  32753. exports.CharStreams = __webpack_require__(/*! ./CharStreams */ "./node_modules/antlr4/CharStreams.js").CharStreams;
  32754. exports.CommonToken = __webpack_require__(/*! ./Token */ "./node_modules/antlr4/Token.js").CommonToken;
  32755. exports.InputStream = __webpack_require__(/*! ./InputStream */ "./node_modules/antlr4/InputStream.js").InputStream;
  32756. exports.FileStream = __webpack_require__(/*! ./FileStream */ "./node_modules/antlr4/FileStream.js").FileStream;
  32757. exports.CommonTokenStream = __webpack_require__(/*! ./CommonTokenStream */ "./node_modules/antlr4/CommonTokenStream.js").CommonTokenStream;
  32758. exports.Lexer = __webpack_require__(/*! ./Lexer */ "./node_modules/antlr4/Lexer.js").Lexer;
  32759. exports.Parser = __webpack_require__(/*! ./Parser */ "./node_modules/antlr4/Parser.js").Parser;
  32760. var pc = __webpack_require__(/*! ./PredictionContext */ "./node_modules/antlr4/PredictionContext.js");
  32761. exports.PredictionContextCache = pc.PredictionContextCache;
  32762. exports.ParserRuleContext = __webpack_require__(/*! ./ParserRuleContext */ "./node_modules/antlr4/ParserRuleContext.js").ParserRuleContext;
  32763. exports.Interval = __webpack_require__(/*! ./IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  32764. exports.Utils = __webpack_require__(/*! ./Utils */ "./node_modules/antlr4/Utils.js");
  32765. /***/ }),
  32766. /***/ "./node_modules/antlr4/polyfills/codepointat.js":
  32767. /*!******************************************************!*\
  32768. !*** ./node_modules/antlr4/polyfills/codepointat.js ***!
  32769. \******************************************************/
  32770. /*! no static exports found */
  32771. /***/ (function(module, exports, __webpack_require__) {
  32772. "use strict";
  32773. /*! https://mths.be/codepointat v0.2.0 by @mathias */
  32774. if (!String.prototype.codePointAt) {
  32775. (function () {
  32776. 'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
  32777. var defineProperty = function () {
  32778. // IE 8 only supports `Object.defineProperty` on DOM elements
  32779. try {
  32780. var object = {};
  32781. var $defineProperty = Object.defineProperty;
  32782. var result = $defineProperty(object, object, object) && $defineProperty;
  32783. } catch (error) {}
  32784. return result;
  32785. }();
  32786. var codePointAt = function codePointAt(position) {
  32787. if (this == null) {
  32788. throw TypeError();
  32789. }
  32790. var string = String(this);
  32791. var size = string.length;
  32792. // `ToInteger`
  32793. var index = position ? Number(position) : 0;
  32794. if (index != index) {
  32795. // better `isNaN`
  32796. index = 0;
  32797. }
  32798. // Account for out-of-bounds indices:
  32799. if (index < 0 || index >= size) {
  32800. return undefined;
  32801. }
  32802. // Get the first code unit
  32803. var first = string.charCodeAt(index);
  32804. var second;
  32805. if ( // check if it’s the start of a surrogate pair
  32806. first >= 0xD800 && first <= 0xDBFF && // high surrogate
  32807. size > index + 1 // there is a next code unit
  32808. ) {
  32809. second = string.charCodeAt(index + 1);
  32810. if (second >= 0xDC00 && second <= 0xDFFF) {
  32811. // low surrogate
  32812. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  32813. return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
  32814. }
  32815. }
  32816. return first;
  32817. };
  32818. if (defineProperty) {
  32819. defineProperty(String.prototype, 'codePointAt', {
  32820. 'value': codePointAt,
  32821. 'configurable': true,
  32822. 'writable': true
  32823. });
  32824. } else {
  32825. String.prototype.codePointAt = codePointAt;
  32826. }
  32827. })();
  32828. }
  32829. /***/ }),
  32830. /***/ "./node_modules/antlr4/polyfills/fromcodepoint.js":
  32831. /*!********************************************************!*\
  32832. !*** ./node_modules/antlr4/polyfills/fromcodepoint.js ***!
  32833. \********************************************************/
  32834. /*! no static exports found */
  32835. /***/ (function(module, exports, __webpack_require__) {
  32836. "use strict";
  32837. /*! https://mths.be/fromcodepoint v0.2.1 by @mathias */
  32838. if (!String.fromCodePoint) {
  32839. (function () {
  32840. var defineProperty = function () {
  32841. // IE 8 only supports `Object.defineProperty` on DOM elements
  32842. try {
  32843. var object = {};
  32844. var $defineProperty = Object.defineProperty;
  32845. var result = $defineProperty(object, object, object) && $defineProperty;
  32846. } catch (error) {}
  32847. return result;
  32848. }();
  32849. var stringFromCharCode = String.fromCharCode;
  32850. var floor = Math.floor;
  32851. var fromCodePoint = function fromCodePoint(_) {
  32852. var MAX_SIZE = 0x4000;
  32853. var codeUnits = [];
  32854. var highSurrogate;
  32855. var lowSurrogate;
  32856. var index = -1;
  32857. var length = arguments.length;
  32858. if (!length) {
  32859. return '';
  32860. }
  32861. var result = '';
  32862. while (++index < length) {
  32863. var codePoint = Number(arguments[index]);
  32864. if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  32865. codePoint < 0 || // not a valid Unicode code point
  32866. codePoint > 0x10FFFF || // not a valid Unicode code point
  32867. floor(codePoint) != codePoint // not an integer
  32868. ) {
  32869. throw RangeError('Invalid code point: ' + codePoint);
  32870. }
  32871. if (codePoint <= 0xFFFF) {
  32872. // BMP code point
  32873. codeUnits.push(codePoint);
  32874. } else {
  32875. // Astral code point; split in surrogate halves
  32876. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  32877. codePoint -= 0x10000;
  32878. highSurrogate = (codePoint >> 10) + 0xD800;
  32879. lowSurrogate = codePoint % 0x400 + 0xDC00;
  32880. codeUnits.push(highSurrogate, lowSurrogate);
  32881. }
  32882. if (index + 1 == length || codeUnits.length > MAX_SIZE) {
  32883. result += stringFromCharCode.apply(null, codeUnits);
  32884. codeUnits.length = 0;
  32885. }
  32886. }
  32887. return result;
  32888. };
  32889. if (defineProperty) {
  32890. defineProperty(String, 'fromCodePoint', {
  32891. 'value': fromCodePoint,
  32892. 'configurable': true,
  32893. 'writable': true
  32894. });
  32895. } else {
  32896. String.fromCodePoint = fromCodePoint;
  32897. }
  32898. })();
  32899. }
  32900. /***/ }),
  32901. /***/ "./node_modules/antlr4/tree/Tree.js":
  32902. /*!******************************************!*\
  32903. !*** ./node_modules/antlr4/tree/Tree.js ***!
  32904. \******************************************/
  32905. /*! no static exports found */
  32906. /***/ (function(module, exports, __webpack_require__) {
  32907. "use strict";
  32908. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  32909. * Use of this file is governed by the BSD 3-clause license that
  32910. * can be found in the LICENSE.txt file in the project root.
  32911. */
  32912. ///
  32913. // The basic notion of a tree has a parent, a payload, and a list of children.
  32914. // It is the most abstract interface for all the trees used by ANTLR.
  32915. ///
  32916. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  32917. var Interval = __webpack_require__(/*! ./../IntervalSet */ "./node_modules/antlr4/IntervalSet.js").Interval;
  32918. var INVALID_INTERVAL = new Interval(-1, -2);
  32919. var Utils = __webpack_require__(/*! ../Utils.js */ "./node_modules/antlr4/Utils.js");
  32920. function Tree() {
  32921. return this;
  32922. }
  32923. function SyntaxTree() {
  32924. Tree.call(this);
  32925. return this;
  32926. }
  32927. SyntaxTree.prototype = Object.create(Tree.prototype);
  32928. SyntaxTree.prototype.constructor = SyntaxTree;
  32929. function ParseTree() {
  32930. SyntaxTree.call(this);
  32931. return this;
  32932. }
  32933. ParseTree.prototype = Object.create(SyntaxTree.prototype);
  32934. ParseTree.prototype.constructor = ParseTree;
  32935. function RuleNode() {
  32936. ParseTree.call(this);
  32937. return this;
  32938. }
  32939. RuleNode.prototype = Object.create(ParseTree.prototype);
  32940. RuleNode.prototype.constructor = RuleNode;
  32941. function TerminalNode() {
  32942. ParseTree.call(this);
  32943. return this;
  32944. }
  32945. TerminalNode.prototype = Object.create(ParseTree.prototype);
  32946. TerminalNode.prototype.constructor = TerminalNode;
  32947. function ErrorNode() {
  32948. TerminalNode.call(this);
  32949. return this;
  32950. }
  32951. ErrorNode.prototype = Object.create(TerminalNode.prototype);
  32952. ErrorNode.prototype.constructor = ErrorNode;
  32953. function ParseTreeVisitor() {
  32954. return this;
  32955. }
  32956. ParseTreeVisitor.prototype.visit = function (ctx) {
  32957. if (Array.isArray(ctx)) {
  32958. return ctx.map(function (child) {
  32959. return child.accept(this);
  32960. }, this);
  32961. } else {
  32962. return ctx.accept(this);
  32963. }
  32964. };
  32965. ParseTreeVisitor.prototype.visitChildren = function (ctx) {
  32966. return this.visit(ctx.children);
  32967. };
  32968. ParseTreeVisitor.prototype.visitTerminal = function (node) {};
  32969. ParseTreeVisitor.prototype.visitErrorNode = function (node) {};
  32970. function ParseTreeListener() {
  32971. return this;
  32972. }
  32973. ParseTreeListener.prototype.visitTerminal = function (node) {};
  32974. ParseTreeListener.prototype.visitErrorNode = function (node) {};
  32975. ParseTreeListener.prototype.enterEveryRule = function (node) {};
  32976. ParseTreeListener.prototype.exitEveryRule = function (node) {};
  32977. function TerminalNodeImpl(symbol) {
  32978. TerminalNode.call(this);
  32979. this.parentCtx = null;
  32980. this.symbol = symbol;
  32981. return this;
  32982. }
  32983. TerminalNodeImpl.prototype = Object.create(TerminalNode.prototype);
  32984. TerminalNodeImpl.prototype.constructor = TerminalNodeImpl;
  32985. TerminalNodeImpl.prototype.getChild = function (i) {
  32986. return null;
  32987. };
  32988. TerminalNodeImpl.prototype.getSymbol = function () {
  32989. return this.symbol;
  32990. };
  32991. TerminalNodeImpl.prototype.getParent = function () {
  32992. return this.parentCtx;
  32993. };
  32994. TerminalNodeImpl.prototype.getPayload = function () {
  32995. return this.symbol;
  32996. };
  32997. TerminalNodeImpl.prototype.getSourceInterval = function () {
  32998. if (this.symbol === null) {
  32999. return INVALID_INTERVAL;
  33000. }
  33001. var tokenIndex = this.symbol.tokenIndex;
  33002. return new Interval(tokenIndex, tokenIndex);
  33003. };
  33004. TerminalNodeImpl.prototype.getChildCount = function () {
  33005. return 0;
  33006. };
  33007. TerminalNodeImpl.prototype.accept = function (visitor) {
  33008. return visitor.visitTerminal(this);
  33009. };
  33010. TerminalNodeImpl.prototype.getText = function () {
  33011. return this.symbol.text;
  33012. };
  33013. TerminalNodeImpl.prototype.toString = function () {
  33014. if (this.symbol.type === Token.EOF) {
  33015. return "<EOF>";
  33016. } else {
  33017. return this.symbol.text;
  33018. }
  33019. };
  33020. // Represents a token that was consumed during resynchronization
  33021. // rather than during a valid match operation. For example,
  33022. // we will create this kind of a node during single token insertion
  33023. // and deletion as well as during "consume until error recovery set"
  33024. // upon no viable alternative exceptions.
  33025. function ErrorNodeImpl(token) {
  33026. TerminalNodeImpl.call(this, token);
  33027. return this;
  33028. }
  33029. ErrorNodeImpl.prototype = Object.create(TerminalNodeImpl.prototype);
  33030. ErrorNodeImpl.prototype.constructor = ErrorNodeImpl;
  33031. ErrorNodeImpl.prototype.isErrorNode = function () {
  33032. return true;
  33033. };
  33034. ErrorNodeImpl.prototype.accept = function (visitor) {
  33035. return visitor.visitErrorNode(this);
  33036. };
  33037. function ParseTreeWalker() {
  33038. return this;
  33039. }
  33040. ParseTreeWalker.prototype.walk = function (listener, t) {
  33041. var errorNode = t instanceof ErrorNode || t.isErrorNode !== undefined && t.isErrorNode();
  33042. if (errorNode) {
  33043. listener.visitErrorNode(t);
  33044. } else if (t instanceof TerminalNode) {
  33045. listener.visitTerminal(t);
  33046. } else {
  33047. this.enterRule(listener, t);
  33048. for (var i = 0; i < t.getChildCount(); i++) {
  33049. var child = t.getChild(i);
  33050. this.walk(listener, child);
  33051. }
  33052. this.exitRule(listener, t);
  33053. }
  33054. };
  33055. //
  33056. // The discovery of a rule node, involves sending two events: the generic
  33057. // {@link ParseTreeListener//enterEveryRule} and a
  33058. // {@link RuleContext}-specific event. First we trigger the generic and then
  33059. // the rule specific. We to them in reverse order upon finishing the node.
  33060. //
  33061. ParseTreeWalker.prototype.enterRule = function (listener, r) {
  33062. var ctx = r.getRuleContext();
  33063. listener.enterEveryRule(ctx);
  33064. ctx.enterRule(listener);
  33065. };
  33066. ParseTreeWalker.prototype.exitRule = function (listener, r) {
  33067. var ctx = r.getRuleContext();
  33068. ctx.exitRule(listener);
  33069. listener.exitEveryRule(ctx);
  33070. };
  33071. ParseTreeWalker.DEFAULT = new ParseTreeWalker();
  33072. exports.RuleNode = RuleNode;
  33073. exports.ErrorNode = ErrorNode;
  33074. exports.TerminalNode = TerminalNode;
  33075. exports.ErrorNodeImpl = ErrorNodeImpl;
  33076. exports.TerminalNodeImpl = TerminalNodeImpl;
  33077. exports.ParseTreeListener = ParseTreeListener;
  33078. exports.ParseTreeVisitor = ParseTreeVisitor;
  33079. exports.ParseTreeWalker = ParseTreeWalker;
  33080. exports.INVALID_INTERVAL = INVALID_INTERVAL;
  33081. /***/ }),
  33082. /***/ "./node_modules/antlr4/tree/Trees.js":
  33083. /*!*******************************************!*\
  33084. !*** ./node_modules/antlr4/tree/Trees.js ***!
  33085. \*******************************************/
  33086. /*! no static exports found */
  33087. /***/ (function(module, exports, __webpack_require__) {
  33088. "use strict";
  33089. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  33090. * Use of this file is governed by the BSD 3-clause license that
  33091. * can be found in the LICENSE.txt file in the project root.
  33092. */
  33093. var Utils = __webpack_require__(/*! ./../Utils */ "./node_modules/antlr4/Utils.js");
  33094. var Token = __webpack_require__(/*! ./../Token */ "./node_modules/antlr4/Token.js").Token;
  33095. var RuleNode = __webpack_require__(/*! ./Tree */ "./node_modules/antlr4/tree/Tree.js").RuleNode;
  33096. var ErrorNode = __webpack_require__(/*! ./Tree */ "./node_modules/antlr4/tree/Tree.js").ErrorNode;
  33097. var TerminalNode = __webpack_require__(/*! ./Tree */ "./node_modules/antlr4/tree/Tree.js").TerminalNode;
  33098. var ParserRuleContext = __webpack_require__(/*! ./../ParserRuleContext */ "./node_modules/antlr4/ParserRuleContext.js").ParserRuleContext;
  33099. var RuleContext = __webpack_require__(/*! ./../RuleContext */ "./node_modules/antlr4/RuleContext.js").RuleContext;
  33100. var INVALID_ALT_NUMBER = __webpack_require__(/*! ./../atn/ATN */ "./node_modules/antlr4/atn/ATN.js").INVALID_ALT_NUMBER;
  33101. /** A set of utility routines useful for all kinds of ANTLR trees. */
  33102. function Trees() {}
  33103. // Print out a whole tree in LISP form. {@link //getNodeText} is used on the
  33104. // node payloads to get the text for the nodes. Detect
  33105. // parse trees and extract data appropriately.
  33106. Trees.toStringTree = function (tree, ruleNames, recog) {
  33107. ruleNames = ruleNames || null;
  33108. recog = recog || null;
  33109. if (recog !== null) {
  33110. ruleNames = recog.ruleNames;
  33111. }
  33112. var s = Trees.getNodeText(tree, ruleNames);
  33113. s = Utils.escapeWhitespace(s, false);
  33114. var c = tree.getChildCount();
  33115. if (c === 0) {
  33116. return s;
  33117. }
  33118. var res = "(" + s + ' ';
  33119. if (c > 0) {
  33120. s = Trees.toStringTree(tree.getChild(0), ruleNames);
  33121. res = res.concat(s);
  33122. }
  33123. for (var i = 1; i < c; i++) {
  33124. s = Trees.toStringTree(tree.getChild(i), ruleNames);
  33125. res = res.concat(' ' + s);
  33126. }
  33127. res = res.concat(")");
  33128. return res;
  33129. };
  33130. Trees.getNodeText = function (t, ruleNames, recog) {
  33131. ruleNames = ruleNames || null;
  33132. recog = recog || null;
  33133. if (recog !== null) {
  33134. ruleNames = recog.ruleNames;
  33135. }
  33136. if (ruleNames !== null) {
  33137. if (t instanceof RuleContext) {
  33138. var altNumber = t.getAltNumber();
  33139. if (altNumber != INVALID_ALT_NUMBER) {
  33140. return ruleNames[t.ruleIndex] + ":" + altNumber;
  33141. }
  33142. return ruleNames[t.ruleIndex];
  33143. } else if (t instanceof ErrorNode) {
  33144. return t.toString();
  33145. } else if (t instanceof TerminalNode) {
  33146. if (t.symbol !== null) {
  33147. return t.symbol.text;
  33148. }
  33149. }
  33150. }
  33151. // no recog for rule names
  33152. var payload = t.getPayload();
  33153. if (payload instanceof Token) {
  33154. return payload.text;
  33155. }
  33156. return t.getPayload().toString();
  33157. };
  33158. // Return ordered list of all children of this node
  33159. Trees.getChildren = function (t) {
  33160. var list = [];
  33161. for (var i = 0; i < t.getChildCount(); i++) {
  33162. list.push(t.getChild(i));
  33163. }
  33164. return list;
  33165. };
  33166. // Return a list of all ancestors of this node. The first node of
  33167. // list is the root and the last is the parent of this node.
  33168. //
  33169. Trees.getAncestors = function (t) {
  33170. var ancestors = [];
  33171. t = t.getParent();
  33172. while (t !== null) {
  33173. ancestors = [t].concat(ancestors);
  33174. t = t.getParent();
  33175. }
  33176. return ancestors;
  33177. };
  33178. Trees.findAllTokenNodes = function (t, ttype) {
  33179. return Trees.findAllNodes(t, ttype, true);
  33180. };
  33181. Trees.findAllRuleNodes = function (t, ruleIndex) {
  33182. return Trees.findAllNodes(t, ruleIndex, false);
  33183. };
  33184. Trees.findAllNodes = function (t, index, findTokens) {
  33185. var nodes = [];
  33186. Trees._findAllNodes(t, index, findTokens, nodes);
  33187. return nodes;
  33188. };
  33189. Trees._findAllNodes = function (t, index, findTokens, nodes) {
  33190. // check this node (the root) first
  33191. if (findTokens && t instanceof TerminalNode) {
  33192. if (t.symbol.type === index) {
  33193. nodes.push(t);
  33194. }
  33195. } else if (!findTokens && t instanceof ParserRuleContext) {
  33196. if (t.ruleIndex === index) {
  33197. nodes.push(t);
  33198. }
  33199. }
  33200. // check children
  33201. for (var i = 0; i < t.getChildCount(); i++) {
  33202. Trees._findAllNodes(t.getChild(i), index, findTokens, nodes);
  33203. }
  33204. };
  33205. Trees.descendants = function (t) {
  33206. var nodes = [t];
  33207. for (var i = 0; i < t.getChildCount(); i++) {
  33208. nodes = nodes.concat(Trees.descendants(t.getChild(i)));
  33209. }
  33210. return nodes;
  33211. };
  33212. exports.Trees = Trees;
  33213. /***/ }),
  33214. /***/ "./node_modules/antlr4/tree/index.js":
  33215. /*!*******************************************!*\
  33216. !*** ./node_modules/antlr4/tree/index.js ***!
  33217. \*******************************************/
  33218. /*! no static exports found */
  33219. /***/ (function(module, exports, __webpack_require__) {
  33220. "use strict";
  33221. /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  33222. * Use of this file is governed by the BSD 3-clause license that
  33223. * can be found in the LICENSE.txt file in the project root.
  33224. */
  33225. var Tree = __webpack_require__(/*! ./Tree */ "./node_modules/antlr4/tree/Tree.js");
  33226. exports.Trees = __webpack_require__(/*! ./Trees */ "./node_modules/antlr4/tree/Trees.js").Trees;
  33227. exports.RuleNode = Tree.RuleNode;
  33228. exports.ParseTreeListener = Tree.ParseTreeListener;
  33229. exports.ParseTreeVisitor = Tree.ParseTreeVisitor;
  33230. exports.ParseTreeWalker = Tree.ParseTreeWalker;
  33231. /***/ }),
  33232. /***/ "./node_modules/decimal.js/decimal.js":
  33233. /*!********************************************!*\
  33234. !*** ./node_modules/decimal.js/decimal.js ***!
  33235. \********************************************/
  33236. /*! no static exports found */
  33237. /***/ (function(module, exports, __webpack_require__) {
  33238. "use strict";
  33239. var __WEBPACK_AMD_DEFINE_RESULT__;
  33240. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  33241. /*! decimal.js v10.0.1 https://github.com/MikeMcl/decimal.js/LICENCE */
  33242. ;(function (globalScope) {
  33243. 'use strict';
  33244. /*
  33245. * decimal.js v10.0.1
  33246. * An arbitrary-precision Decimal type for JavaScript.
  33247. * https://github.com/MikeMcl/decimal.js
  33248. * Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
  33249. * MIT Licence
  33250. */
  33251. // ----------------------------------- EDITABLE DEFAULTS ------------------------------------ //
  33252. // The maximum exponent magnitude.
  33253. // The limit on the value of `toExpNeg`, `toExpPos`, `minE` and `maxE`.
  33254. var EXP_LIMIT = 9e15,
  33255. // 0 to 9e15
  33256. // The limit on the value of `precision`, and on the value of the first argument to
  33257. // `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`.
  33258. MAX_DIGITS = 1e9,
  33259. // 0 to 1e9
  33260. // Base conversion alphabet.
  33261. NUMERALS = '0123456789abcdef',
  33262. // The natural logarithm of 10 (1025 digits).
  33263. LN10 = '2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058',
  33264. // Pi (1025 digits).
  33265. PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789',
  33266. // The initial configuration properties of the Decimal constructor.
  33267. DEFAULTS = {
  33268. // These values must be integers within the stated ranges (inclusive).
  33269. // Most of these values can be changed at run-time using the `Decimal.config` method.
  33270. // The maximum number of significant digits of the result of a calculation or base conversion.
  33271. // E.g. `Decimal.config({ precision: 20 });`
  33272. precision: 20, // 1 to MAX_DIGITS
  33273. // The rounding mode used when rounding to `precision`.
  33274. //
  33275. // ROUND_UP 0 Away from zero.
  33276. // ROUND_DOWN 1 Towards zero.
  33277. // ROUND_CEIL 2 Towards +Infinity.
  33278. // ROUND_FLOOR 3 Towards -Infinity.
  33279. // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
  33280. // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
  33281. // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
  33282. // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
  33283. // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  33284. //
  33285. // E.g.
  33286. // `Decimal.rounding = 4;`
  33287. // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
  33288. rounding: 4, // 0 to 8
  33289. // The modulo mode used when calculating the modulus: a mod n.
  33290. // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  33291. // The remainder (r) is calculated as: r = a - n * q.
  33292. //
  33293. // UP 0 The remainder is positive if the dividend is negative, else is negative.
  33294. // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
  33295. // FLOOR 3 The remainder has the same sign as the divisor (Python %).
  33296. // HALF_EVEN 6 The IEEE 754 remainder function.
  33297. // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
  33298. //
  33299. // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
  33300. // division (9) are commonly used for the modulus operation. The other rounding modes can also
  33301. // be used, but they may not give useful results.
  33302. modulo: 1, // 0 to 9
  33303. // The exponent value at and beneath which `toString` returns exponential notation.
  33304. // JavaScript numbers: -7
  33305. toExpNeg: -7, // 0 to -EXP_LIMIT
  33306. // The exponent value at and above which `toString` returns exponential notation.
  33307. // JavaScript numbers: 21
  33308. toExpPos: 21, // 0 to EXP_LIMIT
  33309. // The minimum exponent value, beneath which underflow to zero occurs.
  33310. // JavaScript numbers: -324 (5e-324)
  33311. minE: -EXP_LIMIT, // -1 to -EXP_LIMIT
  33312. // The maximum exponent value, above which overflow to Infinity occurs.
  33313. // JavaScript numbers: 308 (1.7976931348623157e+308)
  33314. maxE: EXP_LIMIT, // 1 to EXP_LIMIT
  33315. // Whether to use cryptographically-secure random number generation, if available.
  33316. crypto: false // true/false
  33317. },
  33318. // ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- //
  33319. Decimal,
  33320. inexact,
  33321. noConflict,
  33322. quadrant,
  33323. external = true,
  33324. decimalError = '[DecimalError] ',
  33325. invalidArgument = decimalError + 'Invalid argument: ',
  33326. precisionLimitExceeded = decimalError + 'Precision limit exceeded',
  33327. cryptoUnavailable = decimalError + 'crypto unavailable',
  33328. mathfloor = Math.floor,
  33329. mathpow = Math.pow,
  33330. isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,
  33331. isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,
  33332. isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,
  33333. isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
  33334. BASE = 1e7,
  33335. LOG_BASE = 7,
  33336. MAX_SAFE_INTEGER = 9007199254740991,
  33337. LN10_PRECISION = LN10.length - 1,
  33338. PI_PRECISION = PI.length - 1,
  33339. // Decimal.prototype object
  33340. P = { name: '[object Decimal]' };
  33341. // Decimal prototype methods
  33342. /*
  33343. * absoluteValue abs
  33344. * ceil
  33345. * comparedTo cmp
  33346. * cosine cos
  33347. * cubeRoot cbrt
  33348. * decimalPlaces dp
  33349. * dividedBy div
  33350. * dividedToIntegerBy divToInt
  33351. * equals eq
  33352. * floor
  33353. * greaterThan gt
  33354. * greaterThanOrEqualTo gte
  33355. * hyperbolicCosine cosh
  33356. * hyperbolicSine sinh
  33357. * hyperbolicTangent tanh
  33358. * inverseCosine acos
  33359. * inverseHyperbolicCosine acosh
  33360. * inverseHyperbolicSine asinh
  33361. * inverseHyperbolicTangent atanh
  33362. * inverseSine asin
  33363. * inverseTangent atan
  33364. * isFinite
  33365. * isInteger isInt
  33366. * isNaN
  33367. * isNegative isNeg
  33368. * isPositive isPos
  33369. * isZero
  33370. * lessThan lt
  33371. * lessThanOrEqualTo lte
  33372. * logarithm log
  33373. * [maximum] [max]
  33374. * [minimum] [min]
  33375. * minus sub
  33376. * modulo mod
  33377. * naturalExponential exp
  33378. * naturalLogarithm ln
  33379. * negated neg
  33380. * plus add
  33381. * precision sd
  33382. * round
  33383. * sine sin
  33384. * squareRoot sqrt
  33385. * tangent tan
  33386. * times mul
  33387. * toBinary
  33388. * toDecimalPlaces toDP
  33389. * toExponential
  33390. * toFixed
  33391. * toFraction
  33392. * toHexadecimal toHex
  33393. * toNearest
  33394. * toNumber
  33395. * toOctal
  33396. * toPower pow
  33397. * toPrecision
  33398. * toSignificantDigits toSD
  33399. * toString
  33400. * truncated trunc
  33401. * valueOf toJSON
  33402. */
  33403. /*
  33404. * Return a new Decimal whose value is the absolute value of this Decimal.
  33405. *
  33406. */
  33407. P.absoluteValue = P.abs = function () {
  33408. var x = new this.constructor(this);
  33409. if (x.s < 0) x.s = 1;
  33410. return finalise(x);
  33411. };
  33412. /*
  33413. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
  33414. * direction of positive Infinity.
  33415. *
  33416. */
  33417. P.ceil = function () {
  33418. return finalise(new this.constructor(this), this.e + 1, 2);
  33419. };
  33420. /*
  33421. * Return
  33422. * 1 if the value of this Decimal is greater than the value of `y`,
  33423. * -1 if the value of this Decimal is less than the value of `y`,
  33424. * 0 if they have the same value,
  33425. * NaN if the value of either Decimal is NaN.
  33426. *
  33427. */
  33428. P.comparedTo = P.cmp = function (y) {
  33429. var i,
  33430. j,
  33431. xdL,
  33432. ydL,
  33433. x = this,
  33434. xd = x.d,
  33435. yd = (y = new x.constructor(y)).d,
  33436. xs = x.s,
  33437. ys = y.s;
  33438. // Either NaN or ±Infinity?
  33439. if (!xd || !yd) {
  33440. return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
  33441. }
  33442. // Either zero?
  33443. if (!xd[0] || !yd[0]) return xd[0] ? xs : yd[0] ? -ys : 0;
  33444. // Signs differ?
  33445. if (xs !== ys) return xs;
  33446. // Compare exponents.
  33447. if (x.e !== y.e) return x.e > y.e ^ xs < 0 ? 1 : -1;
  33448. xdL = xd.length;
  33449. ydL = yd.length;
  33450. // Compare digit by digit.
  33451. for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
  33452. if (xd[i] !== yd[i]) return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
  33453. }
  33454. // Compare lengths.
  33455. return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
  33456. };
  33457. /*
  33458. * Return a new Decimal whose value is the cosine of the value in radians of this Decimal.
  33459. *
  33460. * Domain: [-Infinity, Infinity]
  33461. * Range: [-1, 1]
  33462. *
  33463. * cos(0) = 1
  33464. * cos(-0) = 1
  33465. * cos(Infinity) = NaN
  33466. * cos(-Infinity) = NaN
  33467. * cos(NaN) = NaN
  33468. *
  33469. */
  33470. P.cosine = P.cos = function () {
  33471. var pr,
  33472. rm,
  33473. x = this,
  33474. Ctor = x.constructor;
  33475. if (!x.d) return new Ctor(NaN);
  33476. // cos(0) = cos(-0) = 1
  33477. if (!x.d[0]) return new Ctor(1);
  33478. pr = Ctor.precision;
  33479. rm = Ctor.rounding;
  33480. Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
  33481. Ctor.rounding = 1;
  33482. x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
  33483. Ctor.precision = pr;
  33484. Ctor.rounding = rm;
  33485. return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
  33486. };
  33487. /*
  33488. *
  33489. * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to
  33490. * `precision` significant digits using rounding mode `rounding`.
  33491. *
  33492. * cbrt(0) = 0
  33493. * cbrt(-0) = -0
  33494. * cbrt(1) = 1
  33495. * cbrt(-1) = -1
  33496. * cbrt(N) = N
  33497. * cbrt(-I) = -I
  33498. * cbrt(I) = I
  33499. *
  33500. * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3))
  33501. *
  33502. */
  33503. P.cubeRoot = P.cbrt = function () {
  33504. var e,
  33505. m,
  33506. n,
  33507. r,
  33508. rep,
  33509. s,
  33510. sd,
  33511. t,
  33512. t3,
  33513. t3plusx,
  33514. x = this,
  33515. Ctor = x.constructor;
  33516. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  33517. external = false;
  33518. // Initial estimate.
  33519. s = x.s * Math.pow(x.s * x, 1 / 3);
  33520. // Math.cbrt underflow/overflow?
  33521. // Pass x to Math.pow as integer, then adjust the exponent of the result.
  33522. if (!s || Math.abs(s) == 1 / 0) {
  33523. n = digitsToString(x.d);
  33524. e = x.e;
  33525. // Adjust n exponent so it is a multiple of 3 away from x exponent.
  33526. if (s = (e - n.length + 1) % 3) n += s == 1 || s == -2 ? '0' : '00';
  33527. s = Math.pow(n, 1 / 3);
  33528. // Rarely, e may be one less than the result exponent value.
  33529. e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
  33530. if (s == 1 / 0) {
  33531. n = '5e' + e;
  33532. } else {
  33533. n = s.toExponential();
  33534. n = n.slice(0, n.indexOf('e') + 1) + e;
  33535. }
  33536. r = new Ctor(n);
  33537. r.s = x.s;
  33538. } else {
  33539. r = new Ctor(s.toString());
  33540. }
  33541. sd = (e = Ctor.precision) + 3;
  33542. // Halley's method.
  33543. // TODO? Compare Newton's method.
  33544. for (;;) {
  33545. t = r;
  33546. t3 = t.times(t).times(t);
  33547. t3plusx = t3.plus(x);
  33548. r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
  33549. // TODO? Replace with for-loop and checkRoundingDigits.
  33550. if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
  33551. n = n.slice(sd - 3, sd + 1);
  33552. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or 4999
  33553. // , i.e. approaching a rounding boundary, continue the iteration.
  33554. if (n == '9999' || !rep && n == '4999') {
  33555. // On the first iteration only, check to see if rounding up gives the exact result as the
  33556. // nines may infinitely repeat.
  33557. if (!rep) {
  33558. finalise(t, e + 1, 0);
  33559. if (t.times(t).times(t).eq(x)) {
  33560. r = t;
  33561. break;
  33562. }
  33563. }
  33564. sd += 4;
  33565. rep = 1;
  33566. } else {
  33567. // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
  33568. // If not, then there are further digits and m will be truthy.
  33569. if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
  33570. // Truncate to the first rounding digit.
  33571. finalise(r, e + 1, 1);
  33572. m = !r.times(r).times(r).eq(x);
  33573. }
  33574. break;
  33575. }
  33576. }
  33577. }
  33578. external = true;
  33579. return finalise(r, e, Ctor.rounding, m);
  33580. };
  33581. /*
  33582. * Return the number of decimal places of the value of this Decimal.
  33583. *
  33584. */
  33585. P.decimalPlaces = P.dp = function () {
  33586. var w,
  33587. d = this.d,
  33588. n = NaN;
  33589. if (d) {
  33590. w = d.length - 1;
  33591. n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
  33592. // Subtract the number of trailing zeros of the last word.
  33593. w = d[w];
  33594. if (w) for (; w % 10 == 0; w /= 10) {
  33595. n--;
  33596. }if (n < 0) n = 0;
  33597. }
  33598. return n;
  33599. };
  33600. /*
  33601. * n / 0 = I
  33602. * n / N = N
  33603. * n / I = 0
  33604. * 0 / n = 0
  33605. * 0 / 0 = N
  33606. * 0 / N = N
  33607. * 0 / I = 0
  33608. * N / n = N
  33609. * N / 0 = N
  33610. * N / N = N
  33611. * N / I = N
  33612. * I / n = I
  33613. * I / 0 = I
  33614. * I / N = N
  33615. * I / I = N
  33616. *
  33617. * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to
  33618. * `precision` significant digits using rounding mode `rounding`.
  33619. *
  33620. */
  33621. P.dividedBy = P.div = function (y) {
  33622. return divide(this, new this.constructor(y));
  33623. };
  33624. /*
  33625. * Return a new Decimal whose value is the integer part of dividing the value of this Decimal
  33626. * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`.
  33627. *
  33628. */
  33629. P.dividedToIntegerBy = P.divToInt = function (y) {
  33630. var x = this,
  33631. Ctor = x.constructor;
  33632. return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
  33633. };
  33634. /*
  33635. * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false.
  33636. *
  33637. */
  33638. P.equals = P.eq = function (y) {
  33639. return this.cmp(y) === 0;
  33640. };
  33641. /*
  33642. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
  33643. * direction of negative Infinity.
  33644. *
  33645. */
  33646. P.floor = function () {
  33647. return finalise(new this.constructor(this), this.e + 1, 3);
  33648. };
  33649. /*
  33650. * Return true if the value of this Decimal is greater than the value of `y`, otherwise return
  33651. * false.
  33652. *
  33653. */
  33654. P.greaterThan = P.gt = function (y) {
  33655. return this.cmp(y) > 0;
  33656. };
  33657. /*
  33658. * Return true if the value of this Decimal is greater than or equal to the value of `y`,
  33659. * otherwise return false.
  33660. *
  33661. */
  33662. P.greaterThanOrEqualTo = P.gte = function (y) {
  33663. var k = this.cmp(y);
  33664. return k == 1 || k === 0;
  33665. };
  33666. /*
  33667. * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this
  33668. * Decimal.
  33669. *
  33670. * Domain: [-Infinity, Infinity]
  33671. * Range: [1, Infinity]
  33672. *
  33673. * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ...
  33674. *
  33675. * cosh(0) = 1
  33676. * cosh(-0) = 1
  33677. * cosh(Infinity) = Infinity
  33678. * cosh(-Infinity) = Infinity
  33679. * cosh(NaN) = NaN
  33680. *
  33681. * x time taken (ms) result
  33682. * 1000 9 9.8503555700852349694e+433
  33683. * 10000 25 4.4034091128314607936e+4342
  33684. * 100000 171 1.4033316802130615897e+43429
  33685. * 1000000 3817 1.5166076984010437725e+434294
  33686. * 10000000 abandoned after 2 minute wait
  33687. *
  33688. * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x))
  33689. *
  33690. */
  33691. P.hyperbolicCosine = P.cosh = function () {
  33692. var k,
  33693. n,
  33694. pr,
  33695. rm,
  33696. len,
  33697. x = this,
  33698. Ctor = x.constructor,
  33699. one = new Ctor(1);
  33700. if (!x.isFinite()) return new Ctor(x.s ? 1 / 0 : NaN);
  33701. if (x.isZero()) return one;
  33702. pr = Ctor.precision;
  33703. rm = Ctor.rounding;
  33704. Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
  33705. Ctor.rounding = 1;
  33706. len = x.d.length;
  33707. // Argument reduction: cos(4x) = 1 - 8cos^2(x) + 8cos^4(x) + 1
  33708. // i.e. cos(x) = 1 - cos^2(x/4)(8 - 8cos^2(x/4))
  33709. // Estimate the optimum number of times to use the argument reduction.
  33710. // TODO? Estimation reused from cosine() and may not be optimal here.
  33711. if (len < 32) {
  33712. k = Math.ceil(len / 3);
  33713. n = Math.pow(4, -k).toString();
  33714. } else {
  33715. k = 16;
  33716. n = '2.3283064365386962890625e-10';
  33717. }
  33718. x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
  33719. // Reverse argument reduction
  33720. var cosh2_x,
  33721. i = k,
  33722. d8 = new Ctor(8);
  33723. for (; i--;) {
  33724. cosh2_x = x.times(x);
  33725. x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
  33726. }
  33727. return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
  33728. };
  33729. /*
  33730. * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this
  33731. * Decimal.
  33732. *
  33733. * Domain: [-Infinity, Infinity]
  33734. * Range: [-Infinity, Infinity]
  33735. *
  33736. * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ...
  33737. *
  33738. * sinh(0) = 0
  33739. * sinh(-0) = -0
  33740. * sinh(Infinity) = Infinity
  33741. * sinh(-Infinity) = -Infinity
  33742. * sinh(NaN) = NaN
  33743. *
  33744. * x time taken (ms)
  33745. * 10 2 ms
  33746. * 100 5 ms
  33747. * 1000 14 ms
  33748. * 10000 82 ms
  33749. * 100000 886 ms 1.4033316802130615897e+43429
  33750. * 200000 2613 ms
  33751. * 300000 5407 ms
  33752. * 400000 8824 ms
  33753. * 500000 13026 ms 8.7080643612718084129e+217146
  33754. * 1000000 48543 ms
  33755. *
  33756. * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x))
  33757. *
  33758. */
  33759. P.hyperbolicSine = P.sinh = function () {
  33760. var k,
  33761. pr,
  33762. rm,
  33763. len,
  33764. x = this,
  33765. Ctor = x.constructor;
  33766. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  33767. pr = Ctor.precision;
  33768. rm = Ctor.rounding;
  33769. Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
  33770. Ctor.rounding = 1;
  33771. len = x.d.length;
  33772. if (len < 3) {
  33773. x = taylorSeries(Ctor, 2, x, x, true);
  33774. } else {
  33775. // Alternative argument reduction: sinh(3x) = sinh(x)(3 + 4sinh^2(x))
  33776. // i.e. sinh(x) = sinh(x/3)(3 + 4sinh^2(x/3))
  33777. // 3 multiplications and 1 addition
  33778. // Argument reduction: sinh(5x) = sinh(x)(5 + sinh^2(x)(20 + 16sinh^2(x)))
  33779. // i.e. sinh(x) = sinh(x/5)(5 + sinh^2(x/5)(20 + 16sinh^2(x/5)))
  33780. // 4 multiplications and 2 additions
  33781. // Estimate the optimum number of times to use the argument reduction.
  33782. k = 1.4 * Math.sqrt(len);
  33783. k = k > 16 ? 16 : k | 0;
  33784. x = x.times(Math.pow(5, -k));
  33785. x = taylorSeries(Ctor, 2, x, x, true);
  33786. // Reverse argument reduction
  33787. var sinh2_x,
  33788. d5 = new Ctor(5),
  33789. d16 = new Ctor(16),
  33790. d20 = new Ctor(20);
  33791. for (; k--;) {
  33792. sinh2_x = x.times(x);
  33793. x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
  33794. }
  33795. }
  33796. Ctor.precision = pr;
  33797. Ctor.rounding = rm;
  33798. return finalise(x, pr, rm, true);
  33799. };
  33800. /*
  33801. * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this
  33802. * Decimal.
  33803. *
  33804. * Domain: [-Infinity, Infinity]
  33805. * Range: [-1, 1]
  33806. *
  33807. * tanh(x) = sinh(x) / cosh(x)
  33808. *
  33809. * tanh(0) = 0
  33810. * tanh(-0) = -0
  33811. * tanh(Infinity) = 1
  33812. * tanh(-Infinity) = -1
  33813. * tanh(NaN) = NaN
  33814. *
  33815. */
  33816. P.hyperbolicTangent = P.tanh = function () {
  33817. var pr,
  33818. rm,
  33819. x = this,
  33820. Ctor = x.constructor;
  33821. if (!x.isFinite()) return new Ctor(x.s);
  33822. if (x.isZero()) return new Ctor(x);
  33823. pr = Ctor.precision;
  33824. rm = Ctor.rounding;
  33825. Ctor.precision = pr + 7;
  33826. Ctor.rounding = 1;
  33827. return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
  33828. };
  33829. /*
  33830. * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of
  33831. * this Decimal.
  33832. *
  33833. * Domain: [-1, 1]
  33834. * Range: [0, pi]
  33835. *
  33836. * acos(x) = pi/2 - asin(x)
  33837. *
  33838. * acos(0) = pi/2
  33839. * acos(-0) = pi/2
  33840. * acos(1) = 0
  33841. * acos(-1) = pi
  33842. * acos(1/2) = pi/3
  33843. * acos(-1/2) = 2*pi/3
  33844. * acos(|x| > 1) = NaN
  33845. * acos(NaN) = NaN
  33846. *
  33847. */
  33848. P.inverseCosine = P.acos = function () {
  33849. var halfPi,
  33850. x = this,
  33851. Ctor = x.constructor,
  33852. k = x.abs().cmp(1),
  33853. pr = Ctor.precision,
  33854. rm = Ctor.rounding;
  33855. if (k !== -1) {
  33856. return k === 0
  33857. // |x| is 1
  33858. ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0)
  33859. // |x| > 1 or x is NaN
  33860. : new Ctor(NaN);
  33861. }
  33862. if (x.isZero()) return getPi(Ctor, pr + 4, rm).times(0.5);
  33863. // TODO? Special case acos(0.5) = pi/3 and acos(-0.5) = 2*pi/3
  33864. Ctor.precision = pr + 6;
  33865. Ctor.rounding = 1;
  33866. x = x.asin();
  33867. halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
  33868. Ctor.precision = pr;
  33869. Ctor.rounding = rm;
  33870. return halfPi.minus(x);
  33871. };
  33872. /*
  33873. * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the
  33874. * value of this Decimal.
  33875. *
  33876. * Domain: [1, Infinity]
  33877. * Range: [0, Infinity]
  33878. *
  33879. * acosh(x) = ln(x + sqrt(x^2 - 1))
  33880. *
  33881. * acosh(x < 1) = NaN
  33882. * acosh(NaN) = NaN
  33883. * acosh(Infinity) = Infinity
  33884. * acosh(-Infinity) = NaN
  33885. * acosh(0) = NaN
  33886. * acosh(-0) = NaN
  33887. * acosh(1) = 0
  33888. * acosh(-1) = NaN
  33889. *
  33890. */
  33891. P.inverseHyperbolicCosine = P.acosh = function () {
  33892. var pr,
  33893. rm,
  33894. x = this,
  33895. Ctor = x.constructor;
  33896. if (x.lte(1)) return new Ctor(x.eq(1) ? 0 : NaN);
  33897. if (!x.isFinite()) return new Ctor(x);
  33898. pr = Ctor.precision;
  33899. rm = Ctor.rounding;
  33900. Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
  33901. Ctor.rounding = 1;
  33902. external = false;
  33903. x = x.times(x).minus(1).sqrt().plus(x);
  33904. external = true;
  33905. Ctor.precision = pr;
  33906. Ctor.rounding = rm;
  33907. return x.ln();
  33908. };
  33909. /*
  33910. * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value
  33911. * of this Decimal.
  33912. *
  33913. * Domain: [-Infinity, Infinity]
  33914. * Range: [-Infinity, Infinity]
  33915. *
  33916. * asinh(x) = ln(x + sqrt(x^2 + 1))
  33917. *
  33918. * asinh(NaN) = NaN
  33919. * asinh(Infinity) = Infinity
  33920. * asinh(-Infinity) = -Infinity
  33921. * asinh(0) = 0
  33922. * asinh(-0) = -0
  33923. *
  33924. */
  33925. P.inverseHyperbolicSine = P.asinh = function () {
  33926. var pr,
  33927. rm,
  33928. x = this,
  33929. Ctor = x.constructor;
  33930. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  33931. pr = Ctor.precision;
  33932. rm = Ctor.rounding;
  33933. Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
  33934. Ctor.rounding = 1;
  33935. external = false;
  33936. x = x.times(x).plus(1).sqrt().plus(x);
  33937. external = true;
  33938. Ctor.precision = pr;
  33939. Ctor.rounding = rm;
  33940. return x.ln();
  33941. };
  33942. /*
  33943. * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the
  33944. * value of this Decimal.
  33945. *
  33946. * Domain: [-1, 1]
  33947. * Range: [-Infinity, Infinity]
  33948. *
  33949. * atanh(x) = 0.5 * ln((1 + x) / (1 - x))
  33950. *
  33951. * atanh(|x| > 1) = NaN
  33952. * atanh(NaN) = NaN
  33953. * atanh(Infinity) = NaN
  33954. * atanh(-Infinity) = NaN
  33955. * atanh(0) = 0
  33956. * atanh(-0) = -0
  33957. * atanh(1) = Infinity
  33958. * atanh(-1) = -Infinity
  33959. *
  33960. */
  33961. P.inverseHyperbolicTangent = P.atanh = function () {
  33962. var pr,
  33963. rm,
  33964. wpr,
  33965. xsd,
  33966. x = this,
  33967. Ctor = x.constructor;
  33968. if (!x.isFinite()) return new Ctor(NaN);
  33969. if (x.e >= 0) return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
  33970. pr = Ctor.precision;
  33971. rm = Ctor.rounding;
  33972. xsd = x.sd();
  33973. if (Math.max(xsd, pr) < 2 * -x.e - 1) return finalise(new Ctor(x), pr, rm, true);
  33974. Ctor.precision = wpr = xsd - x.e;
  33975. x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
  33976. Ctor.precision = pr + 4;
  33977. Ctor.rounding = 1;
  33978. x = x.ln();
  33979. Ctor.precision = pr;
  33980. Ctor.rounding = rm;
  33981. return x.times(0.5);
  33982. };
  33983. /*
  33984. * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this
  33985. * Decimal.
  33986. *
  33987. * Domain: [-Infinity, Infinity]
  33988. * Range: [-pi/2, pi/2]
  33989. *
  33990. * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2)))
  33991. *
  33992. * asin(0) = 0
  33993. * asin(-0) = -0
  33994. * asin(1/2) = pi/6
  33995. * asin(-1/2) = -pi/6
  33996. * asin(1) = pi/2
  33997. * asin(-1) = -pi/2
  33998. * asin(|x| > 1) = NaN
  33999. * asin(NaN) = NaN
  34000. *
  34001. * TODO? Compare performance of Taylor series.
  34002. *
  34003. */
  34004. P.inverseSine = P.asin = function () {
  34005. var halfPi,
  34006. k,
  34007. pr,
  34008. rm,
  34009. x = this,
  34010. Ctor = x.constructor;
  34011. if (x.isZero()) return new Ctor(x);
  34012. k = x.abs().cmp(1);
  34013. pr = Ctor.precision;
  34014. rm = Ctor.rounding;
  34015. if (k !== -1) {
  34016. // |x| is 1
  34017. if (k === 0) {
  34018. halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
  34019. halfPi.s = x.s;
  34020. return halfPi;
  34021. }
  34022. // |x| > 1 or x is NaN
  34023. return new Ctor(NaN);
  34024. }
  34025. // TODO? Special case asin(1/2) = pi/6 and asin(-1/2) = -pi/6
  34026. Ctor.precision = pr + 6;
  34027. Ctor.rounding = 1;
  34028. x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
  34029. Ctor.precision = pr;
  34030. Ctor.rounding = rm;
  34031. return x.times(2);
  34032. };
  34033. /*
  34034. * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value
  34035. * of this Decimal.
  34036. *
  34037. * Domain: [-Infinity, Infinity]
  34038. * Range: [-pi/2, pi/2]
  34039. *
  34040. * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
  34041. *
  34042. * atan(0) = 0
  34043. * atan(-0) = -0
  34044. * atan(1) = pi/4
  34045. * atan(-1) = -pi/4
  34046. * atan(Infinity) = pi/2
  34047. * atan(-Infinity) = -pi/2
  34048. * atan(NaN) = NaN
  34049. *
  34050. */
  34051. P.inverseTangent = P.atan = function () {
  34052. var i,
  34053. j,
  34054. k,
  34055. n,
  34056. px,
  34057. t,
  34058. r,
  34059. wpr,
  34060. x2,
  34061. x = this,
  34062. Ctor = x.constructor,
  34063. pr = Ctor.precision,
  34064. rm = Ctor.rounding;
  34065. if (!x.isFinite()) {
  34066. if (!x.s) return new Ctor(NaN);
  34067. if (pr + 4 <= PI_PRECISION) {
  34068. r = getPi(Ctor, pr + 4, rm).times(0.5);
  34069. r.s = x.s;
  34070. return r;
  34071. }
  34072. } else if (x.isZero()) {
  34073. return new Ctor(x);
  34074. } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
  34075. r = getPi(Ctor, pr + 4, rm).times(0.25);
  34076. r.s = x.s;
  34077. return r;
  34078. }
  34079. Ctor.precision = wpr = pr + 10;
  34080. Ctor.rounding = 1;
  34081. // TODO? if (x >= 1 && pr <= PI_PRECISION) atan(x) = halfPi * x.s - atan(1 / x);
  34082. // Argument reduction
  34083. // Ensure |x| < 0.42
  34084. // atan(x) = 2 * atan(x / (1 + sqrt(1 + x^2)))
  34085. k = Math.min(28, wpr / LOG_BASE + 2 | 0);
  34086. for (i = k; i; --i) {
  34087. x = x.div(x.times(x).plus(1).sqrt().plus(1));
  34088. }external = false;
  34089. j = Math.ceil(wpr / LOG_BASE);
  34090. n = 1;
  34091. x2 = x.times(x);
  34092. r = new Ctor(x);
  34093. px = x;
  34094. // atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
  34095. for (; i !== -1;) {
  34096. px = px.times(x2);
  34097. t = r.minus(px.div(n += 2));
  34098. px = px.times(x2);
  34099. r = t.plus(px.div(n += 2));
  34100. if (r.d[j] !== void 0) for (i = j; r.d[i] === t.d[i] && i--;) {}
  34101. }
  34102. if (k) r = r.times(2 << k - 1);
  34103. external = true;
  34104. return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
  34105. };
  34106. /*
  34107. * Return true if the value of this Decimal is a finite number, otherwise return false.
  34108. *
  34109. */
  34110. P.isFinite = function () {
  34111. return !!this.d;
  34112. };
  34113. /*
  34114. * Return true if the value of this Decimal is an integer, otherwise return false.
  34115. *
  34116. */
  34117. P.isInteger = P.isInt = function () {
  34118. return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
  34119. };
  34120. /*
  34121. * Return true if the value of this Decimal is NaN, otherwise return false.
  34122. *
  34123. */
  34124. P.isNaN = function () {
  34125. return !this.s;
  34126. };
  34127. /*
  34128. * Return true if the value of this Decimal is negative, otherwise return false.
  34129. *
  34130. */
  34131. P.isNegative = P.isNeg = function () {
  34132. return this.s < 0;
  34133. };
  34134. /*
  34135. * Return true if the value of this Decimal is positive, otherwise return false.
  34136. *
  34137. */
  34138. P.isPositive = P.isPos = function () {
  34139. return this.s > 0;
  34140. };
  34141. /*
  34142. * Return true if the value of this Decimal is 0 or -0, otherwise return false.
  34143. *
  34144. */
  34145. P.isZero = function () {
  34146. return !!this.d && this.d[0] === 0;
  34147. };
  34148. /*
  34149. * Return true if the value of this Decimal is less than `y`, otherwise return false.
  34150. *
  34151. */
  34152. P.lessThan = P.lt = function (y) {
  34153. return this.cmp(y) < 0;
  34154. };
  34155. /*
  34156. * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false.
  34157. *
  34158. */
  34159. P.lessThanOrEqualTo = P.lte = function (y) {
  34160. return this.cmp(y) < 1;
  34161. };
  34162. /*
  34163. * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision`
  34164. * significant digits using rounding mode `rounding`.
  34165. *
  34166. * If no base is specified, return log[10](arg).
  34167. *
  34168. * log[base](arg) = ln(arg) / ln(base)
  34169. *
  34170. * The result will always be correctly rounded if the base of the log is 10, and 'almost always'
  34171. * otherwise:
  34172. *
  34173. * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen
  34174. * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error
  34175. * between the result and the correctly rounded result will be one ulp (unit in the last place).
  34176. *
  34177. * log[-b](a) = NaN
  34178. * log[0](a) = NaN
  34179. * log[1](a) = NaN
  34180. * log[NaN](a) = NaN
  34181. * log[Infinity](a) = NaN
  34182. * log[b](0) = -Infinity
  34183. * log[b](-0) = -Infinity
  34184. * log[b](-a) = NaN
  34185. * log[b](1) = 0
  34186. * log[b](Infinity) = Infinity
  34187. * log[b](NaN) = NaN
  34188. *
  34189. * [base] {number|string|Decimal} The base of the logarithm.
  34190. *
  34191. */
  34192. P.logarithm = P.log = function (base) {
  34193. var isBase10,
  34194. d,
  34195. denominator,
  34196. k,
  34197. inf,
  34198. num,
  34199. sd,
  34200. r,
  34201. arg = this,
  34202. Ctor = arg.constructor,
  34203. pr = Ctor.precision,
  34204. rm = Ctor.rounding,
  34205. guard = 5;
  34206. // Default base is 10.
  34207. if (base == null) {
  34208. base = new Ctor(10);
  34209. isBase10 = true;
  34210. } else {
  34211. base = new Ctor(base);
  34212. d = base.d;
  34213. // Return NaN if base is negative, or non-finite, or is 0 or 1.
  34214. if (base.s < 0 || !d || !d[0] || base.eq(1)) return new Ctor(NaN);
  34215. isBase10 = base.eq(10);
  34216. }
  34217. d = arg.d;
  34218. // Is arg negative, non-finite, 0 or 1?
  34219. if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
  34220. return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
  34221. }
  34222. // The result will have a non-terminating decimal expansion if base is 10 and arg is not an
  34223. // integer power of 10.
  34224. if (isBase10) {
  34225. if (d.length > 1) {
  34226. inf = true;
  34227. } else {
  34228. for (k = d[0]; k % 10 === 0;) {
  34229. k /= 10;
  34230. }inf = k !== 1;
  34231. }
  34232. }
  34233. external = false;
  34234. sd = pr + guard;
  34235. num = naturalLogarithm(arg, sd);
  34236. denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
  34237. // The result will have 5 rounding digits.
  34238. r = divide(num, denominator, sd, 1);
  34239. // If at a rounding boundary, i.e. the result's rounding digits are [49]9999 or [50]0000,
  34240. // calculate 10 further digits.
  34241. //
  34242. // If the result is known to have an infinite decimal expansion, repeat this until it is clear
  34243. // that the result is above or below the boundary. Otherwise, if after calculating the 10
  34244. // further digits, the last 14 are nines, round up and assume the result is exact.
  34245. // Also assume the result is exact if the last 14 are zero.
  34246. //
  34247. // Example of a result that will be incorrectly rounded:
  34248. // log[1048576](4503599627370502) = 2.60000000000000009610279511444746...
  34249. // The above result correctly rounded using ROUND_CEIL to 1 decimal place should be 2.7, but it
  34250. // will be given as 2.6 as there are 15 zeros immediately after the requested decimal place, so
  34251. // the exact result would be assumed to be 2.6, which rounded using ROUND_CEIL to 1 decimal
  34252. // place is still 2.6.
  34253. if (checkRoundingDigits(r.d, k = pr, rm)) {
  34254. do {
  34255. sd += 10;
  34256. num = naturalLogarithm(arg, sd);
  34257. denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
  34258. r = divide(num, denominator, sd, 1);
  34259. if (!inf) {
  34260. // Check for 14 nines from the 2nd rounding digit, as the first may be 4.
  34261. if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
  34262. r = finalise(r, pr + 1, 0);
  34263. }
  34264. break;
  34265. }
  34266. } while (checkRoundingDigits(r.d, k += 10, rm));
  34267. }
  34268. external = true;
  34269. return finalise(r, pr, rm);
  34270. };
  34271. /*
  34272. * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal.
  34273. *
  34274. * arguments {number|string|Decimal}
  34275. *
  34276. P.max = function () {
  34277. Array.prototype.push.call(arguments, this);
  34278. return maxOrMin(this.constructor, arguments, 'lt');
  34279. };
  34280. */
  34281. /*
  34282. * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal.
  34283. *
  34284. * arguments {number|string|Decimal}
  34285. *
  34286. P.min = function () {
  34287. Array.prototype.push.call(arguments, this);
  34288. return maxOrMin(this.constructor, arguments, 'gt');
  34289. };
  34290. */
  34291. /*
  34292. * n - 0 = n
  34293. * n - N = N
  34294. * n - I = -I
  34295. * 0 - n = -n
  34296. * 0 - 0 = 0
  34297. * 0 - N = N
  34298. * 0 - I = -I
  34299. * N - n = N
  34300. * N - 0 = N
  34301. * N - N = N
  34302. * N - I = N
  34303. * I - n = I
  34304. * I - 0 = I
  34305. * I - N = N
  34306. * I - I = N
  34307. *
  34308. * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision`
  34309. * significant digits using rounding mode `rounding`.
  34310. *
  34311. */
  34312. P.minus = P.sub = function (y) {
  34313. var d,
  34314. e,
  34315. i,
  34316. j,
  34317. k,
  34318. len,
  34319. pr,
  34320. rm,
  34321. xd,
  34322. xe,
  34323. xLTy,
  34324. yd,
  34325. x = this,
  34326. Ctor = x.constructor;
  34327. y = new Ctor(y);
  34328. // If either is not finite...
  34329. if (!x.d || !y.d) {
  34330. // Return NaN if either is NaN.
  34331. if (!x.s || !y.s) y = new Ctor(NaN);
  34332. // Return y negated if x is finite and y is ±Infinity.
  34333. else if (x.d) y.s = -y.s;
  34334. // Return x if y is finite and x is ±Infinity.
  34335. // Return x if both are ±Infinity with different signs.
  34336. // Return NaN if both are ±Infinity with the same sign.
  34337. else y = new Ctor(y.d || x.s !== y.s ? x : NaN);
  34338. return y;
  34339. }
  34340. // If signs differ...
  34341. if (x.s != y.s) {
  34342. y.s = -y.s;
  34343. return x.plus(y);
  34344. }
  34345. xd = x.d;
  34346. yd = y.d;
  34347. pr = Ctor.precision;
  34348. rm = Ctor.rounding;
  34349. // If either is zero...
  34350. if (!xd[0] || !yd[0]) {
  34351. // Return y negated if x is zero and y is non-zero.
  34352. if (yd[0]) y.s = -y.s;
  34353. // Return x if y is zero and x is non-zero.
  34354. else if (xd[0]) y = new Ctor(x);
  34355. // Return zero if both are zero.
  34356. // From IEEE 754 (2008) 6.3: 0 - 0 = -0 - -0 = -0 when rounding to -Infinity.
  34357. else return new Ctor(rm === 3 ? -0 : 0);
  34358. return external ? finalise(y, pr, rm) : y;
  34359. }
  34360. // x and y are finite, non-zero numbers with the same sign.
  34361. // Calculate base 1e7 exponents.
  34362. e = mathfloor(y.e / LOG_BASE);
  34363. xe = mathfloor(x.e / LOG_BASE);
  34364. xd = xd.slice();
  34365. k = xe - e;
  34366. // If base 1e7 exponents differ...
  34367. if (k) {
  34368. xLTy = k < 0;
  34369. if (xLTy) {
  34370. d = xd;
  34371. k = -k;
  34372. len = yd.length;
  34373. } else {
  34374. d = yd;
  34375. e = xe;
  34376. len = xd.length;
  34377. }
  34378. // Numbers with massively different exponents would result in a very high number of
  34379. // zeros needing to be prepended, but this can be avoided while still ensuring correct
  34380. // rounding by limiting the number of zeros to `Math.ceil(pr / LOG_BASE) + 2`.
  34381. i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
  34382. if (k > i) {
  34383. k = i;
  34384. d.length = 1;
  34385. }
  34386. // Prepend zeros to equalise exponents.
  34387. d.reverse();
  34388. for (i = k; i--;) {
  34389. d.push(0);
  34390. }d.reverse();
  34391. // Base 1e7 exponents equal.
  34392. } else {
  34393. // Check digits to determine which is the bigger number.
  34394. i = xd.length;
  34395. len = yd.length;
  34396. xLTy = i < len;
  34397. if (xLTy) len = i;
  34398. for (i = 0; i < len; i++) {
  34399. if (xd[i] != yd[i]) {
  34400. xLTy = xd[i] < yd[i];
  34401. break;
  34402. }
  34403. }
  34404. k = 0;
  34405. }
  34406. if (xLTy) {
  34407. d = xd;
  34408. xd = yd;
  34409. yd = d;
  34410. y.s = -y.s;
  34411. }
  34412. len = xd.length;
  34413. // Append zeros to `xd` if shorter.
  34414. // Don't add zeros to `yd` if shorter as subtraction only needs to start at `yd` length.
  34415. for (i = yd.length - len; i > 0; --i) {
  34416. xd[len++] = 0;
  34417. } // Subtract yd from xd.
  34418. for (i = yd.length; i > k;) {
  34419. if (xd[--i] < yd[i]) {
  34420. for (j = i; j && xd[--j] === 0;) {
  34421. xd[j] = BASE - 1;
  34422. }--xd[j];
  34423. xd[i] += BASE;
  34424. }
  34425. xd[i] -= yd[i];
  34426. }
  34427. // Remove trailing zeros.
  34428. for (; xd[--len] === 0;) {
  34429. xd.pop();
  34430. } // Remove leading zeros and adjust exponent accordingly.
  34431. for (; xd[0] === 0; xd.shift()) {
  34432. --e;
  34433. } // Zero?
  34434. if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0);
  34435. y.d = xd;
  34436. y.e = getBase10Exponent(xd, e);
  34437. return external ? finalise(y, pr, rm) : y;
  34438. };
  34439. /*
  34440. * n % 0 = N
  34441. * n % N = N
  34442. * n % I = n
  34443. * 0 % n = 0
  34444. * -0 % n = -0
  34445. * 0 % 0 = N
  34446. * 0 % N = N
  34447. * 0 % I = 0
  34448. * N % n = N
  34449. * N % 0 = N
  34450. * N % N = N
  34451. * N % I = N
  34452. * I % n = N
  34453. * I % 0 = N
  34454. * I % N = N
  34455. * I % I = N
  34456. *
  34457. * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to
  34458. * `precision` significant digits using rounding mode `rounding`.
  34459. *
  34460. * The result depends on the modulo mode.
  34461. *
  34462. */
  34463. P.modulo = P.mod = function (y) {
  34464. var q,
  34465. x = this,
  34466. Ctor = x.constructor;
  34467. y = new Ctor(y);
  34468. // Return NaN if x is ±Infinity or NaN, or y is NaN or ±0.
  34469. if (!x.d || !y.s || y.d && !y.d[0]) return new Ctor(NaN);
  34470. // Return x if y is ±Infinity or x is ±0.
  34471. if (!y.d || x.d && !x.d[0]) {
  34472. return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
  34473. }
  34474. // Prevent rounding of intermediate calculations.
  34475. external = false;
  34476. if (Ctor.modulo == 9) {
  34477. // Euclidian division: q = sign(y) * floor(x / abs(y))
  34478. // result = x - q * y where 0 <= result < abs(y)
  34479. q = divide(x, y.abs(), 0, 3, 1);
  34480. q.s *= y.s;
  34481. } else {
  34482. q = divide(x, y, 0, Ctor.modulo, 1);
  34483. }
  34484. q = q.times(y);
  34485. external = true;
  34486. return x.minus(q);
  34487. };
  34488. /*
  34489. * Return a new Decimal whose value is the natural exponential of the value of this Decimal,
  34490. * i.e. the base e raised to the power the value of this Decimal, rounded to `precision`
  34491. * significant digits using rounding mode `rounding`.
  34492. *
  34493. */
  34494. P.naturalExponential = P.exp = function () {
  34495. return naturalExponential(this);
  34496. };
  34497. /*
  34498. * Return a new Decimal whose value is the natural logarithm of the value of this Decimal,
  34499. * rounded to `precision` significant digits using rounding mode `rounding`.
  34500. *
  34501. */
  34502. P.naturalLogarithm = P.ln = function () {
  34503. return naturalLogarithm(this);
  34504. };
  34505. /*
  34506. * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by
  34507. * -1.
  34508. *
  34509. */
  34510. P.negated = P.neg = function () {
  34511. var x = new this.constructor(this);
  34512. x.s = -x.s;
  34513. return finalise(x);
  34514. };
  34515. /*
  34516. * n + 0 = n
  34517. * n + N = N
  34518. * n + I = I
  34519. * 0 + n = n
  34520. * 0 + 0 = 0
  34521. * 0 + N = N
  34522. * 0 + I = I
  34523. * N + n = N
  34524. * N + 0 = N
  34525. * N + N = N
  34526. * N + I = N
  34527. * I + n = I
  34528. * I + 0 = I
  34529. * I + N = N
  34530. * I + I = I
  34531. *
  34532. * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision`
  34533. * significant digits using rounding mode `rounding`.
  34534. *
  34535. */
  34536. P.plus = P.add = function (y) {
  34537. var carry,
  34538. d,
  34539. e,
  34540. i,
  34541. k,
  34542. len,
  34543. pr,
  34544. rm,
  34545. xd,
  34546. yd,
  34547. x = this,
  34548. Ctor = x.constructor;
  34549. y = new Ctor(y);
  34550. // If either is not finite...
  34551. if (!x.d || !y.d) {
  34552. // Return NaN if either is NaN.
  34553. if (!x.s || !y.s) y = new Ctor(NaN);
  34554. // Return x if y is finite and x is ±Infinity.
  34555. // Return x if both are ±Infinity with the same sign.
  34556. // Return NaN if both are ±Infinity with different signs.
  34557. // Return y if x is finite and y is ±Infinity.
  34558. else if (!x.d) y = new Ctor(y.d || x.s === y.s ? x : NaN);
  34559. return y;
  34560. }
  34561. // If signs differ...
  34562. if (x.s != y.s) {
  34563. y.s = -y.s;
  34564. return x.minus(y);
  34565. }
  34566. xd = x.d;
  34567. yd = y.d;
  34568. pr = Ctor.precision;
  34569. rm = Ctor.rounding;
  34570. // If either is zero...
  34571. if (!xd[0] || !yd[0]) {
  34572. // Return x if y is zero.
  34573. // Return y if y is non-zero.
  34574. if (!yd[0]) y = new Ctor(x);
  34575. return external ? finalise(y, pr, rm) : y;
  34576. }
  34577. // x and y are finite, non-zero numbers with the same sign.
  34578. // Calculate base 1e7 exponents.
  34579. k = mathfloor(x.e / LOG_BASE);
  34580. e = mathfloor(y.e / LOG_BASE);
  34581. xd = xd.slice();
  34582. i = k - e;
  34583. // If base 1e7 exponents differ...
  34584. if (i) {
  34585. if (i < 0) {
  34586. d = xd;
  34587. i = -i;
  34588. len = yd.length;
  34589. } else {
  34590. d = yd;
  34591. e = k;
  34592. len = xd.length;
  34593. }
  34594. // Limit number of zeros prepended to max(ceil(pr / LOG_BASE), len) + 1.
  34595. k = Math.ceil(pr / LOG_BASE);
  34596. len = k > len ? k + 1 : len + 1;
  34597. if (i > len) {
  34598. i = len;
  34599. d.length = 1;
  34600. }
  34601. // Prepend zeros to equalise exponents. Note: Faster to use reverse then do unshifts.
  34602. d.reverse();
  34603. for (; i--;) {
  34604. d.push(0);
  34605. }d.reverse();
  34606. }
  34607. len = xd.length;
  34608. i = yd.length;
  34609. // If yd is longer than xd, swap xd and yd so xd points to the longer array.
  34610. if (len - i < 0) {
  34611. i = len;
  34612. d = yd;
  34613. yd = xd;
  34614. xd = d;
  34615. }
  34616. // Only start adding at yd.length - 1 as the further digits of xd can be left as they are.
  34617. for (carry = 0; i;) {
  34618. carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
  34619. xd[i] %= BASE;
  34620. }
  34621. if (carry) {
  34622. xd.unshift(carry);
  34623. ++e;
  34624. }
  34625. // Remove trailing zeros.
  34626. // No need to check for zero, as +x + +y != 0 && -x + -y != 0
  34627. for (len = xd.length; xd[--len] == 0;) {
  34628. xd.pop();
  34629. }y.d = xd;
  34630. y.e = getBase10Exponent(xd, e);
  34631. return external ? finalise(y, pr, rm) : y;
  34632. };
  34633. /*
  34634. * Return the number of significant digits of the value of this Decimal.
  34635. *
  34636. * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
  34637. *
  34638. */
  34639. P.precision = P.sd = function (z) {
  34640. var k,
  34641. x = this;
  34642. if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z);
  34643. if (x.d) {
  34644. k = getPrecision(x.d);
  34645. if (z && x.e + 1 > k) k = x.e + 1;
  34646. } else {
  34647. k = NaN;
  34648. }
  34649. return k;
  34650. };
  34651. /*
  34652. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using
  34653. * rounding mode `rounding`.
  34654. *
  34655. */
  34656. P.round = function () {
  34657. var x = this,
  34658. Ctor = x.constructor;
  34659. return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
  34660. };
  34661. /*
  34662. * Return a new Decimal whose value is the sine of the value in radians of this Decimal.
  34663. *
  34664. * Domain: [-Infinity, Infinity]
  34665. * Range: [-1, 1]
  34666. *
  34667. * sin(x) = x - x^3/3! + x^5/5! - ...
  34668. *
  34669. * sin(0) = 0
  34670. * sin(-0) = -0
  34671. * sin(Infinity) = NaN
  34672. * sin(-Infinity) = NaN
  34673. * sin(NaN) = NaN
  34674. *
  34675. */
  34676. P.sine = P.sin = function () {
  34677. var pr,
  34678. rm,
  34679. x = this,
  34680. Ctor = x.constructor;
  34681. if (!x.isFinite()) return new Ctor(NaN);
  34682. if (x.isZero()) return new Ctor(x);
  34683. pr = Ctor.precision;
  34684. rm = Ctor.rounding;
  34685. Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
  34686. Ctor.rounding = 1;
  34687. x = sine(Ctor, toLessThanHalfPi(Ctor, x));
  34688. Ctor.precision = pr;
  34689. Ctor.rounding = rm;
  34690. return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
  34691. };
  34692. /*
  34693. * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision`
  34694. * significant digits using rounding mode `rounding`.
  34695. *
  34696. * sqrt(-n) = N
  34697. * sqrt(N) = N
  34698. * sqrt(-I) = N
  34699. * sqrt(I) = I
  34700. * sqrt(0) = 0
  34701. * sqrt(-0) = -0
  34702. *
  34703. */
  34704. P.squareRoot = P.sqrt = function () {
  34705. var m,
  34706. n,
  34707. sd,
  34708. r,
  34709. rep,
  34710. t,
  34711. x = this,
  34712. d = x.d,
  34713. e = x.e,
  34714. s = x.s,
  34715. Ctor = x.constructor;
  34716. // Negative/NaN/Infinity/zero?
  34717. if (s !== 1 || !d || !d[0]) {
  34718. return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
  34719. }
  34720. external = false;
  34721. // Initial estimate.
  34722. s = Math.sqrt(+x);
  34723. // Math.sqrt underflow/overflow?
  34724. // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
  34725. if (s == 0 || s == 1 / 0) {
  34726. n = digitsToString(d);
  34727. if ((n.length + e) % 2 == 0) n += '0';
  34728. s = Math.sqrt(n);
  34729. e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
  34730. if (s == 1 / 0) {
  34731. n = '1e' + e;
  34732. } else {
  34733. n = s.toExponential();
  34734. n = n.slice(0, n.indexOf('e') + 1) + e;
  34735. }
  34736. r = new Ctor(n);
  34737. } else {
  34738. r = new Ctor(s.toString());
  34739. }
  34740. sd = (e = Ctor.precision) + 3;
  34741. // Newton-Raphson iteration.
  34742. for (;;) {
  34743. t = r;
  34744. r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
  34745. // TODO? Replace with for-loop and checkRoundingDigits.
  34746. if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
  34747. n = n.slice(sd - 3, sd + 1);
  34748. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or
  34749. // 4999, i.e. approaching a rounding boundary, continue the iteration.
  34750. if (n == '9999' || !rep && n == '4999') {
  34751. // On the first iteration only, check to see if rounding up gives the exact result as the
  34752. // nines may infinitely repeat.
  34753. if (!rep) {
  34754. finalise(t, e + 1, 0);
  34755. if (t.times(t).eq(x)) {
  34756. r = t;
  34757. break;
  34758. }
  34759. }
  34760. sd += 4;
  34761. rep = 1;
  34762. } else {
  34763. // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
  34764. // If not, then there are further digits and m will be truthy.
  34765. if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
  34766. // Truncate to the first rounding digit.
  34767. finalise(r, e + 1, 1);
  34768. m = !r.times(r).eq(x);
  34769. }
  34770. break;
  34771. }
  34772. }
  34773. }
  34774. external = true;
  34775. return finalise(r, e, Ctor.rounding, m);
  34776. };
  34777. /*
  34778. * Return a new Decimal whose value is the tangent of the value in radians of this Decimal.
  34779. *
  34780. * Domain: [-Infinity, Infinity]
  34781. * Range: [-Infinity, Infinity]
  34782. *
  34783. * tan(0) = 0
  34784. * tan(-0) = -0
  34785. * tan(Infinity) = NaN
  34786. * tan(-Infinity) = NaN
  34787. * tan(NaN) = NaN
  34788. *
  34789. */
  34790. P.tangent = P.tan = function () {
  34791. var pr,
  34792. rm,
  34793. x = this,
  34794. Ctor = x.constructor;
  34795. if (!x.isFinite()) return new Ctor(NaN);
  34796. if (x.isZero()) return new Ctor(x);
  34797. pr = Ctor.precision;
  34798. rm = Ctor.rounding;
  34799. Ctor.precision = pr + 10;
  34800. Ctor.rounding = 1;
  34801. x = x.sin();
  34802. x.s = 1;
  34803. x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
  34804. Ctor.precision = pr;
  34805. Ctor.rounding = rm;
  34806. return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
  34807. };
  34808. /*
  34809. * n * 0 = 0
  34810. * n * N = N
  34811. * n * I = I
  34812. * 0 * n = 0
  34813. * 0 * 0 = 0
  34814. * 0 * N = N
  34815. * 0 * I = N
  34816. * N * n = N
  34817. * N * 0 = N
  34818. * N * N = N
  34819. * N * I = N
  34820. * I * n = I
  34821. * I * 0 = N
  34822. * I * N = N
  34823. * I * I = I
  34824. *
  34825. * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant
  34826. * digits using rounding mode `rounding`.
  34827. *
  34828. */
  34829. P.times = P.mul = function (y) {
  34830. var carry,
  34831. e,
  34832. i,
  34833. k,
  34834. r,
  34835. rL,
  34836. t,
  34837. xdL,
  34838. ydL,
  34839. x = this,
  34840. Ctor = x.constructor,
  34841. xd = x.d,
  34842. yd = (y = new Ctor(y)).d;
  34843. y.s *= x.s;
  34844. // If either is NaN, ±Infinity or ±0...
  34845. if (!xd || !xd[0] || !yd || !yd[0]) {
  34846. return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd
  34847. // Return NaN if either is NaN.
  34848. // Return NaN if x is ±0 and y is ±Infinity, or y is ±0 and x is ±Infinity.
  34849. ? NaN
  34850. // Return ±Infinity if either is ±Infinity.
  34851. // Return ±0 if either is ±0.
  34852. : !xd || !yd ? y.s / 0 : y.s * 0);
  34853. }
  34854. e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
  34855. xdL = xd.length;
  34856. ydL = yd.length;
  34857. // Ensure xd points to the longer array.
  34858. if (xdL < ydL) {
  34859. r = xd;
  34860. xd = yd;
  34861. yd = r;
  34862. rL = xdL;
  34863. xdL = ydL;
  34864. ydL = rL;
  34865. }
  34866. // Initialise the result array with zeros.
  34867. r = [];
  34868. rL = xdL + ydL;
  34869. for (i = rL; i--;) {
  34870. r.push(0);
  34871. } // Multiply!
  34872. for (i = ydL; --i >= 0;) {
  34873. carry = 0;
  34874. for (k = xdL + i; k > i;) {
  34875. t = r[k] + yd[i] * xd[k - i - 1] + carry;
  34876. r[k--] = t % BASE | 0;
  34877. carry = t / BASE | 0;
  34878. }
  34879. r[k] = (r[k] + carry) % BASE | 0;
  34880. }
  34881. // Remove trailing zeros.
  34882. for (; !r[--rL];) {
  34883. r.pop();
  34884. }if (carry) ++e;else r.shift();
  34885. y.d = r;
  34886. y.e = getBase10Exponent(r, e);
  34887. return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
  34888. };
  34889. /*
  34890. * Return a string representing the value of this Decimal in base 2, round to `sd` significant
  34891. * digits using rounding mode `rm`.
  34892. *
  34893. * If the optional `sd` argument is present then return binary exponential notation.
  34894. *
  34895. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  34896. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  34897. *
  34898. */
  34899. P.toBinary = function (sd, rm) {
  34900. return toStringBinary(this, 2, sd, rm);
  34901. };
  34902. /*
  34903. * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp`
  34904. * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted.
  34905. *
  34906. * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal.
  34907. *
  34908. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  34909. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  34910. *
  34911. */
  34912. P.toDecimalPlaces = P.toDP = function (dp, rm) {
  34913. var x = this,
  34914. Ctor = x.constructor;
  34915. x = new Ctor(x);
  34916. if (dp === void 0) return x;
  34917. checkInt32(dp, 0, MAX_DIGITS);
  34918. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  34919. return finalise(x, dp + x.e + 1, rm);
  34920. };
  34921. /*
  34922. * Return a string representing the value of this Decimal in exponential notation rounded to
  34923. * `dp` fixed decimal places using rounding mode `rounding`.
  34924. *
  34925. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  34926. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  34927. *
  34928. */
  34929. P.toExponential = function (dp, rm) {
  34930. var str,
  34931. x = this,
  34932. Ctor = x.constructor;
  34933. if (dp === void 0) {
  34934. str = finiteToString(x, true);
  34935. } else {
  34936. checkInt32(dp, 0, MAX_DIGITS);
  34937. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  34938. x = finalise(new Ctor(x), dp + 1, rm);
  34939. str = finiteToString(x, true, dp + 1);
  34940. }
  34941. return x.isNeg() && !x.isZero() ? '-' + str : str;
  34942. };
  34943. /*
  34944. * Return a string representing the value of this Decimal in normal (fixed-point) notation to
  34945. * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is
  34946. * omitted.
  34947. *
  34948. * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'.
  34949. *
  34950. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  34951. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  34952. *
  34953. * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
  34954. * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
  34955. * (-0).toFixed(3) is '0.000'.
  34956. * (-0.5).toFixed(0) is '-0'.
  34957. *
  34958. */
  34959. P.toFixed = function (dp, rm) {
  34960. var str,
  34961. y,
  34962. x = this,
  34963. Ctor = x.constructor;
  34964. if (dp === void 0) {
  34965. str = finiteToString(x);
  34966. } else {
  34967. checkInt32(dp, 0, MAX_DIGITS);
  34968. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  34969. y = finalise(new Ctor(x), dp + x.e + 1, rm);
  34970. str = finiteToString(y, false, dp + y.e + 1);
  34971. }
  34972. // To determine whether to add the minus sign look at the value before it was rounded,
  34973. // i.e. look at `x` rather than `y`.
  34974. return x.isNeg() && !x.isZero() ? '-' + str : str;
  34975. };
  34976. /*
  34977. * Return an array representing the value of this Decimal as a simple fraction with an integer
  34978. * numerator and an integer denominator.
  34979. *
  34980. * The denominator will be a positive non-zero value less than or equal to the specified maximum
  34981. * denominator. If a maximum denominator is not specified, the denominator will be the lowest
  34982. * value necessary to represent the number exactly.
  34983. *
  34984. * [maxD] {number|string|Decimal} Maximum denominator. Integer >= 1 and < Infinity.
  34985. *
  34986. */
  34987. P.toFraction = function (maxD) {
  34988. var d,
  34989. d0,
  34990. d1,
  34991. d2,
  34992. e,
  34993. k,
  34994. n,
  34995. n0,
  34996. n1,
  34997. pr,
  34998. q,
  34999. r,
  35000. x = this,
  35001. xd = x.d,
  35002. Ctor = x.constructor;
  35003. if (!xd) return new Ctor(x);
  35004. n1 = d0 = new Ctor(1);
  35005. d1 = n0 = new Ctor(0);
  35006. d = new Ctor(d1);
  35007. e = d.e = getPrecision(xd) - x.e - 1;
  35008. k = e % LOG_BASE;
  35009. d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
  35010. if (maxD == null) {
  35011. // d is 10**e, the minimum max-denominator needed.
  35012. maxD = e > 0 ? d : n1;
  35013. } else {
  35014. n = new Ctor(maxD);
  35015. if (!n.isInt() || n.lt(n1)) throw Error(invalidArgument + n);
  35016. maxD = n.gt(d) ? e > 0 ? d : n1 : n;
  35017. }
  35018. external = false;
  35019. n = new Ctor(digitsToString(xd));
  35020. pr = Ctor.precision;
  35021. Ctor.precision = e = xd.length * LOG_BASE * 2;
  35022. for (;;) {
  35023. q = divide(n, d, 0, 1, 1);
  35024. d2 = d0.plus(q.times(d1));
  35025. if (d2.cmp(maxD) == 1) break;
  35026. d0 = d1;
  35027. d1 = d2;
  35028. d2 = n1;
  35029. n1 = n0.plus(q.times(d2));
  35030. n0 = d2;
  35031. d2 = d;
  35032. d = n.minus(q.times(d2));
  35033. n = d2;
  35034. }
  35035. d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
  35036. n0 = n0.plus(d2.times(n1));
  35037. d0 = d0.plus(d2.times(d1));
  35038. n0.s = n1.s = x.s;
  35039. // Determine which fraction is closer to x, n0/d0 or n1/d1?
  35040. r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
  35041. Ctor.precision = pr;
  35042. external = true;
  35043. return r;
  35044. };
  35045. /*
  35046. * Return a string representing the value of this Decimal in base 16, round to `sd` significant
  35047. * digits using rounding mode `rm`.
  35048. *
  35049. * If the optional `sd` argument is present then return binary exponential notation.
  35050. *
  35051. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  35052. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  35053. *
  35054. */
  35055. P.toHexadecimal = P.toHex = function (sd, rm) {
  35056. return toStringBinary(this, 16, sd, rm);
  35057. };
  35058. /*
  35059. * Returns a new Decimal whose value is the nearest multiple of `y` in the direction of rounding
  35060. * mode `rm`, or `Decimal.rounding` if `rm` is omitted, to the value of this Decimal.
  35061. *
  35062. * The return value will always have the same sign as this Decimal, unless either this Decimal
  35063. * or `y` is NaN, in which case the return value will be also be NaN.
  35064. *
  35065. * The return value is not affected by the value of `precision`.
  35066. *
  35067. * y {number|string|Decimal} The magnitude to round to a multiple of.
  35068. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  35069. *
  35070. * 'toNearest() rounding mode not an integer: {rm}'
  35071. * 'toNearest() rounding mode out of range: {rm}'
  35072. *
  35073. */
  35074. P.toNearest = function (y, rm) {
  35075. var x = this,
  35076. Ctor = x.constructor;
  35077. x = new Ctor(x);
  35078. if (y == null) {
  35079. // If x is not finite, return x.
  35080. if (!x.d) return x;
  35081. y = new Ctor(1);
  35082. rm = Ctor.rounding;
  35083. } else {
  35084. y = new Ctor(y);
  35085. if (rm === void 0) {
  35086. rm = Ctor.rounding;
  35087. } else {
  35088. checkInt32(rm, 0, 8);
  35089. }
  35090. // If x is not finite, return x if y is not NaN, else NaN.
  35091. if (!x.d) return y.s ? x : y;
  35092. // If y is not finite, return Infinity with the sign of x if y is Infinity, else NaN.
  35093. if (!y.d) {
  35094. if (y.s) y.s = x.s;
  35095. return y;
  35096. }
  35097. }
  35098. // If y is not zero, calculate the nearest multiple of y to x.
  35099. if (y.d[0]) {
  35100. external = false;
  35101. x = divide(x, y, 0, rm, 1).times(y);
  35102. external = true;
  35103. finalise(x);
  35104. // If y is zero, return zero with the sign of x.
  35105. } else {
  35106. y.s = x.s;
  35107. x = y;
  35108. }
  35109. return x;
  35110. };
  35111. /*
  35112. * Return the value of this Decimal converted to a number primitive.
  35113. * Zero keeps its sign.
  35114. *
  35115. */
  35116. P.toNumber = function () {
  35117. return +this;
  35118. };
  35119. /*
  35120. * Return a string representing the value of this Decimal in base 8, round to `sd` significant
  35121. * digits using rounding mode `rm`.
  35122. *
  35123. * If the optional `sd` argument is present then return binary exponential notation.
  35124. *
  35125. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  35126. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  35127. *
  35128. */
  35129. P.toOctal = function (sd, rm) {
  35130. return toStringBinary(this, 8, sd, rm);
  35131. };
  35132. /*
  35133. * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded
  35134. * to `precision` significant digits using rounding mode `rounding`.
  35135. *
  35136. * ECMAScript compliant.
  35137. *
  35138. * pow(x, NaN) = NaN
  35139. * pow(x, ±0) = 1
  35140. * pow(NaN, non-zero) = NaN
  35141. * pow(abs(x) > 1, +Infinity) = +Infinity
  35142. * pow(abs(x) > 1, -Infinity) = +0
  35143. * pow(abs(x) == 1, ±Infinity) = NaN
  35144. * pow(abs(x) < 1, +Infinity) = +0
  35145. * pow(abs(x) < 1, -Infinity) = +Infinity
  35146. * pow(+Infinity, y > 0) = +Infinity
  35147. * pow(+Infinity, y < 0) = +0
  35148. * pow(-Infinity, odd integer > 0) = -Infinity
  35149. * pow(-Infinity, even integer > 0) = +Infinity
  35150. * pow(-Infinity, odd integer < 0) = -0
  35151. * pow(-Infinity, even integer < 0) = +0
  35152. * pow(+0, y > 0) = +0
  35153. * pow(+0, y < 0) = +Infinity
  35154. * pow(-0, odd integer > 0) = -0
  35155. * pow(-0, even integer > 0) = +0
  35156. * pow(-0, odd integer < 0) = -Infinity
  35157. * pow(-0, even integer < 0) = +Infinity
  35158. * pow(finite x < 0, finite non-integer) = NaN
  35159. *
  35160. * For non-integer or very large exponents pow(x, y) is calculated using
  35161. *
  35162. * x^y = exp(y*ln(x))
  35163. *
  35164. * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the
  35165. * probability of an incorrectly rounded result
  35166. * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14
  35167. * i.e. 1 in 250,000,000,000,000
  35168. *
  35169. * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place).
  35170. *
  35171. * y {number|string|Decimal} The power to which to raise this Decimal.
  35172. *
  35173. */
  35174. P.toPower = P.pow = function (y) {
  35175. var e,
  35176. k,
  35177. pr,
  35178. r,
  35179. rm,
  35180. s,
  35181. x = this,
  35182. Ctor = x.constructor,
  35183. yn = +(y = new Ctor(y));
  35184. // Either ±Infinity, NaN or ±0?
  35185. if (!x.d || !y.d || !x.d[0] || !y.d[0]) return new Ctor(mathpow(+x, yn));
  35186. x = new Ctor(x);
  35187. if (x.eq(1)) return x;
  35188. pr = Ctor.precision;
  35189. rm = Ctor.rounding;
  35190. if (y.eq(1)) return finalise(x, pr, rm);
  35191. // y exponent
  35192. e = mathfloor(y.e / LOG_BASE);
  35193. // If y is a small integer use the 'exponentiation by squaring' algorithm.
  35194. if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
  35195. r = intPow(Ctor, x, k, pr);
  35196. return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
  35197. }
  35198. s = x.s;
  35199. // if x is negative
  35200. if (s < 0) {
  35201. // if y is not an integer
  35202. if (e < y.d.length - 1) return new Ctor(NaN);
  35203. // Result is positive if x is negative and the last digit of integer y is even.
  35204. if ((y.d[e] & 1) == 0) s = 1;
  35205. // if x.eq(-1)
  35206. if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
  35207. x.s = s;
  35208. return x;
  35209. }
  35210. }
  35211. // Estimate result exponent.
  35212. // x^y = 10^e, where e = y * log10(x)
  35213. // log10(x) = log10(x_significand) + x_exponent
  35214. // log10(x_significand) = ln(x_significand) / ln(10)
  35215. k = mathpow(+x, yn);
  35216. e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log('0.' + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + '').e;
  35217. // Exponent estimate may be incorrect e.g. x: 0.999999999999999999, y: 2.29, e: 0, r.e: -1.
  35218. // Overflow/underflow?
  35219. if (e > Ctor.maxE + 1 || e < Ctor.minE - 1) return new Ctor(e > 0 ? s / 0 : 0);
  35220. external = false;
  35221. Ctor.rounding = x.s = 1;
  35222. // Estimate the extra guard digits needed to ensure five correct rounding digits from
  35223. // naturalLogarithm(x). Example of failure without these extra digits (precision: 10):
  35224. // new Decimal(2.32456).pow('2087987436534566.46411')
  35225. // should be 1.162377823e+764914905173815, but is 1.162355823e+764914905173815
  35226. k = Math.min(12, (e + '').length);
  35227. // r = x^y = exp(y*ln(x))
  35228. r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
  35229. // r may be Infinity, e.g. (0.9999999999999999).pow(-1e+40)
  35230. if (r.d) {
  35231. // Truncate to the required precision plus five rounding digits.
  35232. r = finalise(r, pr + 5, 1);
  35233. // If the rounding digits are [49]9999 or [50]0000 increase the precision by 10 and recalculate
  35234. // the result.
  35235. if (checkRoundingDigits(r.d, pr, rm)) {
  35236. e = pr + 10;
  35237. // Truncate to the increased precision plus five rounding digits.
  35238. r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
  35239. // Check for 14 nines from the 2nd rounding digit (the first rounding digit may be 4 or 9).
  35240. if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
  35241. r = finalise(r, pr + 1, 0);
  35242. }
  35243. }
  35244. }
  35245. r.s = s;
  35246. external = true;
  35247. Ctor.rounding = rm;
  35248. return finalise(r, pr, rm);
  35249. };
  35250. /*
  35251. * Return a string representing the value of this Decimal rounded to `sd` significant digits
  35252. * using rounding mode `rounding`.
  35253. *
  35254. * Return exponential notation if `sd` is less than the number of digits necessary to represent
  35255. * the integer part of the value in normal notation.
  35256. *
  35257. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  35258. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  35259. *
  35260. */
  35261. P.toPrecision = function (sd, rm) {
  35262. var str,
  35263. x = this,
  35264. Ctor = x.constructor;
  35265. if (sd === void 0) {
  35266. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  35267. } else {
  35268. checkInt32(sd, 1, MAX_DIGITS);
  35269. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  35270. x = finalise(new Ctor(x), sd, rm);
  35271. str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
  35272. }
  35273. return x.isNeg() && !x.isZero() ? '-' + str : str;
  35274. };
  35275. /*
  35276. * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd`
  35277. * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if
  35278. * omitted.
  35279. *
  35280. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  35281. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  35282. *
  35283. * 'toSD() digits out of range: {sd}'
  35284. * 'toSD() digits not an integer: {sd}'
  35285. * 'toSD() rounding mode not an integer: {rm}'
  35286. * 'toSD() rounding mode out of range: {rm}'
  35287. *
  35288. */
  35289. P.toSignificantDigits = P.toSD = function (sd, rm) {
  35290. var x = this,
  35291. Ctor = x.constructor;
  35292. if (sd === void 0) {
  35293. sd = Ctor.precision;
  35294. rm = Ctor.rounding;
  35295. } else {
  35296. checkInt32(sd, 1, MAX_DIGITS);
  35297. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  35298. }
  35299. return finalise(new Ctor(x), sd, rm);
  35300. };
  35301. /*
  35302. * Return a string representing the value of this Decimal.
  35303. *
  35304. * Return exponential notation if this Decimal has a positive exponent equal to or greater than
  35305. * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
  35306. *
  35307. */
  35308. P.toString = function () {
  35309. var x = this,
  35310. Ctor = x.constructor,
  35311. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  35312. return x.isNeg() && !x.isZero() ? '-' + str : str;
  35313. };
  35314. /*
  35315. * Return a new Decimal whose value is the value of this Decimal truncated to a whole number.
  35316. *
  35317. */
  35318. P.truncated = P.trunc = function () {
  35319. return finalise(new this.constructor(this), this.e + 1, 1);
  35320. };
  35321. /*
  35322. * Return a string representing the value of this Decimal.
  35323. * Unlike `toString`, negative zero will include the minus sign.
  35324. *
  35325. */
  35326. P.valueOf = P.toJSON = function () {
  35327. var x = this,
  35328. Ctor = x.constructor,
  35329. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  35330. return x.isNeg() ? '-' + str : str;
  35331. };
  35332. /*
  35333. // Add aliases to match BigDecimal method names.
  35334. // P.add = P.plus;
  35335. P.subtract = P.minus;
  35336. P.multiply = P.times;
  35337. P.divide = P.div;
  35338. P.remainder = P.mod;
  35339. P.compareTo = P.cmp;
  35340. P.negate = P.neg;
  35341. */
  35342. // Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers.
  35343. /*
  35344. * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toPower,
  35345. * finiteToString, naturalExponential, naturalLogarithm
  35346. * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest,
  35347. * P.toPrecision, P.toSignificantDigits, toStringBinary, random
  35348. * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm
  35349. * convertBase toStringBinary, parseOther
  35350. * cos P.cos
  35351. * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy,
  35352. * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction,
  35353. * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm,
  35354. * taylorSeries, atan2, parseOther
  35355. * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh,
  35356. * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus,
  35357. * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot,
  35358. * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed,
  35359. * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits,
  35360. * P.truncated, divide, getLn10, getPi, naturalExponential,
  35361. * naturalLogarithm, ceil, floor, round, trunc
  35362. * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf,
  35363. * toStringBinary
  35364. * getBase10Exponent P.minus, P.plus, P.times, parseOther
  35365. * getLn10 P.logarithm, naturalLogarithm
  35366. * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2
  35367. * getPrecision P.precision, P.toFraction
  35368. * getZeroString digitsToString, finiteToString
  35369. * intPow P.toPower, parseOther
  35370. * isOdd toLessThanHalfPi
  35371. * maxOrMin max, min
  35372. * naturalExponential P.naturalExponential, P.toPower
  35373. * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm,
  35374. * P.toPower, naturalExponential
  35375. * nonFiniteToString finiteToString, toStringBinary
  35376. * parseDecimal Decimal
  35377. * parseOther Decimal
  35378. * sin P.sin
  35379. * taylorSeries P.cosh, P.sinh, cos, sin
  35380. * toLessThanHalfPi P.cos, P.sin
  35381. * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal
  35382. * truncate intPow
  35383. *
  35384. * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi,
  35385. * naturalLogarithm, config, parseOther, random, Decimal
  35386. */
  35387. function digitsToString(d) {
  35388. var i,
  35389. k,
  35390. ws,
  35391. indexOfLastWord = d.length - 1,
  35392. str = '',
  35393. w = d[0];
  35394. if (indexOfLastWord > 0) {
  35395. str += w;
  35396. for (i = 1; i < indexOfLastWord; i++) {
  35397. ws = d[i] + '';
  35398. k = LOG_BASE - ws.length;
  35399. if (k) str += getZeroString(k);
  35400. str += ws;
  35401. }
  35402. w = d[i];
  35403. ws = w + '';
  35404. k = LOG_BASE - ws.length;
  35405. if (k) str += getZeroString(k);
  35406. } else if (w === 0) {
  35407. return '0';
  35408. }
  35409. // Remove trailing zeros of last w.
  35410. for (; w % 10 === 0;) {
  35411. w /= 10;
  35412. }return str + w;
  35413. }
  35414. function checkInt32(i, min, max) {
  35415. if (i !== ~~i || i < min || i > max) {
  35416. throw Error(invalidArgument + i);
  35417. }
  35418. }
  35419. /*
  35420. * Check 5 rounding digits if `repeating` is null, 4 otherwise.
  35421. * `repeating == null` if caller is `log` or `pow`,
  35422. * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`.
  35423. */
  35424. function checkRoundingDigits(d, i, rm, repeating) {
  35425. var di, k, r, rd;
  35426. // Get the length of the first word of the array d.
  35427. for (k = d[0]; k >= 10; k /= 10) {
  35428. --i;
  35429. } // Is the rounding digit in the first word of d?
  35430. if (--i < 0) {
  35431. i += LOG_BASE;
  35432. di = 0;
  35433. } else {
  35434. di = Math.ceil((i + 1) / LOG_BASE);
  35435. i %= LOG_BASE;
  35436. }
  35437. // i is the index (0 - 6) of the rounding digit.
  35438. // E.g. if within the word 3487563 the first rounding digit is 5,
  35439. // then i = 4, k = 1000, rd = 3487563 % 1000 = 563
  35440. k = mathpow(10, LOG_BASE - i);
  35441. rd = d[di] % k | 0;
  35442. if (repeating == null) {
  35443. if (i < 3) {
  35444. if (i == 0) rd = rd / 100 | 0;else if (i == 1) rd = rd / 10 | 0;
  35445. r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
  35446. } else {
  35447. r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
  35448. }
  35449. } else {
  35450. if (i < 4) {
  35451. if (i == 0) rd = rd / 1000 | 0;else if (i == 1) rd = rd / 100 | 0;else if (i == 2) rd = rd / 10 | 0;
  35452. r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
  35453. } else {
  35454. r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1;
  35455. }
  35456. }
  35457. return r;
  35458. }
  35459. // Convert string of `baseIn` to an array of numbers of `baseOut`.
  35460. // Eg. convertBase('255', 10, 16) returns [15, 15].
  35461. // Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
  35462. function convertBase(str, baseIn, baseOut) {
  35463. var j,
  35464. arr = [0],
  35465. arrL,
  35466. i = 0,
  35467. strL = str.length;
  35468. for (; i < strL;) {
  35469. for (arrL = arr.length; arrL--;) {
  35470. arr[arrL] *= baseIn;
  35471. }arr[0] += NUMERALS.indexOf(str.charAt(i++));
  35472. for (j = 0; j < arr.length; j++) {
  35473. if (arr[j] > baseOut - 1) {
  35474. if (arr[j + 1] === void 0) arr[j + 1] = 0;
  35475. arr[j + 1] += arr[j] / baseOut | 0;
  35476. arr[j] %= baseOut;
  35477. }
  35478. }
  35479. }
  35480. return arr.reverse();
  35481. }
  35482. /*
  35483. * cos(x) = 1 - x^2/2! + x^4/4! - ...
  35484. * |x| < pi/2
  35485. *
  35486. */
  35487. function cosine(Ctor, x) {
  35488. var k,
  35489. y,
  35490. len = x.d.length;
  35491. // Argument reduction: cos(4x) = 8*(cos^4(x) - cos^2(x)) + 1
  35492. // i.e. cos(x) = 8*(cos^4(x/4) - cos^2(x/4)) + 1
  35493. // Estimate the optimum number of times to use the argument reduction.
  35494. if (len < 32) {
  35495. k = Math.ceil(len / 3);
  35496. y = Math.pow(4, -k).toString();
  35497. } else {
  35498. k = 16;
  35499. y = '2.3283064365386962890625e-10';
  35500. }
  35501. Ctor.precision += k;
  35502. x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
  35503. // Reverse argument reduction
  35504. for (var i = k; i--;) {
  35505. var cos2x = x.times(x);
  35506. x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
  35507. }
  35508. Ctor.precision -= k;
  35509. return x;
  35510. }
  35511. /*
  35512. * Perform division in the specified base.
  35513. */
  35514. var divide = function () {
  35515. // Assumes non-zero x and k, and hence non-zero result.
  35516. function multiplyInteger(x, k, base) {
  35517. var temp,
  35518. carry = 0,
  35519. i = x.length;
  35520. for (x = x.slice(); i--;) {
  35521. temp = x[i] * k + carry;
  35522. x[i] = temp % base | 0;
  35523. carry = temp / base | 0;
  35524. }
  35525. if (carry) x.unshift(carry);
  35526. return x;
  35527. }
  35528. function compare(a, b, aL, bL) {
  35529. var i, r;
  35530. if (aL != bL) {
  35531. r = aL > bL ? 1 : -1;
  35532. } else {
  35533. for (i = r = 0; i < aL; i++) {
  35534. if (a[i] != b[i]) {
  35535. r = a[i] > b[i] ? 1 : -1;
  35536. break;
  35537. }
  35538. }
  35539. }
  35540. return r;
  35541. }
  35542. function subtract(a, b, aL, base) {
  35543. var i = 0;
  35544. // Subtract b from a.
  35545. for (; aL--;) {
  35546. a[aL] -= i;
  35547. i = a[aL] < b[aL] ? 1 : 0;
  35548. a[aL] = i * base + a[aL] - b[aL];
  35549. }
  35550. // Remove leading zeros.
  35551. for (; !a[0] && a.length > 1;) {
  35552. a.shift();
  35553. }
  35554. }
  35555. return function (x, y, pr, rm, dp, base) {
  35556. var cmp,
  35557. e,
  35558. i,
  35559. k,
  35560. logBase,
  35561. more,
  35562. prod,
  35563. prodL,
  35564. q,
  35565. qd,
  35566. rem,
  35567. remL,
  35568. rem0,
  35569. sd,
  35570. t,
  35571. xi,
  35572. xL,
  35573. yd0,
  35574. yL,
  35575. yz,
  35576. Ctor = x.constructor,
  35577. sign = x.s == y.s ? 1 : -1,
  35578. xd = x.d,
  35579. yd = y.d;
  35580. // Either NaN, Infinity or 0?
  35581. if (!xd || !xd[0] || !yd || !yd[0]) {
  35582. return new Ctor( // Return NaN if either NaN, or both Infinity or 0.
  35583. !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN :
  35584. // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
  35585. xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
  35586. }
  35587. if (base) {
  35588. logBase = 1;
  35589. e = x.e - y.e;
  35590. } else {
  35591. base = BASE;
  35592. logBase = LOG_BASE;
  35593. e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
  35594. }
  35595. yL = yd.length;
  35596. xL = xd.length;
  35597. q = new Ctor(sign);
  35598. qd = q.d = [];
  35599. // Result exponent may be one less than e.
  35600. // The digit array of a Decimal from toStringBinary may have trailing zeros.
  35601. for (i = 0; yd[i] == (xd[i] || 0); i++) {}
  35602. if (yd[i] > (xd[i] || 0)) e--;
  35603. if (pr == null) {
  35604. sd = pr = Ctor.precision;
  35605. rm = Ctor.rounding;
  35606. } else if (dp) {
  35607. sd = pr + (x.e - y.e) + 1;
  35608. } else {
  35609. sd = pr;
  35610. }
  35611. if (sd < 0) {
  35612. qd.push(1);
  35613. more = true;
  35614. } else {
  35615. // Convert precision in number of base 10 digits to base 1e7 digits.
  35616. sd = sd / logBase + 2 | 0;
  35617. i = 0;
  35618. // divisor < 1e7
  35619. if (yL == 1) {
  35620. k = 0;
  35621. yd = yd[0];
  35622. sd++;
  35623. // k is the carry.
  35624. for (; (i < xL || k) && sd--; i++) {
  35625. t = k * base + (xd[i] || 0);
  35626. qd[i] = t / yd | 0;
  35627. k = t % yd | 0;
  35628. }
  35629. more = k || i < xL;
  35630. // divisor >= 1e7
  35631. } else {
  35632. // Normalise xd and yd so highest order digit of yd is >= base/2
  35633. k = base / (yd[0] + 1) | 0;
  35634. if (k > 1) {
  35635. yd = multiplyInteger(yd, k, base);
  35636. xd = multiplyInteger(xd, k, base);
  35637. yL = yd.length;
  35638. xL = xd.length;
  35639. }
  35640. xi = yL;
  35641. rem = xd.slice(0, yL);
  35642. remL = rem.length;
  35643. // Add zeros to make remainder as long as divisor.
  35644. for (; remL < yL;) {
  35645. rem[remL++] = 0;
  35646. }yz = yd.slice();
  35647. yz.unshift(0);
  35648. yd0 = yd[0];
  35649. if (yd[1] >= base / 2) ++yd0;
  35650. do {
  35651. k = 0;
  35652. // Compare divisor and remainder.
  35653. cmp = compare(yd, rem, yL, remL);
  35654. // If divisor < remainder.
  35655. if (cmp < 0) {
  35656. // Calculate trial digit, k.
  35657. rem0 = rem[0];
  35658. if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
  35659. // k will be how many times the divisor goes into the current remainder.
  35660. k = rem0 / yd0 | 0;
  35661. // Algorithm:
  35662. // 1. product = divisor * trial digit (k)
  35663. // 2. if product > remainder: product -= divisor, k--
  35664. // 3. remainder -= product
  35665. // 4. if product was < remainder at 2:
  35666. // 5. compare new remainder and divisor
  35667. // 6. If remainder > divisor: remainder -= divisor, k++
  35668. if (k > 1) {
  35669. if (k >= base) k = base - 1;
  35670. // product = divisor * trial digit.
  35671. prod = multiplyInteger(yd, k, base);
  35672. prodL = prod.length;
  35673. remL = rem.length;
  35674. // Compare product and remainder.
  35675. cmp = compare(prod, rem, prodL, remL);
  35676. // product > remainder.
  35677. if (cmp == 1) {
  35678. k--;
  35679. // Subtract divisor from product.
  35680. subtract(prod, yL < prodL ? yz : yd, prodL, base);
  35681. }
  35682. } else {
  35683. // cmp is -1.
  35684. // If k is 0, there is no need to compare yd and rem again below, so change cmp to 1
  35685. // to avoid it. If k is 1 there is a need to compare yd and rem again below.
  35686. if (k == 0) cmp = k = 1;
  35687. prod = yd.slice();
  35688. }
  35689. prodL = prod.length;
  35690. if (prodL < remL) prod.unshift(0);
  35691. // Subtract product from remainder.
  35692. subtract(rem, prod, remL, base);
  35693. // If product was < previous remainder.
  35694. if (cmp == -1) {
  35695. remL = rem.length;
  35696. // Compare divisor and new remainder.
  35697. cmp = compare(yd, rem, yL, remL);
  35698. // If divisor < new remainder, subtract divisor from remainder.
  35699. if (cmp < 1) {
  35700. k++;
  35701. // Subtract divisor from remainder.
  35702. subtract(rem, yL < remL ? yz : yd, remL, base);
  35703. }
  35704. }
  35705. remL = rem.length;
  35706. } else if (cmp === 0) {
  35707. k++;
  35708. rem = [0];
  35709. } // if cmp === 1, k will be 0
  35710. // Add the next digit, k, to the result array.
  35711. qd[i++] = k;
  35712. // Update the remainder.
  35713. if (cmp && rem[0]) {
  35714. rem[remL++] = xd[xi] || 0;
  35715. } else {
  35716. rem = [xd[xi]];
  35717. remL = 1;
  35718. }
  35719. } while ((xi++ < xL || rem[0] !== void 0) && sd--);
  35720. more = rem[0] !== void 0;
  35721. }
  35722. // Leading zero?
  35723. if (!qd[0]) qd.shift();
  35724. }
  35725. // logBase is 1 when divide is being used for base conversion.
  35726. if (logBase == 1) {
  35727. q.e = e;
  35728. inexact = more;
  35729. } else {
  35730. // To calculate q.e, first get the number of digits of qd[0].
  35731. for (i = 1, k = qd[0]; k >= 10; k /= 10) {
  35732. i++;
  35733. }q.e = i + e * logBase - 1;
  35734. finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
  35735. }
  35736. return q;
  35737. };
  35738. }();
  35739. /*
  35740. * Round `x` to `sd` significant digits using rounding mode `rm`.
  35741. * Check for over/under-flow.
  35742. */
  35743. function finalise(x, sd, rm, isTruncated) {
  35744. var digits,
  35745. i,
  35746. j,
  35747. k,
  35748. rd,
  35749. roundUp,
  35750. w,
  35751. xd,
  35752. xdi,
  35753. Ctor = x.constructor;
  35754. // Don't round if sd is null or undefined.
  35755. out: if (sd != null) {
  35756. xd = x.d;
  35757. // Infinity/NaN.
  35758. if (!xd) return x;
  35759. // rd: the rounding digit, i.e. the digit after the digit that may be rounded up.
  35760. // w: the word of xd containing rd, a base 1e7 number.
  35761. // xdi: the index of w within xd.
  35762. // digits: the number of digits of w.
  35763. // i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if
  35764. // they had leading zeros)
  35765. // j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
  35766. // Get the length of the first word of the digits array xd.
  35767. for (digits = 1, k = xd[0]; k >= 10; k /= 10) {
  35768. digits++;
  35769. }i = sd - digits;
  35770. // Is the rounding digit in the first word of xd?
  35771. if (i < 0) {
  35772. i += LOG_BASE;
  35773. j = sd;
  35774. w = xd[xdi = 0];
  35775. // Get the rounding digit at index j of w.
  35776. rd = w / mathpow(10, digits - j - 1) % 10 | 0;
  35777. } else {
  35778. xdi = Math.ceil((i + 1) / LOG_BASE);
  35779. k = xd.length;
  35780. if (xdi >= k) {
  35781. if (isTruncated) {
  35782. // Needed by `naturalExponential`, `naturalLogarithm` and `squareRoot`.
  35783. for (; k++ <= xdi;) {
  35784. xd.push(0);
  35785. }w = rd = 0;
  35786. digits = 1;
  35787. i %= LOG_BASE;
  35788. j = i - LOG_BASE + 1;
  35789. } else {
  35790. break out;
  35791. }
  35792. } else {
  35793. w = k = xd[xdi];
  35794. // Get the number of digits of w.
  35795. for (digits = 1; k >= 10; k /= 10) {
  35796. digits++;
  35797. } // Get the index of rd within w.
  35798. i %= LOG_BASE;
  35799. // Get the index of rd within w, adjusted for leading zeros.
  35800. // The number of leading zeros of w is given by LOG_BASE - digits.
  35801. j = i - LOG_BASE + digits;
  35802. // Get the rounding digit at index j of w.
  35803. rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
  35804. }
  35805. }
  35806. // Are there any non-zero digits after the rounding digit?
  35807. isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
  35808. // The expression `w % mathpow(10, digits - j - 1)` returns all the digits of w to the right
  35809. // of the digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression
  35810. // will give 714.
  35811. roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 &&
  35812. // Check whether the digit to the left of the rounding digit is odd.
  35813. (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
  35814. if (sd < 1 || !xd[0]) {
  35815. xd.length = 0;
  35816. if (roundUp) {
  35817. // Convert sd to decimal places.
  35818. sd -= x.e + 1;
  35819. // 1, 0.1, 0.01, 0.001, 0.0001 etc.
  35820. xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
  35821. x.e = -sd || 0;
  35822. } else {
  35823. // Zero.
  35824. xd[0] = x.e = 0;
  35825. }
  35826. return x;
  35827. }
  35828. // Remove excess digits.
  35829. if (i == 0) {
  35830. xd.length = xdi;
  35831. k = 1;
  35832. xdi--;
  35833. } else {
  35834. xd.length = xdi + 1;
  35835. k = mathpow(10, LOG_BASE - i);
  35836. // E.g. 56700 becomes 56000 if 7 is the rounding digit.
  35837. // j > 0 means i > number of leading zeros of w.
  35838. xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
  35839. }
  35840. if (roundUp) {
  35841. for (;;) {
  35842. // Is the digit to be rounded up in the first word of xd?
  35843. if (xdi == 0) {
  35844. // i will be the length of xd[0] before k is added.
  35845. for (i = 1, j = xd[0]; j >= 10; j /= 10) {
  35846. i++;
  35847. }j = xd[0] += k;
  35848. for (k = 1; j >= 10; j /= 10) {
  35849. k++;
  35850. } // if i != k the length has increased.
  35851. if (i != k) {
  35852. x.e++;
  35853. if (xd[0] == BASE) xd[0] = 1;
  35854. }
  35855. break;
  35856. } else {
  35857. xd[xdi] += k;
  35858. if (xd[xdi] != BASE) break;
  35859. xd[xdi--] = 0;
  35860. k = 1;
  35861. }
  35862. }
  35863. }
  35864. // Remove trailing zeros.
  35865. for (i = xd.length; xd[--i] === 0;) {
  35866. xd.pop();
  35867. }
  35868. }
  35869. if (external) {
  35870. // Overflow?
  35871. if (x.e > Ctor.maxE) {
  35872. // Infinity.
  35873. x.d = null;
  35874. x.e = NaN;
  35875. // Underflow?
  35876. } else if (x.e < Ctor.minE) {
  35877. // Zero.
  35878. x.e = 0;
  35879. x.d = [0];
  35880. // Ctor.underflow = true;
  35881. } // else Ctor.underflow = false;
  35882. }
  35883. return x;
  35884. }
  35885. function finiteToString(x, isExp, sd) {
  35886. if (!x.isFinite()) return nonFiniteToString(x);
  35887. var k,
  35888. e = x.e,
  35889. str = digitsToString(x.d),
  35890. len = str.length;
  35891. if (isExp) {
  35892. if (sd && (k = sd - len) > 0) {
  35893. str = str.charAt(0) + '.' + str.slice(1) + getZeroString(k);
  35894. } else if (len > 1) {
  35895. str = str.charAt(0) + '.' + str.slice(1);
  35896. }
  35897. str = str + (x.e < 0 ? 'e' : 'e+') + x.e;
  35898. } else if (e < 0) {
  35899. str = '0.' + getZeroString(-e - 1) + str;
  35900. if (sd && (k = sd - len) > 0) str += getZeroString(k);
  35901. } else if (e >= len) {
  35902. str += getZeroString(e + 1 - len);
  35903. if (sd && (k = sd - e - 1) > 0) str = str + '.' + getZeroString(k);
  35904. } else {
  35905. if ((k = e + 1) < len) str = str.slice(0, k) + '.' + str.slice(k);
  35906. if (sd && (k = sd - len) > 0) {
  35907. if (e + 1 === len) str += '.';
  35908. str += getZeroString(k);
  35909. }
  35910. }
  35911. return str;
  35912. }
  35913. // Calculate the base 10 exponent from the base 1e7 exponent.
  35914. function getBase10Exponent(digits, e) {
  35915. var w = digits[0];
  35916. // Add the number of digits of the first word of the digits array.
  35917. for (e *= LOG_BASE; w >= 10; w /= 10) {
  35918. e++;
  35919. }return e;
  35920. }
  35921. function getLn10(Ctor, sd, pr) {
  35922. if (sd > LN10_PRECISION) {
  35923. // Reset global state in case the exception is caught.
  35924. external = true;
  35925. if (pr) Ctor.precision = pr;
  35926. throw Error(precisionLimitExceeded);
  35927. }
  35928. return finalise(new Ctor(LN10), sd, 1, true);
  35929. }
  35930. function getPi(Ctor, sd, rm) {
  35931. if (sd > PI_PRECISION) throw Error(precisionLimitExceeded);
  35932. return finalise(new Ctor(PI), sd, rm, true);
  35933. }
  35934. function getPrecision(digits) {
  35935. var w = digits.length - 1,
  35936. len = w * LOG_BASE + 1;
  35937. w = digits[w];
  35938. // If non-zero...
  35939. if (w) {
  35940. // Subtract the number of trailing zeros of the last word.
  35941. for (; w % 10 == 0; w /= 10) {
  35942. len--;
  35943. } // Add the number of digits of the first word.
  35944. for (w = digits[0]; w >= 10; w /= 10) {
  35945. len++;
  35946. }
  35947. }
  35948. return len;
  35949. }
  35950. function getZeroString(k) {
  35951. var zs = '';
  35952. for (; k--;) {
  35953. zs += '0';
  35954. }return zs;
  35955. }
  35956. /*
  35957. * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an
  35958. * integer of type number.
  35959. *
  35960. * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`.
  35961. *
  35962. */
  35963. function intPow(Ctor, x, n, pr) {
  35964. var isTruncated,
  35965. r = new Ctor(1),
  35966. // Max n of 9007199254740991 takes 53 loop iterations.
  35967. // Maximum digits array length; leaves [28, 34] guard digits.
  35968. k = Math.ceil(pr / LOG_BASE + 4);
  35969. external = false;
  35970. for (;;) {
  35971. if (n % 2) {
  35972. r = r.times(x);
  35973. if (truncate(r.d, k)) isTruncated = true;
  35974. }
  35975. n = mathfloor(n / 2);
  35976. if (n === 0) {
  35977. // To ensure correct rounding when r.d is truncated, increment the last word if it is zero.
  35978. n = r.d.length - 1;
  35979. if (isTruncated && r.d[n] === 0) ++r.d[n];
  35980. break;
  35981. }
  35982. x = x.times(x);
  35983. truncate(x.d, k);
  35984. }
  35985. external = true;
  35986. return r;
  35987. }
  35988. function isOdd(n) {
  35989. return n.d[n.d.length - 1] & 1;
  35990. }
  35991. /*
  35992. * Handle `max` and `min`. `ltgt` is 'lt' or 'gt'.
  35993. */
  35994. function maxOrMin(Ctor, args, ltgt) {
  35995. var y,
  35996. x = new Ctor(args[0]),
  35997. i = 0;
  35998. for (; ++i < args.length;) {
  35999. y = new Ctor(args[i]);
  36000. if (!y.s) {
  36001. x = y;
  36002. break;
  36003. } else if (x[ltgt](y)) {
  36004. x = y;
  36005. }
  36006. }
  36007. return x;
  36008. }
  36009. /*
  36010. * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant
  36011. * digits.
  36012. *
  36013. * Taylor/Maclaurin series.
  36014. *
  36015. * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ...
  36016. *
  36017. * Argument reduction:
  36018. * Repeat x = x / 32, k += 5, until |x| < 0.1
  36019. * exp(x) = exp(x / 2^k)^(2^k)
  36020. *
  36021. * Previously, the argument was initially reduced by
  36022. * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10)
  36023. * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was
  36024. * found to be slower than just dividing repeatedly by 32 as above.
  36025. *
  36026. * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000
  36027. * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000
  36028. * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324)
  36029. *
  36030. * exp(Infinity) = Infinity
  36031. * exp(-Infinity) = 0
  36032. * exp(NaN) = NaN
  36033. * exp(±0) = 1
  36034. *
  36035. * exp(x) is non-terminating for any finite, non-zero x.
  36036. *
  36037. * The result will always be correctly rounded.
  36038. *
  36039. */
  36040. function naturalExponential(x, sd) {
  36041. var denominator,
  36042. guard,
  36043. j,
  36044. pow,
  36045. sum,
  36046. t,
  36047. wpr,
  36048. rep = 0,
  36049. i = 0,
  36050. k = 0,
  36051. Ctor = x.constructor,
  36052. rm = Ctor.rounding,
  36053. pr = Ctor.precision;
  36054. // 0/NaN/Infinity?
  36055. if (!x.d || !x.d[0] || x.e > 17) {
  36056. return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
  36057. }
  36058. if (sd == null) {
  36059. external = false;
  36060. wpr = pr;
  36061. } else {
  36062. wpr = sd;
  36063. }
  36064. t = new Ctor(0.03125);
  36065. // while abs(x) >= 0.1
  36066. while (x.e > -2) {
  36067. // x = x / 2^5
  36068. x = x.times(t);
  36069. k += 5;
  36070. }
  36071. // Use 2 * log10(2^k) + 5 (empirically derived) to estimate the increase in precision
  36072. // necessary to ensure the first 4 rounding digits are correct.
  36073. guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
  36074. wpr += guard;
  36075. denominator = pow = sum = new Ctor(1);
  36076. Ctor.precision = wpr;
  36077. for (;;) {
  36078. pow = finalise(pow.times(x), wpr, 1);
  36079. denominator = denominator.times(++i);
  36080. t = sum.plus(divide(pow, denominator, wpr, 1));
  36081. if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
  36082. j = k;
  36083. while (j--) {
  36084. sum = finalise(sum.times(sum), wpr, 1);
  36085. } // Check to see if the first 4 rounding digits are [49]999.
  36086. // If so, repeat the summation with a higher precision, otherwise
  36087. // e.g. with precision: 18, rounding: 1
  36088. // exp(18.404272462595034083567793919843761) = 98372560.1229999999 (should be 98372560.123)
  36089. // `wpr - guard` is the index of first rounding digit.
  36090. if (sd == null) {
  36091. if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
  36092. Ctor.precision = wpr += 10;
  36093. denominator = pow = t = new Ctor(1);
  36094. i = 0;
  36095. rep++;
  36096. } else {
  36097. return finalise(sum, Ctor.precision = pr, rm, external = true);
  36098. }
  36099. } else {
  36100. Ctor.precision = pr;
  36101. return sum;
  36102. }
  36103. }
  36104. sum = t;
  36105. }
  36106. }
  36107. /*
  36108. * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant
  36109. * digits.
  36110. *
  36111. * ln(-n) = NaN
  36112. * ln(0) = -Infinity
  36113. * ln(-0) = -Infinity
  36114. * ln(1) = 0
  36115. * ln(Infinity) = Infinity
  36116. * ln(-Infinity) = NaN
  36117. * ln(NaN) = NaN
  36118. *
  36119. * ln(n) (n != 1) is non-terminating.
  36120. *
  36121. */
  36122. function naturalLogarithm(y, sd) {
  36123. var c,
  36124. c0,
  36125. denominator,
  36126. e,
  36127. numerator,
  36128. rep,
  36129. sum,
  36130. t,
  36131. wpr,
  36132. x1,
  36133. x2,
  36134. n = 1,
  36135. guard = 10,
  36136. x = y,
  36137. xd = x.d,
  36138. Ctor = x.constructor,
  36139. rm = Ctor.rounding,
  36140. pr = Ctor.precision;
  36141. // Is x negative or Infinity, NaN, 0 or 1?
  36142. if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
  36143. return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
  36144. }
  36145. if (sd == null) {
  36146. external = false;
  36147. wpr = pr;
  36148. } else {
  36149. wpr = sd;
  36150. }
  36151. Ctor.precision = wpr += guard;
  36152. c = digitsToString(xd);
  36153. c0 = c.charAt(0);
  36154. if (Math.abs(e = x.e) < 1.5e15) {
  36155. // Argument reduction.
  36156. // The series converges faster the closer the argument is to 1, so using
  36157. // ln(a^b) = b * ln(a), ln(a) = ln(a^b) / b
  36158. // multiply the argument by itself until the leading digits of the significand are 7, 8, 9,
  36159. // 10, 11, 12 or 13, recording the number of multiplications so the sum of the series can
  36160. // later be divided by this number, then separate out the power of 10 using
  36161. // ln(a*10^b) = ln(a) + b*ln(10).
  36162. // max n is 21 (gives 0.9, 1.0 or 1.1) (9e15 / 21 = 4.2e14).
  36163. //while (c0 < 9 && c0 != 1 || c0 == 1 && c.charAt(1) > 1) {
  36164. // max n is 6 (gives 0.7 - 1.3)
  36165. while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
  36166. x = x.times(y);
  36167. c = digitsToString(x.d);
  36168. c0 = c.charAt(0);
  36169. n++;
  36170. }
  36171. e = x.e;
  36172. if (c0 > 1) {
  36173. x = new Ctor('0.' + c);
  36174. e++;
  36175. } else {
  36176. x = new Ctor(c0 + '.' + c.slice(1));
  36177. }
  36178. } else {
  36179. // The argument reduction method above may result in overflow if the argument y is a massive
  36180. // number with exponent >= 1500000000000000 (9e15 / 6 = 1.5e15), so instead recall this
  36181. // function using ln(x*10^e) = ln(x) + e*ln(10).
  36182. t = getLn10(Ctor, wpr + 2, pr).times(e + '');
  36183. x = naturalLogarithm(new Ctor(c0 + '.' + c.slice(1)), wpr - guard).plus(t);
  36184. Ctor.precision = pr;
  36185. return sd == null ? finalise(x, pr, rm, external = true) : x;
  36186. }
  36187. // x1 is x reduced to a value near 1.
  36188. x1 = x;
  36189. // Taylor series.
  36190. // ln(y) = ln((1 + x)/(1 - x)) = 2(x + x^3/3 + x^5/5 + x^7/7 + ...)
  36191. // where x = (y - 1)/(y + 1) (|x| < 1)
  36192. sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
  36193. x2 = finalise(x.times(x), wpr, 1);
  36194. denominator = 3;
  36195. for (;;) {
  36196. numerator = finalise(numerator.times(x2), wpr, 1);
  36197. t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
  36198. if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
  36199. sum = sum.times(2);
  36200. // Reverse the argument reduction. Check that e is not 0 because, besides preventing an
  36201. // unnecessary calculation, -0 + 0 = +0 and to ensure correct rounding -0 needs to stay -0.
  36202. if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ''));
  36203. sum = divide(sum, new Ctor(n), wpr, 1);
  36204. // Is rm > 3 and the first 4 rounding digits 4999, or rm < 4 (or the summation has
  36205. // been repeated previously) and the first 4 rounding digits 9999?
  36206. // If so, restart the summation with a higher precision, otherwise
  36207. // e.g. with precision: 12, rounding: 1
  36208. // ln(135520028.6126091714265381533) = 18.7246299999 when it should be 18.72463.
  36209. // `wpr - guard` is the index of first rounding digit.
  36210. if (sd == null) {
  36211. if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
  36212. Ctor.precision = wpr += guard;
  36213. t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
  36214. x2 = finalise(x.times(x), wpr, 1);
  36215. denominator = rep = 1;
  36216. } else {
  36217. return finalise(sum, Ctor.precision = pr, rm, external = true);
  36218. }
  36219. } else {
  36220. Ctor.precision = pr;
  36221. return sum;
  36222. }
  36223. }
  36224. sum = t;
  36225. denominator += 2;
  36226. }
  36227. }
  36228. // ±Infinity, NaN.
  36229. function nonFiniteToString(x) {
  36230. // Unsigned.
  36231. return String(x.s * x.s / 0);
  36232. }
  36233. /*
  36234. * Parse the value of a new Decimal `x` from string `str`.
  36235. */
  36236. function parseDecimal(x, str) {
  36237. var e, i, len;
  36238. // Decimal point?
  36239. if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
  36240. // Exponential form?
  36241. if ((i = str.search(/e/i)) > 0) {
  36242. // Determine exponent.
  36243. if (e < 0) e = i;
  36244. e += +str.slice(i + 1);
  36245. str = str.substring(0, i);
  36246. } else if (e < 0) {
  36247. // Integer.
  36248. e = str.length;
  36249. }
  36250. // Determine leading zeros.
  36251. for (i = 0; str.charCodeAt(i) === 48; i++) {}
  36252. // Determine trailing zeros.
  36253. for (len = str.length; str.charCodeAt(len - 1) === 48; --len) {}
  36254. str = str.slice(i, len);
  36255. if (str) {
  36256. len -= i;
  36257. x.e = e = e - i - 1;
  36258. x.d = [];
  36259. // Transform base
  36260. // e is the base 10 exponent.
  36261. // i is where to slice str to get the first word of the digits array.
  36262. i = (e + 1) % LOG_BASE;
  36263. if (e < 0) i += LOG_BASE;
  36264. if (i < len) {
  36265. if (i) x.d.push(+str.slice(0, i));
  36266. for (len -= LOG_BASE; i < len;) {
  36267. x.d.push(+str.slice(i, i += LOG_BASE));
  36268. }str = str.slice(i);
  36269. i = LOG_BASE - str.length;
  36270. } else {
  36271. i -= len;
  36272. }
  36273. for (; i--;) {
  36274. str += '0';
  36275. }x.d.push(+str);
  36276. if (external) {
  36277. // Overflow?
  36278. if (x.e > x.constructor.maxE) {
  36279. // Infinity.
  36280. x.d = null;
  36281. x.e = NaN;
  36282. // Underflow?
  36283. } else if (x.e < x.constructor.minE) {
  36284. // Zero.
  36285. x.e = 0;
  36286. x.d = [0];
  36287. // x.constructor.underflow = true;
  36288. } // else x.constructor.underflow = false;
  36289. }
  36290. } else {
  36291. // Zero.
  36292. x.e = 0;
  36293. x.d = [0];
  36294. }
  36295. return x;
  36296. }
  36297. /*
  36298. * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value.
  36299. */
  36300. function parseOther(x, str) {
  36301. var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
  36302. if (str === 'Infinity' || str === 'NaN') {
  36303. if (!+str) x.s = NaN;
  36304. x.e = NaN;
  36305. x.d = null;
  36306. return x;
  36307. }
  36308. if (isHex.test(str)) {
  36309. base = 16;
  36310. str = str.toLowerCase();
  36311. } else if (isBinary.test(str)) {
  36312. base = 2;
  36313. } else if (isOctal.test(str)) {
  36314. base = 8;
  36315. } else {
  36316. throw Error(invalidArgument + str);
  36317. }
  36318. // Is there a binary exponent part?
  36319. i = str.search(/p/i);
  36320. if (i > 0) {
  36321. p = +str.slice(i + 1);
  36322. str = str.substring(2, i);
  36323. } else {
  36324. str = str.slice(2);
  36325. }
  36326. // Convert `str` as an integer then divide the result by `base` raised to a power such that the
  36327. // fraction part will be restored.
  36328. i = str.indexOf('.');
  36329. isFloat = i >= 0;
  36330. Ctor = x.constructor;
  36331. if (isFloat) {
  36332. str = str.replace('.', '');
  36333. len = str.length;
  36334. i = len - i;
  36335. // log[10](16) = 1.2041... , log[10](88) = 1.9444....
  36336. divisor = intPow(Ctor, new Ctor(base), i, i * 2);
  36337. }
  36338. xd = convertBase(str, base, BASE);
  36339. xe = xd.length - 1;
  36340. // Remove trailing zeros.
  36341. for (i = xe; xd[i] === 0; --i) {
  36342. xd.pop();
  36343. }if (i < 0) return new Ctor(x.s * 0);
  36344. x.e = getBase10Exponent(xd, xe);
  36345. x.d = xd;
  36346. external = false;
  36347. // At what precision to perform the division to ensure exact conversion?
  36348. // maxDecimalIntegerPartDigitCount = ceil(log[10](b) * otherBaseIntegerPartDigitCount)
  36349. // log[10](2) = 0.30103, log[10](8) = 0.90309, log[10](16) = 1.20412
  36350. // E.g. ceil(1.2 * 3) = 4, so up to 4 decimal digits are needed to represent 3 hex int digits.
  36351. // maxDecimalFractionPartDigitCount = {Hex:4|Oct:3|Bin:1} * otherBaseFractionPartDigitCount
  36352. // Therefore using 4 * the number of digits of str will always be enough.
  36353. if (isFloat) x = divide(x, divisor, len * 4);
  36354. // Multiply by the binary exponent part if present.
  36355. if (p) x = x.times(Math.abs(p) < 54 ? Math.pow(2, p) : Decimal.pow(2, p));
  36356. external = true;
  36357. return x;
  36358. }
  36359. /*
  36360. * sin(x) = x - x^3/3! + x^5/5! - ...
  36361. * |x| < pi/2
  36362. *
  36363. */
  36364. function sine(Ctor, x) {
  36365. var k,
  36366. len = x.d.length;
  36367. if (len < 3) return taylorSeries(Ctor, 2, x, x);
  36368. // Argument reduction: sin(5x) = 16*sin^5(x) - 20*sin^3(x) + 5*sin(x)
  36369. // i.e. sin(x) = 16*sin^5(x/5) - 20*sin^3(x/5) + 5*sin(x/5)
  36370. // and sin(x) = sin(x/5)(5 + sin^2(x/5)(16sin^2(x/5) - 20))
  36371. // Estimate the optimum number of times to use the argument reduction.
  36372. k = 1.4 * Math.sqrt(len);
  36373. k = k > 16 ? 16 : k | 0;
  36374. // Max k before Math.pow precision loss is 22
  36375. x = x.times(Math.pow(5, -k));
  36376. x = taylorSeries(Ctor, 2, x, x);
  36377. // Reverse argument reduction
  36378. var sin2_x,
  36379. d5 = new Ctor(5),
  36380. d16 = new Ctor(16),
  36381. d20 = new Ctor(20);
  36382. for (; k--;) {
  36383. sin2_x = x.times(x);
  36384. x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
  36385. }
  36386. return x;
  36387. }
  36388. // Calculate Taylor series for `cos`, `cosh`, `sin` and `sinh`.
  36389. function taylorSeries(Ctor, n, x, y, isHyperbolic) {
  36390. var j,
  36391. t,
  36392. u,
  36393. x2,
  36394. i = 1,
  36395. pr = Ctor.precision,
  36396. k = Math.ceil(pr / LOG_BASE);
  36397. external = false;
  36398. x2 = x.times(x);
  36399. u = new Ctor(y);
  36400. for (;;) {
  36401. t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
  36402. u = isHyperbolic ? y.plus(t) : y.minus(t);
  36403. y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
  36404. t = u.plus(y);
  36405. if (t.d[k] !== void 0) {
  36406. for (j = k; t.d[j] === u.d[j] && j--;) {}
  36407. if (j == -1) break;
  36408. }
  36409. j = u;
  36410. u = y;
  36411. y = t;
  36412. t = j;
  36413. i++;
  36414. }
  36415. external = true;
  36416. t.d.length = k + 1;
  36417. return t;
  36418. }
  36419. // Return the absolute value of `x` reduced to less than or equal to half pi.
  36420. function toLessThanHalfPi(Ctor, x) {
  36421. var t,
  36422. isNeg = x.s < 0,
  36423. pi = getPi(Ctor, Ctor.precision, 1),
  36424. halfPi = pi.times(0.5);
  36425. x = x.abs();
  36426. if (x.lte(halfPi)) {
  36427. quadrant = isNeg ? 4 : 1;
  36428. return x;
  36429. }
  36430. t = x.divToInt(pi);
  36431. if (t.isZero()) {
  36432. quadrant = isNeg ? 3 : 2;
  36433. } else {
  36434. x = x.minus(t.times(pi));
  36435. // 0 <= x < pi
  36436. if (x.lte(halfPi)) {
  36437. quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
  36438. return x;
  36439. }
  36440. quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
  36441. }
  36442. return x.minus(pi).abs();
  36443. }
  36444. /*
  36445. * Return the value of Decimal `x` as a string in base `baseOut`.
  36446. *
  36447. * If the optional `sd` argument is present include a binary exponent suffix.
  36448. */
  36449. function toStringBinary(x, baseOut, sd, rm) {
  36450. var base,
  36451. e,
  36452. i,
  36453. k,
  36454. len,
  36455. roundUp,
  36456. str,
  36457. xd,
  36458. y,
  36459. Ctor = x.constructor,
  36460. isExp = sd !== void 0;
  36461. if (isExp) {
  36462. checkInt32(sd, 1, MAX_DIGITS);
  36463. if (rm === void 0) rm = Ctor.rounding;else checkInt32(rm, 0, 8);
  36464. } else {
  36465. sd = Ctor.precision;
  36466. rm = Ctor.rounding;
  36467. }
  36468. if (!x.isFinite()) {
  36469. str = nonFiniteToString(x);
  36470. } else {
  36471. str = finiteToString(x);
  36472. i = str.indexOf('.');
  36473. // Use exponential notation according to `toExpPos` and `toExpNeg`? No, but if required:
  36474. // maxBinaryExponent = floor((decimalExponent + 1) * log[2](10))
  36475. // minBinaryExponent = floor(decimalExponent * log[2](10))
  36476. // log[2](10) = 3.321928094887362347870319429489390175864
  36477. if (isExp) {
  36478. base = 2;
  36479. if (baseOut == 16) {
  36480. sd = sd * 4 - 3;
  36481. } else if (baseOut == 8) {
  36482. sd = sd * 3 - 2;
  36483. }
  36484. } else {
  36485. base = baseOut;
  36486. }
  36487. // Convert the number as an integer then divide the result by its base raised to a power such
  36488. // that the fraction part will be restored.
  36489. // Non-integer.
  36490. if (i >= 0) {
  36491. str = str.replace('.', '');
  36492. y = new Ctor(1);
  36493. y.e = str.length - i;
  36494. y.d = convertBase(finiteToString(y), 10, base);
  36495. y.e = y.d.length;
  36496. }
  36497. xd = convertBase(str, 10, base);
  36498. e = len = xd.length;
  36499. // Remove trailing zeros.
  36500. for (; xd[--len] == 0;) {
  36501. xd.pop();
  36502. }if (!xd[0]) {
  36503. str = isExp ? '0p+0' : '0';
  36504. } else {
  36505. if (i < 0) {
  36506. e--;
  36507. } else {
  36508. x = new Ctor(x);
  36509. x.d = xd;
  36510. x.e = e;
  36511. x = divide(x, y, sd, rm, 0, base);
  36512. xd = x.d;
  36513. e = x.e;
  36514. roundUp = inexact;
  36515. }
  36516. // The rounding digit, i.e. the digit after the digit that may be rounded up.
  36517. i = xd[sd];
  36518. k = base / 2;
  36519. roundUp = roundUp || xd[sd + 1] !== void 0;
  36520. roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
  36521. xd.length = sd;
  36522. if (roundUp) {
  36523. // Rounding up may mean the previous digit has to be rounded up and so on.
  36524. for (; ++xd[--sd] > base - 1;) {
  36525. xd[sd] = 0;
  36526. if (!sd) {
  36527. ++e;
  36528. xd.unshift(1);
  36529. }
  36530. }
  36531. }
  36532. // Determine trailing zeros.
  36533. for (len = xd.length; !xd[len - 1]; --len) {}
  36534. // E.g. [4, 11, 15] becomes 4bf.
  36535. for (i = 0, str = ''; i < len; i++) {
  36536. str += NUMERALS.charAt(xd[i]);
  36537. } // Add binary exponent suffix?
  36538. if (isExp) {
  36539. if (len > 1) {
  36540. if (baseOut == 16 || baseOut == 8) {
  36541. i = baseOut == 16 ? 4 : 3;
  36542. for (--len; len % i; len++) {
  36543. str += '0';
  36544. }xd = convertBase(str, base, baseOut);
  36545. for (len = xd.length; !xd[len - 1]; --len) {}
  36546. // xd[0] will always be be 1
  36547. for (i = 1, str = '1.'; i < len; i++) {
  36548. str += NUMERALS.charAt(xd[i]);
  36549. }
  36550. } else {
  36551. str = str.charAt(0) + '.' + str.slice(1);
  36552. }
  36553. }
  36554. str = str + (e < 0 ? 'p' : 'p+') + e;
  36555. } else if (e < 0) {
  36556. for (; ++e;) {
  36557. str = '0' + str;
  36558. }str = '0.' + str;
  36559. } else {
  36560. if (++e > len) for (e -= len; e--;) {
  36561. str += '0';
  36562. } else if (e < len) str = str.slice(0, e) + '.' + str.slice(e);
  36563. }
  36564. }
  36565. str = (baseOut == 16 ? '0x' : baseOut == 2 ? '0b' : baseOut == 8 ? '0o' : '') + str;
  36566. }
  36567. return x.s < 0 ? '-' + str : str;
  36568. }
  36569. // Does not strip trailing zeros.
  36570. function truncate(arr, len) {
  36571. if (arr.length > len) {
  36572. arr.length = len;
  36573. return true;
  36574. }
  36575. }
  36576. // Decimal methods
  36577. /*
  36578. * abs
  36579. * acos
  36580. * acosh
  36581. * add
  36582. * asin
  36583. * asinh
  36584. * atan
  36585. * atanh
  36586. * atan2
  36587. * cbrt
  36588. * ceil
  36589. * clone
  36590. * config
  36591. * cos
  36592. * cosh
  36593. * div
  36594. * exp
  36595. * floor
  36596. * hypot
  36597. * ln
  36598. * log
  36599. * log2
  36600. * log10
  36601. * max
  36602. * min
  36603. * mod
  36604. * mul
  36605. * pow
  36606. * random
  36607. * round
  36608. * set
  36609. * sign
  36610. * sin
  36611. * sinh
  36612. * sqrt
  36613. * sub
  36614. * tan
  36615. * tanh
  36616. * trunc
  36617. */
  36618. /*
  36619. * Return a new Decimal whose value is the absolute value of `x`.
  36620. *
  36621. * x {number|string|Decimal}
  36622. *
  36623. */
  36624. function abs(x) {
  36625. return new this(x).abs();
  36626. }
  36627. /*
  36628. * Return a new Decimal whose value is the arccosine in radians of `x`.
  36629. *
  36630. * x {number|string|Decimal}
  36631. *
  36632. */
  36633. function acos(x) {
  36634. return new this(x).acos();
  36635. }
  36636. /*
  36637. * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to
  36638. * `precision` significant digits using rounding mode `rounding`.
  36639. *
  36640. * x {number|string|Decimal} A value in radians.
  36641. *
  36642. */
  36643. function acosh(x) {
  36644. return new this(x).acosh();
  36645. }
  36646. /*
  36647. * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant
  36648. * digits using rounding mode `rounding`.
  36649. *
  36650. * x {number|string|Decimal}
  36651. * y {number|string|Decimal}
  36652. *
  36653. */
  36654. function add(x, y) {
  36655. return new this(x).plus(y);
  36656. }
  36657. /*
  36658. * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision`
  36659. * significant digits using rounding mode `rounding`.
  36660. *
  36661. * x {number|string|Decimal}
  36662. *
  36663. */
  36664. function asin(x) {
  36665. return new this(x).asin();
  36666. }
  36667. /*
  36668. * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to
  36669. * `precision` significant digits using rounding mode `rounding`.
  36670. *
  36671. * x {number|string|Decimal} A value in radians.
  36672. *
  36673. */
  36674. function asinh(x) {
  36675. return new this(x).asinh();
  36676. }
  36677. /*
  36678. * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision`
  36679. * significant digits using rounding mode `rounding`.
  36680. *
  36681. * x {number|string|Decimal}
  36682. *
  36683. */
  36684. function atan(x) {
  36685. return new this(x).atan();
  36686. }
  36687. /*
  36688. * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to
  36689. * `precision` significant digits using rounding mode `rounding`.
  36690. *
  36691. * x {number|string|Decimal} A value in radians.
  36692. *
  36693. */
  36694. function atanh(x) {
  36695. return new this(x).atanh();
  36696. }
  36697. /*
  36698. * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi
  36699. * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`.
  36700. *
  36701. * Domain: [-Infinity, Infinity]
  36702. * Range: [-pi, pi]
  36703. *
  36704. * y {number|string|Decimal} The y-coordinate.
  36705. * x {number|string|Decimal} The x-coordinate.
  36706. *
  36707. * atan2(±0, -0) = ±pi
  36708. * atan2(±0, +0) = ±0
  36709. * atan2(±0, -x) = ±pi for x > 0
  36710. * atan2(±0, x) = ±0 for x > 0
  36711. * atan2(-y, ±0) = -pi/2 for y > 0
  36712. * atan2(y, ±0) = pi/2 for y > 0
  36713. * atan2(±y, -Infinity) = ±pi for finite y > 0
  36714. * atan2(±y, +Infinity) = ±0 for finite y > 0
  36715. * atan2(±Infinity, x) = ±pi/2 for finite x
  36716. * atan2(±Infinity, -Infinity) = ±3*pi/4
  36717. * atan2(±Infinity, +Infinity) = ±pi/4
  36718. * atan2(NaN, x) = NaN
  36719. * atan2(y, NaN) = NaN
  36720. *
  36721. */
  36722. function atan2(y, x) {
  36723. y = new this(y);
  36724. x = new this(x);
  36725. var r,
  36726. pr = this.precision,
  36727. rm = this.rounding,
  36728. wpr = pr + 4;
  36729. // Either NaN
  36730. if (!y.s || !x.s) {
  36731. r = new this(NaN);
  36732. // Both ±Infinity
  36733. } else if (!y.d && !x.d) {
  36734. r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
  36735. r.s = y.s;
  36736. // x is ±Infinity or y is ±0
  36737. } else if (!x.d || y.isZero()) {
  36738. r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
  36739. r.s = y.s;
  36740. // y is ±Infinity or x is ±0
  36741. } else if (!y.d || x.isZero()) {
  36742. r = getPi(this, wpr, 1).times(0.5);
  36743. r.s = y.s;
  36744. // Both non-zero and finite
  36745. } else if (x.s < 0) {
  36746. this.precision = wpr;
  36747. this.rounding = 1;
  36748. r = this.atan(divide(y, x, wpr, 1));
  36749. x = getPi(this, wpr, 1);
  36750. this.precision = pr;
  36751. this.rounding = rm;
  36752. r = y.s < 0 ? r.minus(x) : r.plus(x);
  36753. } else {
  36754. r = this.atan(divide(y, x, wpr, 1));
  36755. }
  36756. return r;
  36757. }
  36758. /*
  36759. * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant
  36760. * digits using rounding mode `rounding`.
  36761. *
  36762. * x {number|string|Decimal}
  36763. *
  36764. */
  36765. function cbrt(x) {
  36766. return new this(x).cbrt();
  36767. }
  36768. /*
  36769. * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`.
  36770. *
  36771. * x {number|string|Decimal}
  36772. *
  36773. */
  36774. function ceil(x) {
  36775. return finalise(x = new this(x), x.e + 1, 2);
  36776. }
  36777. /*
  36778. * Configure global settings for a Decimal constructor.
  36779. *
  36780. * `obj` is an object with one or more of the following properties,
  36781. *
  36782. * precision {number}
  36783. * rounding {number}
  36784. * toExpNeg {number}
  36785. * toExpPos {number}
  36786. * maxE {number}
  36787. * minE {number}
  36788. * modulo {number}
  36789. * crypto {boolean|number}
  36790. * defaults {true}
  36791. *
  36792. * E.g. Decimal.config({ precision: 20, rounding: 4 })
  36793. *
  36794. */
  36795. function config(obj) {
  36796. if (!obj || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') throw Error(decimalError + 'Object expected');
  36797. var i,
  36798. p,
  36799. v,
  36800. useDefaults = obj.defaults === true,
  36801. ps = ['precision', 1, MAX_DIGITS, 'rounding', 0, 8, 'toExpNeg', -EXP_LIMIT, 0, 'toExpPos', 0, EXP_LIMIT, 'maxE', 0, EXP_LIMIT, 'minE', -EXP_LIMIT, 0, 'modulo', 0, 9];
  36802. for (i = 0; i < ps.length; i += 3) {
  36803. if (p = ps[i], useDefaults) this[p] = DEFAULTS[p];
  36804. if ((v = obj[p]) !== void 0) {
  36805. if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;else throw Error(invalidArgument + p + ': ' + v);
  36806. }
  36807. }
  36808. if (p = 'crypto', useDefaults) this[p] = DEFAULTS[p];
  36809. if ((v = obj[p]) !== void 0) {
  36810. if (v === true || v === false || v === 0 || v === 1) {
  36811. if (v) {
  36812. if (typeof crypto != 'undefined' && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
  36813. this[p] = true;
  36814. } else {
  36815. throw Error(cryptoUnavailable);
  36816. }
  36817. } else {
  36818. this[p] = false;
  36819. }
  36820. } else {
  36821. throw Error(invalidArgument + p + ': ' + v);
  36822. }
  36823. }
  36824. return this;
  36825. }
  36826. /*
  36827. * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant
  36828. * digits using rounding mode `rounding`.
  36829. *
  36830. * x {number|string|Decimal} A value in radians.
  36831. *
  36832. */
  36833. function cos(x) {
  36834. return new this(x).cos();
  36835. }
  36836. /*
  36837. * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision
  36838. * significant digits using rounding mode `rounding`.
  36839. *
  36840. * x {number|string|Decimal} A value in radians.
  36841. *
  36842. */
  36843. function cosh(x) {
  36844. return new this(x).cosh();
  36845. }
  36846. /*
  36847. * Create and return a Decimal constructor with the same configuration properties as this Decimal
  36848. * constructor.
  36849. *
  36850. */
  36851. function clone(obj) {
  36852. var i, p, ps;
  36853. /*
  36854. * The Decimal constructor and exported function.
  36855. * Return a new Decimal instance.
  36856. *
  36857. * v {number|string|Decimal} A numeric value.
  36858. *
  36859. */
  36860. function Decimal(v) {
  36861. var e,
  36862. i,
  36863. t,
  36864. x = this;
  36865. // Decimal called without new.
  36866. if (!(x instanceof Decimal)) return new Decimal(v);
  36867. // Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor
  36868. // which points to Object.
  36869. x.constructor = Decimal;
  36870. // Duplicate.
  36871. if (v instanceof Decimal) {
  36872. x.s = v.s;
  36873. x.e = v.e;
  36874. x.d = (v = v.d) ? v.slice() : v;
  36875. return;
  36876. }
  36877. t = typeof v === 'undefined' ? 'undefined' : _typeof(v);
  36878. if (t === 'number') {
  36879. if (v === 0) {
  36880. x.s = 1 / v < 0 ? -1 : 1;
  36881. x.e = 0;
  36882. x.d = [0];
  36883. return;
  36884. }
  36885. if (v < 0) {
  36886. v = -v;
  36887. x.s = -1;
  36888. } else {
  36889. x.s = 1;
  36890. }
  36891. // Fast path for small integers.
  36892. if (v === ~~v && v < 1e7) {
  36893. for (e = 0, i = v; i >= 10; i /= 10) {
  36894. e++;
  36895. }x.e = e;
  36896. x.d = [v];
  36897. return;
  36898. // Infinity, NaN.
  36899. } else if (v * 0 !== 0) {
  36900. if (!v) x.s = NaN;
  36901. x.e = NaN;
  36902. x.d = null;
  36903. return;
  36904. }
  36905. return parseDecimal(x, v.toString());
  36906. } else if (t !== 'string') {
  36907. throw Error(invalidArgument + v);
  36908. }
  36909. // Minus sign?
  36910. if (v.charCodeAt(0) === 45) {
  36911. v = v.slice(1);
  36912. x.s = -1;
  36913. } else {
  36914. x.s = 1;
  36915. }
  36916. return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
  36917. }
  36918. Decimal.prototype = P;
  36919. Decimal.ROUND_UP = 0;
  36920. Decimal.ROUND_DOWN = 1;
  36921. Decimal.ROUND_CEIL = 2;
  36922. Decimal.ROUND_FLOOR = 3;
  36923. Decimal.ROUND_HALF_UP = 4;
  36924. Decimal.ROUND_HALF_DOWN = 5;
  36925. Decimal.ROUND_HALF_EVEN = 6;
  36926. Decimal.ROUND_HALF_CEIL = 7;
  36927. Decimal.ROUND_HALF_FLOOR = 8;
  36928. Decimal.EUCLID = 9;
  36929. Decimal.config = Decimal.set = config;
  36930. Decimal.clone = clone;
  36931. Decimal.isDecimal = isDecimalInstance;
  36932. Decimal.abs = abs;
  36933. Decimal.acos = acos;
  36934. Decimal.acosh = acosh; // ES6
  36935. Decimal.add = add;
  36936. Decimal.asin = asin;
  36937. Decimal.asinh = asinh; // ES6
  36938. Decimal.atan = atan;
  36939. Decimal.atanh = atanh; // ES6
  36940. Decimal.atan2 = atan2;
  36941. Decimal.cbrt = cbrt; // ES6
  36942. Decimal.ceil = ceil;
  36943. Decimal.cos = cos;
  36944. Decimal.cosh = cosh; // ES6
  36945. Decimal.div = div;
  36946. Decimal.exp = exp;
  36947. Decimal.floor = floor;
  36948. Decimal.hypot = hypot; // ES6
  36949. Decimal.ln = ln;
  36950. Decimal.log = log;
  36951. Decimal.log10 = log10; // ES6
  36952. Decimal.log2 = log2; // ES6
  36953. Decimal.max = max;
  36954. Decimal.min = min;
  36955. Decimal.mod = mod;
  36956. Decimal.mul = mul;
  36957. Decimal.pow = pow;
  36958. Decimal.random = random;
  36959. Decimal.round = round;
  36960. Decimal.sign = sign; // ES6
  36961. Decimal.sin = sin;
  36962. Decimal.sinh = sinh; // ES6
  36963. Decimal.sqrt = sqrt;
  36964. Decimal.sub = sub;
  36965. Decimal.tan = tan;
  36966. Decimal.tanh = tanh; // ES6
  36967. Decimal.trunc = trunc; // ES6
  36968. if (obj === void 0) obj = {};
  36969. if (obj) {
  36970. if (obj.defaults !== true) {
  36971. ps = ['precision', 'rounding', 'toExpNeg', 'toExpPos', 'maxE', 'minE', 'modulo', 'crypto'];
  36972. for (i = 0; i < ps.length;) {
  36973. if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p];
  36974. }
  36975. }
  36976. }
  36977. Decimal.config(obj);
  36978. return Decimal;
  36979. }
  36980. /*
  36981. * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant
  36982. * digits using rounding mode `rounding`.
  36983. *
  36984. * x {number|string|Decimal}
  36985. * y {number|string|Decimal}
  36986. *
  36987. */
  36988. function div(x, y) {
  36989. return new this(x).div(y);
  36990. }
  36991. /*
  36992. * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision`
  36993. * significant digits using rounding mode `rounding`.
  36994. *
  36995. * x {number|string|Decimal} The power to which to raise the base of the natural log.
  36996. *
  36997. */
  36998. function exp(x) {
  36999. return new this(x).exp();
  37000. }
  37001. /*
  37002. * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`.
  37003. *
  37004. * x {number|string|Decimal}
  37005. *
  37006. */
  37007. function floor(x) {
  37008. return finalise(x = new this(x), x.e + 1, 3);
  37009. }
  37010. /*
  37011. * Return a new Decimal whose value is the square root of the sum of the squares of the arguments,
  37012. * rounded to `precision` significant digits using rounding mode `rounding`.
  37013. *
  37014. * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...)
  37015. *
  37016. */
  37017. function hypot() {
  37018. var i,
  37019. n,
  37020. t = new this(0);
  37021. external = false;
  37022. for (i = 0; i < arguments.length;) {
  37023. n = new this(arguments[i++]);
  37024. if (!n.d) {
  37025. if (n.s) {
  37026. external = true;
  37027. return new this(1 / 0);
  37028. }
  37029. t = n;
  37030. } else if (t.d) {
  37031. t = t.plus(n.times(n));
  37032. }
  37033. }
  37034. external = true;
  37035. return t.sqrt();
  37036. }
  37037. /*
  37038. * Return true if object is a Decimal instance (where Decimal is any Decimal constructor),
  37039. * otherwise return false.
  37040. *
  37041. */
  37042. function isDecimalInstance(obj) {
  37043. return obj instanceof Decimal || obj && obj.name === '[object Decimal]' || false;
  37044. }
  37045. /*
  37046. * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision`
  37047. * significant digits using rounding mode `rounding`.
  37048. *
  37049. * x {number|string|Decimal}
  37050. *
  37051. */
  37052. function ln(x) {
  37053. return new this(x).ln();
  37054. }
  37055. /*
  37056. * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base
  37057. * is specified, rounded to `precision` significant digits using rounding mode `rounding`.
  37058. *
  37059. * log[y](x)
  37060. *
  37061. * x {number|string|Decimal} The argument of the logarithm.
  37062. * y {number|string|Decimal} The base of the logarithm.
  37063. *
  37064. */
  37065. function log(x, y) {
  37066. return new this(x).log(y);
  37067. }
  37068. /*
  37069. * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision`
  37070. * significant digits using rounding mode `rounding`.
  37071. *
  37072. * x {number|string|Decimal}
  37073. *
  37074. */
  37075. function log2(x) {
  37076. return new this(x).log(2);
  37077. }
  37078. /*
  37079. * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision`
  37080. * significant digits using rounding mode `rounding`.
  37081. *
  37082. * x {number|string|Decimal}
  37083. *
  37084. */
  37085. function log10(x) {
  37086. return new this(x).log(10);
  37087. }
  37088. /*
  37089. * Return a new Decimal whose value is the maximum of the arguments.
  37090. *
  37091. * arguments {number|string|Decimal}
  37092. *
  37093. */
  37094. function max() {
  37095. return maxOrMin(this, arguments, 'lt');
  37096. }
  37097. /*
  37098. * Return a new Decimal whose value is the minimum of the arguments.
  37099. *
  37100. * arguments {number|string|Decimal}
  37101. *
  37102. */
  37103. function min() {
  37104. return maxOrMin(this, arguments, 'gt');
  37105. }
  37106. /*
  37107. * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits
  37108. * using rounding mode `rounding`.
  37109. *
  37110. * x {number|string|Decimal}
  37111. * y {number|string|Decimal}
  37112. *
  37113. */
  37114. function mod(x, y) {
  37115. return new this(x).mod(y);
  37116. }
  37117. /*
  37118. * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant
  37119. * digits using rounding mode `rounding`.
  37120. *
  37121. * x {number|string|Decimal}
  37122. * y {number|string|Decimal}
  37123. *
  37124. */
  37125. function mul(x, y) {
  37126. return new this(x).mul(y);
  37127. }
  37128. /*
  37129. * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision
  37130. * significant digits using rounding mode `rounding`.
  37131. *
  37132. * x {number|string|Decimal} The base.
  37133. * y {number|string|Decimal} The exponent.
  37134. *
  37135. */
  37136. function pow(x, y) {
  37137. return new this(x).pow(y);
  37138. }
  37139. /*
  37140. * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with
  37141. * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros
  37142. * are produced).
  37143. *
  37144. * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive.
  37145. *
  37146. */
  37147. function random(sd) {
  37148. var d,
  37149. e,
  37150. k,
  37151. n,
  37152. i = 0,
  37153. r = new this(1),
  37154. rd = [];
  37155. if (sd === void 0) sd = this.precision;else checkInt32(sd, 1, MAX_DIGITS);
  37156. k = Math.ceil(sd / LOG_BASE);
  37157. if (!this.crypto) {
  37158. for (; i < k;) {
  37159. rd[i++] = Math.random() * 1e7 | 0;
  37160. } // Browsers supporting crypto.getRandomValues.
  37161. } else if (crypto.getRandomValues) {
  37162. d = crypto.getRandomValues(new Uint32Array(k));
  37163. for (; i < k;) {
  37164. n = d[i];
  37165. // 0 <= n < 4294967296
  37166. // Probability n >= 4.29e9, is 4967296 / 4294967296 = 0.00116 (1 in 865).
  37167. if (n >= 4.29e9) {
  37168. d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
  37169. } else {
  37170. // 0 <= n <= 4289999999
  37171. // 0 <= (n % 1e7) <= 9999999
  37172. rd[i++] = n % 1e7;
  37173. }
  37174. }
  37175. // Node.js supporting crypto.randomBytes.
  37176. } else if (crypto.randomBytes) {
  37177. // buffer
  37178. d = crypto.randomBytes(k *= 4);
  37179. for (; i < k;) {
  37180. // 0 <= n < 2147483648
  37181. n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 0x7f) << 24);
  37182. // Probability n >= 2.14e9, is 7483648 / 2147483648 = 0.0035 (1 in 286).
  37183. if (n >= 2.14e9) {
  37184. crypto.randomBytes(4).copy(d, i);
  37185. } else {
  37186. // 0 <= n <= 2139999999
  37187. // 0 <= (n % 1e7) <= 9999999
  37188. rd.push(n % 1e7);
  37189. i += 4;
  37190. }
  37191. }
  37192. i = k / 4;
  37193. } else {
  37194. throw Error(cryptoUnavailable);
  37195. }
  37196. k = rd[--i];
  37197. sd %= LOG_BASE;
  37198. // Convert trailing digits to zeros according to sd.
  37199. if (k && sd) {
  37200. n = mathpow(10, LOG_BASE - sd);
  37201. rd[i] = (k / n | 0) * n;
  37202. }
  37203. // Remove trailing words which are zero.
  37204. for (; rd[i] === 0; i--) {
  37205. rd.pop();
  37206. } // Zero?
  37207. if (i < 0) {
  37208. e = 0;
  37209. rd = [0];
  37210. } else {
  37211. e = -1;
  37212. // Remove leading words which are zero and adjust exponent accordingly.
  37213. for (; rd[0] === 0; e -= LOG_BASE) {
  37214. rd.shift();
  37215. } // Count the digits of the first word of rd to determine leading zeros.
  37216. for (k = 1, n = rd[0]; n >= 10; n /= 10) {
  37217. k++;
  37218. } // Adjust the exponent for leading zeros of the first word of rd.
  37219. if (k < LOG_BASE) e -= LOG_BASE - k;
  37220. }
  37221. r.e = e;
  37222. r.d = rd;
  37223. return r;
  37224. }
  37225. /*
  37226. * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`.
  37227. *
  37228. * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL).
  37229. *
  37230. * x {number|string|Decimal}
  37231. *
  37232. */
  37233. function round(x) {
  37234. return finalise(x = new this(x), x.e + 1, this.rounding);
  37235. }
  37236. /*
  37237. * Return
  37238. * 1 if x > 0,
  37239. * -1 if x < 0,
  37240. * 0 if x is 0,
  37241. * -0 if x is -0,
  37242. * NaN otherwise
  37243. *
  37244. */
  37245. function sign(x) {
  37246. x = new this(x);
  37247. return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
  37248. }
  37249. /*
  37250. * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits
  37251. * using rounding mode `rounding`.
  37252. *
  37253. * x {number|string|Decimal} A value in radians.
  37254. *
  37255. */
  37256. function sin(x) {
  37257. return new this(x).sin();
  37258. }
  37259. /*
  37260. * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision`
  37261. * significant digits using rounding mode `rounding`.
  37262. *
  37263. * x {number|string|Decimal} A value in radians.
  37264. *
  37265. */
  37266. function sinh(x) {
  37267. return new this(x).sinh();
  37268. }
  37269. /*
  37270. * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant
  37271. * digits using rounding mode `rounding`.
  37272. *
  37273. * x {number|string|Decimal}
  37274. *
  37275. */
  37276. function sqrt(x) {
  37277. return new this(x).sqrt();
  37278. }
  37279. /*
  37280. * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits
  37281. * using rounding mode `rounding`.
  37282. *
  37283. * x {number|string|Decimal}
  37284. * y {number|string|Decimal}
  37285. *
  37286. */
  37287. function sub(x, y) {
  37288. return new this(x).sub(y);
  37289. }
  37290. /*
  37291. * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant
  37292. * digits using rounding mode `rounding`.
  37293. *
  37294. * x {number|string|Decimal} A value in radians.
  37295. *
  37296. */
  37297. function tan(x) {
  37298. return new this(x).tan();
  37299. }
  37300. /*
  37301. * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision`
  37302. * significant digits using rounding mode `rounding`.
  37303. *
  37304. * x {number|string|Decimal} A value in radians.
  37305. *
  37306. */
  37307. function tanh(x) {
  37308. return new this(x).tanh();
  37309. }
  37310. /*
  37311. * Return a new Decimal whose value is `x` truncated to an integer.
  37312. *
  37313. * x {number|string|Decimal}
  37314. *
  37315. */
  37316. function trunc(x) {
  37317. return finalise(x = new this(x), x.e + 1, 1);
  37318. }
  37319. // Create and configure initial Decimal constructor.
  37320. Decimal = clone(DEFAULTS);
  37321. Decimal['default'] = Decimal.Decimal = Decimal;
  37322. // Create the internal constants from their string values.
  37323. LN10 = new Decimal(LN10);
  37324. PI = new Decimal(PI);
  37325. // Export.
  37326. // AMD.
  37327. if (true) {
  37328. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  37329. return Decimal;
  37330. }).call(exports, __webpack_require__, exports, module),
  37331. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  37332. // Node and other environments that support module.exports.
  37333. } else {}
  37334. })(undefined);
  37335. /***/ }),
  37336. /***/ "./node_modules/jquery/dist/jquery.js":
  37337. /*!********************************************!*\
  37338. !*** ./node_modules/jquery/dist/jquery.js ***!
  37339. \********************************************/
  37340. /*! no static exports found */
  37341. /***/ (function(module, exports, __webpack_require__) {
  37342. "use strict";
  37343. /* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
  37344. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  37345. /*!
  37346. * jQuery JavaScript Library v3.3.1
  37347. * https://jquery.com/
  37348. *
  37349. * Includes Sizzle.js
  37350. * https://sizzlejs.com/
  37351. *
  37352. * Copyright JS Foundation and other contributors
  37353. * Released under the MIT license
  37354. * https://jquery.org/license
  37355. *
  37356. * Date: 2018-01-20T17:24Z
  37357. */
  37358. (function (global, factory) {
  37359. "use strict";
  37360. if (( false ? undefined : _typeof(module)) === "object" && _typeof(module.exports) === "object") {
  37361. // For CommonJS and CommonJS-like environments where a proper `window`
  37362. // is present, execute the factory and get jQuery.
  37363. // For environments that do not have a `window` with a `document`
  37364. // (such as Node.js), expose a factory as module.exports.
  37365. // This accentuates the need for the creation of a real `window`.
  37366. // e.g. var jQuery = require("jquery")(window);
  37367. // See ticket #14549 for more info.
  37368. module.exports = global.document ? factory(global, true) : function (w) {
  37369. if (!w.document) {
  37370. throw new Error("jQuery requires a window with a document");
  37371. }
  37372. return factory(w);
  37373. };
  37374. } else {
  37375. factory(global);
  37376. }
  37377. // Pass this if window is not defined yet
  37378. })(typeof window !== "undefined" ? window : undefined, function (window, noGlobal) {
  37379. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  37380. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  37381. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  37382. // enough that all such attempts are guarded in a try block.
  37383. "use strict";
  37384. var arr = [];
  37385. var document = window.document;
  37386. var getProto = Object.getPrototypeOf;
  37387. var _slice = arr.slice;
  37388. var concat = arr.concat;
  37389. var push = arr.push;
  37390. var indexOf = arr.indexOf;
  37391. var class2type = {};
  37392. var toString = class2type.toString;
  37393. var hasOwn = class2type.hasOwnProperty;
  37394. var fnToString = hasOwn.toString;
  37395. var ObjectFunctionString = fnToString.call(Object);
  37396. var support = {};
  37397. var isFunction = function isFunction(obj) {
  37398. // Support: Chrome <=57, Firefox <=52
  37399. // In some browsers, typeof returns "function" for HTML <object> elements
  37400. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  37401. // We don't want to classify *any* DOM node as a function.
  37402. return typeof obj === "function" && typeof obj.nodeType !== "number";
  37403. };
  37404. var isWindow = function isWindow(obj) {
  37405. return obj != null && obj === obj.window;
  37406. };
  37407. var preservedScriptAttributes = {
  37408. type: true,
  37409. src: true,
  37410. noModule: true
  37411. };
  37412. function DOMEval(code, doc, node) {
  37413. doc = doc || document;
  37414. var i,
  37415. script = doc.createElement("script");
  37416. script.text = code;
  37417. if (node) {
  37418. for (i in preservedScriptAttributes) {
  37419. if (node[i]) {
  37420. script[i] = node[i];
  37421. }
  37422. }
  37423. }
  37424. doc.head.appendChild(script).parentNode.removeChild(script);
  37425. }
  37426. function toType(obj) {
  37427. if (obj == null) {
  37428. return obj + "";
  37429. }
  37430. // Support: Android <=2.3 only (functionish RegExp)
  37431. return (typeof obj === "undefined" ? "undefined" : _typeof(obj)) === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
  37432. }
  37433. /* global Symbol */
  37434. // Defining this global in .eslintrc.json would create a danger of using the global
  37435. // unguarded in another place, it seems safer to define global only for this module
  37436. var version = "3.3.1",
  37437. // Define a local copy of jQuery
  37438. jQuery = function jQuery(selector, context) {
  37439. // The jQuery object is actually just the init constructor 'enhanced'
  37440. // Need init if jQuery is called (just allow error to be thrown if not included)
  37441. return new jQuery.fn.init(selector, context);
  37442. },
  37443. // Support: Android <=4.0 only
  37444. // Make sure we trim BOM and NBSP
  37445. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  37446. jQuery.fn = jQuery.prototype = {
  37447. // The current version of jQuery being used
  37448. jquery: version,
  37449. constructor: jQuery,
  37450. // The default length of a jQuery object is 0
  37451. length: 0,
  37452. toArray: function toArray() {
  37453. return _slice.call(this);
  37454. },
  37455. // Get the Nth element in the matched element set OR
  37456. // Get the whole matched element set as a clean array
  37457. get: function get(num) {
  37458. // Return all the elements in a clean array
  37459. if (num == null) {
  37460. return _slice.call(this);
  37461. }
  37462. // Return just the one element from the set
  37463. return num < 0 ? this[num + this.length] : this[num];
  37464. },
  37465. // Take an array of elements and push it onto the stack
  37466. // (returning the new matched element set)
  37467. pushStack: function pushStack(elems) {
  37468. // Build a new jQuery matched element set
  37469. var ret = jQuery.merge(this.constructor(), elems);
  37470. // Add the old object onto the stack (as a reference)
  37471. ret.prevObject = this;
  37472. // Return the newly-formed element set
  37473. return ret;
  37474. },
  37475. // Execute a callback for every element in the matched set.
  37476. each: function each(callback) {
  37477. return jQuery.each(this, callback);
  37478. },
  37479. map: function map(callback) {
  37480. return this.pushStack(jQuery.map(this, function (elem, i) {
  37481. return callback.call(elem, i, elem);
  37482. }));
  37483. },
  37484. slice: function slice() {
  37485. return this.pushStack(_slice.apply(this, arguments));
  37486. },
  37487. first: function first() {
  37488. return this.eq(0);
  37489. },
  37490. last: function last() {
  37491. return this.eq(-1);
  37492. },
  37493. eq: function eq(i) {
  37494. var len = this.length,
  37495. j = +i + (i < 0 ? len : 0);
  37496. return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
  37497. },
  37498. end: function end() {
  37499. return this.prevObject || this.constructor();
  37500. },
  37501. // For internal use only.
  37502. // Behaves like an Array's method, not like a jQuery method.
  37503. push: push,
  37504. sort: arr.sort,
  37505. splice: arr.splice
  37506. };
  37507. jQuery.extend = jQuery.fn.extend = function () {
  37508. var options,
  37509. name,
  37510. src,
  37511. copy,
  37512. copyIsArray,
  37513. clone,
  37514. target = arguments[0] || {},
  37515. i = 1,
  37516. length = arguments.length,
  37517. deep = false;
  37518. // Handle a deep copy situation
  37519. if (typeof target === "boolean") {
  37520. deep = target;
  37521. // Skip the boolean and the target
  37522. target = arguments[i] || {};
  37523. i++;
  37524. }
  37525. // Handle case when target is a string or something (possible in deep copy)
  37526. if ((typeof target === "undefined" ? "undefined" : _typeof(target)) !== "object" && !isFunction(target)) {
  37527. target = {};
  37528. }
  37529. // Extend jQuery itself if only one argument is passed
  37530. if (i === length) {
  37531. target = this;
  37532. i--;
  37533. }
  37534. for (; i < length; i++) {
  37535. // Only deal with non-null/undefined values
  37536. if ((options = arguments[i]) != null) {
  37537. // Extend the base object
  37538. for (name in options) {
  37539. src = target[name];
  37540. copy = options[name];
  37541. // Prevent never-ending loop
  37542. if (target === copy) {
  37543. continue;
  37544. }
  37545. // Recurse if we're merging plain objects or arrays
  37546. if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
  37547. if (copyIsArray) {
  37548. copyIsArray = false;
  37549. clone = src && Array.isArray(src) ? src : [];
  37550. } else {
  37551. clone = src && jQuery.isPlainObject(src) ? src : {};
  37552. }
  37553. // Never move original objects, clone them
  37554. target[name] = jQuery.extend(deep, clone, copy);
  37555. // Don't bring in undefined values
  37556. } else if (copy !== undefined) {
  37557. target[name] = copy;
  37558. }
  37559. }
  37560. }
  37561. }
  37562. // Return the modified object
  37563. return target;
  37564. };
  37565. jQuery.extend({
  37566. // Unique for each copy of jQuery on the page
  37567. expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""),
  37568. // Assume jQuery is ready without the ready module
  37569. isReady: true,
  37570. error: function error(msg) {
  37571. throw new Error(msg);
  37572. },
  37573. noop: function noop() {},
  37574. isPlainObject: function isPlainObject(obj) {
  37575. var proto, Ctor;
  37576. // Detect obvious negatives
  37577. // Use toString instead of jQuery.type to catch host objects
  37578. if (!obj || toString.call(obj) !== "[object Object]") {
  37579. return false;
  37580. }
  37581. proto = getProto(obj);
  37582. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  37583. if (!proto) {
  37584. return true;
  37585. }
  37586. // Objects with prototype are plain iff they were constructed by a global Object function
  37587. Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
  37588. return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
  37589. },
  37590. isEmptyObject: function isEmptyObject(obj) {
  37591. /* eslint-disable no-unused-vars */
  37592. // See https://github.com/eslint/eslint/issues/6125
  37593. var name;
  37594. for (name in obj) {
  37595. return false;
  37596. }
  37597. return true;
  37598. },
  37599. // Evaluates a script in a global context
  37600. globalEval: function globalEval(code) {
  37601. DOMEval(code);
  37602. },
  37603. each: function each(obj, callback) {
  37604. var length,
  37605. i = 0;
  37606. if (isArrayLike(obj)) {
  37607. length = obj.length;
  37608. for (; i < length; i++) {
  37609. if (callback.call(obj[i], i, obj[i]) === false) {
  37610. break;
  37611. }
  37612. }
  37613. } else {
  37614. for (i in obj) {
  37615. if (callback.call(obj[i], i, obj[i]) === false) {
  37616. break;
  37617. }
  37618. }
  37619. }
  37620. return obj;
  37621. },
  37622. // Support: Android <=4.0 only
  37623. trim: function trim(text) {
  37624. return text == null ? "" : (text + "").replace(rtrim, "");
  37625. },
  37626. // results is for internal usage only
  37627. makeArray: function makeArray(arr, results) {
  37628. var ret = results || [];
  37629. if (arr != null) {
  37630. if (isArrayLike(Object(arr))) {
  37631. jQuery.merge(ret, typeof arr === "string" ? [arr] : arr);
  37632. } else {
  37633. push.call(ret, arr);
  37634. }
  37635. }
  37636. return ret;
  37637. },
  37638. inArray: function inArray(elem, arr, i) {
  37639. return arr == null ? -1 : indexOf.call(arr, elem, i);
  37640. },
  37641. // Support: Android <=4.0 only, PhantomJS 1 only
  37642. // push.apply(_, arraylike) throws on ancient WebKit
  37643. merge: function merge(first, second) {
  37644. var len = +second.length,
  37645. j = 0,
  37646. i = first.length;
  37647. for (; j < len; j++) {
  37648. first[i++] = second[j];
  37649. }
  37650. first.length = i;
  37651. return first;
  37652. },
  37653. grep: function grep(elems, callback, invert) {
  37654. var callbackInverse,
  37655. matches = [],
  37656. i = 0,
  37657. length = elems.length,
  37658. callbackExpect = !invert;
  37659. // Go through the array, only saving the items
  37660. // that pass the validator function
  37661. for (; i < length; i++) {
  37662. callbackInverse = !callback(elems[i], i);
  37663. if (callbackInverse !== callbackExpect) {
  37664. matches.push(elems[i]);
  37665. }
  37666. }
  37667. return matches;
  37668. },
  37669. // arg is for internal usage only
  37670. map: function map(elems, callback, arg) {
  37671. var length,
  37672. value,
  37673. i = 0,
  37674. ret = [];
  37675. // Go through the array, translating each of the items to their new values
  37676. if (isArrayLike(elems)) {
  37677. length = elems.length;
  37678. for (; i < length; i++) {
  37679. value = callback(elems[i], i, arg);
  37680. if (value != null) {
  37681. ret.push(value);
  37682. }
  37683. }
  37684. // Go through every key on the object,
  37685. } else {
  37686. for (i in elems) {
  37687. value = callback(elems[i], i, arg);
  37688. if (value != null) {
  37689. ret.push(value);
  37690. }
  37691. }
  37692. }
  37693. // Flatten any nested arrays
  37694. return concat.apply([], ret);
  37695. },
  37696. // A global GUID counter for objects
  37697. guid: 1,
  37698. // jQuery.support is not used in Core but other projects attach their
  37699. // properties to it so it needs to exist.
  37700. support: support
  37701. });
  37702. if (typeof Symbol === "function") {
  37703. jQuery.fn[Symbol.iterator] = arr[Symbol.iterator];
  37704. }
  37705. // Populate the class2type map
  37706. jQuery.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "), function (i, name) {
  37707. class2type["[object " + name + "]"] = name.toLowerCase();
  37708. });
  37709. function isArrayLike(obj) {
  37710. // Support: real iOS 8.2 only (not reproducible in simulator)
  37711. // `in` check used to prevent JIT error (gh-2145)
  37712. // hasOwn isn't used here due to false negatives
  37713. // regarding Nodelist length in IE
  37714. var length = !!obj && "length" in obj && obj.length,
  37715. type = toType(obj);
  37716. if (isFunction(obj) || isWindow(obj)) {
  37717. return false;
  37718. }
  37719. return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj;
  37720. }
  37721. var Sizzle =
  37722. /*!
  37723. * Sizzle CSS Selector Engine v2.3.3
  37724. * https://sizzlejs.com/
  37725. *
  37726. * Copyright jQuery Foundation and other contributors
  37727. * Released under the MIT license
  37728. * http://jquery.org/license
  37729. *
  37730. * Date: 2016-08-08
  37731. */
  37732. function (window) {
  37733. var i,
  37734. support,
  37735. Expr,
  37736. getText,
  37737. isXML,
  37738. tokenize,
  37739. compile,
  37740. select,
  37741. outermostContext,
  37742. sortInput,
  37743. hasDuplicate,
  37744. // Local document vars
  37745. setDocument,
  37746. document,
  37747. docElem,
  37748. documentIsHTML,
  37749. rbuggyQSA,
  37750. rbuggyMatches,
  37751. matches,
  37752. contains,
  37753. // Instance-specific data
  37754. expando = "sizzle" + 1 * new Date(),
  37755. preferredDoc = window.document,
  37756. dirruns = 0,
  37757. done = 0,
  37758. classCache = createCache(),
  37759. tokenCache = createCache(),
  37760. compilerCache = createCache(),
  37761. sortOrder = function sortOrder(a, b) {
  37762. if (a === b) {
  37763. hasDuplicate = true;
  37764. }
  37765. return 0;
  37766. },
  37767. // Instance methods
  37768. hasOwn = {}.hasOwnProperty,
  37769. arr = [],
  37770. pop = arr.pop,
  37771. push_native = arr.push,
  37772. push = arr.push,
  37773. slice = arr.slice,
  37774. // Use a stripped-down indexOf as it's faster than native
  37775. // https://jsperf.com/thor-indexof-vs-for/5
  37776. indexOf = function indexOf(list, elem) {
  37777. var i = 0,
  37778. len = list.length;
  37779. for (; i < len; i++) {
  37780. if (list[i] === elem) {
  37781. return i;
  37782. }
  37783. }
  37784. return -1;
  37785. },
  37786. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  37787. // Regular expressions
  37788. // http://www.w3.org/TR/css3-selectors/#whitespace
  37789. whitespace = "[\\x20\\t\\r\\n\\f]",
  37790. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  37791. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  37792. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  37793. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  37794. // Operator (capture 2)
  37795. "*([*^$|!~]?=)" + whitespace +
  37796. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  37797. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]",
  37798. pseudos = ":(" + identifier + ")(?:\\((" +
  37799. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  37800. // 1. quoted (capture 3; capture 4 or capture 5)
  37801. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  37802. // 2. simple (capture 6)
  37803. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  37804. // 3. anything else (capture 2)
  37805. ".*" + ")\\)|)",
  37806. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  37807. rwhitespace = new RegExp(whitespace + "+", "g"),
  37808. rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"),
  37809. rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"),
  37810. rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"),
  37811. rattributeQuotes = new RegExp("=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g"),
  37812. rpseudo = new RegExp(pseudos),
  37813. ridentifier = new RegExp("^" + identifier + "$"),
  37814. matchExpr = {
  37815. "ID": new RegExp("^#(" + identifier + ")"),
  37816. "CLASS": new RegExp("^\\.(" + identifier + ")"),
  37817. "TAG": new RegExp("^(" + identifier + "|[*])"),
  37818. "ATTR": new RegExp("^" + attributes),
  37819. "PSEUDO": new RegExp("^" + pseudos),
  37820. "CHILD": new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"),
  37821. "bool": new RegExp("^(?:" + booleans + ")$", "i"),
  37822. // For use in libraries implementing .is()
  37823. // We use this for POS matching in `select`
  37824. "needsContext": new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
  37825. },
  37826. rinputs = /^(?:input|select|textarea|button)$/i,
  37827. rheader = /^h\d$/i,
  37828. rnative = /^[^{]+\{\s*\[native \w/,
  37829. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  37830. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  37831. rsibling = /[+~]/,
  37832. // CSS escapes
  37833. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  37834. runescape = new RegExp("\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig"),
  37835. funescape = function funescape(_, escaped, escapedWhitespace) {
  37836. var high = "0x" + escaped - 0x10000;
  37837. // NaN means non-codepoint
  37838. // Support: Firefox<24
  37839. // Workaround erroneous numeric interpretation of +"0x"
  37840. return high !== high || escapedWhitespace ? escaped : high < 0 ?
  37841. // BMP codepoint
  37842. String.fromCharCode(high + 0x10000) :
  37843. // Supplemental Plane codepoint (surrogate pair)
  37844. String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00);
  37845. },
  37846. // CSS string/identifier serialization
  37847. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  37848. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  37849. fcssescape = function fcssescape(ch, asCodePoint) {
  37850. if (asCodePoint) {
  37851. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  37852. if (ch === "\0") {
  37853. return "\uFFFD";
  37854. }
  37855. // Control characters and (dependent upon position) numbers get escaped as code points
  37856. return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " ";
  37857. }
  37858. // Other potentially-special ASCII characters get backslash-escaped
  37859. return "\\" + ch;
  37860. },
  37861. // Used for iframes
  37862. // See setDocument()
  37863. // Removing the function wrapper causes a "Permission Denied"
  37864. // error in IE
  37865. unloadHandler = function unloadHandler() {
  37866. setDocument();
  37867. },
  37868. disabledAncestor = addCombinator(function (elem) {
  37869. return elem.disabled === true && ("form" in elem || "label" in elem);
  37870. }, { dir: "parentNode", next: "legend" });
  37871. // Optimize for push.apply( _, NodeList )
  37872. try {
  37873. push.apply(arr = slice.call(preferredDoc.childNodes), preferredDoc.childNodes);
  37874. // Support: Android<4.0
  37875. // Detect silently failing push.apply
  37876. arr[preferredDoc.childNodes.length].nodeType;
  37877. } catch (e) {
  37878. push = { apply: arr.length ?
  37879. // Leverage slice if possible
  37880. function (target, els) {
  37881. push_native.apply(target, slice.call(els));
  37882. } :
  37883. // Support: IE<9
  37884. // Otherwise append directly
  37885. function (target, els) {
  37886. var j = target.length,
  37887. i = 0;
  37888. // Can't trust NodeList.length
  37889. while (target[j++] = els[i++]) {}
  37890. target.length = j - 1;
  37891. }
  37892. };
  37893. }
  37894. function Sizzle(selector, context, results, seed) {
  37895. var m,
  37896. i,
  37897. elem,
  37898. nid,
  37899. match,
  37900. groups,
  37901. newSelector,
  37902. newContext = context && context.ownerDocument,
  37903. // nodeType defaults to 9, since context defaults to document
  37904. nodeType = context ? context.nodeType : 9;
  37905. results = results || [];
  37906. // Return early from calls with invalid selector or context
  37907. if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
  37908. return results;
  37909. }
  37910. // Try to shortcut find operations (as opposed to filters) in HTML documents
  37911. if (!seed) {
  37912. if ((context ? context.ownerDocument || context : preferredDoc) !== document) {
  37913. setDocument(context);
  37914. }
  37915. context = context || document;
  37916. if (documentIsHTML) {
  37917. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  37918. // (excepting DocumentFragment context, where the methods don't exist)
  37919. if (nodeType !== 11 && (match = rquickExpr.exec(selector))) {
  37920. // ID selector
  37921. if (m = match[1]) {
  37922. // Document context
  37923. if (nodeType === 9) {
  37924. if (elem = context.getElementById(m)) {
  37925. // Support: IE, Opera, Webkit
  37926. // TODO: identify versions
  37927. // getElementById can match elements by name instead of ID
  37928. if (elem.id === m) {
  37929. results.push(elem);
  37930. return results;
  37931. }
  37932. } else {
  37933. return results;
  37934. }
  37935. // Element context
  37936. } else {
  37937. // Support: IE, Opera, Webkit
  37938. // TODO: identify versions
  37939. // getElementById can match elements by name instead of ID
  37940. if (newContext && (elem = newContext.getElementById(m)) && contains(context, elem) && elem.id === m) {
  37941. results.push(elem);
  37942. return results;
  37943. }
  37944. }
  37945. // Type selector
  37946. } else if (match[2]) {
  37947. push.apply(results, context.getElementsByTagName(selector));
  37948. return results;
  37949. // Class selector
  37950. } else if ((m = match[3]) && support.getElementsByClassName && context.getElementsByClassName) {
  37951. push.apply(results, context.getElementsByClassName(m));
  37952. return results;
  37953. }
  37954. }
  37955. // Take advantage of querySelectorAll
  37956. if (support.qsa && !compilerCache[selector + " "] && (!rbuggyQSA || !rbuggyQSA.test(selector))) {
  37957. if (nodeType !== 1) {
  37958. newContext = context;
  37959. newSelector = selector;
  37960. // qSA looks outside Element context, which is not what we want
  37961. // Thanks to Andrew Dupont for this workaround technique
  37962. // Support: IE <=8
  37963. // Exclude object elements
  37964. } else if (context.nodeName.toLowerCase() !== "object") {
  37965. // Capture the context ID, setting it first if necessary
  37966. if (nid = context.getAttribute("id")) {
  37967. nid = nid.replace(rcssescape, fcssescape);
  37968. } else {
  37969. context.setAttribute("id", nid = expando);
  37970. }
  37971. // Prefix every selector in the list
  37972. groups = tokenize(selector);
  37973. i = groups.length;
  37974. while (i--) {
  37975. groups[i] = "#" + nid + " " + toSelector(groups[i]);
  37976. }
  37977. newSelector = groups.join(",");
  37978. // Expand context for sibling selectors
  37979. newContext = rsibling.test(selector) && testContext(context.parentNode) || context;
  37980. }
  37981. if (newSelector) {
  37982. try {
  37983. push.apply(results, newContext.querySelectorAll(newSelector));
  37984. return results;
  37985. } catch (qsaError) {} finally {
  37986. if (nid === expando) {
  37987. context.removeAttribute("id");
  37988. }
  37989. }
  37990. }
  37991. }
  37992. }
  37993. }
  37994. // All others
  37995. return select(selector.replace(rtrim, "$1"), context, results, seed);
  37996. }
  37997. /**
  37998. * Create key-value caches of limited size
  37999. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  38000. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  38001. * deleting the oldest entry
  38002. */
  38003. function createCache() {
  38004. var keys = [];
  38005. function cache(key, value) {
  38006. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  38007. if (keys.push(key + " ") > Expr.cacheLength) {
  38008. // Only keep the most recent entries
  38009. delete cache[keys.shift()];
  38010. }
  38011. return cache[key + " "] = value;
  38012. }
  38013. return cache;
  38014. }
  38015. /**
  38016. * Mark a function for special use by Sizzle
  38017. * @param {Function} fn The function to mark
  38018. */
  38019. function markFunction(fn) {
  38020. fn[expando] = true;
  38021. return fn;
  38022. }
  38023. /**
  38024. * Support testing using an element
  38025. * @param {Function} fn Passed the created element and returns a boolean result
  38026. */
  38027. function assert(fn) {
  38028. var el = document.createElement("fieldset");
  38029. try {
  38030. return !!fn(el);
  38031. } catch (e) {
  38032. return false;
  38033. } finally {
  38034. // Remove from its parent by default
  38035. if (el.parentNode) {
  38036. el.parentNode.removeChild(el);
  38037. }
  38038. // release memory in IE
  38039. el = null;
  38040. }
  38041. }
  38042. /**
  38043. * Adds the same handler for all of the specified attrs
  38044. * @param {String} attrs Pipe-separated list of attributes
  38045. * @param {Function} handler The method that will be applied
  38046. */
  38047. function addHandle(attrs, handler) {
  38048. var arr = attrs.split("|"),
  38049. i = arr.length;
  38050. while (i--) {
  38051. Expr.attrHandle[arr[i]] = handler;
  38052. }
  38053. }
  38054. /**
  38055. * Checks document order of two siblings
  38056. * @param {Element} a
  38057. * @param {Element} b
  38058. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  38059. */
  38060. function siblingCheck(a, b) {
  38061. var cur = b && a,
  38062. diff = cur && a.nodeType === 1 && b.nodeType === 1 && a.sourceIndex - b.sourceIndex;
  38063. // Use IE sourceIndex if available on both nodes
  38064. if (diff) {
  38065. return diff;
  38066. }
  38067. // Check if b follows a
  38068. if (cur) {
  38069. while (cur = cur.nextSibling) {
  38070. if (cur === b) {
  38071. return -1;
  38072. }
  38073. }
  38074. }
  38075. return a ? 1 : -1;
  38076. }
  38077. /**
  38078. * Returns a function to use in pseudos for input types
  38079. * @param {String} type
  38080. */
  38081. function createInputPseudo(type) {
  38082. return function (elem) {
  38083. var name = elem.nodeName.toLowerCase();
  38084. return name === "input" && elem.type === type;
  38085. };
  38086. }
  38087. /**
  38088. * Returns a function to use in pseudos for buttons
  38089. * @param {String} type
  38090. */
  38091. function createButtonPseudo(type) {
  38092. return function (elem) {
  38093. var name = elem.nodeName.toLowerCase();
  38094. return (name === "input" || name === "button") && elem.type === type;
  38095. };
  38096. }
  38097. /**
  38098. * Returns a function to use in pseudos for :enabled/:disabled
  38099. * @param {Boolean} disabled true for :disabled; false for :enabled
  38100. */
  38101. function createDisabledPseudo(disabled) {
  38102. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  38103. return function (elem) {
  38104. // Only certain elements can match :enabled or :disabled
  38105. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  38106. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  38107. if ("form" in elem) {
  38108. // Check for inherited disabledness on relevant non-disabled elements:
  38109. // * listed form-associated elements in a disabled fieldset
  38110. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  38111. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  38112. // * option elements in a disabled optgroup
  38113. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  38114. // All such elements have a "form" property.
  38115. if (elem.parentNode && elem.disabled === false) {
  38116. // Option elements defer to a parent optgroup if present
  38117. if ("label" in elem) {
  38118. if ("label" in elem.parentNode) {
  38119. return elem.parentNode.disabled === disabled;
  38120. } else {
  38121. return elem.disabled === disabled;
  38122. }
  38123. }
  38124. // Support: IE 6 - 11
  38125. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  38126. return elem.isDisabled === disabled ||
  38127. // Where there is no isDisabled, check manually
  38128. /* jshint -W018 */
  38129. elem.isDisabled !== !disabled && disabledAncestor(elem) === disabled;
  38130. }
  38131. return elem.disabled === disabled;
  38132. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  38133. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  38134. // even exist on them, let alone have a boolean value.
  38135. } else if ("label" in elem) {
  38136. return elem.disabled === disabled;
  38137. }
  38138. // Remaining elements are neither :enabled nor :disabled
  38139. return false;
  38140. };
  38141. }
  38142. /**
  38143. * Returns a function to use in pseudos for positionals
  38144. * @param {Function} fn
  38145. */
  38146. function createPositionalPseudo(fn) {
  38147. return markFunction(function (argument) {
  38148. argument = +argument;
  38149. return markFunction(function (seed, matches) {
  38150. var j,
  38151. matchIndexes = fn([], seed.length, argument),
  38152. i = matchIndexes.length;
  38153. // Match elements found at the specified indexes
  38154. while (i--) {
  38155. if (seed[j = matchIndexes[i]]) {
  38156. seed[j] = !(matches[j] = seed[j]);
  38157. }
  38158. }
  38159. });
  38160. });
  38161. }
  38162. /**
  38163. * Checks a node for validity as a Sizzle context
  38164. * @param {Element|Object=} context
  38165. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  38166. */
  38167. function testContext(context) {
  38168. return context && typeof context.getElementsByTagName !== "undefined" && context;
  38169. }
  38170. // Expose support vars for convenience
  38171. support = Sizzle.support = {};
  38172. /**
  38173. * Detects XML nodes
  38174. * @param {Element|Object} elem An element or a document
  38175. * @returns {Boolean} True iff elem is a non-HTML XML node
  38176. */
  38177. isXML = Sizzle.isXML = function (elem) {
  38178. // documentElement is verified for cases where it doesn't yet exist
  38179. // (such as loading iframes in IE - #4833)
  38180. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  38181. return documentElement ? documentElement.nodeName !== "HTML" : false;
  38182. };
  38183. /**
  38184. * Sets document-related variables once based on the current document
  38185. * @param {Element|Object} [doc] An element or document object to use to set the document
  38186. * @returns {Object} Returns the current document
  38187. */
  38188. setDocument = Sizzle.setDocument = function (node) {
  38189. var hasCompare,
  38190. subWindow,
  38191. doc = node ? node.ownerDocument || node : preferredDoc;
  38192. // Return early if doc is invalid or already selected
  38193. if (doc === document || doc.nodeType !== 9 || !doc.documentElement) {
  38194. return document;
  38195. }
  38196. // Update global variables
  38197. document = doc;
  38198. docElem = document.documentElement;
  38199. documentIsHTML = !isXML(document);
  38200. // Support: IE 9-11, Edge
  38201. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  38202. if (preferredDoc !== document && (subWindow = document.defaultView) && subWindow.top !== subWindow) {
  38203. // Support: IE 11, Edge
  38204. if (subWindow.addEventListener) {
  38205. subWindow.addEventListener("unload", unloadHandler, false);
  38206. // Support: IE 9 - 10 only
  38207. } else if (subWindow.attachEvent) {
  38208. subWindow.attachEvent("onunload", unloadHandler);
  38209. }
  38210. }
  38211. /* Attributes
  38212. ---------------------------------------------------------------------- */
  38213. // Support: IE<8
  38214. // Verify that getAttribute really returns attributes and not properties
  38215. // (excepting IE8 booleans)
  38216. support.attributes = assert(function (el) {
  38217. el.className = "i";
  38218. return !el.getAttribute("className");
  38219. });
  38220. /* getElement(s)By*
  38221. ---------------------------------------------------------------------- */
  38222. // Check if getElementsByTagName("*") returns only elements
  38223. support.getElementsByTagName = assert(function (el) {
  38224. el.appendChild(document.createComment(""));
  38225. return !el.getElementsByTagName("*").length;
  38226. });
  38227. // Support: IE<9
  38228. support.getElementsByClassName = rnative.test(document.getElementsByClassName);
  38229. // Support: IE<10
  38230. // Check if getElementById returns elements by name
  38231. // The broken getElementById methods don't pick up programmatically-set names,
  38232. // so use a roundabout getElementsByName test
  38233. support.getById = assert(function (el) {
  38234. docElem.appendChild(el).id = expando;
  38235. return !document.getElementsByName || !document.getElementsByName(expando).length;
  38236. });
  38237. // ID filter and find
  38238. if (support.getById) {
  38239. Expr.filter["ID"] = function (id) {
  38240. var attrId = id.replace(runescape, funescape);
  38241. return function (elem) {
  38242. return elem.getAttribute("id") === attrId;
  38243. };
  38244. };
  38245. Expr.find["ID"] = function (id, context) {
  38246. if (typeof context.getElementById !== "undefined" && documentIsHTML) {
  38247. var elem = context.getElementById(id);
  38248. return elem ? [elem] : [];
  38249. }
  38250. };
  38251. } else {
  38252. Expr.filter["ID"] = function (id) {
  38253. var attrId = id.replace(runescape, funescape);
  38254. return function (elem) {
  38255. var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
  38256. return node && node.value === attrId;
  38257. };
  38258. };
  38259. // Support: IE 6 - 7 only
  38260. // getElementById is not reliable as a find shortcut
  38261. Expr.find["ID"] = function (id, context) {
  38262. if (typeof context.getElementById !== "undefined" && documentIsHTML) {
  38263. var node,
  38264. i,
  38265. elems,
  38266. elem = context.getElementById(id);
  38267. if (elem) {
  38268. // Verify the id attribute
  38269. node = elem.getAttributeNode("id");
  38270. if (node && node.value === id) {
  38271. return [elem];
  38272. }
  38273. // Fall back on getElementsByName
  38274. elems = context.getElementsByName(id);
  38275. i = 0;
  38276. while (elem = elems[i++]) {
  38277. node = elem.getAttributeNode("id");
  38278. if (node && node.value === id) {
  38279. return [elem];
  38280. }
  38281. }
  38282. }
  38283. return [];
  38284. }
  38285. };
  38286. }
  38287. // Tag
  38288. Expr.find["TAG"] = support.getElementsByTagName ? function (tag, context) {
  38289. if (typeof context.getElementsByTagName !== "undefined") {
  38290. return context.getElementsByTagName(tag);
  38291. // DocumentFragment nodes don't have gEBTN
  38292. } else if (support.qsa) {
  38293. return context.querySelectorAll(tag);
  38294. }
  38295. } : function (tag, context) {
  38296. var elem,
  38297. tmp = [],
  38298. i = 0,
  38299. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  38300. results = context.getElementsByTagName(tag);
  38301. // Filter out possible comments
  38302. if (tag === "*") {
  38303. while (elem = results[i++]) {
  38304. if (elem.nodeType === 1) {
  38305. tmp.push(elem);
  38306. }
  38307. }
  38308. return tmp;
  38309. }
  38310. return results;
  38311. };
  38312. // Class
  38313. Expr.find["CLASS"] = support.getElementsByClassName && function (className, context) {
  38314. if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) {
  38315. return context.getElementsByClassName(className);
  38316. }
  38317. };
  38318. /* QSA/matchesSelector
  38319. ---------------------------------------------------------------------- */
  38320. // QSA and matchesSelector support
  38321. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  38322. rbuggyMatches = [];
  38323. // qSa(:focus) reports false when true (Chrome 21)
  38324. // We allow this because of a bug in IE8/9 that throws an error
  38325. // whenever `document.activeElement` is accessed on an iframe
  38326. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  38327. // See https://bugs.jquery.com/ticket/13378
  38328. rbuggyQSA = [];
  38329. if (support.qsa = rnative.test(document.querySelectorAll)) {
  38330. // Build QSA regex
  38331. // Regex strategy adopted from Diego Perini
  38332. assert(function (el) {
  38333. // Select is set to empty string on purpose
  38334. // This is to test IE's treatment of not explicitly
  38335. // setting a boolean content attribute,
  38336. // since its presence should be enough
  38337. // https://bugs.jquery.com/ticket/12359
  38338. docElem.appendChild(el).innerHTML = "<a id='" + expando + "'></a>" + "<select id='" + expando + "-\r\\' msallowcapture=''>" + "<option selected=''></option></select>";
  38339. // Support: IE8, Opera 11-12.16
  38340. // Nothing should be selected when empty strings follow ^= or $= or *=
  38341. // The test attribute must be unknown in Opera but "safe" for WinRT
  38342. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  38343. if (el.querySelectorAll("[msallowcapture^='']").length) {
  38344. rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")");
  38345. }
  38346. // Support: IE8
  38347. // Boolean attributes and "value" are not treated correctly
  38348. if (!el.querySelectorAll("[selected]").length) {
  38349. rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")");
  38350. }
  38351. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  38352. if (!el.querySelectorAll("[id~=" + expando + "-]").length) {
  38353. rbuggyQSA.push("~=");
  38354. }
  38355. // Webkit/Opera - :checked should return selected option elements
  38356. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  38357. // IE8 throws error here and will not see later tests
  38358. if (!el.querySelectorAll(":checked").length) {
  38359. rbuggyQSA.push(":checked");
  38360. }
  38361. // Support: Safari 8+, iOS 8+
  38362. // https://bugs.webkit.org/show_bug.cgi?id=136851
  38363. // In-page `selector#id sibling-combinator selector` fails
  38364. if (!el.querySelectorAll("a#" + expando + "+*").length) {
  38365. rbuggyQSA.push(".#.+[+~]");
  38366. }
  38367. });
  38368. assert(function (el) {
  38369. el.innerHTML = "<a href='' disabled='disabled'></a>" + "<select disabled='disabled'><option/></select>";
  38370. // Support: Windows 8 Native Apps
  38371. // The type and name attributes are restricted during .innerHTML assignment
  38372. var input = document.createElement("input");
  38373. input.setAttribute("type", "hidden");
  38374. el.appendChild(input).setAttribute("name", "D");
  38375. // Support: IE8
  38376. // Enforce case-sensitivity of name attribute
  38377. if (el.querySelectorAll("[name=d]").length) {
  38378. rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?=");
  38379. }
  38380. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  38381. // IE8 throws error here and will not see later tests
  38382. if (el.querySelectorAll(":enabled").length !== 2) {
  38383. rbuggyQSA.push(":enabled", ":disabled");
  38384. }
  38385. // Support: IE9-11+
  38386. // IE's :disabled selector does not pick up the children of disabled fieldsets
  38387. docElem.appendChild(el).disabled = true;
  38388. if (el.querySelectorAll(":disabled").length !== 2) {
  38389. rbuggyQSA.push(":enabled", ":disabled");
  38390. }
  38391. // Opera 10-11 does not throw on post-comma invalid pseudos
  38392. el.querySelectorAll("*,:x");
  38393. rbuggyQSA.push(",.*:");
  38394. });
  38395. }
  38396. if (support.matchesSelector = rnative.test(matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)) {
  38397. assert(function (el) {
  38398. // Check to see if it's possible to do matchesSelector
  38399. // on a disconnected node (IE 9)
  38400. support.disconnectedMatch = matches.call(el, "*");
  38401. // This should fail with an exception
  38402. // Gecko does not error, returns false instead
  38403. matches.call(el, "[s!='']:x");
  38404. rbuggyMatches.push("!=", pseudos);
  38405. });
  38406. }
  38407. rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
  38408. rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|"));
  38409. /* Contains
  38410. ---------------------------------------------------------------------- */
  38411. hasCompare = rnative.test(docElem.compareDocumentPosition);
  38412. // Element contains another
  38413. // Purposefully self-exclusive
  38414. // As in, an element does not contain itself
  38415. contains = hasCompare || rnative.test(docElem.contains) ? function (a, b) {
  38416. var adown = a.nodeType === 9 ? a.documentElement : a,
  38417. bup = b && b.parentNode;
  38418. return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16));
  38419. } : function (a, b) {
  38420. if (b) {
  38421. while (b = b.parentNode) {
  38422. if (b === a) {
  38423. return true;
  38424. }
  38425. }
  38426. }
  38427. return false;
  38428. };
  38429. /* Sorting
  38430. ---------------------------------------------------------------------- */
  38431. // Document order sorting
  38432. sortOrder = hasCompare ? function (a, b) {
  38433. // Flag for duplicate removal
  38434. if (a === b) {
  38435. hasDuplicate = true;
  38436. return 0;
  38437. }
  38438. // Sort on method existence if only one input has compareDocumentPosition
  38439. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  38440. if (compare) {
  38441. return compare;
  38442. }
  38443. // Calculate position if both inputs belong to the same document
  38444. compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) :
  38445. // Otherwise we know they are disconnected
  38446. 1;
  38447. // Disconnected nodes
  38448. if (compare & 1 || !support.sortDetached && b.compareDocumentPosition(a) === compare) {
  38449. // Choose the first element that is related to our preferred document
  38450. if (a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {
  38451. return -1;
  38452. }
  38453. if (b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {
  38454. return 1;
  38455. }
  38456. // Maintain original order
  38457. return sortInput ? indexOf(sortInput, a) - indexOf(sortInput, b) : 0;
  38458. }
  38459. return compare & 4 ? -1 : 1;
  38460. } : function (a, b) {
  38461. // Exit early if the nodes are identical
  38462. if (a === b) {
  38463. hasDuplicate = true;
  38464. return 0;
  38465. }
  38466. var cur,
  38467. i = 0,
  38468. aup = a.parentNode,
  38469. bup = b.parentNode,
  38470. ap = [a],
  38471. bp = [b];
  38472. // Parentless nodes are either documents or disconnected
  38473. if (!aup || !bup) {
  38474. return a === document ? -1 : b === document ? 1 : aup ? -1 : bup ? 1 : sortInput ? indexOf(sortInput, a) - indexOf(sortInput, b) : 0;
  38475. // If the nodes are siblings, we can do a quick check
  38476. } else if (aup === bup) {
  38477. return siblingCheck(a, b);
  38478. }
  38479. // Otherwise we need full lists of their ancestors for comparison
  38480. cur = a;
  38481. while (cur = cur.parentNode) {
  38482. ap.unshift(cur);
  38483. }
  38484. cur = b;
  38485. while (cur = cur.parentNode) {
  38486. bp.unshift(cur);
  38487. }
  38488. // Walk down the tree looking for a discrepancy
  38489. while (ap[i] === bp[i]) {
  38490. i++;
  38491. }
  38492. return i ?
  38493. // Do a sibling check if the nodes have a common ancestor
  38494. siblingCheck(ap[i], bp[i]) :
  38495. // Otherwise nodes in our document sort first
  38496. ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0;
  38497. };
  38498. return document;
  38499. };
  38500. Sizzle.matches = function (expr, elements) {
  38501. return Sizzle(expr, null, null, elements);
  38502. };
  38503. Sizzle.matchesSelector = function (elem, expr) {
  38504. // Set document vars if needed
  38505. if ((elem.ownerDocument || elem) !== document) {
  38506. setDocument(elem);
  38507. }
  38508. // Make sure that attribute selectors are quoted
  38509. expr = expr.replace(rattributeQuotes, "='$1']");
  38510. if (support.matchesSelector && documentIsHTML && !compilerCache[expr + " "] && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) {
  38511. try {
  38512. var ret = matches.call(elem, expr);
  38513. // IE 9's matchesSelector returns false on disconnected nodes
  38514. if (ret || support.disconnectedMatch ||
  38515. // As well, disconnected nodes are said to be in a document
  38516. // fragment in IE 9
  38517. elem.document && elem.document.nodeType !== 11) {
  38518. return ret;
  38519. }
  38520. } catch (e) {}
  38521. }
  38522. return Sizzle(expr, document, null, [elem]).length > 0;
  38523. };
  38524. Sizzle.contains = function (context, elem) {
  38525. // Set document vars if needed
  38526. if ((context.ownerDocument || context) !== document) {
  38527. setDocument(context);
  38528. }
  38529. return contains(context, elem);
  38530. };
  38531. Sizzle.attr = function (elem, name) {
  38532. // Set document vars if needed
  38533. if ((elem.ownerDocument || elem) !== document) {
  38534. setDocument(elem);
  38535. }
  38536. var fn = Expr.attrHandle[name.toLowerCase()],
  38537. // Don't get fooled by Object.prototype properties (jQuery #13807)
  38538. val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : undefined;
  38539. return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null;
  38540. };
  38541. Sizzle.escape = function (sel) {
  38542. return (sel + "").replace(rcssescape, fcssescape);
  38543. };
  38544. Sizzle.error = function (msg) {
  38545. throw new Error("Syntax error, unrecognized expression: " + msg);
  38546. };
  38547. /**
  38548. * Document sorting and removing duplicates
  38549. * @param {ArrayLike} results
  38550. */
  38551. Sizzle.uniqueSort = function (results) {
  38552. var elem,
  38553. duplicates = [],
  38554. j = 0,
  38555. i = 0;
  38556. // Unless we *know* we can detect duplicates, assume their presence
  38557. hasDuplicate = !support.detectDuplicates;
  38558. sortInput = !support.sortStable && results.slice(0);
  38559. results.sort(sortOrder);
  38560. if (hasDuplicate) {
  38561. while (elem = results[i++]) {
  38562. if (elem === results[i]) {
  38563. j = duplicates.push(i);
  38564. }
  38565. }
  38566. while (j--) {
  38567. results.splice(duplicates[j], 1);
  38568. }
  38569. }
  38570. // Clear input after sorting to release objects
  38571. // See https://github.com/jquery/sizzle/pull/225
  38572. sortInput = null;
  38573. return results;
  38574. };
  38575. /**
  38576. * Utility function for retrieving the text value of an array of DOM nodes
  38577. * @param {Array|Element} elem
  38578. */
  38579. getText = Sizzle.getText = function (elem) {
  38580. var node,
  38581. ret = "",
  38582. i = 0,
  38583. nodeType = elem.nodeType;
  38584. if (!nodeType) {
  38585. // If no nodeType, this is expected to be an array
  38586. while (node = elem[i++]) {
  38587. // Do not traverse comment nodes
  38588. ret += getText(node);
  38589. }
  38590. } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {
  38591. // Use textContent for elements
  38592. // innerText usage removed for consistency of new lines (jQuery #11153)
  38593. if (typeof elem.textContent === "string") {
  38594. return elem.textContent;
  38595. } else {
  38596. // Traverse its children
  38597. for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
  38598. ret += getText(elem);
  38599. }
  38600. }
  38601. } else if (nodeType === 3 || nodeType === 4) {
  38602. return elem.nodeValue;
  38603. }
  38604. // Do not include comment or processing instruction nodes
  38605. return ret;
  38606. };
  38607. Expr = Sizzle.selectors = {
  38608. // Can be adjusted by the user
  38609. cacheLength: 50,
  38610. createPseudo: markFunction,
  38611. match: matchExpr,
  38612. attrHandle: {},
  38613. find: {},
  38614. relative: {
  38615. ">": { dir: "parentNode", first: true },
  38616. " ": { dir: "parentNode" },
  38617. "+": { dir: "previousSibling", first: true },
  38618. "~": { dir: "previousSibling" }
  38619. },
  38620. preFilter: {
  38621. "ATTR": function ATTR(match) {
  38622. match[1] = match[1].replace(runescape, funescape);
  38623. // Move the given value to match[3] whether quoted or unquoted
  38624. match[3] = (match[3] || match[4] || match[5] || "").replace(runescape, funescape);
  38625. if (match[2] === "~=") {
  38626. match[3] = " " + match[3] + " ";
  38627. }
  38628. return match.slice(0, 4);
  38629. },
  38630. "CHILD": function CHILD(match) {
  38631. /* matches from matchExpr["CHILD"]
  38632. 1 type (only|nth|...)
  38633. 2 what (child|of-type)
  38634. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  38635. 4 xn-component of xn+y argument ([+-]?\d*n|)
  38636. 5 sign of xn-component
  38637. 6 x of xn-component
  38638. 7 sign of y-component
  38639. 8 y of y-component
  38640. */
  38641. match[1] = match[1].toLowerCase();
  38642. if (match[1].slice(0, 3) === "nth") {
  38643. // nth-* requires argument
  38644. if (!match[3]) {
  38645. Sizzle.error(match[0]);
  38646. }
  38647. // numeric x and y parameters for Expr.filter.CHILD
  38648. // remember that false/true cast respectively to 0/1
  38649. match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd"));
  38650. match[5] = +(match[7] + match[8] || match[3] === "odd");
  38651. // other types prohibit arguments
  38652. } else if (match[3]) {
  38653. Sizzle.error(match[0]);
  38654. }
  38655. return match;
  38656. },
  38657. "PSEUDO": function PSEUDO(match) {
  38658. var excess,
  38659. unquoted = !match[6] && match[2];
  38660. if (matchExpr["CHILD"].test(match[0])) {
  38661. return null;
  38662. }
  38663. // Accept quoted arguments as-is
  38664. if (match[3]) {
  38665. match[2] = match[4] || match[5] || "";
  38666. // Strip excess characters from unquoted arguments
  38667. } else if (unquoted && rpseudo.test(unquoted) && (
  38668. // Get excess from tokenize (recursively)
  38669. excess = tokenize(unquoted, true)) && (
  38670. // advance to the next closing parenthesis
  38671. excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
  38672. // excess is a negative index
  38673. match[0] = match[0].slice(0, excess);
  38674. match[2] = unquoted.slice(0, excess);
  38675. }
  38676. // Return only captures needed by the pseudo filter method (type and argument)
  38677. return match.slice(0, 3);
  38678. }
  38679. },
  38680. filter: {
  38681. "TAG": function TAG(nodeNameSelector) {
  38682. var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();
  38683. return nodeNameSelector === "*" ? function () {
  38684. return true;
  38685. } : function (elem) {
  38686. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  38687. };
  38688. },
  38689. "CLASS": function CLASS(className) {
  38690. var pattern = classCache[className + " "];
  38691. return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function (elem) {
  38692. return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "");
  38693. });
  38694. },
  38695. "ATTR": function ATTR(name, operator, check) {
  38696. return function (elem) {
  38697. var result = Sizzle.attr(elem, name);
  38698. if (result == null) {
  38699. return operator === "!=";
  38700. }
  38701. if (!operator) {
  38702. return true;
  38703. }
  38704. result += "";
  38705. return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf(check) === 0 : operator === "*=" ? check && result.indexOf(check) > -1 : operator === "$=" ? check && result.slice(-check.length) === check : operator === "~=" ? (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1 : operator === "|=" ? result === check || result.slice(0, check.length + 1) === check + "-" : false;
  38706. };
  38707. },
  38708. "CHILD": function CHILD(type, what, argument, first, last) {
  38709. var simple = type.slice(0, 3) !== "nth",
  38710. forward = type.slice(-4) !== "last",
  38711. ofType = what === "of-type";
  38712. return first === 1 && last === 0 ?
  38713. // Shortcut for :nth-*(n)
  38714. function (elem) {
  38715. return !!elem.parentNode;
  38716. } : function (elem, context, xml) {
  38717. var cache,
  38718. uniqueCache,
  38719. outerCache,
  38720. node,
  38721. nodeIndex,
  38722. start,
  38723. dir = simple !== forward ? "nextSibling" : "previousSibling",
  38724. parent = elem.parentNode,
  38725. name = ofType && elem.nodeName.toLowerCase(),
  38726. useCache = !xml && !ofType,
  38727. diff = false;
  38728. if (parent) {
  38729. // :(first|last|only)-(child|of-type)
  38730. if (simple) {
  38731. while (dir) {
  38732. node = elem;
  38733. while (node = node[dir]) {
  38734. if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {
  38735. return false;
  38736. }
  38737. }
  38738. // Reverse direction for :only-* (if we haven't yet done so)
  38739. start = dir = type === "only" && !start && "nextSibling";
  38740. }
  38741. return true;
  38742. }
  38743. start = [forward ? parent.firstChild : parent.lastChild];
  38744. // non-xml :nth-child(...) stores cache data on `parent`
  38745. if (forward && useCache) {
  38746. // Seek `elem` from a previously-cached index
  38747. // ...in a gzip-friendly way
  38748. node = parent;
  38749. outerCache = node[expando] || (node[expando] = {});
  38750. // Support: IE <9 only
  38751. // Defend against cloned attroperties (jQuery gh-1709)
  38752. uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});
  38753. cache = uniqueCache[type] || [];
  38754. nodeIndex = cache[0] === dirruns && cache[1];
  38755. diff = nodeIndex && cache[2];
  38756. node = nodeIndex && parent.childNodes[nodeIndex];
  38757. while (node = ++nodeIndex && node && node[dir] || (
  38758. // Fallback to seeking `elem` from the start
  38759. diff = nodeIndex = 0) || start.pop()) {
  38760. // When found, cache indexes on `parent` and break
  38761. if (node.nodeType === 1 && ++diff && node === elem) {
  38762. uniqueCache[type] = [dirruns, nodeIndex, diff];
  38763. break;
  38764. }
  38765. }
  38766. } else {
  38767. // Use previously-cached element index if available
  38768. if (useCache) {
  38769. // ...in a gzip-friendly way
  38770. node = elem;
  38771. outerCache = node[expando] || (node[expando] = {});
  38772. // Support: IE <9 only
  38773. // Defend against cloned attroperties (jQuery gh-1709)
  38774. uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});
  38775. cache = uniqueCache[type] || [];
  38776. nodeIndex = cache[0] === dirruns && cache[1];
  38777. diff = nodeIndex;
  38778. }
  38779. // xml :nth-child(...)
  38780. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  38781. if (diff === false) {
  38782. // Use the same loop as above to seek `elem` from the start
  38783. while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) {
  38784. if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) {
  38785. // Cache the index of each encountered element
  38786. if (useCache) {
  38787. outerCache = node[expando] || (node[expando] = {});
  38788. // Support: IE <9 only
  38789. // Defend against cloned attroperties (jQuery gh-1709)
  38790. uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});
  38791. uniqueCache[type] = [dirruns, diff];
  38792. }
  38793. if (node === elem) {
  38794. break;
  38795. }
  38796. }
  38797. }
  38798. }
  38799. }
  38800. // Incorporate the offset, then check against cycle size
  38801. diff -= last;
  38802. return diff === first || diff % first === 0 && diff / first >= 0;
  38803. }
  38804. };
  38805. },
  38806. "PSEUDO": function PSEUDO(pseudo, argument) {
  38807. // pseudo-class names are case-insensitive
  38808. // http://www.w3.org/TR/selectors/#pseudo-classes
  38809. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  38810. // Remember that setFilters inherits from pseudos
  38811. var args,
  38812. fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error("unsupported pseudo: " + pseudo);
  38813. // The user may use createPseudo to indicate that
  38814. // arguments are needed to create the filter function
  38815. // just as Sizzle does
  38816. if (fn[expando]) {
  38817. return fn(argument);
  38818. }
  38819. // But maintain support for old signatures
  38820. if (fn.length > 1) {
  38821. args = [pseudo, pseudo, "", argument];
  38822. return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function (seed, matches) {
  38823. var idx,
  38824. matched = fn(seed, argument),
  38825. i = matched.length;
  38826. while (i--) {
  38827. idx = indexOf(seed, matched[i]);
  38828. seed[idx] = !(matches[idx] = matched[i]);
  38829. }
  38830. }) : function (elem) {
  38831. return fn(elem, 0, args);
  38832. };
  38833. }
  38834. return fn;
  38835. }
  38836. },
  38837. pseudos: {
  38838. // Potentially complex pseudos
  38839. "not": markFunction(function (selector) {
  38840. // Trim the selector passed to compile
  38841. // to avoid treating leading and trailing
  38842. // spaces as combinators
  38843. var input = [],
  38844. results = [],
  38845. matcher = compile(selector.replace(rtrim, "$1"));
  38846. return matcher[expando] ? markFunction(function (seed, matches, context, xml) {
  38847. var elem,
  38848. unmatched = matcher(seed, null, xml, []),
  38849. i = seed.length;
  38850. // Match elements unmatched by `matcher`
  38851. while (i--) {
  38852. if (elem = unmatched[i]) {
  38853. seed[i] = !(matches[i] = elem);
  38854. }
  38855. }
  38856. }) : function (elem, context, xml) {
  38857. input[0] = elem;
  38858. matcher(input, null, xml, results);
  38859. // Don't keep the element (issue #299)
  38860. input[0] = null;
  38861. return !results.pop();
  38862. };
  38863. }),
  38864. "has": markFunction(function (selector) {
  38865. return function (elem) {
  38866. return Sizzle(selector, elem).length > 0;
  38867. };
  38868. }),
  38869. "contains": markFunction(function (text) {
  38870. text = text.replace(runescape, funescape);
  38871. return function (elem) {
  38872. return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1;
  38873. };
  38874. }),
  38875. // "Whether an element is represented by a :lang() selector
  38876. // is based solely on the element's language value
  38877. // being equal to the identifier C,
  38878. // or beginning with the identifier C immediately followed by "-".
  38879. // The matching of C against the element's language value is performed case-insensitively.
  38880. // The identifier C does not have to be a valid language name."
  38881. // http://www.w3.org/TR/selectors/#lang-pseudo
  38882. "lang": markFunction(function (lang) {
  38883. // lang value must be a valid identifier
  38884. if (!ridentifier.test(lang || "")) {
  38885. Sizzle.error("unsupported lang: " + lang);
  38886. }
  38887. lang = lang.replace(runescape, funescape).toLowerCase();
  38888. return function (elem) {
  38889. var elemLang;
  38890. do {
  38891. if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) {
  38892. elemLang = elemLang.toLowerCase();
  38893. return elemLang === lang || elemLang.indexOf(lang + "-") === 0;
  38894. }
  38895. } while ((elem = elem.parentNode) && elem.nodeType === 1);
  38896. return false;
  38897. };
  38898. }),
  38899. // Miscellaneous
  38900. "target": function target(elem) {
  38901. var hash = window.location && window.location.hash;
  38902. return hash && hash.slice(1) === elem.id;
  38903. },
  38904. "root": function root(elem) {
  38905. return elem === docElem;
  38906. },
  38907. "focus": function focus(elem) {
  38908. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  38909. },
  38910. // Boolean properties
  38911. "enabled": createDisabledPseudo(false),
  38912. "disabled": createDisabledPseudo(true),
  38913. "checked": function checked(elem) {
  38914. // In CSS3, :checked should return both checked and selected elements
  38915. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  38916. var nodeName = elem.nodeName.toLowerCase();
  38917. return nodeName === "input" && !!elem.checked || nodeName === "option" && !!elem.selected;
  38918. },
  38919. "selected": function selected(elem) {
  38920. // Accessing this property makes selected-by-default
  38921. // options in Safari work properly
  38922. if (elem.parentNode) {
  38923. elem.parentNode.selectedIndex;
  38924. }
  38925. return elem.selected === true;
  38926. },
  38927. // Contents
  38928. "empty": function empty(elem) {
  38929. // http://www.w3.org/TR/selectors/#empty-pseudo
  38930. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  38931. // but not by others (comment: 8; processing instruction: 7; etc.)
  38932. // nodeType < 6 works because attributes (2) do not appear as children
  38933. for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
  38934. if (elem.nodeType < 6) {
  38935. return false;
  38936. }
  38937. }
  38938. return true;
  38939. },
  38940. "parent": function parent(elem) {
  38941. return !Expr.pseudos["empty"](elem);
  38942. },
  38943. // Element/input types
  38944. "header": function header(elem) {
  38945. return rheader.test(elem.nodeName);
  38946. },
  38947. "input": function input(elem) {
  38948. return rinputs.test(elem.nodeName);
  38949. },
  38950. "button": function button(elem) {
  38951. var name = elem.nodeName.toLowerCase();
  38952. return name === "input" && elem.type === "button" || name === "button";
  38953. },
  38954. "text": function text(elem) {
  38955. var attr;
  38956. return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && (
  38957. // Support: IE<8
  38958. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  38959. (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text");
  38960. },
  38961. // Position-in-collection
  38962. "first": createPositionalPseudo(function () {
  38963. return [0];
  38964. }),
  38965. "last": createPositionalPseudo(function (matchIndexes, length) {
  38966. return [length - 1];
  38967. }),
  38968. "eq": createPositionalPseudo(function (matchIndexes, length, argument) {
  38969. return [argument < 0 ? argument + length : argument];
  38970. }),
  38971. "even": createPositionalPseudo(function (matchIndexes, length) {
  38972. var i = 0;
  38973. for (; i < length; i += 2) {
  38974. matchIndexes.push(i);
  38975. }
  38976. return matchIndexes;
  38977. }),
  38978. "odd": createPositionalPseudo(function (matchIndexes, length) {
  38979. var i = 1;
  38980. for (; i < length; i += 2) {
  38981. matchIndexes.push(i);
  38982. }
  38983. return matchIndexes;
  38984. }),
  38985. "lt": createPositionalPseudo(function (matchIndexes, length, argument) {
  38986. var i = argument < 0 ? argument + length : argument;
  38987. for (; --i >= 0;) {
  38988. matchIndexes.push(i);
  38989. }
  38990. return matchIndexes;
  38991. }),
  38992. "gt": createPositionalPseudo(function (matchIndexes, length, argument) {
  38993. var i = argument < 0 ? argument + length : argument;
  38994. for (; ++i < length;) {
  38995. matchIndexes.push(i);
  38996. }
  38997. return matchIndexes;
  38998. })
  38999. }
  39000. };
  39001. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  39002. // Add button/input type pseudos
  39003. for (i in { radio: true, checkbox: true, file: true, password: true, image: true }) {
  39004. Expr.pseudos[i] = createInputPseudo(i);
  39005. }
  39006. for (i in { submit: true, reset: true }) {
  39007. Expr.pseudos[i] = createButtonPseudo(i);
  39008. }
  39009. // Easy API for creating new setFilters
  39010. function setFilters() {}
  39011. setFilters.prototype = Expr.filters = Expr.pseudos;
  39012. Expr.setFilters = new setFilters();
  39013. tokenize = Sizzle.tokenize = function (selector, parseOnly) {
  39014. var matched,
  39015. match,
  39016. tokens,
  39017. type,
  39018. soFar,
  39019. groups,
  39020. preFilters,
  39021. cached = tokenCache[selector + " "];
  39022. if (cached) {
  39023. return parseOnly ? 0 : cached.slice(0);
  39024. }
  39025. soFar = selector;
  39026. groups = [];
  39027. preFilters = Expr.preFilter;
  39028. while (soFar) {
  39029. // Comma and first run
  39030. if (!matched || (match = rcomma.exec(soFar))) {
  39031. if (match) {
  39032. // Don't consume trailing commas as valid
  39033. soFar = soFar.slice(match[0].length) || soFar;
  39034. }
  39035. groups.push(tokens = []);
  39036. }
  39037. matched = false;
  39038. // Combinators
  39039. if (match = rcombinators.exec(soFar)) {
  39040. matched = match.shift();
  39041. tokens.push({
  39042. value: matched,
  39043. // Cast descendant combinators to space
  39044. type: match[0].replace(rtrim, " ")
  39045. });
  39046. soFar = soFar.slice(matched.length);
  39047. }
  39048. // Filters
  39049. for (type in Expr.filter) {
  39050. if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) {
  39051. matched = match.shift();
  39052. tokens.push({
  39053. value: matched,
  39054. type: type,
  39055. matches: match
  39056. });
  39057. soFar = soFar.slice(matched.length);
  39058. }
  39059. }
  39060. if (!matched) {
  39061. break;
  39062. }
  39063. }
  39064. // Return the length of the invalid excess
  39065. // if we're just parsing
  39066. // Otherwise, throw an error or return tokens
  39067. return parseOnly ? soFar.length : soFar ? Sizzle.error(selector) :
  39068. // Cache the tokens
  39069. tokenCache(selector, groups).slice(0);
  39070. };
  39071. function toSelector(tokens) {
  39072. var i = 0,
  39073. len = tokens.length,
  39074. selector = "";
  39075. for (; i < len; i++) {
  39076. selector += tokens[i].value;
  39077. }
  39078. return selector;
  39079. }
  39080. function addCombinator(matcher, combinator, base) {
  39081. var dir = combinator.dir,
  39082. skip = combinator.next,
  39083. key = skip || dir,
  39084. checkNonElements = base && key === "parentNode",
  39085. doneName = done++;
  39086. return combinator.first ?
  39087. // Check against closest ancestor/preceding element
  39088. function (elem, context, xml) {
  39089. while (elem = elem[dir]) {
  39090. if (elem.nodeType === 1 || checkNonElements) {
  39091. return matcher(elem, context, xml);
  39092. }
  39093. }
  39094. return false;
  39095. } :
  39096. // Check against all ancestor/preceding elements
  39097. function (elem, context, xml) {
  39098. var oldCache,
  39099. uniqueCache,
  39100. outerCache,
  39101. newCache = [dirruns, doneName];
  39102. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  39103. if (xml) {
  39104. while (elem = elem[dir]) {
  39105. if (elem.nodeType === 1 || checkNonElements) {
  39106. if (matcher(elem, context, xml)) {
  39107. return true;
  39108. }
  39109. }
  39110. }
  39111. } else {
  39112. while (elem = elem[dir]) {
  39113. if (elem.nodeType === 1 || checkNonElements) {
  39114. outerCache = elem[expando] || (elem[expando] = {});
  39115. // Support: IE <9 only
  39116. // Defend against cloned attroperties (jQuery gh-1709)
  39117. uniqueCache = outerCache[elem.uniqueID] || (outerCache[elem.uniqueID] = {});
  39118. if (skip && skip === elem.nodeName.toLowerCase()) {
  39119. elem = elem[dir] || elem;
  39120. } else if ((oldCache = uniqueCache[key]) && oldCache[0] === dirruns && oldCache[1] === doneName) {
  39121. // Assign to newCache so results back-propagate to previous elements
  39122. return newCache[2] = oldCache[2];
  39123. } else {
  39124. // Reuse newcache so results back-propagate to previous elements
  39125. uniqueCache[key] = newCache;
  39126. // A match means we're done; a fail means we have to keep checking
  39127. if (newCache[2] = matcher(elem, context, xml)) {
  39128. return true;
  39129. }
  39130. }
  39131. }
  39132. }
  39133. }
  39134. return false;
  39135. };
  39136. }
  39137. function elementMatcher(matchers) {
  39138. return matchers.length > 1 ? function (elem, context, xml) {
  39139. var i = matchers.length;
  39140. while (i--) {
  39141. if (!matchers[i](elem, context, xml)) {
  39142. return false;
  39143. }
  39144. }
  39145. return true;
  39146. } : matchers[0];
  39147. }
  39148. function multipleContexts(selector, contexts, results) {
  39149. var i = 0,
  39150. len = contexts.length;
  39151. for (; i < len; i++) {
  39152. Sizzle(selector, contexts[i], results);
  39153. }
  39154. return results;
  39155. }
  39156. function condense(unmatched, map, filter, context, xml) {
  39157. var elem,
  39158. newUnmatched = [],
  39159. i = 0,
  39160. len = unmatched.length,
  39161. mapped = map != null;
  39162. for (; i < len; i++) {
  39163. if (elem = unmatched[i]) {
  39164. if (!filter || filter(elem, context, xml)) {
  39165. newUnmatched.push(elem);
  39166. if (mapped) {
  39167. map.push(i);
  39168. }
  39169. }
  39170. }
  39171. }
  39172. return newUnmatched;
  39173. }
  39174. function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
  39175. if (postFilter && !postFilter[expando]) {
  39176. postFilter = setMatcher(postFilter);
  39177. }
  39178. if (postFinder && !postFinder[expando]) {
  39179. postFinder = setMatcher(postFinder, postSelector);
  39180. }
  39181. return markFunction(function (seed, results, context, xml) {
  39182. var temp,
  39183. i,
  39184. elem,
  39185. preMap = [],
  39186. postMap = [],
  39187. preexisting = results.length,
  39188. // Get initial elements from seed or context
  39189. elems = seed || multipleContexts(selector || "*", context.nodeType ? [context] : context, []),
  39190. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  39191. matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems,
  39192. matcherOut = matcher ?
  39193. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  39194. postFinder || (seed ? preFilter : preexisting || postFilter) ?
  39195. // ...intermediate processing is necessary
  39196. [] :
  39197. // ...otherwise use results directly
  39198. results : matcherIn;
  39199. // Find primary matches
  39200. if (matcher) {
  39201. matcher(matcherIn, matcherOut, context, xml);
  39202. }
  39203. // Apply postFilter
  39204. if (postFilter) {
  39205. temp = condense(matcherOut, postMap);
  39206. postFilter(temp, [], context, xml);
  39207. // Un-match failing elements by moving them back to matcherIn
  39208. i = temp.length;
  39209. while (i--) {
  39210. if (elem = temp[i]) {
  39211. matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem);
  39212. }
  39213. }
  39214. }
  39215. if (seed) {
  39216. if (postFinder || preFilter) {
  39217. if (postFinder) {
  39218. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  39219. temp = [];
  39220. i = matcherOut.length;
  39221. while (i--) {
  39222. if (elem = matcherOut[i]) {
  39223. // Restore matcherIn since elem is not yet a final match
  39224. temp.push(matcherIn[i] = elem);
  39225. }
  39226. }
  39227. postFinder(null, matcherOut = [], temp, xml);
  39228. }
  39229. // Move matched elements from seed to results to keep them synchronized
  39230. i = matcherOut.length;
  39231. while (i--) {
  39232. if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf(seed, elem) : preMap[i]) > -1) {
  39233. seed[temp] = !(results[temp] = elem);
  39234. }
  39235. }
  39236. }
  39237. // Add elements to results, through postFinder if defined
  39238. } else {
  39239. matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut);
  39240. if (postFinder) {
  39241. postFinder(null, results, matcherOut, xml);
  39242. } else {
  39243. push.apply(results, matcherOut);
  39244. }
  39245. }
  39246. });
  39247. }
  39248. function matcherFromTokens(tokens) {
  39249. var checkContext,
  39250. matcher,
  39251. j,
  39252. len = tokens.length,
  39253. leadingRelative = Expr.relative[tokens[0].type],
  39254. implicitRelative = leadingRelative || Expr.relative[" "],
  39255. i = leadingRelative ? 1 : 0,
  39256. // The foundational matcher ensures that elements are reachable from top-level context(s)
  39257. matchContext = addCombinator(function (elem) {
  39258. return elem === checkContext;
  39259. }, implicitRelative, true),
  39260. matchAnyContext = addCombinator(function (elem) {
  39261. return indexOf(checkContext, elem) > -1;
  39262. }, implicitRelative, true),
  39263. matchers = [function (elem, context, xml) {
  39264. var ret = !leadingRelative && (xml || context !== outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));
  39265. // Avoid hanging onto element (issue #299)
  39266. checkContext = null;
  39267. return ret;
  39268. }];
  39269. for (; i < len; i++) {
  39270. if (matcher = Expr.relative[tokens[i].type]) {
  39271. matchers = [addCombinator(elementMatcher(matchers), matcher)];
  39272. } else {
  39273. matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches);
  39274. // Return special upon seeing a positional matcher
  39275. if (matcher[expando]) {
  39276. // Find the next relative operator (if any) for proper handling
  39277. j = ++i;
  39278. for (; j < len; j++) {
  39279. if (Expr.relative[tokens[j].type]) {
  39280. break;
  39281. }
  39282. }
  39283. return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(
  39284. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  39285. tokens.slice(0, i - 1).concat({ value: tokens[i - 2].type === " " ? "*" : "" })).replace(rtrim, "$1"), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens(tokens = tokens.slice(j)), j < len && toSelector(tokens));
  39286. }
  39287. matchers.push(matcher);
  39288. }
  39289. }
  39290. return elementMatcher(matchers);
  39291. }
  39292. function matcherFromGroupMatchers(elementMatchers, setMatchers) {
  39293. var bySet = setMatchers.length > 0,
  39294. byElement = elementMatchers.length > 0,
  39295. superMatcher = function superMatcher(seed, context, xml, results, outermost) {
  39296. var elem,
  39297. j,
  39298. matcher,
  39299. matchedCount = 0,
  39300. i = "0",
  39301. unmatched = seed && [],
  39302. setMatched = [],
  39303. contextBackup = outermostContext,
  39304. // We must always have either seed elements or outermost context
  39305. elems = seed || byElement && Expr.find["TAG"]("*", outermost),
  39306. // Use integer dirruns iff this is the outermost matcher
  39307. dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || 0.1,
  39308. len = elems.length;
  39309. if (outermost) {
  39310. outermostContext = context === document || context || outermost;
  39311. }
  39312. // Add elements passing elementMatchers directly to results
  39313. // Support: IE<9, Safari
  39314. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  39315. for (; i !== len && (elem = elems[i]) != null; i++) {
  39316. if (byElement && elem) {
  39317. j = 0;
  39318. if (!context && elem.ownerDocument !== document) {
  39319. setDocument(elem);
  39320. xml = !documentIsHTML;
  39321. }
  39322. while (matcher = elementMatchers[j++]) {
  39323. if (matcher(elem, context || document, xml)) {
  39324. results.push(elem);
  39325. break;
  39326. }
  39327. }
  39328. if (outermost) {
  39329. dirruns = dirrunsUnique;
  39330. }
  39331. }
  39332. // Track unmatched elements for set filters
  39333. if (bySet) {
  39334. // They will have gone through all possible matchers
  39335. if (elem = !matcher && elem) {
  39336. matchedCount--;
  39337. }
  39338. // Lengthen the array for every element, matched or not
  39339. if (seed) {
  39340. unmatched.push(elem);
  39341. }
  39342. }
  39343. }
  39344. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  39345. // makes the latter nonnegative.
  39346. matchedCount += i;
  39347. // Apply set filters to unmatched elements
  39348. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  39349. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  39350. // no element matchers and no seed.
  39351. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  39352. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  39353. // numerically zero.
  39354. if (bySet && i !== matchedCount) {
  39355. j = 0;
  39356. while (matcher = setMatchers[j++]) {
  39357. matcher(unmatched, setMatched, context, xml);
  39358. }
  39359. if (seed) {
  39360. // Reintegrate element matches to eliminate the need for sorting
  39361. if (matchedCount > 0) {
  39362. while (i--) {
  39363. if (!(unmatched[i] || setMatched[i])) {
  39364. setMatched[i] = pop.call(results);
  39365. }
  39366. }
  39367. }
  39368. // Discard index placeholder values to get only actual matches
  39369. setMatched = condense(setMatched);
  39370. }
  39371. // Add matches to results
  39372. push.apply(results, setMatched);
  39373. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  39374. if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) {
  39375. Sizzle.uniqueSort(results);
  39376. }
  39377. }
  39378. // Override manipulation of globals by nested matchers
  39379. if (outermost) {
  39380. dirruns = dirrunsUnique;
  39381. outermostContext = contextBackup;
  39382. }
  39383. return unmatched;
  39384. };
  39385. return bySet ? markFunction(superMatcher) : superMatcher;
  39386. }
  39387. compile = Sizzle.compile = function (selector, match /* Internal Use Only */) {
  39388. var i,
  39389. setMatchers = [],
  39390. elementMatchers = [],
  39391. cached = compilerCache[selector + " "];
  39392. if (!cached) {
  39393. // Generate a function of recursive functions that can be used to check each element
  39394. if (!match) {
  39395. match = tokenize(selector);
  39396. }
  39397. i = match.length;
  39398. while (i--) {
  39399. cached = matcherFromTokens(match[i]);
  39400. if (cached[expando]) {
  39401. setMatchers.push(cached);
  39402. } else {
  39403. elementMatchers.push(cached);
  39404. }
  39405. }
  39406. // Cache the compiled function
  39407. cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));
  39408. // Save selector and tokenization
  39409. cached.selector = selector;
  39410. }
  39411. return cached;
  39412. };
  39413. /**
  39414. * A low-level selection function that works with Sizzle's compiled
  39415. * selector functions
  39416. * @param {String|Function} selector A selector or a pre-compiled
  39417. * selector function built with Sizzle.compile
  39418. * @param {Element} context
  39419. * @param {Array} [results]
  39420. * @param {Array} [seed] A set of elements to match against
  39421. */
  39422. select = Sizzle.select = function (selector, context, results, seed) {
  39423. var i,
  39424. tokens,
  39425. token,
  39426. type,
  39427. find,
  39428. compiled = typeof selector === "function" && selector,
  39429. match = !seed && tokenize(selector = compiled.selector || selector);
  39430. results = results || [];
  39431. // Try to minimize operations if there is only one selector in the list and no seed
  39432. // (the latter of which guarantees us context)
  39433. if (match.length === 1) {
  39434. // Reduce context if the leading compound selector is an ID
  39435. tokens = match[0] = match[0].slice(0);
  39436. if (tokens.length > 2 && (token = tokens[0]).type === "ID" && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) {
  39437. context = (Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [])[0];
  39438. if (!context) {
  39439. return results;
  39440. // Precompiled matchers will still verify ancestry, so step up a level
  39441. } else if (compiled) {
  39442. context = context.parentNode;
  39443. }
  39444. selector = selector.slice(tokens.shift().value.length);
  39445. }
  39446. // Fetch a seed set for right-to-left matching
  39447. i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length;
  39448. while (i--) {
  39449. token = tokens[i];
  39450. // Abort if we hit a combinator
  39451. if (Expr.relative[type = token.type]) {
  39452. break;
  39453. }
  39454. if (find = Expr.find[type]) {
  39455. // Search, expanding context for leading sibling combinators
  39456. if (seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && testContext(context.parentNode) || context)) {
  39457. // If seed is empty or no tokens remain, we can return early
  39458. tokens.splice(i, 1);
  39459. selector = seed.length && toSelector(tokens);
  39460. if (!selector) {
  39461. push.apply(results, seed);
  39462. return results;
  39463. }
  39464. break;
  39465. }
  39466. }
  39467. }
  39468. }
  39469. // Compile and execute a filtering function if one is not provided
  39470. // Provide `match` to avoid retokenization if we modified the selector above
  39471. (compiled || compile(selector, match))(seed, context, !documentIsHTML, results, !context || rsibling.test(selector) && testContext(context.parentNode) || context);
  39472. return results;
  39473. };
  39474. // One-time assignments
  39475. // Sort stability
  39476. support.sortStable = expando.split("").sort(sortOrder).join("") === expando;
  39477. // Support: Chrome 14-35+
  39478. // Always assume duplicates if they aren't passed to the comparison function
  39479. support.detectDuplicates = !!hasDuplicate;
  39480. // Initialize against the default document
  39481. setDocument();
  39482. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  39483. // Detached nodes confoundingly follow *each other*
  39484. support.sortDetached = assert(function (el) {
  39485. // Should return 1, but returns 4 (following)
  39486. return el.compareDocumentPosition(document.createElement("fieldset")) & 1;
  39487. });
  39488. // Support: IE<8
  39489. // Prevent attribute/property "interpolation"
  39490. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  39491. if (!assert(function (el) {
  39492. el.innerHTML = "<a href='#'></a>";
  39493. return el.firstChild.getAttribute("href") === "#";
  39494. })) {
  39495. addHandle("type|href|height|width", function (elem, name, isXML) {
  39496. if (!isXML) {
  39497. return elem.getAttribute(name, name.toLowerCase() === "type" ? 1 : 2);
  39498. }
  39499. });
  39500. }
  39501. // Support: IE<9
  39502. // Use defaultValue in place of getAttribute("value")
  39503. if (!support.attributes || !assert(function (el) {
  39504. el.innerHTML = "<input/>";
  39505. el.firstChild.setAttribute("value", "");
  39506. return el.firstChild.getAttribute("value") === "";
  39507. })) {
  39508. addHandle("value", function (elem, name, isXML) {
  39509. if (!isXML && elem.nodeName.toLowerCase() === "input") {
  39510. return elem.defaultValue;
  39511. }
  39512. });
  39513. }
  39514. // Support: IE<9
  39515. // Use getAttributeNode to fetch booleans when getAttribute lies
  39516. if (!assert(function (el) {
  39517. return el.getAttribute("disabled") == null;
  39518. })) {
  39519. addHandle(booleans, function (elem, name, isXML) {
  39520. var val;
  39521. if (!isXML) {
  39522. return elem[name] === true ? name.toLowerCase() : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null;
  39523. }
  39524. });
  39525. }
  39526. return Sizzle;
  39527. }(window);
  39528. jQuery.find = Sizzle;
  39529. jQuery.expr = Sizzle.selectors;
  39530. // Deprecated
  39531. jQuery.expr[":"] = jQuery.expr.pseudos;
  39532. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  39533. jQuery.text = Sizzle.getText;
  39534. jQuery.isXMLDoc = Sizzle.isXML;
  39535. jQuery.contains = Sizzle.contains;
  39536. jQuery.escapeSelector = Sizzle.escape;
  39537. var dir = function dir(elem, _dir, until) {
  39538. var matched = [],
  39539. truncate = until !== undefined;
  39540. while ((elem = elem[_dir]) && elem.nodeType !== 9) {
  39541. if (elem.nodeType === 1) {
  39542. if (truncate && jQuery(elem).is(until)) {
  39543. break;
  39544. }
  39545. matched.push(elem);
  39546. }
  39547. }
  39548. return matched;
  39549. };
  39550. var _siblings = function _siblings(n, elem) {
  39551. var matched = [];
  39552. for (; n; n = n.nextSibling) {
  39553. if (n.nodeType === 1 && n !== elem) {
  39554. matched.push(n);
  39555. }
  39556. }
  39557. return matched;
  39558. };
  39559. var rneedsContext = jQuery.expr.match.needsContext;
  39560. function nodeName(elem, name) {
  39561. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  39562. };
  39563. var rsingleTag = /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;
  39564. // Implement the identical functionality for filter and not
  39565. function winnow(elements, qualifier, not) {
  39566. if (isFunction(qualifier)) {
  39567. return jQuery.grep(elements, function (elem, i) {
  39568. return !!qualifier.call(elem, i, elem) !== not;
  39569. });
  39570. }
  39571. // Single element
  39572. if (qualifier.nodeType) {
  39573. return jQuery.grep(elements, function (elem) {
  39574. return elem === qualifier !== not;
  39575. });
  39576. }
  39577. // Arraylike of elements (jQuery, arguments, Array)
  39578. if (typeof qualifier !== "string") {
  39579. return jQuery.grep(elements, function (elem) {
  39580. return indexOf.call(qualifier, elem) > -1 !== not;
  39581. });
  39582. }
  39583. // Filtered directly for both simple and complex selectors
  39584. return jQuery.filter(qualifier, elements, not);
  39585. }
  39586. jQuery.filter = function (expr, elems, not) {
  39587. var elem = elems[0];
  39588. if (not) {
  39589. expr = ":not(" + expr + ")";
  39590. }
  39591. if (elems.length === 1 && elem.nodeType === 1) {
  39592. return jQuery.find.matchesSelector(elem, expr) ? [elem] : [];
  39593. }
  39594. return jQuery.find.matches(expr, jQuery.grep(elems, function (elem) {
  39595. return elem.nodeType === 1;
  39596. }));
  39597. };
  39598. jQuery.fn.extend({
  39599. find: function find(selector) {
  39600. var i,
  39601. ret,
  39602. len = this.length,
  39603. self = this;
  39604. if (typeof selector !== "string") {
  39605. return this.pushStack(jQuery(selector).filter(function () {
  39606. for (i = 0; i < len; i++) {
  39607. if (jQuery.contains(self[i], this)) {
  39608. return true;
  39609. }
  39610. }
  39611. }));
  39612. }
  39613. ret = this.pushStack([]);
  39614. for (i = 0; i < len; i++) {
  39615. jQuery.find(selector, self[i], ret);
  39616. }
  39617. return len > 1 ? jQuery.uniqueSort(ret) : ret;
  39618. },
  39619. filter: function filter(selector) {
  39620. return this.pushStack(winnow(this, selector || [], false));
  39621. },
  39622. not: function not(selector) {
  39623. return this.pushStack(winnow(this, selector || [], true));
  39624. },
  39625. is: function is(selector) {
  39626. return !!winnow(this,
  39627. // If this is a positional/relative selector, check membership in the returned set
  39628. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  39629. typeof selector === "string" && rneedsContext.test(selector) ? jQuery(selector) : selector || [], false).length;
  39630. }
  39631. });
  39632. // Initialize a jQuery object
  39633. // A central reference to the root jQuery(document)
  39634. var rootjQuery,
  39635. // A simple way to check for HTML strings
  39636. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  39637. // Strict HTML recognition (#11290: must start with <)
  39638. // Shortcut simple #id case for speed
  39639. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  39640. init = jQuery.fn.init = function (selector, context, root) {
  39641. var match, elem;
  39642. // HANDLE: $(""), $(null), $(undefined), $(false)
  39643. if (!selector) {
  39644. return this;
  39645. }
  39646. // Method init() accepts an alternate rootjQuery
  39647. // so migrate can support jQuery.sub (gh-2101)
  39648. root = root || rootjQuery;
  39649. // Handle HTML strings
  39650. if (typeof selector === "string") {
  39651. if (selector[0] === "<" && selector[selector.length - 1] === ">" && selector.length >= 3) {
  39652. // Assume that strings that start and end with <> are HTML and skip the regex check
  39653. match = [null, selector, null];
  39654. } else {
  39655. match = rquickExpr.exec(selector);
  39656. }
  39657. // Match html or make sure no context is specified for #id
  39658. if (match && (match[1] || !context)) {
  39659. // HANDLE: $(html) -> $(array)
  39660. if (match[1]) {
  39661. context = context instanceof jQuery ? context[0] : context;
  39662. // Option to run scripts is true for back-compat
  39663. // Intentionally let the error be thrown if parseHTML is not present
  39664. jQuery.merge(this, jQuery.parseHTML(match[1], context && context.nodeType ? context.ownerDocument || context : document, true));
  39665. // HANDLE: $(html, props)
  39666. if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) {
  39667. for (match in context) {
  39668. // Properties of context are called as methods if possible
  39669. if (isFunction(this[match])) {
  39670. this[match](context[match]);
  39671. // ...and otherwise set as attributes
  39672. } else {
  39673. this.attr(match, context[match]);
  39674. }
  39675. }
  39676. }
  39677. return this;
  39678. // HANDLE: $(#id)
  39679. } else {
  39680. elem = document.getElementById(match[2]);
  39681. if (elem) {
  39682. // Inject the element directly into the jQuery object
  39683. this[0] = elem;
  39684. this.length = 1;
  39685. }
  39686. return this;
  39687. }
  39688. // HANDLE: $(expr, $(...))
  39689. } else if (!context || context.jquery) {
  39690. return (context || root).find(selector);
  39691. // HANDLE: $(expr, context)
  39692. // (which is just equivalent to: $(context).find(expr)
  39693. } else {
  39694. return this.constructor(context).find(selector);
  39695. }
  39696. // HANDLE: $(DOMElement)
  39697. } else if (selector.nodeType) {
  39698. this[0] = selector;
  39699. this.length = 1;
  39700. return this;
  39701. // HANDLE: $(function)
  39702. // Shortcut for document ready
  39703. } else if (isFunction(selector)) {
  39704. return root.ready !== undefined ? root.ready(selector) :
  39705. // Execute immediately if ready is not present
  39706. selector(jQuery);
  39707. }
  39708. return jQuery.makeArray(selector, this);
  39709. };
  39710. // Give the init function the jQuery prototype for later instantiation
  39711. init.prototype = jQuery.fn;
  39712. // Initialize central reference
  39713. rootjQuery = jQuery(document);
  39714. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  39715. // Methods guaranteed to produce a unique set when starting from a unique set
  39716. guaranteedUnique = {
  39717. children: true,
  39718. contents: true,
  39719. next: true,
  39720. prev: true
  39721. };
  39722. jQuery.fn.extend({
  39723. has: function has(target) {
  39724. var targets = jQuery(target, this),
  39725. l = targets.length;
  39726. return this.filter(function () {
  39727. var i = 0;
  39728. for (; i < l; i++) {
  39729. if (jQuery.contains(this, targets[i])) {
  39730. return true;
  39731. }
  39732. }
  39733. });
  39734. },
  39735. closest: function closest(selectors, context) {
  39736. var cur,
  39737. i = 0,
  39738. l = this.length,
  39739. matched = [],
  39740. targets = typeof selectors !== "string" && jQuery(selectors);
  39741. // Positional selectors never match, since there's no _selection_ context
  39742. if (!rneedsContext.test(selectors)) {
  39743. for (; i < l; i++) {
  39744. for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) {
  39745. // Always skip document fragments
  39746. if (cur.nodeType < 11 && (targets ? targets.index(cur) > -1 :
  39747. // Don't pass non-elements to Sizzle
  39748. cur.nodeType === 1 && jQuery.find.matchesSelector(cur, selectors))) {
  39749. matched.push(cur);
  39750. break;
  39751. }
  39752. }
  39753. }
  39754. }
  39755. return this.pushStack(matched.length > 1 ? jQuery.uniqueSort(matched) : matched);
  39756. },
  39757. // Determine the position of an element within the set
  39758. index: function index(elem) {
  39759. // No argument, return index in parent
  39760. if (!elem) {
  39761. return this[0] && this[0].parentNode ? this.first().prevAll().length : -1;
  39762. }
  39763. // Index in selector
  39764. if (typeof elem === "string") {
  39765. return indexOf.call(jQuery(elem), this[0]);
  39766. }
  39767. // Locate the position of the desired element
  39768. return indexOf.call(this,
  39769. // If it receives a jQuery object, the first element is used
  39770. elem.jquery ? elem[0] : elem);
  39771. },
  39772. add: function add(selector, context) {
  39773. return this.pushStack(jQuery.uniqueSort(jQuery.merge(this.get(), jQuery(selector, context))));
  39774. },
  39775. addBack: function addBack(selector) {
  39776. return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector));
  39777. }
  39778. });
  39779. function sibling(cur, dir) {
  39780. while ((cur = cur[dir]) && cur.nodeType !== 1) {}
  39781. return cur;
  39782. }
  39783. jQuery.each({
  39784. parent: function parent(elem) {
  39785. var parent = elem.parentNode;
  39786. return parent && parent.nodeType !== 11 ? parent : null;
  39787. },
  39788. parents: function parents(elem) {
  39789. return dir(elem, "parentNode");
  39790. },
  39791. parentsUntil: function parentsUntil(elem, i, until) {
  39792. return dir(elem, "parentNode", until);
  39793. },
  39794. next: function next(elem) {
  39795. return sibling(elem, "nextSibling");
  39796. },
  39797. prev: function prev(elem) {
  39798. return sibling(elem, "previousSibling");
  39799. },
  39800. nextAll: function nextAll(elem) {
  39801. return dir(elem, "nextSibling");
  39802. },
  39803. prevAll: function prevAll(elem) {
  39804. return dir(elem, "previousSibling");
  39805. },
  39806. nextUntil: function nextUntil(elem, i, until) {
  39807. return dir(elem, "nextSibling", until);
  39808. },
  39809. prevUntil: function prevUntil(elem, i, until) {
  39810. return dir(elem, "previousSibling", until);
  39811. },
  39812. siblings: function siblings(elem) {
  39813. return _siblings((elem.parentNode || {}).firstChild, elem);
  39814. },
  39815. children: function children(elem) {
  39816. return _siblings(elem.firstChild);
  39817. },
  39818. contents: function contents(elem) {
  39819. if (nodeName(elem, "iframe")) {
  39820. return elem.contentDocument;
  39821. }
  39822. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  39823. // Treat the template element as a regular one in browsers that
  39824. // don't support it.
  39825. if (nodeName(elem, "template")) {
  39826. elem = elem.content || elem;
  39827. }
  39828. return jQuery.merge([], elem.childNodes);
  39829. }
  39830. }, function (name, fn) {
  39831. jQuery.fn[name] = function (until, selector) {
  39832. var matched = jQuery.map(this, fn, until);
  39833. if (name.slice(-5) !== "Until") {
  39834. selector = until;
  39835. }
  39836. if (selector && typeof selector === "string") {
  39837. matched = jQuery.filter(selector, matched);
  39838. }
  39839. if (this.length > 1) {
  39840. // Remove duplicates
  39841. if (!guaranteedUnique[name]) {
  39842. jQuery.uniqueSort(matched);
  39843. }
  39844. // Reverse order for parents* and prev-derivatives
  39845. if (rparentsprev.test(name)) {
  39846. matched.reverse();
  39847. }
  39848. }
  39849. return this.pushStack(matched);
  39850. };
  39851. });
  39852. var rnothtmlwhite = /[^\x20\t\r\n\f]+/g;
  39853. // Convert String-formatted options into Object-formatted ones
  39854. function createOptions(options) {
  39855. var object = {};
  39856. jQuery.each(options.match(rnothtmlwhite) || [], function (_, flag) {
  39857. object[flag] = true;
  39858. });
  39859. return object;
  39860. }
  39861. /*
  39862. * Create a callback list using the following parameters:
  39863. *
  39864. * options: an optional list of space-separated options that will change how
  39865. * the callback list behaves or a more traditional option object
  39866. *
  39867. * By default a callback list will act like an event callback list and can be
  39868. * "fired" multiple times.
  39869. *
  39870. * Possible options:
  39871. *
  39872. * once: will ensure the callback list can only be fired once (like a Deferred)
  39873. *
  39874. * memory: will keep track of previous values and will call any callback added
  39875. * after the list has been fired right away with the latest "memorized"
  39876. * values (like a Deferred)
  39877. *
  39878. * unique: will ensure a callback can only be added once (no duplicate in the list)
  39879. *
  39880. * stopOnFalse: interrupt callings when a callback returns false
  39881. *
  39882. */
  39883. jQuery.Callbacks = function (options) {
  39884. // Convert options from String-formatted to Object-formatted if needed
  39885. // (we check in cache first)
  39886. options = typeof options === "string" ? createOptions(options) : jQuery.extend({}, options);
  39887. var // Flag to know if list is currently firing
  39888. firing,
  39889. // Last fire value for non-forgettable lists
  39890. memory,
  39891. // Flag to know if list was already fired
  39892. _fired,
  39893. // Flag to prevent firing
  39894. _locked,
  39895. // Actual callback list
  39896. list = [],
  39897. // Queue of execution data for repeatable lists
  39898. queue = [],
  39899. // Index of currently firing callback (modified by add/remove as needed)
  39900. firingIndex = -1,
  39901. // Fire callbacks
  39902. fire = function fire() {
  39903. // Enforce single-firing
  39904. _locked = _locked || options.once;
  39905. // Execute callbacks for all pending executions,
  39906. // respecting firingIndex overrides and runtime changes
  39907. _fired = firing = true;
  39908. for (; queue.length; firingIndex = -1) {
  39909. memory = queue.shift();
  39910. while (++firingIndex < list.length) {
  39911. // Run callback and check for early termination
  39912. if (list[firingIndex].apply(memory[0], memory[1]) === false && options.stopOnFalse) {
  39913. // Jump to end and forget the data so .add doesn't re-fire
  39914. firingIndex = list.length;
  39915. memory = false;
  39916. }
  39917. }
  39918. }
  39919. // Forget the data if we're done with it
  39920. if (!options.memory) {
  39921. memory = false;
  39922. }
  39923. firing = false;
  39924. // Clean up if we're done firing for good
  39925. if (_locked) {
  39926. // Keep an empty list if we have data for future add calls
  39927. if (memory) {
  39928. list = [];
  39929. // Otherwise, this object is spent
  39930. } else {
  39931. list = "";
  39932. }
  39933. }
  39934. },
  39935. // Actual Callbacks object
  39936. self = {
  39937. // Add a callback or a collection of callbacks to the list
  39938. add: function add() {
  39939. if (list) {
  39940. // If we have memory from a past run, we should fire after adding
  39941. if (memory && !firing) {
  39942. firingIndex = list.length - 1;
  39943. queue.push(memory);
  39944. }
  39945. (function add(args) {
  39946. jQuery.each(args, function (_, arg) {
  39947. if (isFunction(arg)) {
  39948. if (!options.unique || !self.has(arg)) {
  39949. list.push(arg);
  39950. }
  39951. } else if (arg && arg.length && toType(arg) !== "string") {
  39952. // Inspect recursively
  39953. add(arg);
  39954. }
  39955. });
  39956. })(arguments);
  39957. if (memory && !firing) {
  39958. fire();
  39959. }
  39960. }
  39961. return this;
  39962. },
  39963. // Remove a callback from the list
  39964. remove: function remove() {
  39965. jQuery.each(arguments, function (_, arg) {
  39966. var index;
  39967. while ((index = jQuery.inArray(arg, list, index)) > -1) {
  39968. list.splice(index, 1);
  39969. // Handle firing indexes
  39970. if (index <= firingIndex) {
  39971. firingIndex--;
  39972. }
  39973. }
  39974. });
  39975. return this;
  39976. },
  39977. // Check if a given callback is in the list.
  39978. // If no argument is given, return whether or not list has callbacks attached.
  39979. has: function has(fn) {
  39980. return fn ? jQuery.inArray(fn, list) > -1 : list.length > 0;
  39981. },
  39982. // Remove all callbacks from the list
  39983. empty: function empty() {
  39984. if (list) {
  39985. list = [];
  39986. }
  39987. return this;
  39988. },
  39989. // Disable .fire and .add
  39990. // Abort any current/pending executions
  39991. // Clear all callbacks and values
  39992. disable: function disable() {
  39993. _locked = queue = [];
  39994. list = memory = "";
  39995. return this;
  39996. },
  39997. disabled: function disabled() {
  39998. return !list;
  39999. },
  40000. // Disable .fire
  40001. // Also disable .add unless we have memory (since it would have no effect)
  40002. // Abort any pending executions
  40003. lock: function lock() {
  40004. _locked = queue = [];
  40005. if (!memory && !firing) {
  40006. list = memory = "";
  40007. }
  40008. return this;
  40009. },
  40010. locked: function locked() {
  40011. return !!_locked;
  40012. },
  40013. // Call all callbacks with the given context and arguments
  40014. fireWith: function fireWith(context, args) {
  40015. if (!_locked) {
  40016. args = args || [];
  40017. args = [context, args.slice ? args.slice() : args];
  40018. queue.push(args);
  40019. if (!firing) {
  40020. fire();
  40021. }
  40022. }
  40023. return this;
  40024. },
  40025. // Call all the callbacks with the given arguments
  40026. fire: function fire() {
  40027. self.fireWith(this, arguments);
  40028. return this;
  40029. },
  40030. // To know if the callbacks have already been called at least once
  40031. fired: function fired() {
  40032. return !!_fired;
  40033. }
  40034. };
  40035. return self;
  40036. };
  40037. function Identity(v) {
  40038. return v;
  40039. }
  40040. function Thrower(ex) {
  40041. throw ex;
  40042. }
  40043. function adoptValue(value, resolve, reject, noValue) {
  40044. var method;
  40045. try {
  40046. // Check for promise aspect first to privilege synchronous behavior
  40047. if (value && isFunction(method = value.promise)) {
  40048. method.call(value).done(resolve).fail(reject);
  40049. // Other thenables
  40050. } else if (value && isFunction(method = value.then)) {
  40051. method.call(value, resolve, reject);
  40052. // Other non-thenables
  40053. } else {
  40054. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  40055. // * false: [ value ].slice( 0 ) => resolve( value )
  40056. // * true: [ value ].slice( 1 ) => resolve()
  40057. resolve.apply(undefined, [value].slice(noValue));
  40058. }
  40059. // For Promises/A+, convert exceptions into rejections
  40060. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  40061. // Deferred#then to conditionally suppress rejection.
  40062. } catch (value) {
  40063. // Support: Android 4.0 only
  40064. // Strict mode functions invoked without .call/.apply get global-object context
  40065. reject.apply(undefined, [value]);
  40066. }
  40067. }
  40068. jQuery.extend({
  40069. Deferred: function Deferred(func) {
  40070. var tuples = [
  40071. // action, add listener, callbacks,
  40072. // ... .then handlers, argument index, [final state]
  40073. ["notify", "progress", jQuery.Callbacks("memory"), jQuery.Callbacks("memory"), 2], ["resolve", "done", jQuery.Callbacks("once memory"), jQuery.Callbacks("once memory"), 0, "resolved"], ["reject", "fail", jQuery.Callbacks("once memory"), jQuery.Callbacks("once memory"), 1, "rejected"]],
  40074. _state = "pending",
  40075. _promise = {
  40076. state: function state() {
  40077. return _state;
  40078. },
  40079. always: function always() {
  40080. deferred.done(arguments).fail(arguments);
  40081. return this;
  40082. },
  40083. "catch": function _catch(fn) {
  40084. return _promise.then(null, fn);
  40085. },
  40086. // Keep pipe for back-compat
  40087. pipe: function pipe() /* fnDone, fnFail, fnProgress */{
  40088. var fns = arguments;
  40089. return jQuery.Deferred(function (newDefer) {
  40090. jQuery.each(tuples, function (i, tuple) {
  40091. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  40092. var fn = isFunction(fns[tuple[4]]) && fns[tuple[4]];
  40093. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  40094. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  40095. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  40096. deferred[tuple[1]](function () {
  40097. var returned = fn && fn.apply(this, arguments);
  40098. if (returned && isFunction(returned.promise)) {
  40099. returned.promise().progress(newDefer.notify).done(newDefer.resolve).fail(newDefer.reject);
  40100. } else {
  40101. newDefer[tuple[0] + "With"](this, fn ? [returned] : arguments);
  40102. }
  40103. });
  40104. });
  40105. fns = null;
  40106. }).promise();
  40107. },
  40108. then: function then(onFulfilled, onRejected, onProgress) {
  40109. var maxDepth = 0;
  40110. function resolve(depth, deferred, handler, special) {
  40111. return function () {
  40112. var that = this,
  40113. args = arguments,
  40114. mightThrow = function mightThrow() {
  40115. var returned, then;
  40116. // Support: Promises/A+ section 2.3.3.3.3
  40117. // https://promisesaplus.com/#point-59
  40118. // Ignore double-resolution attempts
  40119. if (depth < maxDepth) {
  40120. return;
  40121. }
  40122. returned = handler.apply(that, args);
  40123. // Support: Promises/A+ section 2.3.1
  40124. // https://promisesaplus.com/#point-48
  40125. if (returned === deferred.promise()) {
  40126. throw new TypeError("Thenable self-resolution");
  40127. }
  40128. // Support: Promises/A+ sections 2.3.3.1, 3.5
  40129. // https://promisesaplus.com/#point-54
  40130. // https://promisesaplus.com/#point-75
  40131. // Retrieve `then` only once
  40132. then = returned && (
  40133. // Support: Promises/A+ section 2.3.4
  40134. // https://promisesaplus.com/#point-64
  40135. // Only check objects and functions for thenability
  40136. (typeof returned === "undefined" ? "undefined" : _typeof(returned)) === "object" || typeof returned === "function") && returned.then;
  40137. // Handle a returned thenable
  40138. if (isFunction(then)) {
  40139. // Special processors (notify) just wait for resolution
  40140. if (special) {
  40141. then.call(returned, resolve(maxDepth, deferred, Identity, special), resolve(maxDepth, deferred, Thrower, special));
  40142. // Normal processors (resolve) also hook into progress
  40143. } else {
  40144. // ...and disregard older resolution values
  40145. maxDepth++;
  40146. then.call(returned, resolve(maxDepth, deferred, Identity, special), resolve(maxDepth, deferred, Thrower, special), resolve(maxDepth, deferred, Identity, deferred.notifyWith));
  40147. }
  40148. // Handle all other returned values
  40149. } else {
  40150. // Only substitute handlers pass on context
  40151. // and multiple values (non-spec behavior)
  40152. if (handler !== Identity) {
  40153. that = undefined;
  40154. args = [returned];
  40155. }
  40156. // Process the value(s)
  40157. // Default process is resolve
  40158. (special || deferred.resolveWith)(that, args);
  40159. }
  40160. },
  40161. // Only normal processors (resolve) catch and reject exceptions
  40162. process = special ? mightThrow : function () {
  40163. try {
  40164. mightThrow();
  40165. } catch (e) {
  40166. if (jQuery.Deferred.exceptionHook) {
  40167. jQuery.Deferred.exceptionHook(e, process.stackTrace);
  40168. }
  40169. // Support: Promises/A+ section 2.3.3.3.4.1
  40170. // https://promisesaplus.com/#point-61
  40171. // Ignore post-resolution exceptions
  40172. if (depth + 1 >= maxDepth) {
  40173. // Only substitute handlers pass on context
  40174. // and multiple values (non-spec behavior)
  40175. if (handler !== Thrower) {
  40176. that = undefined;
  40177. args = [e];
  40178. }
  40179. deferred.rejectWith(that, args);
  40180. }
  40181. }
  40182. };
  40183. // Support: Promises/A+ section 2.3.3.3.1
  40184. // https://promisesaplus.com/#point-57
  40185. // Re-resolve promises immediately to dodge false rejection from
  40186. // subsequent errors
  40187. if (depth) {
  40188. process();
  40189. } else {
  40190. // Call an optional hook to record the stack, in case of exception
  40191. // since it's otherwise lost when execution goes async
  40192. if (jQuery.Deferred.getStackHook) {
  40193. process.stackTrace = jQuery.Deferred.getStackHook();
  40194. }
  40195. window.setTimeout(process);
  40196. }
  40197. };
  40198. }
  40199. return jQuery.Deferred(function (newDefer) {
  40200. // progress_handlers.add( ... )
  40201. tuples[0][3].add(resolve(0, newDefer, isFunction(onProgress) ? onProgress : Identity, newDefer.notifyWith));
  40202. // fulfilled_handlers.add( ... )
  40203. tuples[1][3].add(resolve(0, newDefer, isFunction(onFulfilled) ? onFulfilled : Identity));
  40204. // rejected_handlers.add( ... )
  40205. tuples[2][3].add(resolve(0, newDefer, isFunction(onRejected) ? onRejected : Thrower));
  40206. }).promise();
  40207. },
  40208. // Get a promise for this deferred
  40209. // If obj is provided, the promise aspect is added to the object
  40210. promise: function promise(obj) {
  40211. return obj != null ? jQuery.extend(obj, _promise) : _promise;
  40212. }
  40213. },
  40214. deferred = {};
  40215. // Add list-specific methods
  40216. jQuery.each(tuples, function (i, tuple) {
  40217. var list = tuple[2],
  40218. stateString = tuple[5];
  40219. // promise.progress = list.add
  40220. // promise.done = list.add
  40221. // promise.fail = list.add
  40222. _promise[tuple[1]] = list.add;
  40223. // Handle state
  40224. if (stateString) {
  40225. list.add(function () {
  40226. // state = "resolved" (i.e., fulfilled)
  40227. // state = "rejected"
  40228. _state = stateString;
  40229. },
  40230. // rejected_callbacks.disable
  40231. // fulfilled_callbacks.disable
  40232. tuples[3 - i][2].disable,
  40233. // rejected_handlers.disable
  40234. // fulfilled_handlers.disable
  40235. tuples[3 - i][3].disable,
  40236. // progress_callbacks.lock
  40237. tuples[0][2].lock,
  40238. // progress_handlers.lock
  40239. tuples[0][3].lock);
  40240. }
  40241. // progress_handlers.fire
  40242. // fulfilled_handlers.fire
  40243. // rejected_handlers.fire
  40244. list.add(tuple[3].fire);
  40245. // deferred.notify = function() { deferred.notifyWith(...) }
  40246. // deferred.resolve = function() { deferred.resolveWith(...) }
  40247. // deferred.reject = function() { deferred.rejectWith(...) }
  40248. deferred[tuple[0]] = function () {
  40249. deferred[tuple[0] + "With"](this === deferred ? undefined : this, arguments);
  40250. return this;
  40251. };
  40252. // deferred.notifyWith = list.fireWith
  40253. // deferred.resolveWith = list.fireWith
  40254. // deferred.rejectWith = list.fireWith
  40255. deferred[tuple[0] + "With"] = list.fireWith;
  40256. });
  40257. // Make the deferred a promise
  40258. _promise.promise(deferred);
  40259. // Call given func if any
  40260. if (func) {
  40261. func.call(deferred, deferred);
  40262. }
  40263. // All done!
  40264. return deferred;
  40265. },
  40266. // Deferred helper
  40267. when: function when(singleValue) {
  40268. var
  40269. // count of uncompleted subordinates
  40270. remaining = arguments.length,
  40271. // count of unprocessed arguments
  40272. i = remaining,
  40273. // subordinate fulfillment data
  40274. resolveContexts = Array(i),
  40275. resolveValues = _slice.call(arguments),
  40276. // the master Deferred
  40277. master = jQuery.Deferred(),
  40278. // subordinate callback factory
  40279. updateFunc = function updateFunc(i) {
  40280. return function (value) {
  40281. resolveContexts[i] = this;
  40282. resolveValues[i] = arguments.length > 1 ? _slice.call(arguments) : value;
  40283. if (! --remaining) {
  40284. master.resolveWith(resolveContexts, resolveValues);
  40285. }
  40286. };
  40287. };
  40288. // Single- and empty arguments are adopted like Promise.resolve
  40289. if (remaining <= 1) {
  40290. adoptValue(singleValue, master.done(updateFunc(i)).resolve, master.reject, !remaining);
  40291. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  40292. if (master.state() === "pending" || isFunction(resolveValues[i] && resolveValues[i].then)) {
  40293. return master.then();
  40294. }
  40295. }
  40296. // Multiple arguments are aggregated like Promise.all array elements
  40297. while (i--) {
  40298. adoptValue(resolveValues[i], updateFunc(i), master.reject);
  40299. }
  40300. return master.promise();
  40301. }
  40302. });
  40303. // These usually indicate a programmer mistake during development,
  40304. // warn about them ASAP rather than swallowing them by default.
  40305. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  40306. jQuery.Deferred.exceptionHook = function (error, stack) {
  40307. // Support: IE 8 - 9 only
  40308. // Console exists when dev tools are open, which can happen at any time
  40309. if (window.console && window.console.warn && error && rerrorNames.test(error.name)) {
  40310. window.console.warn("jQuery.Deferred exception: " + error.message, error.stack, stack);
  40311. }
  40312. };
  40313. jQuery.readyException = function (error) {
  40314. window.setTimeout(function () {
  40315. throw error;
  40316. });
  40317. };
  40318. // The deferred used on DOM ready
  40319. var readyList = jQuery.Deferred();
  40320. jQuery.fn.ready = function (fn) {
  40321. readyList.then(fn)
  40322. // Wrap jQuery.readyException in a function so that the lookup
  40323. // happens at the time of error handling instead of callback
  40324. // registration.
  40325. .catch(function (error) {
  40326. jQuery.readyException(error);
  40327. });
  40328. return this;
  40329. };
  40330. jQuery.extend({
  40331. // Is the DOM ready to be used? Set to true once it occurs.
  40332. isReady: false,
  40333. // A counter to track how many items to wait for before
  40334. // the ready event fires. See #6781
  40335. readyWait: 1,
  40336. // Handle when the DOM is ready
  40337. ready: function ready(wait) {
  40338. // Abort if there are pending holds or we're already ready
  40339. if (wait === true ? --jQuery.readyWait : jQuery.isReady) {
  40340. return;
  40341. }
  40342. // Remember that the DOM is ready
  40343. jQuery.isReady = true;
  40344. // If a normal DOM Ready event fired, decrement, and wait if need be
  40345. if (wait !== true && --jQuery.readyWait > 0) {
  40346. return;
  40347. }
  40348. // If there are functions bound, to execute
  40349. readyList.resolveWith(document, [jQuery]);
  40350. }
  40351. });
  40352. jQuery.ready.then = readyList.then;
  40353. // The ready event handler and self cleanup method
  40354. function completed() {
  40355. document.removeEventListener("DOMContentLoaded", completed);
  40356. window.removeEventListener("load", completed);
  40357. jQuery.ready();
  40358. }
  40359. // Catch cases where $(document).ready() is called
  40360. // after the browser event has already occurred.
  40361. // Support: IE <=9 - 10 only
  40362. // Older IE sometimes signals "interactive" too soon
  40363. if (document.readyState === "complete" || document.readyState !== "loading" && !document.documentElement.doScroll) {
  40364. // Handle it asynchronously to allow scripts the opportunity to delay ready
  40365. window.setTimeout(jQuery.ready);
  40366. } else {
  40367. // Use the handy event callback
  40368. document.addEventListener("DOMContentLoaded", completed);
  40369. // A fallback to window.onload, that will always work
  40370. window.addEventListener("load", completed);
  40371. }
  40372. // Multifunctional method to get and set values of a collection
  40373. // The value/s can optionally be executed if it's a function
  40374. var access = function access(elems, fn, key, value, chainable, emptyGet, raw) {
  40375. var i = 0,
  40376. len = elems.length,
  40377. bulk = key == null;
  40378. // Sets many values
  40379. if (toType(key) === "object") {
  40380. chainable = true;
  40381. for (i in key) {
  40382. access(elems, fn, i, key[i], true, emptyGet, raw);
  40383. }
  40384. // Sets one value
  40385. } else if (value !== undefined) {
  40386. chainable = true;
  40387. if (!isFunction(value)) {
  40388. raw = true;
  40389. }
  40390. if (bulk) {
  40391. // Bulk operations run against the entire set
  40392. if (raw) {
  40393. fn.call(elems, value);
  40394. fn = null;
  40395. // ...except when executing function values
  40396. } else {
  40397. bulk = fn;
  40398. fn = function fn(elem, key, value) {
  40399. return bulk.call(jQuery(elem), value);
  40400. };
  40401. }
  40402. }
  40403. if (fn) {
  40404. for (; i < len; i++) {
  40405. fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key)));
  40406. }
  40407. }
  40408. }
  40409. if (chainable) {
  40410. return elems;
  40411. }
  40412. // Gets
  40413. if (bulk) {
  40414. return fn.call(elems);
  40415. }
  40416. return len ? fn(elems[0], key) : emptyGet;
  40417. };
  40418. // Matches dashed string for camelizing
  40419. var rmsPrefix = /^-ms-/,
  40420. rdashAlpha = /-([a-z])/g;
  40421. // Used by camelCase as callback to replace()
  40422. function fcamelCase(all, letter) {
  40423. return letter.toUpperCase();
  40424. }
  40425. // Convert dashed to camelCase; used by the css and data modules
  40426. // Support: IE <=9 - 11, Edge 12 - 15
  40427. // Microsoft forgot to hump their vendor prefix (#9572)
  40428. function camelCase(string) {
  40429. return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase);
  40430. }
  40431. var acceptData = function acceptData(owner) {
  40432. // Accepts only:
  40433. // - Node
  40434. // - Node.ELEMENT_NODE
  40435. // - Node.DOCUMENT_NODE
  40436. // - Object
  40437. // - Any
  40438. return owner.nodeType === 1 || owner.nodeType === 9 || !+owner.nodeType;
  40439. };
  40440. function Data() {
  40441. this.expando = jQuery.expando + Data.uid++;
  40442. }
  40443. Data.uid = 1;
  40444. Data.prototype = {
  40445. cache: function cache(owner) {
  40446. // Check if the owner object already has a cache
  40447. var value = owner[this.expando];
  40448. // If not, create one
  40449. if (!value) {
  40450. value = {};
  40451. // We can accept data for non-element nodes in modern browsers,
  40452. // but we should not, see #8335.
  40453. // Always return an empty object.
  40454. if (acceptData(owner)) {
  40455. // If it is a node unlikely to be stringify-ed or looped over
  40456. // use plain assignment
  40457. if (owner.nodeType) {
  40458. owner[this.expando] = value;
  40459. // Otherwise secure it in a non-enumerable property
  40460. // configurable must be true to allow the property to be
  40461. // deleted when data is removed
  40462. } else {
  40463. Object.defineProperty(owner, this.expando, {
  40464. value: value,
  40465. configurable: true
  40466. });
  40467. }
  40468. }
  40469. }
  40470. return value;
  40471. },
  40472. set: function set(owner, data, value) {
  40473. var prop,
  40474. cache = this.cache(owner);
  40475. // Handle: [ owner, key, value ] args
  40476. // Always use camelCase key (gh-2257)
  40477. if (typeof data === "string") {
  40478. cache[camelCase(data)] = value;
  40479. // Handle: [ owner, { properties } ] args
  40480. } else {
  40481. // Copy the properties one-by-one to the cache object
  40482. for (prop in data) {
  40483. cache[camelCase(prop)] = data[prop];
  40484. }
  40485. }
  40486. return cache;
  40487. },
  40488. get: function get(owner, key) {
  40489. return key === undefined ? this.cache(owner) :
  40490. // Always use camelCase key (gh-2257)
  40491. owner[this.expando] && owner[this.expando][camelCase(key)];
  40492. },
  40493. access: function access(owner, key, value) {
  40494. // In cases where either:
  40495. //
  40496. // 1. No key was specified
  40497. // 2. A string key was specified, but no value provided
  40498. //
  40499. // Take the "read" path and allow the get method to determine
  40500. // which value to return, respectively either:
  40501. //
  40502. // 1. The entire cache object
  40503. // 2. The data stored at the key
  40504. //
  40505. if (key === undefined || key && typeof key === "string" && value === undefined) {
  40506. return this.get(owner, key);
  40507. }
  40508. // When the key is not a string, or both a key and value
  40509. // are specified, set or extend (existing objects) with either:
  40510. //
  40511. // 1. An object of properties
  40512. // 2. A key and value
  40513. //
  40514. this.set(owner, key, value);
  40515. // Since the "set" path can have two possible entry points
  40516. // return the expected data based on which path was taken[*]
  40517. return value !== undefined ? value : key;
  40518. },
  40519. remove: function remove(owner, key) {
  40520. var i,
  40521. cache = owner[this.expando];
  40522. if (cache === undefined) {
  40523. return;
  40524. }
  40525. if (key !== undefined) {
  40526. // Support array or space separated string of keys
  40527. if (Array.isArray(key)) {
  40528. // If key is an array of keys...
  40529. // We always set camelCase keys, so remove that.
  40530. key = key.map(camelCase);
  40531. } else {
  40532. key = camelCase(key);
  40533. // If a key with the spaces exists, use it.
  40534. // Otherwise, create an array by matching non-whitespace
  40535. key = key in cache ? [key] : key.match(rnothtmlwhite) || [];
  40536. }
  40537. i = key.length;
  40538. while (i--) {
  40539. delete cache[key[i]];
  40540. }
  40541. }
  40542. // Remove the expando if there's no more data
  40543. if (key === undefined || jQuery.isEmptyObject(cache)) {
  40544. // Support: Chrome <=35 - 45
  40545. // Webkit & Blink performance suffers when deleting properties
  40546. // from DOM nodes, so set to undefined instead
  40547. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  40548. if (owner.nodeType) {
  40549. owner[this.expando] = undefined;
  40550. } else {
  40551. delete owner[this.expando];
  40552. }
  40553. }
  40554. },
  40555. hasData: function hasData(owner) {
  40556. var cache = owner[this.expando];
  40557. return cache !== undefined && !jQuery.isEmptyObject(cache);
  40558. }
  40559. };
  40560. var dataPriv = new Data();
  40561. var dataUser = new Data();
  40562. // Implementation Summary
  40563. //
  40564. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  40565. // 2. Improve the module's maintainability by reducing the storage
  40566. // paths to a single mechanism.
  40567. // 3. Use the same single mechanism to support "private" and "user" data.
  40568. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  40569. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  40570. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  40571. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  40572. rmultiDash = /[A-Z]/g;
  40573. function getData(data) {
  40574. if (data === "true") {
  40575. return true;
  40576. }
  40577. if (data === "false") {
  40578. return false;
  40579. }
  40580. if (data === "null") {
  40581. return null;
  40582. }
  40583. // Only convert to a number if it doesn't change the string
  40584. if (data === +data + "") {
  40585. return +data;
  40586. }
  40587. if (rbrace.test(data)) {
  40588. return JSON.parse(data);
  40589. }
  40590. return data;
  40591. }
  40592. function dataAttr(elem, key, data) {
  40593. var name;
  40594. // If nothing was found internally, try to fetch any
  40595. // data from the HTML5 data-* attribute
  40596. if (data === undefined && elem.nodeType === 1) {
  40597. name = "data-" + key.replace(rmultiDash, "-$&").toLowerCase();
  40598. data = elem.getAttribute(name);
  40599. if (typeof data === "string") {
  40600. try {
  40601. data = getData(data);
  40602. } catch (e) {}
  40603. // Make sure we set the data so it isn't changed later
  40604. dataUser.set(elem, key, data);
  40605. } else {
  40606. data = undefined;
  40607. }
  40608. }
  40609. return data;
  40610. }
  40611. jQuery.extend({
  40612. hasData: function hasData(elem) {
  40613. return dataUser.hasData(elem) || dataPriv.hasData(elem);
  40614. },
  40615. data: function data(elem, name, _data) {
  40616. return dataUser.access(elem, name, _data);
  40617. },
  40618. removeData: function removeData(elem, name) {
  40619. dataUser.remove(elem, name);
  40620. },
  40621. // TODO: Now that all calls to _data and _removeData have been replaced
  40622. // with direct calls to dataPriv methods, these can be deprecated.
  40623. _data: function _data(elem, name, data) {
  40624. return dataPriv.access(elem, name, data);
  40625. },
  40626. _removeData: function _removeData(elem, name) {
  40627. dataPriv.remove(elem, name);
  40628. }
  40629. });
  40630. jQuery.fn.extend({
  40631. data: function data(key, value) {
  40632. var i,
  40633. name,
  40634. data,
  40635. elem = this[0],
  40636. attrs = elem && elem.attributes;
  40637. // Gets all values
  40638. if (key === undefined) {
  40639. if (this.length) {
  40640. data = dataUser.get(elem);
  40641. if (elem.nodeType === 1 && !dataPriv.get(elem, "hasDataAttrs")) {
  40642. i = attrs.length;
  40643. while (i--) {
  40644. // Support: IE 11 only
  40645. // The attrs elements can be null (#14894)
  40646. if (attrs[i]) {
  40647. name = attrs[i].name;
  40648. if (name.indexOf("data-") === 0) {
  40649. name = camelCase(name.slice(5));
  40650. dataAttr(elem, name, data[name]);
  40651. }
  40652. }
  40653. }
  40654. dataPriv.set(elem, "hasDataAttrs", true);
  40655. }
  40656. }
  40657. return data;
  40658. }
  40659. // Sets multiple values
  40660. if ((typeof key === "undefined" ? "undefined" : _typeof(key)) === "object") {
  40661. return this.each(function () {
  40662. dataUser.set(this, key);
  40663. });
  40664. }
  40665. return access(this, function (value) {
  40666. var data;
  40667. // The calling jQuery object (element matches) is not empty
  40668. // (and therefore has an element appears at this[ 0 ]) and the
  40669. // `value` parameter was not undefined. An empty jQuery object
  40670. // will result in `undefined` for elem = this[ 0 ] which will
  40671. // throw an exception if an attempt to read a data cache is made.
  40672. if (elem && value === undefined) {
  40673. // Attempt to get data from the cache
  40674. // The key will always be camelCased in Data
  40675. data = dataUser.get(elem, key);
  40676. if (data !== undefined) {
  40677. return data;
  40678. }
  40679. // Attempt to "discover" the data in
  40680. // HTML5 custom data-* attrs
  40681. data = dataAttr(elem, key);
  40682. if (data !== undefined) {
  40683. return data;
  40684. }
  40685. // We tried really hard, but the data doesn't exist.
  40686. return;
  40687. }
  40688. // Set the data...
  40689. this.each(function () {
  40690. // We always store the camelCased key
  40691. dataUser.set(this, key, value);
  40692. });
  40693. }, null, value, arguments.length > 1, null, true);
  40694. },
  40695. removeData: function removeData(key) {
  40696. return this.each(function () {
  40697. dataUser.remove(this, key);
  40698. });
  40699. }
  40700. });
  40701. jQuery.extend({
  40702. queue: function queue(elem, type, data) {
  40703. var queue;
  40704. if (elem) {
  40705. type = (type || "fx") + "queue";
  40706. queue = dataPriv.get(elem, type);
  40707. // Speed up dequeue by getting out quickly if this is just a lookup
  40708. if (data) {
  40709. if (!queue || Array.isArray(data)) {
  40710. queue = dataPriv.access(elem, type, jQuery.makeArray(data));
  40711. } else {
  40712. queue.push(data);
  40713. }
  40714. }
  40715. return queue || [];
  40716. }
  40717. },
  40718. dequeue: function dequeue(elem, type) {
  40719. type = type || "fx";
  40720. var queue = jQuery.queue(elem, type),
  40721. startLength = queue.length,
  40722. fn = queue.shift(),
  40723. hooks = jQuery._queueHooks(elem, type),
  40724. next = function next() {
  40725. jQuery.dequeue(elem, type);
  40726. };
  40727. // If the fx queue is dequeued, always remove the progress sentinel
  40728. if (fn === "inprogress") {
  40729. fn = queue.shift();
  40730. startLength--;
  40731. }
  40732. if (fn) {
  40733. // Add a progress sentinel to prevent the fx queue from being
  40734. // automatically dequeued
  40735. if (type === "fx") {
  40736. queue.unshift("inprogress");
  40737. }
  40738. // Clear up the last queue stop function
  40739. delete hooks.stop;
  40740. fn.call(elem, next, hooks);
  40741. }
  40742. if (!startLength && hooks) {
  40743. hooks.empty.fire();
  40744. }
  40745. },
  40746. // Not public - generate a queueHooks object, or return the current one
  40747. _queueHooks: function _queueHooks(elem, type) {
  40748. var key = type + "queueHooks";
  40749. return dataPriv.get(elem, key) || dataPriv.access(elem, key, {
  40750. empty: jQuery.Callbacks("once memory").add(function () {
  40751. dataPriv.remove(elem, [type + "queue", key]);
  40752. })
  40753. });
  40754. }
  40755. });
  40756. jQuery.fn.extend({
  40757. queue: function queue(type, data) {
  40758. var setter = 2;
  40759. if (typeof type !== "string") {
  40760. data = type;
  40761. type = "fx";
  40762. setter--;
  40763. }
  40764. if (arguments.length < setter) {
  40765. return jQuery.queue(this[0], type);
  40766. }
  40767. return data === undefined ? this : this.each(function () {
  40768. var queue = jQuery.queue(this, type, data);
  40769. // Ensure a hooks for this queue
  40770. jQuery._queueHooks(this, type);
  40771. if (type === "fx" && queue[0] !== "inprogress") {
  40772. jQuery.dequeue(this, type);
  40773. }
  40774. });
  40775. },
  40776. dequeue: function dequeue(type) {
  40777. return this.each(function () {
  40778. jQuery.dequeue(this, type);
  40779. });
  40780. },
  40781. clearQueue: function clearQueue(type) {
  40782. return this.queue(type || "fx", []);
  40783. },
  40784. // Get a promise resolved when queues of a certain type
  40785. // are emptied (fx is the type by default)
  40786. promise: function promise(type, obj) {
  40787. var tmp,
  40788. count = 1,
  40789. defer = jQuery.Deferred(),
  40790. elements = this,
  40791. i = this.length,
  40792. resolve = function resolve() {
  40793. if (! --count) {
  40794. defer.resolveWith(elements, [elements]);
  40795. }
  40796. };
  40797. if (typeof type !== "string") {
  40798. obj = type;
  40799. type = undefined;
  40800. }
  40801. type = type || "fx";
  40802. while (i--) {
  40803. tmp = dataPriv.get(elements[i], type + "queueHooks");
  40804. if (tmp && tmp.empty) {
  40805. count++;
  40806. tmp.empty.add(resolve);
  40807. }
  40808. }
  40809. resolve();
  40810. return defer.promise(obj);
  40811. }
  40812. });
  40813. var pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source;
  40814. var rcssNum = new RegExp("^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i");
  40815. var cssExpand = ["Top", "Right", "Bottom", "Left"];
  40816. var isHiddenWithinTree = function isHiddenWithinTree(elem, el) {
  40817. // isHiddenWithinTree might be called from jQuery#filter function;
  40818. // in that case, element will be second argument
  40819. elem = el || elem;
  40820. // Inline style trumps all
  40821. return elem.style.display === "none" || elem.style.display === "" &&
  40822. // Otherwise, check computed style
  40823. // Support: Firefox <=43 - 45
  40824. // Disconnected elements can have computed display: none, so first confirm that elem is
  40825. // in the document.
  40826. jQuery.contains(elem.ownerDocument, elem) && jQuery.css(elem, "display") === "none";
  40827. };
  40828. var swap = function swap(elem, options, callback, args) {
  40829. var ret,
  40830. name,
  40831. old = {};
  40832. // Remember the old values, and insert the new ones
  40833. for (name in options) {
  40834. old[name] = elem.style[name];
  40835. elem.style[name] = options[name];
  40836. }
  40837. ret = callback.apply(elem, args || []);
  40838. // Revert the old values
  40839. for (name in options) {
  40840. elem.style[name] = old[name];
  40841. }
  40842. return ret;
  40843. };
  40844. function adjustCSS(elem, prop, valueParts, tween) {
  40845. var adjusted,
  40846. scale,
  40847. maxIterations = 20,
  40848. currentValue = tween ? function () {
  40849. return tween.cur();
  40850. } : function () {
  40851. return jQuery.css(elem, prop, "");
  40852. },
  40853. initial = currentValue(),
  40854. unit = valueParts && valueParts[3] || (jQuery.cssNumber[prop] ? "" : "px"),
  40855. // Starting value computation is required for potential unit mismatches
  40856. initialInUnit = (jQuery.cssNumber[prop] || unit !== "px" && +initial) && rcssNum.exec(jQuery.css(elem, prop));
  40857. if (initialInUnit && initialInUnit[3] !== unit) {
  40858. // Support: Firefox <=54
  40859. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  40860. initial = initial / 2;
  40861. // Trust units reported by jQuery.css
  40862. unit = unit || initialInUnit[3];
  40863. // Iteratively approximate from a nonzero starting point
  40864. initialInUnit = +initial || 1;
  40865. while (maxIterations--) {
  40866. // Evaluate and update our best guess (doubling guesses that zero out).
  40867. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  40868. jQuery.style(elem, prop, initialInUnit + unit);
  40869. if ((1 - scale) * (1 - (scale = currentValue() / initial || 0.5)) <= 0) {
  40870. maxIterations = 0;
  40871. }
  40872. initialInUnit = initialInUnit / scale;
  40873. }
  40874. initialInUnit = initialInUnit * 2;
  40875. jQuery.style(elem, prop, initialInUnit + unit);
  40876. // Make sure we update the tween properties later on
  40877. valueParts = valueParts || [];
  40878. }
  40879. if (valueParts) {
  40880. initialInUnit = +initialInUnit || +initial || 0;
  40881. // Apply relative offset (+=/-=) if specified
  40882. adjusted = valueParts[1] ? initialInUnit + (valueParts[1] + 1) * valueParts[2] : +valueParts[2];
  40883. if (tween) {
  40884. tween.unit = unit;
  40885. tween.start = initialInUnit;
  40886. tween.end = adjusted;
  40887. }
  40888. }
  40889. return adjusted;
  40890. }
  40891. var defaultDisplayMap = {};
  40892. function getDefaultDisplay(elem) {
  40893. var temp,
  40894. doc = elem.ownerDocument,
  40895. nodeName = elem.nodeName,
  40896. display = defaultDisplayMap[nodeName];
  40897. if (display) {
  40898. return display;
  40899. }
  40900. temp = doc.body.appendChild(doc.createElement(nodeName));
  40901. display = jQuery.css(temp, "display");
  40902. temp.parentNode.removeChild(temp);
  40903. if (display === "none") {
  40904. display = "block";
  40905. }
  40906. defaultDisplayMap[nodeName] = display;
  40907. return display;
  40908. }
  40909. function showHide(elements, show) {
  40910. var display,
  40911. elem,
  40912. values = [],
  40913. index = 0,
  40914. length = elements.length;
  40915. // Determine new display value for elements that need to change
  40916. for (; index < length; index++) {
  40917. elem = elements[index];
  40918. if (!elem.style) {
  40919. continue;
  40920. }
  40921. display = elem.style.display;
  40922. if (show) {
  40923. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  40924. // check is required in this first loop unless we have a nonempty display value (either
  40925. // inline or about-to-be-restored)
  40926. if (display === "none") {
  40927. values[index] = dataPriv.get(elem, "display") || null;
  40928. if (!values[index]) {
  40929. elem.style.display = "";
  40930. }
  40931. }
  40932. if (elem.style.display === "" && isHiddenWithinTree(elem)) {
  40933. values[index] = getDefaultDisplay(elem);
  40934. }
  40935. } else {
  40936. if (display !== "none") {
  40937. values[index] = "none";
  40938. // Remember what we're overwriting
  40939. dataPriv.set(elem, "display", display);
  40940. }
  40941. }
  40942. }
  40943. // Set the display of the elements in a second loop to avoid constant reflow
  40944. for (index = 0; index < length; index++) {
  40945. if (values[index] != null) {
  40946. elements[index].style.display = values[index];
  40947. }
  40948. }
  40949. return elements;
  40950. }
  40951. jQuery.fn.extend({
  40952. show: function show() {
  40953. return showHide(this, true);
  40954. },
  40955. hide: function hide() {
  40956. return showHide(this);
  40957. },
  40958. toggle: function toggle(state) {
  40959. if (typeof state === "boolean") {
  40960. return state ? this.show() : this.hide();
  40961. }
  40962. return this.each(function () {
  40963. if (isHiddenWithinTree(this)) {
  40964. jQuery(this).show();
  40965. } else {
  40966. jQuery(this).hide();
  40967. }
  40968. });
  40969. }
  40970. });
  40971. var rcheckableType = /^(?:checkbox|radio)$/i;
  40972. var rtagName = /<([a-z][^\/\0>\x20\t\r\n\f]+)/i;
  40973. var rscriptType = /^$|^module$|\/(?:java|ecma)script/i;
  40974. // We have to close these tags to support XHTML (#13200)
  40975. var wrapMap = {
  40976. // Support: IE <=9 only
  40977. option: [1, "<select multiple='multiple'>", "</select>"],
  40978. // XHTML parsers do not magically insert elements in the
  40979. // same way that tag soup parsers do. So we cannot shorten
  40980. // this by omitting <tbody> or other required elements.
  40981. thead: [1, "<table>", "</table>"],
  40982. col: [2, "<table><colgroup>", "</colgroup></table>"],
  40983. tr: [2, "<table><tbody>", "</tbody></table>"],
  40984. td: [3, "<table><tbody><tr>", "</tr></tbody></table>"],
  40985. _default: [0, "", ""]
  40986. };
  40987. // Support: IE <=9 only
  40988. wrapMap.optgroup = wrapMap.option;
  40989. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  40990. wrapMap.th = wrapMap.td;
  40991. function getAll(context, tag) {
  40992. // Support: IE <=9 - 11 only
  40993. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  40994. var ret;
  40995. if (typeof context.getElementsByTagName !== "undefined") {
  40996. ret = context.getElementsByTagName(tag || "*");
  40997. } else if (typeof context.querySelectorAll !== "undefined") {
  40998. ret = context.querySelectorAll(tag || "*");
  40999. } else {
  41000. ret = [];
  41001. }
  41002. if (tag === undefined || tag && nodeName(context, tag)) {
  41003. return jQuery.merge([context], ret);
  41004. }
  41005. return ret;
  41006. }
  41007. // Mark scripts as having already been evaluated
  41008. function setGlobalEval(elems, refElements) {
  41009. var i = 0,
  41010. l = elems.length;
  41011. for (; i < l; i++) {
  41012. dataPriv.set(elems[i], "globalEval", !refElements || dataPriv.get(refElements[i], "globalEval"));
  41013. }
  41014. }
  41015. var rhtml = /<|&#?\w+;/;
  41016. function buildFragment(elems, context, scripts, selection, ignored) {
  41017. var elem,
  41018. tmp,
  41019. tag,
  41020. wrap,
  41021. contains,
  41022. j,
  41023. fragment = context.createDocumentFragment(),
  41024. nodes = [],
  41025. i = 0,
  41026. l = elems.length;
  41027. for (; i < l; i++) {
  41028. elem = elems[i];
  41029. if (elem || elem === 0) {
  41030. // Add nodes directly
  41031. if (toType(elem) === "object") {
  41032. // Support: Android <=4.0 only, PhantomJS 1 only
  41033. // push.apply(_, arraylike) throws on ancient WebKit
  41034. jQuery.merge(nodes, elem.nodeType ? [elem] : elem);
  41035. // Convert non-html into a text node
  41036. } else if (!rhtml.test(elem)) {
  41037. nodes.push(context.createTextNode(elem));
  41038. // Convert html into DOM nodes
  41039. } else {
  41040. tmp = tmp || fragment.appendChild(context.createElement("div"));
  41041. // Deserialize a standard representation
  41042. tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase();
  41043. wrap = wrapMap[tag] || wrapMap._default;
  41044. tmp.innerHTML = wrap[1] + jQuery.htmlPrefilter(elem) + wrap[2];
  41045. // Descend through wrappers to the right content
  41046. j = wrap[0];
  41047. while (j--) {
  41048. tmp = tmp.lastChild;
  41049. }
  41050. // Support: Android <=4.0 only, PhantomJS 1 only
  41051. // push.apply(_, arraylike) throws on ancient WebKit
  41052. jQuery.merge(nodes, tmp.childNodes);
  41053. // Remember the top-level container
  41054. tmp = fragment.firstChild;
  41055. // Ensure the created nodes are orphaned (#12392)
  41056. tmp.textContent = "";
  41057. }
  41058. }
  41059. }
  41060. // Remove wrapper from fragment
  41061. fragment.textContent = "";
  41062. i = 0;
  41063. while (elem = nodes[i++]) {
  41064. // Skip elements already in the context collection (trac-4087)
  41065. if (selection && jQuery.inArray(elem, selection) > -1) {
  41066. if (ignored) {
  41067. ignored.push(elem);
  41068. }
  41069. continue;
  41070. }
  41071. contains = jQuery.contains(elem.ownerDocument, elem);
  41072. // Append to fragment
  41073. tmp = getAll(fragment.appendChild(elem), "script");
  41074. // Preserve script evaluation history
  41075. if (contains) {
  41076. setGlobalEval(tmp);
  41077. }
  41078. // Capture executables
  41079. if (scripts) {
  41080. j = 0;
  41081. while (elem = tmp[j++]) {
  41082. if (rscriptType.test(elem.type || "")) {
  41083. scripts.push(elem);
  41084. }
  41085. }
  41086. }
  41087. }
  41088. return fragment;
  41089. }
  41090. (function () {
  41091. var fragment = document.createDocumentFragment(),
  41092. div = fragment.appendChild(document.createElement("div")),
  41093. input = document.createElement("input");
  41094. // Support: Android 4.0 - 4.3 only
  41095. // Check state lost if the name is set (#11217)
  41096. // Support: Windows Web Apps (WWA)
  41097. // `name` and `type` must use .setAttribute for WWA (#14901)
  41098. input.setAttribute("type", "radio");
  41099. input.setAttribute("checked", "checked");
  41100. input.setAttribute("name", "t");
  41101. div.appendChild(input);
  41102. // Support: Android <=4.1 only
  41103. // Older WebKit doesn't clone checked state correctly in fragments
  41104. support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked;
  41105. // Support: IE <=11 only
  41106. // Make sure textarea (and checkbox) defaultValue is properly cloned
  41107. div.innerHTML = "<textarea>x</textarea>";
  41108. support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue;
  41109. })();
  41110. var documentElement = document.documentElement;
  41111. var rkeyEvent = /^key/,
  41112. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  41113. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  41114. function returnTrue() {
  41115. return true;
  41116. }
  41117. function returnFalse() {
  41118. return false;
  41119. }
  41120. // Support: IE <=9 only
  41121. // See #13393 for more info
  41122. function safeActiveElement() {
  41123. try {
  41124. return document.activeElement;
  41125. } catch (err) {}
  41126. }
  41127. function _on(elem, types, selector, data, fn, one) {
  41128. var origFn, type;
  41129. // Types can be a map of types/handlers
  41130. if ((typeof types === "undefined" ? "undefined" : _typeof(types)) === "object") {
  41131. // ( types-Object, selector, data )
  41132. if (typeof selector !== "string") {
  41133. // ( types-Object, data )
  41134. data = data || selector;
  41135. selector = undefined;
  41136. }
  41137. for (type in types) {
  41138. _on(elem, type, selector, data, types[type], one);
  41139. }
  41140. return elem;
  41141. }
  41142. if (data == null && fn == null) {
  41143. // ( types, fn )
  41144. fn = selector;
  41145. data = selector = undefined;
  41146. } else if (fn == null) {
  41147. if (typeof selector === "string") {
  41148. // ( types, selector, fn )
  41149. fn = data;
  41150. data = undefined;
  41151. } else {
  41152. // ( types, data, fn )
  41153. fn = data;
  41154. data = selector;
  41155. selector = undefined;
  41156. }
  41157. }
  41158. if (fn === false) {
  41159. fn = returnFalse;
  41160. } else if (!fn) {
  41161. return elem;
  41162. }
  41163. if (one === 1) {
  41164. origFn = fn;
  41165. fn = function fn(event) {
  41166. // Can use an empty set, since event contains the info
  41167. jQuery().off(event);
  41168. return origFn.apply(this, arguments);
  41169. };
  41170. // Use same guid so caller can remove using origFn
  41171. fn.guid = origFn.guid || (origFn.guid = jQuery.guid++);
  41172. }
  41173. return elem.each(function () {
  41174. jQuery.event.add(this, types, fn, data, selector);
  41175. });
  41176. }
  41177. /*
  41178. * Helper functions for managing events -- not part of the public interface.
  41179. * Props to Dean Edwards' addEvent library for many of the ideas.
  41180. */
  41181. jQuery.event = {
  41182. global: {},
  41183. add: function add(elem, types, handler, data, selector) {
  41184. var handleObjIn,
  41185. eventHandle,
  41186. tmp,
  41187. events,
  41188. t,
  41189. handleObj,
  41190. special,
  41191. handlers,
  41192. type,
  41193. namespaces,
  41194. origType,
  41195. elemData = dataPriv.get(elem);
  41196. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  41197. if (!elemData) {
  41198. return;
  41199. }
  41200. // Caller can pass in an object of custom data in lieu of the handler
  41201. if (handler.handler) {
  41202. handleObjIn = handler;
  41203. handler = handleObjIn.handler;
  41204. selector = handleObjIn.selector;
  41205. }
  41206. // Ensure that invalid selectors throw exceptions at attach time
  41207. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  41208. if (selector) {
  41209. jQuery.find.matchesSelector(documentElement, selector);
  41210. }
  41211. // Make sure that the handler has a unique ID, used to find/remove it later
  41212. if (!handler.guid) {
  41213. handler.guid = jQuery.guid++;
  41214. }
  41215. // Init the element's event structure and main handler, if this is the first
  41216. if (!(events = elemData.events)) {
  41217. events = elemData.events = {};
  41218. }
  41219. if (!(eventHandle = elemData.handle)) {
  41220. eventHandle = elemData.handle = function (e) {
  41221. // Discard the second event of a jQuery.event.trigger() and
  41222. // when an event is called after a page has unloaded
  41223. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? jQuery.event.dispatch.apply(elem, arguments) : undefined;
  41224. };
  41225. }
  41226. // Handle multiple events separated by a space
  41227. types = (types || "").match(rnothtmlwhite) || [""];
  41228. t = types.length;
  41229. while (t--) {
  41230. tmp = rtypenamespace.exec(types[t]) || [];
  41231. type = origType = tmp[1];
  41232. namespaces = (tmp[2] || "").split(".").sort();
  41233. // There *must* be a type, no attaching namespace-only handlers
  41234. if (!type) {
  41235. continue;
  41236. }
  41237. // If event changes its type, use the special event handlers for the changed type
  41238. special = jQuery.event.special[type] || {};
  41239. // If selector defined, determine special event api type, otherwise given type
  41240. type = (selector ? special.delegateType : special.bindType) || type;
  41241. // Update special based on newly reset type
  41242. special = jQuery.event.special[type] || {};
  41243. // handleObj is passed to all event handlers
  41244. handleObj = jQuery.extend({
  41245. type: type,
  41246. origType: origType,
  41247. data: data,
  41248. handler: handler,
  41249. guid: handler.guid,
  41250. selector: selector,
  41251. needsContext: selector && jQuery.expr.match.needsContext.test(selector),
  41252. namespace: namespaces.join(".")
  41253. }, handleObjIn);
  41254. // Init the event handler queue if we're the first
  41255. if (!(handlers = events[type])) {
  41256. handlers = events[type] = [];
  41257. handlers.delegateCount = 0;
  41258. // Only use addEventListener if the special events handler returns false
  41259. if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) {
  41260. if (elem.addEventListener) {
  41261. elem.addEventListener(type, eventHandle);
  41262. }
  41263. }
  41264. }
  41265. if (special.add) {
  41266. special.add.call(elem, handleObj);
  41267. if (!handleObj.handler.guid) {
  41268. handleObj.handler.guid = handler.guid;
  41269. }
  41270. }
  41271. // Add to the element's handler list, delegates in front
  41272. if (selector) {
  41273. handlers.splice(handlers.delegateCount++, 0, handleObj);
  41274. } else {
  41275. handlers.push(handleObj);
  41276. }
  41277. // Keep track of which events have ever been used, for event optimization
  41278. jQuery.event.global[type] = true;
  41279. }
  41280. },
  41281. // Detach an event or set of events from an element
  41282. remove: function remove(elem, types, handler, selector, mappedTypes) {
  41283. var j,
  41284. origCount,
  41285. tmp,
  41286. events,
  41287. t,
  41288. handleObj,
  41289. special,
  41290. handlers,
  41291. type,
  41292. namespaces,
  41293. origType,
  41294. elemData = dataPriv.hasData(elem) && dataPriv.get(elem);
  41295. if (!elemData || !(events = elemData.events)) {
  41296. return;
  41297. }
  41298. // Once for each type.namespace in types; type may be omitted
  41299. types = (types || "").match(rnothtmlwhite) || [""];
  41300. t = types.length;
  41301. while (t--) {
  41302. tmp = rtypenamespace.exec(types[t]) || [];
  41303. type = origType = tmp[1];
  41304. namespaces = (tmp[2] || "").split(".").sort();
  41305. // Unbind all events (on this namespace, if provided) for the element
  41306. if (!type) {
  41307. for (type in events) {
  41308. jQuery.event.remove(elem, type + types[t], handler, selector, true);
  41309. }
  41310. continue;
  41311. }
  41312. special = jQuery.event.special[type] || {};
  41313. type = (selector ? special.delegateType : special.bindType) || type;
  41314. handlers = events[type] || [];
  41315. tmp = tmp[2] && new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)");
  41316. // Remove matching events
  41317. origCount = j = handlers.length;
  41318. while (j--) {
  41319. handleObj = handlers[j];
  41320. if ((mappedTypes || origType === handleObj.origType) && (!handler || handler.guid === handleObj.guid) && (!tmp || tmp.test(handleObj.namespace)) && (!selector || selector === handleObj.selector || selector === "**" && handleObj.selector)) {
  41321. handlers.splice(j, 1);
  41322. if (handleObj.selector) {
  41323. handlers.delegateCount--;
  41324. }
  41325. if (special.remove) {
  41326. special.remove.call(elem, handleObj);
  41327. }
  41328. }
  41329. }
  41330. // Remove generic event handler if we removed something and no more handlers exist
  41331. // (avoids potential for endless recursion during removal of special event handlers)
  41332. if (origCount && !handlers.length) {
  41333. if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) {
  41334. jQuery.removeEvent(elem, type, elemData.handle);
  41335. }
  41336. delete events[type];
  41337. }
  41338. }
  41339. // Remove data and the expando if it's no longer used
  41340. if (jQuery.isEmptyObject(events)) {
  41341. dataPriv.remove(elem, "handle events");
  41342. }
  41343. },
  41344. dispatch: function dispatch(nativeEvent) {
  41345. // Make a writable jQuery.Event from the native event object
  41346. var event = jQuery.event.fix(nativeEvent);
  41347. var i,
  41348. j,
  41349. ret,
  41350. matched,
  41351. handleObj,
  41352. handlerQueue,
  41353. args = new Array(arguments.length),
  41354. handlers = (dataPriv.get(this, "events") || {})[event.type] || [],
  41355. special = jQuery.event.special[event.type] || {};
  41356. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  41357. args[0] = event;
  41358. for (i = 1; i < arguments.length; i++) {
  41359. args[i] = arguments[i];
  41360. }
  41361. event.delegateTarget = this;
  41362. // Call the preDispatch hook for the mapped type, and let it bail if desired
  41363. if (special.preDispatch && special.preDispatch.call(this, event) === false) {
  41364. return;
  41365. }
  41366. // Determine handlers
  41367. handlerQueue = jQuery.event.handlers.call(this, event, handlers);
  41368. // Run delegates first; they may want to stop propagation beneath us
  41369. i = 0;
  41370. while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {
  41371. event.currentTarget = matched.elem;
  41372. j = 0;
  41373. while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) {
  41374. // Triggered event must either 1) have no namespace, or 2) have namespace(s)
  41375. // a subset or equal to those in the bound event (both can have no namespace).
  41376. if (!event.rnamespace || event.rnamespace.test(handleObj.namespace)) {
  41377. event.handleObj = handleObj;
  41378. event.data = handleObj.data;
  41379. ret = ((jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply(matched.elem, args);
  41380. if (ret !== undefined) {
  41381. if ((event.result = ret) === false) {
  41382. event.preventDefault();
  41383. event.stopPropagation();
  41384. }
  41385. }
  41386. }
  41387. }
  41388. }
  41389. // Call the postDispatch hook for the mapped type
  41390. if (special.postDispatch) {
  41391. special.postDispatch.call(this, event);
  41392. }
  41393. return event.result;
  41394. },
  41395. handlers: function handlers(event, _handlers) {
  41396. var i,
  41397. handleObj,
  41398. sel,
  41399. matchedHandlers,
  41400. matchedSelectors,
  41401. handlerQueue = [],
  41402. delegateCount = _handlers.delegateCount,
  41403. cur = event.target;
  41404. // Find delegate handlers
  41405. if (delegateCount &&
  41406. // Support: IE <=9
  41407. // Black-hole SVG <use> instance trees (trac-13180)
  41408. cur.nodeType &&
  41409. // Support: Firefox <=42
  41410. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  41411. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  41412. // Support: IE 11 only
  41413. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  41414. !(event.type === "click" && event.button >= 1)) {
  41415. for (; cur !== this; cur = cur.parentNode || this) {
  41416. // Don't check non-elements (#13208)
  41417. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  41418. if (cur.nodeType === 1 && !(event.type === "click" && cur.disabled === true)) {
  41419. matchedHandlers = [];
  41420. matchedSelectors = {};
  41421. for (i = 0; i < delegateCount; i++) {
  41422. handleObj = _handlers[i];
  41423. // Don't conflict with Object.prototype properties (#13203)
  41424. sel = handleObj.selector + " ";
  41425. if (matchedSelectors[sel] === undefined) {
  41426. matchedSelectors[sel] = handleObj.needsContext ? jQuery(sel, this).index(cur) > -1 : jQuery.find(sel, this, null, [cur]).length;
  41427. }
  41428. if (matchedSelectors[sel]) {
  41429. matchedHandlers.push(handleObj);
  41430. }
  41431. }
  41432. if (matchedHandlers.length) {
  41433. handlerQueue.push({ elem: cur, handlers: matchedHandlers });
  41434. }
  41435. }
  41436. }
  41437. }
  41438. // Add the remaining (directly-bound) handlers
  41439. cur = this;
  41440. if (delegateCount < _handlers.length) {
  41441. handlerQueue.push({ elem: cur, handlers: _handlers.slice(delegateCount) });
  41442. }
  41443. return handlerQueue;
  41444. },
  41445. addProp: function addProp(name, hook) {
  41446. Object.defineProperty(jQuery.Event.prototype, name, {
  41447. enumerable: true,
  41448. configurable: true,
  41449. get: isFunction(hook) ? function () {
  41450. if (this.originalEvent) {
  41451. return hook(this.originalEvent);
  41452. }
  41453. } : function () {
  41454. if (this.originalEvent) {
  41455. return this.originalEvent[name];
  41456. }
  41457. },
  41458. set: function set(value) {
  41459. Object.defineProperty(this, name, {
  41460. enumerable: true,
  41461. configurable: true,
  41462. writable: true,
  41463. value: value
  41464. });
  41465. }
  41466. });
  41467. },
  41468. fix: function fix(originalEvent) {
  41469. return originalEvent[jQuery.expando] ? originalEvent : new jQuery.Event(originalEvent);
  41470. },
  41471. special: {
  41472. load: {
  41473. // Prevent triggered image.load events from bubbling to window.load
  41474. noBubble: true
  41475. },
  41476. focus: {
  41477. // Fire native event if possible so blur/focus sequence is correct
  41478. trigger: function trigger() {
  41479. if (this !== safeActiveElement() && this.focus) {
  41480. this.focus();
  41481. return false;
  41482. }
  41483. },
  41484. delegateType: "focusin"
  41485. },
  41486. blur: {
  41487. trigger: function trigger() {
  41488. if (this === safeActiveElement() && this.blur) {
  41489. this.blur();
  41490. return false;
  41491. }
  41492. },
  41493. delegateType: "focusout"
  41494. },
  41495. click: {
  41496. // For checkbox, fire native event so checked state will be right
  41497. trigger: function trigger() {
  41498. if (this.type === "checkbox" && this.click && nodeName(this, "input")) {
  41499. this.click();
  41500. return false;
  41501. }
  41502. },
  41503. // For cross-browser consistency, don't fire native .click() on links
  41504. _default: function _default(event) {
  41505. return nodeName(event.target, "a");
  41506. }
  41507. },
  41508. beforeunload: {
  41509. postDispatch: function postDispatch(event) {
  41510. // Support: Firefox 20+
  41511. // Firefox doesn't alert if the returnValue field is not set.
  41512. if (event.result !== undefined && event.originalEvent) {
  41513. event.originalEvent.returnValue = event.result;
  41514. }
  41515. }
  41516. }
  41517. }
  41518. };
  41519. jQuery.removeEvent = function (elem, type, handle) {
  41520. // This "if" is needed for plain objects
  41521. if (elem.removeEventListener) {
  41522. elem.removeEventListener(type, handle);
  41523. }
  41524. };
  41525. jQuery.Event = function (src, props) {
  41526. // Allow instantiation without the 'new' keyword
  41527. if (!(this instanceof jQuery.Event)) {
  41528. return new jQuery.Event(src, props);
  41529. }
  41530. // Event object
  41531. if (src && src.type) {
  41532. this.originalEvent = src;
  41533. this.type = src.type;
  41534. // Events bubbling up the document may have been marked as prevented
  41535. // by a handler lower down the tree; reflect the correct value.
  41536. this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === undefined &&
  41537. // Support: Android <=2.3 only
  41538. src.returnValue === false ? returnTrue : returnFalse;
  41539. // Create target properties
  41540. // Support: Safari <=6 - 7 only
  41541. // Target should not be a text node (#504, #13143)
  41542. this.target = src.target && src.target.nodeType === 3 ? src.target.parentNode : src.target;
  41543. this.currentTarget = src.currentTarget;
  41544. this.relatedTarget = src.relatedTarget;
  41545. // Event type
  41546. } else {
  41547. this.type = src;
  41548. }
  41549. // Put explicitly provided properties onto the event object
  41550. if (props) {
  41551. jQuery.extend(this, props);
  41552. }
  41553. // Create a timestamp if incoming event doesn't have one
  41554. this.timeStamp = src && src.timeStamp || Date.now();
  41555. // Mark it as fixed
  41556. this[jQuery.expando] = true;
  41557. };
  41558. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  41559. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  41560. jQuery.Event.prototype = {
  41561. constructor: jQuery.Event,
  41562. isDefaultPrevented: returnFalse,
  41563. isPropagationStopped: returnFalse,
  41564. isImmediatePropagationStopped: returnFalse,
  41565. isSimulated: false,
  41566. preventDefault: function preventDefault() {
  41567. var e = this.originalEvent;
  41568. this.isDefaultPrevented = returnTrue;
  41569. if (e && !this.isSimulated) {
  41570. e.preventDefault();
  41571. }
  41572. },
  41573. stopPropagation: function stopPropagation() {
  41574. var e = this.originalEvent;
  41575. this.isPropagationStopped = returnTrue;
  41576. if (e && !this.isSimulated) {
  41577. e.stopPropagation();
  41578. }
  41579. },
  41580. stopImmediatePropagation: function stopImmediatePropagation() {
  41581. var e = this.originalEvent;
  41582. this.isImmediatePropagationStopped = returnTrue;
  41583. if (e && !this.isSimulated) {
  41584. e.stopImmediatePropagation();
  41585. }
  41586. this.stopPropagation();
  41587. }
  41588. };
  41589. // Includes all common event props including KeyEvent and MouseEvent specific props
  41590. jQuery.each({
  41591. altKey: true,
  41592. bubbles: true,
  41593. cancelable: true,
  41594. changedTouches: true,
  41595. ctrlKey: true,
  41596. detail: true,
  41597. eventPhase: true,
  41598. metaKey: true,
  41599. pageX: true,
  41600. pageY: true,
  41601. shiftKey: true,
  41602. view: true,
  41603. "char": true,
  41604. charCode: true,
  41605. key: true,
  41606. keyCode: true,
  41607. button: true,
  41608. buttons: true,
  41609. clientX: true,
  41610. clientY: true,
  41611. offsetX: true,
  41612. offsetY: true,
  41613. pointerId: true,
  41614. pointerType: true,
  41615. screenX: true,
  41616. screenY: true,
  41617. targetTouches: true,
  41618. toElement: true,
  41619. touches: true,
  41620. which: function which(event) {
  41621. var button = event.button;
  41622. // Add which for key events
  41623. if (event.which == null && rkeyEvent.test(event.type)) {
  41624. return event.charCode != null ? event.charCode : event.keyCode;
  41625. }
  41626. // Add which for click: 1 === left; 2 === middle; 3 === right
  41627. if (!event.which && button !== undefined && rmouseEvent.test(event.type)) {
  41628. if (button & 1) {
  41629. return 1;
  41630. }
  41631. if (button & 2) {
  41632. return 3;
  41633. }
  41634. if (button & 4) {
  41635. return 2;
  41636. }
  41637. return 0;
  41638. }
  41639. return event.which;
  41640. }
  41641. }, jQuery.event.addProp);
  41642. // Create mouseenter/leave events using mouseover/out and event-time checks
  41643. // so that event delegation works in jQuery.
  41644. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  41645. //
  41646. // Support: Safari 7 only
  41647. // Safari sends mouseenter too often; see:
  41648. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  41649. // for the description of the bug (it existed in older Chrome versions as well).
  41650. jQuery.each({
  41651. mouseenter: "mouseover",
  41652. mouseleave: "mouseout",
  41653. pointerenter: "pointerover",
  41654. pointerleave: "pointerout"
  41655. }, function (orig, fix) {
  41656. jQuery.event.special[orig] = {
  41657. delegateType: fix,
  41658. bindType: fix,
  41659. handle: function handle(event) {
  41660. var ret,
  41661. target = this,
  41662. related = event.relatedTarget,
  41663. handleObj = event.handleObj;
  41664. // For mouseenter/leave call the handler if related is outside the target.
  41665. // NB: No relatedTarget if the mouse left/entered the browser window
  41666. if (!related || related !== target && !jQuery.contains(target, related)) {
  41667. event.type = handleObj.origType;
  41668. ret = handleObj.handler.apply(this, arguments);
  41669. event.type = fix;
  41670. }
  41671. return ret;
  41672. }
  41673. };
  41674. });
  41675. jQuery.fn.extend({
  41676. on: function on(types, selector, data, fn) {
  41677. return _on(this, types, selector, data, fn);
  41678. },
  41679. one: function one(types, selector, data, fn) {
  41680. return _on(this, types, selector, data, fn, 1);
  41681. },
  41682. off: function off(types, selector, fn) {
  41683. var handleObj, type;
  41684. if (types && types.preventDefault && types.handleObj) {
  41685. // ( event ) dispatched jQuery.Event
  41686. handleObj = types.handleObj;
  41687. jQuery(types.delegateTarget).off(handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler);
  41688. return this;
  41689. }
  41690. if ((typeof types === "undefined" ? "undefined" : _typeof(types)) === "object") {
  41691. // ( types-object [, selector] )
  41692. for (type in types) {
  41693. this.off(type, selector, types[type]);
  41694. }
  41695. return this;
  41696. }
  41697. if (selector === false || typeof selector === "function") {
  41698. // ( types [, fn] )
  41699. fn = selector;
  41700. selector = undefined;
  41701. }
  41702. if (fn === false) {
  41703. fn = returnFalse;
  41704. }
  41705. return this.each(function () {
  41706. jQuery.event.remove(this, types, fn, selector);
  41707. });
  41708. }
  41709. });
  41710. var
  41711. /* eslint-disable max-len */
  41712. // See https://github.com/eslint/eslint/issues/3229
  41713. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  41714. /* eslint-enable */
  41715. // Support: IE <=10 - 11, Edge 12 - 13 only
  41716. // In IE/Edge using regex groups here causes severe slowdowns.
  41717. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  41718. rnoInnerhtml = /<script|<style|<link/i,
  41719. // checked="checked" or checked
  41720. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  41721. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  41722. // Prefer a tbody over its parent table for containing new rows
  41723. function manipulationTarget(elem, content) {
  41724. if (nodeName(elem, "table") && nodeName(content.nodeType !== 11 ? content : content.firstChild, "tr")) {
  41725. return jQuery(elem).children("tbody")[0] || elem;
  41726. }
  41727. return elem;
  41728. }
  41729. // Replace/restore the type attribute of script elements for safe DOM manipulation
  41730. function disableScript(elem) {
  41731. elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
  41732. return elem;
  41733. }
  41734. function restoreScript(elem) {
  41735. if ((elem.type || "").slice(0, 5) === "true/") {
  41736. elem.type = elem.type.slice(5);
  41737. } else {
  41738. elem.removeAttribute("type");
  41739. }
  41740. return elem;
  41741. }
  41742. function cloneCopyEvent(src, dest) {
  41743. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  41744. if (dest.nodeType !== 1) {
  41745. return;
  41746. }
  41747. // 1. Copy private data: events, handlers, etc.
  41748. if (dataPriv.hasData(src)) {
  41749. pdataOld = dataPriv.access(src);
  41750. pdataCur = dataPriv.set(dest, pdataOld);
  41751. events = pdataOld.events;
  41752. if (events) {
  41753. delete pdataCur.handle;
  41754. pdataCur.events = {};
  41755. for (type in events) {
  41756. for (i = 0, l = events[type].length; i < l; i++) {
  41757. jQuery.event.add(dest, type, events[type][i]);
  41758. }
  41759. }
  41760. }
  41761. }
  41762. // 2. Copy user data
  41763. if (dataUser.hasData(src)) {
  41764. udataOld = dataUser.access(src);
  41765. udataCur = jQuery.extend({}, udataOld);
  41766. dataUser.set(dest, udataCur);
  41767. }
  41768. }
  41769. // Fix IE bugs, see support tests
  41770. function fixInput(src, dest) {
  41771. var nodeName = dest.nodeName.toLowerCase();
  41772. // Fails to persist the checked state of a cloned checkbox or radio button.
  41773. if (nodeName === "input" && rcheckableType.test(src.type)) {
  41774. dest.checked = src.checked;
  41775. // Fails to return the selected option to the default selected state when cloning options
  41776. } else if (nodeName === "input" || nodeName === "textarea") {
  41777. dest.defaultValue = src.defaultValue;
  41778. }
  41779. }
  41780. function domManip(collection, args, callback, ignored) {
  41781. // Flatten any nested arrays
  41782. args = concat.apply([], args);
  41783. var fragment,
  41784. first,
  41785. scripts,
  41786. hasScripts,
  41787. node,
  41788. doc,
  41789. i = 0,
  41790. l = collection.length,
  41791. iNoClone = l - 1,
  41792. value = args[0],
  41793. valueIsFunction = isFunction(value);
  41794. // We can't cloneNode fragments that contain checked, in WebKit
  41795. if (valueIsFunction || l > 1 && typeof value === "string" && !support.checkClone && rchecked.test(value)) {
  41796. return collection.each(function (index) {
  41797. var self = collection.eq(index);
  41798. if (valueIsFunction) {
  41799. args[0] = value.call(this, index, self.html());
  41800. }
  41801. domManip(self, args, callback, ignored);
  41802. });
  41803. }
  41804. if (l) {
  41805. fragment = buildFragment(args, collection[0].ownerDocument, false, collection, ignored);
  41806. first = fragment.firstChild;
  41807. if (fragment.childNodes.length === 1) {
  41808. fragment = first;
  41809. }
  41810. // Require either new content or an interest in ignored elements to invoke the callback
  41811. if (first || ignored) {
  41812. scripts = jQuery.map(getAll(fragment, "script"), disableScript);
  41813. hasScripts = scripts.length;
  41814. // Use the original fragment for the last item
  41815. // instead of the first because it can end up
  41816. // being emptied incorrectly in certain situations (#8070).
  41817. for (; i < l; i++) {
  41818. node = fragment;
  41819. if (i !== iNoClone) {
  41820. node = jQuery.clone(node, true, true);
  41821. // Keep references to cloned scripts for later restoration
  41822. if (hasScripts) {
  41823. // Support: Android <=4.0 only, PhantomJS 1 only
  41824. // push.apply(_, arraylike) throws on ancient WebKit
  41825. jQuery.merge(scripts, getAll(node, "script"));
  41826. }
  41827. }
  41828. callback.call(collection[i], node, i);
  41829. }
  41830. if (hasScripts) {
  41831. doc = scripts[scripts.length - 1].ownerDocument;
  41832. // Reenable scripts
  41833. jQuery.map(scripts, restoreScript);
  41834. // Evaluate executable scripts on first document insertion
  41835. for (i = 0; i < hasScripts; i++) {
  41836. node = scripts[i];
  41837. if (rscriptType.test(node.type || "") && !dataPriv.access(node, "globalEval") && jQuery.contains(doc, node)) {
  41838. if (node.src && (node.type || "").toLowerCase() !== "module") {
  41839. // Optional AJAX dependency, but won't run scripts if not present
  41840. if (jQuery._evalUrl) {
  41841. jQuery._evalUrl(node.src);
  41842. }
  41843. } else {
  41844. DOMEval(node.textContent.replace(rcleanScript, ""), doc, node);
  41845. }
  41846. }
  41847. }
  41848. }
  41849. }
  41850. }
  41851. return collection;
  41852. }
  41853. function _remove(elem, selector, keepData) {
  41854. var node,
  41855. nodes = selector ? jQuery.filter(selector, elem) : elem,
  41856. i = 0;
  41857. for (; (node = nodes[i]) != null; i++) {
  41858. if (!keepData && node.nodeType === 1) {
  41859. jQuery.cleanData(getAll(node));
  41860. }
  41861. if (node.parentNode) {
  41862. if (keepData && jQuery.contains(node.ownerDocument, node)) {
  41863. setGlobalEval(getAll(node, "script"));
  41864. }
  41865. node.parentNode.removeChild(node);
  41866. }
  41867. }
  41868. return elem;
  41869. }
  41870. jQuery.extend({
  41871. htmlPrefilter: function htmlPrefilter(html) {
  41872. return html.replace(rxhtmlTag, "<$1></$2>");
  41873. },
  41874. clone: function clone(elem, dataAndEvents, deepDataAndEvents) {
  41875. var i,
  41876. l,
  41877. srcElements,
  41878. destElements,
  41879. clone = elem.cloneNode(true),
  41880. inPage = jQuery.contains(elem.ownerDocument, elem);
  41881. // Fix IE cloning issues
  41882. if (!support.noCloneChecked && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) {
  41883. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  41884. destElements = getAll(clone);
  41885. srcElements = getAll(elem);
  41886. for (i = 0, l = srcElements.length; i < l; i++) {
  41887. fixInput(srcElements[i], destElements[i]);
  41888. }
  41889. }
  41890. // Copy the events from the original to the clone
  41891. if (dataAndEvents) {
  41892. if (deepDataAndEvents) {
  41893. srcElements = srcElements || getAll(elem);
  41894. destElements = destElements || getAll(clone);
  41895. for (i = 0, l = srcElements.length; i < l; i++) {
  41896. cloneCopyEvent(srcElements[i], destElements[i]);
  41897. }
  41898. } else {
  41899. cloneCopyEvent(elem, clone);
  41900. }
  41901. }
  41902. // Preserve script evaluation history
  41903. destElements = getAll(clone, "script");
  41904. if (destElements.length > 0) {
  41905. setGlobalEval(destElements, !inPage && getAll(elem, "script"));
  41906. }
  41907. // Return the cloned set
  41908. return clone;
  41909. },
  41910. cleanData: function cleanData(elems) {
  41911. var data,
  41912. elem,
  41913. type,
  41914. special = jQuery.event.special,
  41915. i = 0;
  41916. for (; (elem = elems[i]) !== undefined; i++) {
  41917. if (acceptData(elem)) {
  41918. if (data = elem[dataPriv.expando]) {
  41919. if (data.events) {
  41920. for (type in data.events) {
  41921. if (special[type]) {
  41922. jQuery.event.remove(elem, type);
  41923. // This is a shortcut to avoid jQuery.event.remove's overhead
  41924. } else {
  41925. jQuery.removeEvent(elem, type, data.handle);
  41926. }
  41927. }
  41928. }
  41929. // Support: Chrome <=35 - 45+
  41930. // Assign undefined instead of using delete, see Data#remove
  41931. elem[dataPriv.expando] = undefined;
  41932. }
  41933. if (elem[dataUser.expando]) {
  41934. // Support: Chrome <=35 - 45+
  41935. // Assign undefined instead of using delete, see Data#remove
  41936. elem[dataUser.expando] = undefined;
  41937. }
  41938. }
  41939. }
  41940. }
  41941. });
  41942. jQuery.fn.extend({
  41943. detach: function detach(selector) {
  41944. return _remove(this, selector, true);
  41945. },
  41946. remove: function remove(selector) {
  41947. return _remove(this, selector);
  41948. },
  41949. text: function text(value) {
  41950. return access(this, function (value) {
  41951. return value === undefined ? jQuery.text(this) : this.empty().each(function () {
  41952. if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
  41953. this.textContent = value;
  41954. }
  41955. });
  41956. }, null, value, arguments.length);
  41957. },
  41958. append: function append() {
  41959. return domManip(this, arguments, function (elem) {
  41960. if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
  41961. var target = manipulationTarget(this, elem);
  41962. target.appendChild(elem);
  41963. }
  41964. });
  41965. },
  41966. prepend: function prepend() {
  41967. return domManip(this, arguments, function (elem) {
  41968. if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
  41969. var target = manipulationTarget(this, elem);
  41970. target.insertBefore(elem, target.firstChild);
  41971. }
  41972. });
  41973. },
  41974. before: function before() {
  41975. return domManip(this, arguments, function (elem) {
  41976. if (this.parentNode) {
  41977. this.parentNode.insertBefore(elem, this);
  41978. }
  41979. });
  41980. },
  41981. after: function after() {
  41982. return domManip(this, arguments, function (elem) {
  41983. if (this.parentNode) {
  41984. this.parentNode.insertBefore(elem, this.nextSibling);
  41985. }
  41986. });
  41987. },
  41988. empty: function empty() {
  41989. var elem,
  41990. i = 0;
  41991. for (; (elem = this[i]) != null; i++) {
  41992. if (elem.nodeType === 1) {
  41993. // Prevent memory leaks
  41994. jQuery.cleanData(getAll(elem, false));
  41995. // Remove any remaining nodes
  41996. elem.textContent = "";
  41997. }
  41998. }
  41999. return this;
  42000. },
  42001. clone: function clone(dataAndEvents, deepDataAndEvents) {
  42002. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  42003. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  42004. return this.map(function () {
  42005. return jQuery.clone(this, dataAndEvents, deepDataAndEvents);
  42006. });
  42007. },
  42008. html: function html(value) {
  42009. return access(this, function (value) {
  42010. var elem = this[0] || {},
  42011. i = 0,
  42012. l = this.length;
  42013. if (value === undefined && elem.nodeType === 1) {
  42014. return elem.innerHTML;
  42015. }
  42016. // See if we can take a shortcut and just use innerHTML
  42017. if (typeof value === "string" && !rnoInnerhtml.test(value) && !wrapMap[(rtagName.exec(value) || ["", ""])[1].toLowerCase()]) {
  42018. value = jQuery.htmlPrefilter(value);
  42019. try {
  42020. for (; i < l; i++) {
  42021. elem = this[i] || {};
  42022. // Remove element nodes and prevent memory leaks
  42023. if (elem.nodeType === 1) {
  42024. jQuery.cleanData(getAll(elem, false));
  42025. elem.innerHTML = value;
  42026. }
  42027. }
  42028. elem = 0;
  42029. // If using innerHTML throws an exception, use the fallback method
  42030. } catch (e) {}
  42031. }
  42032. if (elem) {
  42033. this.empty().append(value);
  42034. }
  42035. }, null, value, arguments.length);
  42036. },
  42037. replaceWith: function replaceWith() {
  42038. var ignored = [];
  42039. // Make the changes, replacing each non-ignored context element with the new content
  42040. return domManip(this, arguments, function (elem) {
  42041. var parent = this.parentNode;
  42042. if (jQuery.inArray(this, ignored) < 0) {
  42043. jQuery.cleanData(getAll(this));
  42044. if (parent) {
  42045. parent.replaceChild(elem, this);
  42046. }
  42047. }
  42048. // Force callback invocation
  42049. }, ignored);
  42050. }
  42051. });
  42052. jQuery.each({
  42053. appendTo: "append",
  42054. prependTo: "prepend",
  42055. insertBefore: "before",
  42056. insertAfter: "after",
  42057. replaceAll: "replaceWith"
  42058. }, function (name, original) {
  42059. jQuery.fn[name] = function (selector) {
  42060. var elems,
  42061. ret = [],
  42062. insert = jQuery(selector),
  42063. last = insert.length - 1,
  42064. i = 0;
  42065. for (; i <= last; i++) {
  42066. elems = i === last ? this : this.clone(true);
  42067. jQuery(insert[i])[original](elems);
  42068. // Support: Android <=4.0 only, PhantomJS 1 only
  42069. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  42070. push.apply(ret, elems.get());
  42071. }
  42072. return this.pushStack(ret);
  42073. };
  42074. });
  42075. var rnumnonpx = new RegExp("^(" + pnum + ")(?!px)[a-z%]+$", "i");
  42076. var getStyles = function getStyles(elem) {
  42077. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  42078. // IE throws on elements created in popups
  42079. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  42080. var view = elem.ownerDocument.defaultView;
  42081. if (!view || !view.opener) {
  42082. view = window;
  42083. }
  42084. return view.getComputedStyle(elem);
  42085. };
  42086. var rboxStyle = new RegExp(cssExpand.join("|"), "i");
  42087. (function () {
  42088. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  42089. // so they're executed at the same time to save the second computation.
  42090. function computeStyleTests() {
  42091. // This is a singleton, we need to execute it only once
  42092. if (!div) {
  42093. return;
  42094. }
  42095. container.style.cssText = "position:absolute;left:-11111px;width:60px;" + "margin-top:1px;padding:0;border:0";
  42096. div.style.cssText = "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + "margin:auto;border:1px;padding:1px;" + "width:60%;top:1%";
  42097. documentElement.appendChild(container).appendChild(div);
  42098. var divStyle = window.getComputedStyle(div);
  42099. pixelPositionVal = divStyle.top !== "1%";
  42100. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  42101. reliableMarginLeftVal = roundPixelMeasures(divStyle.marginLeft) === 12;
  42102. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  42103. // Some styles come back with percentage values, even though they shouldn't
  42104. div.style.right = "60%";
  42105. pixelBoxStylesVal = roundPixelMeasures(divStyle.right) === 36;
  42106. // Support: IE 9 - 11 only
  42107. // Detect misreporting of content dimensions for box-sizing:border-box elements
  42108. boxSizingReliableVal = roundPixelMeasures(divStyle.width) === 36;
  42109. // Support: IE 9 only
  42110. // Detect overflow:scroll screwiness (gh-3699)
  42111. div.style.position = "absolute";
  42112. scrollboxSizeVal = div.offsetWidth === 36 || "absolute";
  42113. documentElement.removeChild(container);
  42114. // Nullify the div so it wouldn't be stored in the memory and
  42115. // it will also be a sign that checks already performed
  42116. div = null;
  42117. }
  42118. function roundPixelMeasures(measure) {
  42119. return Math.round(parseFloat(measure));
  42120. }
  42121. var pixelPositionVal,
  42122. boxSizingReliableVal,
  42123. scrollboxSizeVal,
  42124. pixelBoxStylesVal,
  42125. reliableMarginLeftVal,
  42126. container = document.createElement("div"),
  42127. div = document.createElement("div");
  42128. // Finish early in limited (non-browser) environments
  42129. if (!div.style) {
  42130. return;
  42131. }
  42132. // Support: IE <=9 - 11 only
  42133. // Style of cloned element affects source element cloned (#8908)
  42134. div.style.backgroundClip = "content-box";
  42135. div.cloneNode(true).style.backgroundClip = "";
  42136. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  42137. jQuery.extend(support, {
  42138. boxSizingReliable: function boxSizingReliable() {
  42139. computeStyleTests();
  42140. return boxSizingReliableVal;
  42141. },
  42142. pixelBoxStyles: function pixelBoxStyles() {
  42143. computeStyleTests();
  42144. return pixelBoxStylesVal;
  42145. },
  42146. pixelPosition: function pixelPosition() {
  42147. computeStyleTests();
  42148. return pixelPositionVal;
  42149. },
  42150. reliableMarginLeft: function reliableMarginLeft() {
  42151. computeStyleTests();
  42152. return reliableMarginLeftVal;
  42153. },
  42154. scrollboxSize: function scrollboxSize() {
  42155. computeStyleTests();
  42156. return scrollboxSizeVal;
  42157. }
  42158. });
  42159. })();
  42160. function curCSS(elem, name, computed) {
  42161. var width,
  42162. minWidth,
  42163. maxWidth,
  42164. ret,
  42165. // Support: Firefox 51+
  42166. // Retrieving style before computed somehow
  42167. // fixes an issue with getting wrong values
  42168. // on detached elements
  42169. style = elem.style;
  42170. computed = computed || getStyles(elem);
  42171. // getPropertyValue is needed for:
  42172. // .css('filter') (IE 9 only, #12537)
  42173. // .css('--customProperty) (#3144)
  42174. if (computed) {
  42175. ret = computed.getPropertyValue(name) || computed[name];
  42176. if (ret === "" && !jQuery.contains(elem.ownerDocument, elem)) {
  42177. ret = jQuery.style(elem, name);
  42178. }
  42179. // A tribute to the "awesome hack by Dean Edwards"
  42180. // Android Browser returns percentage for some values,
  42181. // but width seems to be reliably pixels.
  42182. // This is against the CSSOM draft spec:
  42183. // https://drafts.csswg.org/cssom/#resolved-values
  42184. if (!support.pixelBoxStyles() && rnumnonpx.test(ret) && rboxStyle.test(name)) {
  42185. // Remember the original values
  42186. width = style.width;
  42187. minWidth = style.minWidth;
  42188. maxWidth = style.maxWidth;
  42189. // Put in the new values to get a computed value out
  42190. style.minWidth = style.maxWidth = style.width = ret;
  42191. ret = computed.width;
  42192. // Revert the changed values
  42193. style.width = width;
  42194. style.minWidth = minWidth;
  42195. style.maxWidth = maxWidth;
  42196. }
  42197. }
  42198. return ret !== undefined ?
  42199. // Support: IE <=9 - 11 only
  42200. // IE returns zIndex value as an integer.
  42201. ret + "" : ret;
  42202. }
  42203. function addGetHookIf(conditionFn, hookFn) {
  42204. // Define the hook, we'll check on the first run if it's really needed.
  42205. return {
  42206. get: function get() {
  42207. if (conditionFn()) {
  42208. // Hook not needed (or it's not possible to use it due
  42209. // to missing dependency), remove it.
  42210. delete this.get;
  42211. return;
  42212. }
  42213. // Hook needed; redefine it so that the support test is not executed again.
  42214. return (this.get = hookFn).apply(this, arguments);
  42215. }
  42216. };
  42217. }
  42218. var
  42219. // Swappable if display is none or starts with table
  42220. // except "table", "table-cell", or "table-caption"
  42221. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  42222. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  42223. rcustomProp = /^--/,
  42224. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  42225. cssNormalTransform = {
  42226. letterSpacing: "0",
  42227. fontWeight: "400"
  42228. },
  42229. cssPrefixes = ["Webkit", "Moz", "ms"],
  42230. emptyStyle = document.createElement("div").style;
  42231. // Return a css property mapped to a potentially vendor prefixed property
  42232. function vendorPropName(name) {
  42233. // Shortcut for names that are not vendor prefixed
  42234. if (name in emptyStyle) {
  42235. return name;
  42236. }
  42237. // Check for vendor prefixed names
  42238. var capName = name[0].toUpperCase() + name.slice(1),
  42239. i = cssPrefixes.length;
  42240. while (i--) {
  42241. name = cssPrefixes[i] + capName;
  42242. if (name in emptyStyle) {
  42243. return name;
  42244. }
  42245. }
  42246. }
  42247. // Return a property mapped along what jQuery.cssProps suggests or to
  42248. // a vendor prefixed property.
  42249. function finalPropName(name) {
  42250. var ret = jQuery.cssProps[name];
  42251. if (!ret) {
  42252. ret = jQuery.cssProps[name] = vendorPropName(name) || name;
  42253. }
  42254. return ret;
  42255. }
  42256. function setPositiveNumber(elem, value, subtract) {
  42257. // Any relative (+/-) values have already been
  42258. // normalized at this point
  42259. var matches = rcssNum.exec(value);
  42260. return matches ?
  42261. // Guard against undefined "subtract", e.g., when used as in cssHooks
  42262. Math.max(0, matches[2] - (subtract || 0)) + (matches[3] || "px") : value;
  42263. }
  42264. function boxModelAdjustment(elem, dimension, box, isBorderBox, styles, computedVal) {
  42265. var i = dimension === "width" ? 1 : 0,
  42266. extra = 0,
  42267. delta = 0;
  42268. // Adjustment may not be necessary
  42269. if (box === (isBorderBox ? "border" : "content")) {
  42270. return 0;
  42271. }
  42272. for (; i < 4; i += 2) {
  42273. // Both box models exclude margin
  42274. if (box === "margin") {
  42275. delta += jQuery.css(elem, box + cssExpand[i], true, styles);
  42276. }
  42277. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  42278. if (!isBorderBox) {
  42279. // Add padding
  42280. delta += jQuery.css(elem, "padding" + cssExpand[i], true, styles);
  42281. // For "border" or "margin", add border
  42282. if (box !== "padding") {
  42283. delta += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
  42284. // But still keep track of it otherwise
  42285. } else {
  42286. extra += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
  42287. }
  42288. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  42289. // "padding" or "margin"
  42290. } else {
  42291. // For "content", subtract padding
  42292. if (box === "content") {
  42293. delta -= jQuery.css(elem, "padding" + cssExpand[i], true, styles);
  42294. }
  42295. // For "content" or "padding", subtract border
  42296. if (box !== "margin") {
  42297. delta -= jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
  42298. }
  42299. }
  42300. }
  42301. // Account for positive content-box scroll gutter when requested by providing computedVal
  42302. if (!isBorderBox && computedVal >= 0) {
  42303. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  42304. // Assuming integer scroll gutter, subtract the rest and round down
  42305. delta += Math.max(0, Math.ceil(elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] - computedVal - delta - extra - 0.5));
  42306. }
  42307. return delta;
  42308. }
  42309. function getWidthOrHeight(elem, dimension, extra) {
  42310. // Start with computed style
  42311. var styles = getStyles(elem),
  42312. val = curCSS(elem, dimension, styles),
  42313. isBorderBox = jQuery.css(elem, "boxSizing", false, styles) === "border-box",
  42314. valueIsBorderBox = isBorderBox;
  42315. // Support: Firefox <=54
  42316. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  42317. if (rnumnonpx.test(val)) {
  42318. if (!extra) {
  42319. return val;
  42320. }
  42321. val = "auto";
  42322. }
  42323. // Check for style in case a browser which returns unreliable values
  42324. // for getComputedStyle silently falls back to the reliable elem.style
  42325. valueIsBorderBox = valueIsBorderBox && (support.boxSizingReliable() || val === elem.style[dimension]);
  42326. // Fall back to offsetWidth/offsetHeight when value is "auto"
  42327. // This happens for inline elements with no explicit setting (gh-3571)
  42328. // Support: Android <=4.1 - 4.3 only
  42329. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  42330. if (val === "auto" || !parseFloat(val) && jQuery.css(elem, "display", false, styles) === "inline") {
  42331. val = elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)];
  42332. // offsetWidth/offsetHeight provide border-box values
  42333. valueIsBorderBox = true;
  42334. }
  42335. // Normalize "" and auto
  42336. val = parseFloat(val) || 0;
  42337. // Adjust for the element's box model
  42338. return val + boxModelAdjustment(elem, dimension, extra || (isBorderBox ? "border" : "content"), valueIsBorderBox, styles,
  42339. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  42340. val) + "px";
  42341. }
  42342. jQuery.extend({
  42343. // Add in style property hooks for overriding the default
  42344. // behavior of getting and setting a style property
  42345. cssHooks: {
  42346. opacity: {
  42347. get: function get(elem, computed) {
  42348. if (computed) {
  42349. // We should always get a number back from opacity
  42350. var ret = curCSS(elem, "opacity");
  42351. return ret === "" ? "1" : ret;
  42352. }
  42353. }
  42354. }
  42355. },
  42356. // Don't automatically add "px" to these possibly-unitless properties
  42357. cssNumber: {
  42358. "animationIterationCount": true,
  42359. "columnCount": true,
  42360. "fillOpacity": true,
  42361. "flexGrow": true,
  42362. "flexShrink": true,
  42363. "fontWeight": true,
  42364. "lineHeight": true,
  42365. "opacity": true,
  42366. "order": true,
  42367. "orphans": true,
  42368. "widows": true,
  42369. "zIndex": true,
  42370. "zoom": true
  42371. },
  42372. // Add in properties whose names you wish to fix before
  42373. // setting or getting the value
  42374. cssProps: {},
  42375. // Get and set the style property on a DOM Node
  42376. style: function style(elem, name, value, extra) {
  42377. // Don't set styles on text and comment nodes
  42378. if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) {
  42379. return;
  42380. }
  42381. // Make sure that we're working with the right name
  42382. var ret,
  42383. type,
  42384. hooks,
  42385. origName = camelCase(name),
  42386. isCustomProp = rcustomProp.test(name),
  42387. style = elem.style;
  42388. // Make sure that we're working with the right name. We don't
  42389. // want to query the value if it is a CSS custom property
  42390. // since they are user-defined.
  42391. if (!isCustomProp) {
  42392. name = finalPropName(origName);
  42393. }
  42394. // Gets hook for the prefixed version, then unprefixed version
  42395. hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
  42396. // Check if we're setting a value
  42397. if (value !== undefined) {
  42398. type = typeof value === "undefined" ? "undefined" : _typeof(value);
  42399. // Convert "+=" or "-=" to relative numbers (#7345)
  42400. if (type === "string" && (ret = rcssNum.exec(value)) && ret[1]) {
  42401. value = adjustCSS(elem, name, ret);
  42402. // Fixes bug #9237
  42403. type = "number";
  42404. }
  42405. // Make sure that null and NaN values aren't set (#7116)
  42406. if (value == null || value !== value) {
  42407. return;
  42408. }
  42409. // If a number was passed in, add the unit (except for certain CSS properties)
  42410. if (type === "number") {
  42411. value += ret && ret[3] || (jQuery.cssNumber[origName] ? "" : "px");
  42412. }
  42413. // background-* props affect original clone's values
  42414. if (!support.clearCloneStyle && value === "" && name.indexOf("background") === 0) {
  42415. style[name] = "inherit";
  42416. }
  42417. // If a hook was provided, use that value, otherwise just set the specified value
  42418. if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value, extra)) !== undefined) {
  42419. if (isCustomProp) {
  42420. style.setProperty(name, value);
  42421. } else {
  42422. style[name] = value;
  42423. }
  42424. }
  42425. } else {
  42426. // If a hook was provided get the non-computed value from there
  42427. if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== undefined) {
  42428. return ret;
  42429. }
  42430. // Otherwise just get the value from the style object
  42431. return style[name];
  42432. }
  42433. },
  42434. css: function css(elem, name, extra, styles) {
  42435. var val,
  42436. num,
  42437. hooks,
  42438. origName = camelCase(name),
  42439. isCustomProp = rcustomProp.test(name);
  42440. // Make sure that we're working with the right name. We don't
  42441. // want to modify the value if it is a CSS custom property
  42442. // since they are user-defined.
  42443. if (!isCustomProp) {
  42444. name = finalPropName(origName);
  42445. }
  42446. // Try prefixed name followed by the unprefixed name
  42447. hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
  42448. // If a hook was provided get the computed value from there
  42449. if (hooks && "get" in hooks) {
  42450. val = hooks.get(elem, true, extra);
  42451. }
  42452. // Otherwise, if a way to get the computed value exists, use that
  42453. if (val === undefined) {
  42454. val = curCSS(elem, name, styles);
  42455. }
  42456. // Convert "normal" to computed value
  42457. if (val === "normal" && name in cssNormalTransform) {
  42458. val = cssNormalTransform[name];
  42459. }
  42460. // Make numeric if forced or a qualifier was provided and val looks numeric
  42461. if (extra === "" || extra) {
  42462. num = parseFloat(val);
  42463. return extra === true || isFinite(num) ? num || 0 : val;
  42464. }
  42465. return val;
  42466. }
  42467. });
  42468. jQuery.each(["height", "width"], function (i, dimension) {
  42469. jQuery.cssHooks[dimension] = {
  42470. get: function get(elem, computed, extra) {
  42471. if (computed) {
  42472. // Certain elements can have dimension info if we invisibly show them
  42473. // but it must have a current display style that would benefit
  42474. return rdisplayswap.test(jQuery.css(elem, "display")) && (
  42475. // Support: Safari 8+
  42476. // Table columns in Safari have non-zero offsetWidth & zero
  42477. // getBoundingClientRect().width unless display is changed.
  42478. // Support: IE <=11 only
  42479. // Running getBoundingClientRect on a disconnected node
  42480. // in IE throws an error.
  42481. !elem.getClientRects().length || !elem.getBoundingClientRect().width) ? swap(elem, cssShow, function () {
  42482. return getWidthOrHeight(elem, dimension, extra);
  42483. }) : getWidthOrHeight(elem, dimension, extra);
  42484. }
  42485. },
  42486. set: function set(elem, value, extra) {
  42487. var matches,
  42488. styles = getStyles(elem),
  42489. isBorderBox = jQuery.css(elem, "boxSizing", false, styles) === "border-box",
  42490. subtract = extra && boxModelAdjustment(elem, dimension, extra, isBorderBox, styles);
  42491. // Account for unreliable border-box dimensions by comparing offset* to computed and
  42492. // faking a content-box to get border and padding (gh-3699)
  42493. if (isBorderBox && support.scrollboxSize() === styles.position) {
  42494. subtract -= Math.ceil(elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] - parseFloat(styles[dimension]) - boxModelAdjustment(elem, dimension, "border", false, styles) - 0.5);
  42495. }
  42496. // Convert to pixels if value adjustment is needed
  42497. if (subtract && (matches = rcssNum.exec(value)) && (matches[3] || "px") !== "px") {
  42498. elem.style[dimension] = value;
  42499. value = jQuery.css(elem, dimension);
  42500. }
  42501. return setPositiveNumber(elem, value, subtract);
  42502. }
  42503. };
  42504. });
  42505. jQuery.cssHooks.marginLeft = addGetHookIf(support.reliableMarginLeft, function (elem, computed) {
  42506. if (computed) {
  42507. return (parseFloat(curCSS(elem, "marginLeft")) || elem.getBoundingClientRect().left - swap(elem, { marginLeft: 0 }, function () {
  42508. return elem.getBoundingClientRect().left;
  42509. })) + "px";
  42510. }
  42511. });
  42512. // These hooks are used by animate to expand properties
  42513. jQuery.each({
  42514. margin: "",
  42515. padding: "",
  42516. border: "Width"
  42517. }, function (prefix, suffix) {
  42518. jQuery.cssHooks[prefix + suffix] = {
  42519. expand: function expand(value) {
  42520. var i = 0,
  42521. expanded = {},
  42522. // Assumes a single number if not a string
  42523. parts = typeof value === "string" ? value.split(" ") : [value];
  42524. for (; i < 4; i++) {
  42525. expanded[prefix + cssExpand[i] + suffix] = parts[i] || parts[i - 2] || parts[0];
  42526. }
  42527. return expanded;
  42528. }
  42529. };
  42530. if (prefix !== "margin") {
  42531. jQuery.cssHooks[prefix + suffix].set = setPositiveNumber;
  42532. }
  42533. });
  42534. jQuery.fn.extend({
  42535. css: function css(name, value) {
  42536. return access(this, function (elem, name, value) {
  42537. var styles,
  42538. len,
  42539. map = {},
  42540. i = 0;
  42541. if (Array.isArray(name)) {
  42542. styles = getStyles(elem);
  42543. len = name.length;
  42544. for (; i < len; i++) {
  42545. map[name[i]] = jQuery.css(elem, name[i], false, styles);
  42546. }
  42547. return map;
  42548. }
  42549. return value !== undefined ? jQuery.style(elem, name, value) : jQuery.css(elem, name);
  42550. }, name, value, arguments.length > 1);
  42551. }
  42552. });
  42553. function Tween(elem, options, prop, end, easing) {
  42554. return new Tween.prototype.init(elem, options, prop, end, easing);
  42555. }
  42556. jQuery.Tween = Tween;
  42557. Tween.prototype = {
  42558. constructor: Tween,
  42559. init: function init(elem, options, prop, end, easing, unit) {
  42560. this.elem = elem;
  42561. this.prop = prop;
  42562. this.easing = easing || jQuery.easing._default;
  42563. this.options = options;
  42564. this.start = this.now = this.cur();
  42565. this.end = end;
  42566. this.unit = unit || (jQuery.cssNumber[prop] ? "" : "px");
  42567. },
  42568. cur: function cur() {
  42569. var hooks = Tween.propHooks[this.prop];
  42570. return hooks && hooks.get ? hooks.get(this) : Tween.propHooks._default.get(this);
  42571. },
  42572. run: function run(percent) {
  42573. var eased,
  42574. hooks = Tween.propHooks[this.prop];
  42575. if (this.options.duration) {
  42576. this.pos = eased = jQuery.easing[this.easing](percent, this.options.duration * percent, 0, 1, this.options.duration);
  42577. } else {
  42578. this.pos = eased = percent;
  42579. }
  42580. this.now = (this.end - this.start) * eased + this.start;
  42581. if (this.options.step) {
  42582. this.options.step.call(this.elem, this.now, this);
  42583. }
  42584. if (hooks && hooks.set) {
  42585. hooks.set(this);
  42586. } else {
  42587. Tween.propHooks._default.set(this);
  42588. }
  42589. return this;
  42590. }
  42591. };
  42592. Tween.prototype.init.prototype = Tween.prototype;
  42593. Tween.propHooks = {
  42594. _default: {
  42595. get: function get(tween) {
  42596. var result;
  42597. // Use a property on the element directly when it is not a DOM element,
  42598. // or when there is no matching style property that exists.
  42599. if (tween.elem.nodeType !== 1 || tween.elem[tween.prop] != null && tween.elem.style[tween.prop] == null) {
  42600. return tween.elem[tween.prop];
  42601. }
  42602. // Passing an empty string as a 3rd parameter to .css will automatically
  42603. // attempt a parseFloat and fallback to a string if the parse fails.
  42604. // Simple values such as "10px" are parsed to Float;
  42605. // complex values such as "rotate(1rad)" are returned as-is.
  42606. result = jQuery.css(tween.elem, tween.prop, "");
  42607. // Empty strings, null, undefined and "auto" are converted to 0.
  42608. return !result || result === "auto" ? 0 : result;
  42609. },
  42610. set: function set(tween) {
  42611. // Use step hook for back compat.
  42612. // Use cssHook if its there.
  42613. // Use .style if available and use plain properties where available.
  42614. if (jQuery.fx.step[tween.prop]) {
  42615. jQuery.fx.step[tween.prop](tween);
  42616. } else if (tween.elem.nodeType === 1 && (tween.elem.style[jQuery.cssProps[tween.prop]] != null || jQuery.cssHooks[tween.prop])) {
  42617. jQuery.style(tween.elem, tween.prop, tween.now + tween.unit);
  42618. } else {
  42619. tween.elem[tween.prop] = tween.now;
  42620. }
  42621. }
  42622. }
  42623. };
  42624. // Support: IE <=9 only
  42625. // Panic based approach to setting things on disconnected nodes
  42626. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  42627. set: function set(tween) {
  42628. if (tween.elem.nodeType && tween.elem.parentNode) {
  42629. tween.elem[tween.prop] = tween.now;
  42630. }
  42631. }
  42632. };
  42633. jQuery.easing = {
  42634. linear: function linear(p) {
  42635. return p;
  42636. },
  42637. swing: function swing(p) {
  42638. return 0.5 - Math.cos(p * Math.PI) / 2;
  42639. },
  42640. _default: "swing"
  42641. };
  42642. jQuery.fx = Tween.prototype.init;
  42643. // Back compat <1.8 extension point
  42644. jQuery.fx.step = {};
  42645. var fxNow,
  42646. inProgress,
  42647. rfxtypes = /^(?:toggle|show|hide)$/,
  42648. rrun = /queueHooks$/;
  42649. function schedule() {
  42650. if (inProgress) {
  42651. if (document.hidden === false && window.requestAnimationFrame) {
  42652. window.requestAnimationFrame(schedule);
  42653. } else {
  42654. window.setTimeout(schedule, jQuery.fx.interval);
  42655. }
  42656. jQuery.fx.tick();
  42657. }
  42658. }
  42659. // Animations created synchronously will run synchronously
  42660. function createFxNow() {
  42661. window.setTimeout(function () {
  42662. fxNow = undefined;
  42663. });
  42664. return fxNow = Date.now();
  42665. }
  42666. // Generate parameters to create a standard animation
  42667. function genFx(type, includeWidth) {
  42668. var which,
  42669. i = 0,
  42670. attrs = { height: type };
  42671. // If we include width, step value is 1 to do all cssExpand values,
  42672. // otherwise step value is 2 to skip over Left and Right
  42673. includeWidth = includeWidth ? 1 : 0;
  42674. for (; i < 4; i += 2 - includeWidth) {
  42675. which = cssExpand[i];
  42676. attrs["margin" + which] = attrs["padding" + which] = type;
  42677. }
  42678. if (includeWidth) {
  42679. attrs.opacity = attrs.width = type;
  42680. }
  42681. return attrs;
  42682. }
  42683. function createTween(value, prop, animation) {
  42684. var tween,
  42685. collection = (Animation.tweeners[prop] || []).concat(Animation.tweeners["*"]),
  42686. index = 0,
  42687. length = collection.length;
  42688. for (; index < length; index++) {
  42689. if (tween = collection[index].call(animation, prop, value)) {
  42690. // We're done with this property
  42691. return tween;
  42692. }
  42693. }
  42694. }
  42695. function defaultPrefilter(elem, props, opts) {
  42696. var prop,
  42697. value,
  42698. toggle,
  42699. hooks,
  42700. oldfire,
  42701. propTween,
  42702. restoreDisplay,
  42703. display,
  42704. isBox = "width" in props || "height" in props,
  42705. anim = this,
  42706. orig = {},
  42707. style = elem.style,
  42708. hidden = elem.nodeType && isHiddenWithinTree(elem),
  42709. dataShow = dataPriv.get(elem, "fxshow");
  42710. // Queue-skipping animations hijack the fx hooks
  42711. if (!opts.queue) {
  42712. hooks = jQuery._queueHooks(elem, "fx");
  42713. if (hooks.unqueued == null) {
  42714. hooks.unqueued = 0;
  42715. oldfire = hooks.empty.fire;
  42716. hooks.empty.fire = function () {
  42717. if (!hooks.unqueued) {
  42718. oldfire();
  42719. }
  42720. };
  42721. }
  42722. hooks.unqueued++;
  42723. anim.always(function () {
  42724. // Ensure the complete handler is called before this completes
  42725. anim.always(function () {
  42726. hooks.unqueued--;
  42727. if (!jQuery.queue(elem, "fx").length) {
  42728. hooks.empty.fire();
  42729. }
  42730. });
  42731. });
  42732. }
  42733. // Detect show/hide animations
  42734. for (prop in props) {
  42735. value = props[prop];
  42736. if (rfxtypes.test(value)) {
  42737. delete props[prop];
  42738. toggle = toggle || value === "toggle";
  42739. if (value === (hidden ? "hide" : "show")) {
  42740. // Pretend to be hidden if this is a "show" and
  42741. // there is still data from a stopped show/hide
  42742. if (value === "show" && dataShow && dataShow[prop] !== undefined) {
  42743. hidden = true;
  42744. // Ignore all other no-op show/hide data
  42745. } else {
  42746. continue;
  42747. }
  42748. }
  42749. orig[prop] = dataShow && dataShow[prop] || jQuery.style(elem, prop);
  42750. }
  42751. }
  42752. // Bail out if this is a no-op like .hide().hide()
  42753. propTween = !jQuery.isEmptyObject(props);
  42754. if (!propTween && jQuery.isEmptyObject(orig)) {
  42755. return;
  42756. }
  42757. // Restrict "overflow" and "display" styles during box animations
  42758. if (isBox && elem.nodeType === 1) {
  42759. // Support: IE <=9 - 11, Edge 12 - 15
  42760. // Record all 3 overflow attributes because IE does not infer the shorthand
  42761. // from identically-valued overflowX and overflowY and Edge just mirrors
  42762. // the overflowX value there.
  42763. opts.overflow = [style.overflow, style.overflowX, style.overflowY];
  42764. // Identify a display type, preferring old show/hide data over the CSS cascade
  42765. restoreDisplay = dataShow && dataShow.display;
  42766. if (restoreDisplay == null) {
  42767. restoreDisplay = dataPriv.get(elem, "display");
  42768. }
  42769. display = jQuery.css(elem, "display");
  42770. if (display === "none") {
  42771. if (restoreDisplay) {
  42772. display = restoreDisplay;
  42773. } else {
  42774. // Get nonempty value(s) by temporarily forcing visibility
  42775. showHide([elem], true);
  42776. restoreDisplay = elem.style.display || restoreDisplay;
  42777. display = jQuery.css(elem, "display");
  42778. showHide([elem]);
  42779. }
  42780. }
  42781. // Animate inline elements as inline-block
  42782. if (display === "inline" || display === "inline-block" && restoreDisplay != null) {
  42783. if (jQuery.css(elem, "float") === "none") {
  42784. // Restore the original display value at the end of pure show/hide animations
  42785. if (!propTween) {
  42786. anim.done(function () {
  42787. style.display = restoreDisplay;
  42788. });
  42789. if (restoreDisplay == null) {
  42790. display = style.display;
  42791. restoreDisplay = display === "none" ? "" : display;
  42792. }
  42793. }
  42794. style.display = "inline-block";
  42795. }
  42796. }
  42797. }
  42798. if (opts.overflow) {
  42799. style.overflow = "hidden";
  42800. anim.always(function () {
  42801. style.overflow = opts.overflow[0];
  42802. style.overflowX = opts.overflow[1];
  42803. style.overflowY = opts.overflow[2];
  42804. });
  42805. }
  42806. // Implement show/hide animations
  42807. propTween = false;
  42808. for (prop in orig) {
  42809. // General show/hide setup for this element animation
  42810. if (!propTween) {
  42811. if (dataShow) {
  42812. if ("hidden" in dataShow) {
  42813. hidden = dataShow.hidden;
  42814. }
  42815. } else {
  42816. dataShow = dataPriv.access(elem, "fxshow", { display: restoreDisplay });
  42817. }
  42818. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  42819. if (toggle) {
  42820. dataShow.hidden = !hidden;
  42821. }
  42822. // Show elements before animating them
  42823. if (hidden) {
  42824. showHide([elem], true);
  42825. }
  42826. /* eslint-disable no-loop-func */
  42827. anim.done(function () {
  42828. /* eslint-enable no-loop-func */
  42829. // The final step of a "hide" animation is actually hiding the element
  42830. if (!hidden) {
  42831. showHide([elem]);
  42832. }
  42833. dataPriv.remove(elem, "fxshow");
  42834. for (prop in orig) {
  42835. jQuery.style(elem, prop, orig[prop]);
  42836. }
  42837. });
  42838. }
  42839. // Per-property setup
  42840. propTween = createTween(hidden ? dataShow[prop] : 0, prop, anim);
  42841. if (!(prop in dataShow)) {
  42842. dataShow[prop] = propTween.start;
  42843. if (hidden) {
  42844. propTween.end = propTween.start;
  42845. propTween.start = 0;
  42846. }
  42847. }
  42848. }
  42849. }
  42850. function propFilter(props, specialEasing) {
  42851. var index, name, easing, value, hooks;
  42852. // camelCase, specialEasing and expand cssHook pass
  42853. for (index in props) {
  42854. name = camelCase(index);
  42855. easing = specialEasing[name];
  42856. value = props[index];
  42857. if (Array.isArray(value)) {
  42858. easing = value[1];
  42859. value = props[index] = value[0];
  42860. }
  42861. if (index !== name) {
  42862. props[name] = value;
  42863. delete props[index];
  42864. }
  42865. hooks = jQuery.cssHooks[name];
  42866. if (hooks && "expand" in hooks) {
  42867. value = hooks.expand(value);
  42868. delete props[name];
  42869. // Not quite $.extend, this won't overwrite existing keys.
  42870. // Reusing 'index' because we have the correct "name"
  42871. for (index in value) {
  42872. if (!(index in props)) {
  42873. props[index] = value[index];
  42874. specialEasing[index] = easing;
  42875. }
  42876. }
  42877. } else {
  42878. specialEasing[name] = easing;
  42879. }
  42880. }
  42881. }
  42882. function Animation(elem, properties, options) {
  42883. var result,
  42884. stopped,
  42885. index = 0,
  42886. length = Animation.prefilters.length,
  42887. deferred = jQuery.Deferred().always(function () {
  42888. // Don't match elem in the :animated selector
  42889. delete tick.elem;
  42890. }),
  42891. tick = function tick() {
  42892. if (stopped) {
  42893. return false;
  42894. }
  42895. var currentTime = fxNow || createFxNow(),
  42896. remaining = Math.max(0, animation.startTime + animation.duration - currentTime),
  42897. // Support: Android 2.3 only
  42898. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  42899. temp = remaining / animation.duration || 0,
  42900. percent = 1 - temp,
  42901. index = 0,
  42902. length = animation.tweens.length;
  42903. for (; index < length; index++) {
  42904. animation.tweens[index].run(percent);
  42905. }
  42906. deferred.notifyWith(elem, [animation, percent, remaining]);
  42907. // If there's more to do, yield
  42908. if (percent < 1 && length) {
  42909. return remaining;
  42910. }
  42911. // If this was an empty animation, synthesize a final progress notification
  42912. if (!length) {
  42913. deferred.notifyWith(elem, [animation, 1, 0]);
  42914. }
  42915. // Resolve the animation and report its conclusion
  42916. deferred.resolveWith(elem, [animation]);
  42917. return false;
  42918. },
  42919. animation = deferred.promise({
  42920. elem: elem,
  42921. props: jQuery.extend({}, properties),
  42922. opts: jQuery.extend(true, {
  42923. specialEasing: {},
  42924. easing: jQuery.easing._default
  42925. }, options),
  42926. originalProperties: properties,
  42927. originalOptions: options,
  42928. startTime: fxNow || createFxNow(),
  42929. duration: options.duration,
  42930. tweens: [],
  42931. createTween: function createTween(prop, end) {
  42932. var tween = jQuery.Tween(elem, animation.opts, prop, end, animation.opts.specialEasing[prop] || animation.opts.easing);
  42933. animation.tweens.push(tween);
  42934. return tween;
  42935. },
  42936. stop: function stop(gotoEnd) {
  42937. var index = 0,
  42938. // If we are going to the end, we want to run all the tweens
  42939. // otherwise we skip this part
  42940. length = gotoEnd ? animation.tweens.length : 0;
  42941. if (stopped) {
  42942. return this;
  42943. }
  42944. stopped = true;
  42945. for (; index < length; index++) {
  42946. animation.tweens[index].run(1);
  42947. }
  42948. // Resolve when we played the last frame; otherwise, reject
  42949. if (gotoEnd) {
  42950. deferred.notifyWith(elem, [animation, 1, 0]);
  42951. deferred.resolveWith(elem, [animation, gotoEnd]);
  42952. } else {
  42953. deferred.rejectWith(elem, [animation, gotoEnd]);
  42954. }
  42955. return this;
  42956. }
  42957. }),
  42958. props = animation.props;
  42959. propFilter(props, animation.opts.specialEasing);
  42960. for (; index < length; index++) {
  42961. result = Animation.prefilters[index].call(animation, elem, props, animation.opts);
  42962. if (result) {
  42963. if (isFunction(result.stop)) {
  42964. jQuery._queueHooks(animation.elem, animation.opts.queue).stop = result.stop.bind(result);
  42965. }
  42966. return result;
  42967. }
  42968. }
  42969. jQuery.map(props, createTween, animation);
  42970. if (isFunction(animation.opts.start)) {
  42971. animation.opts.start.call(elem, animation);
  42972. }
  42973. // Attach callbacks from options
  42974. animation.progress(animation.opts.progress).done(animation.opts.done, animation.opts.complete).fail(animation.opts.fail).always(animation.opts.always);
  42975. jQuery.fx.timer(jQuery.extend(tick, {
  42976. elem: elem,
  42977. anim: animation,
  42978. queue: animation.opts.queue
  42979. }));
  42980. return animation;
  42981. }
  42982. jQuery.Animation = jQuery.extend(Animation, {
  42983. tweeners: {
  42984. "*": [function (prop, value) {
  42985. var tween = this.createTween(prop, value);
  42986. adjustCSS(tween.elem, prop, rcssNum.exec(value), tween);
  42987. return tween;
  42988. }]
  42989. },
  42990. tweener: function tweener(props, callback) {
  42991. if (isFunction(props)) {
  42992. callback = props;
  42993. props = ["*"];
  42994. } else {
  42995. props = props.match(rnothtmlwhite);
  42996. }
  42997. var prop,
  42998. index = 0,
  42999. length = props.length;
  43000. for (; index < length; index++) {
  43001. prop = props[index];
  43002. Animation.tweeners[prop] = Animation.tweeners[prop] || [];
  43003. Animation.tweeners[prop].unshift(callback);
  43004. }
  43005. },
  43006. prefilters: [defaultPrefilter],
  43007. prefilter: function prefilter(callback, prepend) {
  43008. if (prepend) {
  43009. Animation.prefilters.unshift(callback);
  43010. } else {
  43011. Animation.prefilters.push(callback);
  43012. }
  43013. }
  43014. });
  43015. jQuery.speed = function (speed, easing, fn) {
  43016. var opt = speed && (typeof speed === "undefined" ? "undefined" : _typeof(speed)) === "object" ? jQuery.extend({}, speed) : {
  43017. complete: fn || !fn && easing || isFunction(speed) && speed,
  43018. duration: speed,
  43019. easing: fn && easing || easing && !isFunction(easing) && easing
  43020. };
  43021. // Go to the end state if fx are off
  43022. if (jQuery.fx.off) {
  43023. opt.duration = 0;
  43024. } else {
  43025. if (typeof opt.duration !== "number") {
  43026. if (opt.duration in jQuery.fx.speeds) {
  43027. opt.duration = jQuery.fx.speeds[opt.duration];
  43028. } else {
  43029. opt.duration = jQuery.fx.speeds._default;
  43030. }
  43031. }
  43032. }
  43033. // Normalize opt.queue - true/undefined/null -> "fx"
  43034. if (opt.queue == null || opt.queue === true) {
  43035. opt.queue = "fx";
  43036. }
  43037. // Queueing
  43038. opt.old = opt.complete;
  43039. opt.complete = function () {
  43040. if (isFunction(opt.old)) {
  43041. opt.old.call(this);
  43042. }
  43043. if (opt.queue) {
  43044. jQuery.dequeue(this, opt.queue);
  43045. }
  43046. };
  43047. return opt;
  43048. };
  43049. jQuery.fn.extend({
  43050. fadeTo: function fadeTo(speed, to, easing, callback) {
  43051. // Show any hidden elements after setting opacity to 0
  43052. return this.filter(isHiddenWithinTree).css("opacity", 0).show()
  43053. // Animate to the value specified
  43054. .end().animate({ opacity: to }, speed, easing, callback);
  43055. },
  43056. animate: function animate(prop, speed, easing, callback) {
  43057. var empty = jQuery.isEmptyObject(prop),
  43058. optall = jQuery.speed(speed, easing, callback),
  43059. doAnimation = function doAnimation() {
  43060. // Operate on a copy of prop so per-property easing won't be lost
  43061. var anim = Animation(this, jQuery.extend({}, prop), optall);
  43062. // Empty animations, or finishing resolves immediately
  43063. if (empty || dataPriv.get(this, "finish")) {
  43064. anim.stop(true);
  43065. }
  43066. };
  43067. doAnimation.finish = doAnimation;
  43068. return empty || optall.queue === false ? this.each(doAnimation) : this.queue(optall.queue, doAnimation);
  43069. },
  43070. stop: function stop(type, clearQueue, gotoEnd) {
  43071. var stopQueue = function stopQueue(hooks) {
  43072. var stop = hooks.stop;
  43073. delete hooks.stop;
  43074. stop(gotoEnd);
  43075. };
  43076. if (typeof type !== "string") {
  43077. gotoEnd = clearQueue;
  43078. clearQueue = type;
  43079. type = undefined;
  43080. }
  43081. if (clearQueue && type !== false) {
  43082. this.queue(type || "fx", []);
  43083. }
  43084. return this.each(function () {
  43085. var dequeue = true,
  43086. index = type != null && type + "queueHooks",
  43087. timers = jQuery.timers,
  43088. data = dataPriv.get(this);
  43089. if (index) {
  43090. if (data[index] && data[index].stop) {
  43091. stopQueue(data[index]);
  43092. }
  43093. } else {
  43094. for (index in data) {
  43095. if (data[index] && data[index].stop && rrun.test(index)) {
  43096. stopQueue(data[index]);
  43097. }
  43098. }
  43099. }
  43100. for (index = timers.length; index--;) {
  43101. if (timers[index].elem === this && (type == null || timers[index].queue === type)) {
  43102. timers[index].anim.stop(gotoEnd);
  43103. dequeue = false;
  43104. timers.splice(index, 1);
  43105. }
  43106. }
  43107. // Start the next in the queue if the last step wasn't forced.
  43108. // Timers currently will call their complete callbacks, which
  43109. // will dequeue but only if they were gotoEnd.
  43110. if (dequeue || !gotoEnd) {
  43111. jQuery.dequeue(this, type);
  43112. }
  43113. });
  43114. },
  43115. finish: function finish(type) {
  43116. if (type !== false) {
  43117. type = type || "fx";
  43118. }
  43119. return this.each(function () {
  43120. var index,
  43121. data = dataPriv.get(this),
  43122. queue = data[type + "queue"],
  43123. hooks = data[type + "queueHooks"],
  43124. timers = jQuery.timers,
  43125. length = queue ? queue.length : 0;
  43126. // Enable finishing flag on private data
  43127. data.finish = true;
  43128. // Empty the queue first
  43129. jQuery.queue(this, type, []);
  43130. if (hooks && hooks.stop) {
  43131. hooks.stop.call(this, true);
  43132. }
  43133. // Look for any active animations, and finish them
  43134. for (index = timers.length; index--;) {
  43135. if (timers[index].elem === this && timers[index].queue === type) {
  43136. timers[index].anim.stop(true);
  43137. timers.splice(index, 1);
  43138. }
  43139. }
  43140. // Look for any animations in the old queue and finish them
  43141. for (index = 0; index < length; index++) {
  43142. if (queue[index] && queue[index].finish) {
  43143. queue[index].finish.call(this);
  43144. }
  43145. }
  43146. // Turn off finishing flag
  43147. delete data.finish;
  43148. });
  43149. }
  43150. });
  43151. jQuery.each(["toggle", "show", "hide"], function (i, name) {
  43152. var cssFn = jQuery.fn[name];
  43153. jQuery.fn[name] = function (speed, easing, callback) {
  43154. return speed == null || typeof speed === "boolean" ? cssFn.apply(this, arguments) : this.animate(genFx(name, true), speed, easing, callback);
  43155. };
  43156. });
  43157. // Generate shortcuts for custom animations
  43158. jQuery.each({
  43159. slideDown: genFx("show"),
  43160. slideUp: genFx("hide"),
  43161. slideToggle: genFx("toggle"),
  43162. fadeIn: { opacity: "show" },
  43163. fadeOut: { opacity: "hide" },
  43164. fadeToggle: { opacity: "toggle" }
  43165. }, function (name, props) {
  43166. jQuery.fn[name] = function (speed, easing, callback) {
  43167. return this.animate(props, speed, easing, callback);
  43168. };
  43169. });
  43170. jQuery.timers = [];
  43171. jQuery.fx.tick = function () {
  43172. var timer,
  43173. i = 0,
  43174. timers = jQuery.timers;
  43175. fxNow = Date.now();
  43176. for (; i < timers.length; i++) {
  43177. timer = timers[i];
  43178. // Run the timer and safely remove it when done (allowing for external removal)
  43179. if (!timer() && timers[i] === timer) {
  43180. timers.splice(i--, 1);
  43181. }
  43182. }
  43183. if (!timers.length) {
  43184. jQuery.fx.stop();
  43185. }
  43186. fxNow = undefined;
  43187. };
  43188. jQuery.fx.timer = function (timer) {
  43189. jQuery.timers.push(timer);
  43190. jQuery.fx.start();
  43191. };
  43192. jQuery.fx.interval = 13;
  43193. jQuery.fx.start = function () {
  43194. if (inProgress) {
  43195. return;
  43196. }
  43197. inProgress = true;
  43198. schedule();
  43199. };
  43200. jQuery.fx.stop = function () {
  43201. inProgress = null;
  43202. };
  43203. jQuery.fx.speeds = {
  43204. slow: 600,
  43205. fast: 200,
  43206. // Default speed
  43207. _default: 400
  43208. };
  43209. // Based off of the plugin by Clint Helfers, with permission.
  43210. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  43211. jQuery.fn.delay = function (time, type) {
  43212. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  43213. type = type || "fx";
  43214. return this.queue(type, function (next, hooks) {
  43215. var timeout = window.setTimeout(next, time);
  43216. hooks.stop = function () {
  43217. window.clearTimeout(timeout);
  43218. };
  43219. });
  43220. };
  43221. (function () {
  43222. var input = document.createElement("input"),
  43223. select = document.createElement("select"),
  43224. opt = select.appendChild(document.createElement("option"));
  43225. input.type = "checkbox";
  43226. // Support: Android <=4.3 only
  43227. // Default value for a checkbox should be "on"
  43228. support.checkOn = input.value !== "";
  43229. // Support: IE <=11 only
  43230. // Must access selectedIndex to make default options select
  43231. support.optSelected = opt.selected;
  43232. // Support: IE <=11 only
  43233. // An input loses its value after becoming a radio
  43234. input = document.createElement("input");
  43235. input.value = "t";
  43236. input.type = "radio";
  43237. support.radioValue = input.value === "t";
  43238. })();
  43239. var boolHook,
  43240. attrHandle = jQuery.expr.attrHandle;
  43241. jQuery.fn.extend({
  43242. attr: function attr(name, value) {
  43243. return access(this, jQuery.attr, name, value, arguments.length > 1);
  43244. },
  43245. removeAttr: function removeAttr(name) {
  43246. return this.each(function () {
  43247. jQuery.removeAttr(this, name);
  43248. });
  43249. }
  43250. });
  43251. jQuery.extend({
  43252. attr: function attr(elem, name, value) {
  43253. var ret,
  43254. hooks,
  43255. nType = elem.nodeType;
  43256. // Don't get/set attributes on text, comment and attribute nodes
  43257. if (nType === 3 || nType === 8 || nType === 2) {
  43258. return;
  43259. }
  43260. // Fallback to prop when attributes are not supported
  43261. if (typeof elem.getAttribute === "undefined") {
  43262. return jQuery.prop(elem, name, value);
  43263. }
  43264. // Attribute hooks are determined by the lowercase version
  43265. // Grab necessary hook if one is defined
  43266. if (nType !== 1 || !jQuery.isXMLDoc(elem)) {
  43267. hooks = jQuery.attrHooks[name.toLowerCase()] || (jQuery.expr.match.bool.test(name) ? boolHook : undefined);
  43268. }
  43269. if (value !== undefined) {
  43270. if (value === null) {
  43271. jQuery.removeAttr(elem, name);
  43272. return;
  43273. }
  43274. if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) {
  43275. return ret;
  43276. }
  43277. elem.setAttribute(name, value + "");
  43278. return value;
  43279. }
  43280. if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) {
  43281. return ret;
  43282. }
  43283. ret = jQuery.find.attr(elem, name);
  43284. // Non-existent attributes return null, we normalize to undefined
  43285. return ret == null ? undefined : ret;
  43286. },
  43287. attrHooks: {
  43288. type: {
  43289. set: function set(elem, value) {
  43290. if (!support.radioValue && value === "radio" && nodeName(elem, "input")) {
  43291. var val = elem.value;
  43292. elem.setAttribute("type", value);
  43293. if (val) {
  43294. elem.value = val;
  43295. }
  43296. return value;
  43297. }
  43298. }
  43299. }
  43300. },
  43301. removeAttr: function removeAttr(elem, value) {
  43302. var name,
  43303. i = 0,
  43304. // Attribute names can contain non-HTML whitespace characters
  43305. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  43306. attrNames = value && value.match(rnothtmlwhite);
  43307. if (attrNames && elem.nodeType === 1) {
  43308. while (name = attrNames[i++]) {
  43309. elem.removeAttribute(name);
  43310. }
  43311. }
  43312. }
  43313. });
  43314. // Hooks for boolean attributes
  43315. boolHook = {
  43316. set: function set(elem, value, name) {
  43317. if (value === false) {
  43318. // Remove boolean attributes when set to false
  43319. jQuery.removeAttr(elem, name);
  43320. } else {
  43321. elem.setAttribute(name, name);
  43322. }
  43323. return name;
  43324. }
  43325. };
  43326. jQuery.each(jQuery.expr.match.bool.source.match(/\w+/g), function (i, name) {
  43327. var getter = attrHandle[name] || jQuery.find.attr;
  43328. attrHandle[name] = function (elem, name, isXML) {
  43329. var ret,
  43330. handle,
  43331. lowercaseName = name.toLowerCase();
  43332. if (!isXML) {
  43333. // Avoid an infinite loop by temporarily removing this function from the getter
  43334. handle = attrHandle[lowercaseName];
  43335. attrHandle[lowercaseName] = ret;
  43336. ret = getter(elem, name, isXML) != null ? lowercaseName : null;
  43337. attrHandle[lowercaseName] = handle;
  43338. }
  43339. return ret;
  43340. };
  43341. });
  43342. var rfocusable = /^(?:input|select|textarea|button)$/i,
  43343. rclickable = /^(?:a|area)$/i;
  43344. jQuery.fn.extend({
  43345. prop: function prop(name, value) {
  43346. return access(this, jQuery.prop, name, value, arguments.length > 1);
  43347. },
  43348. removeProp: function removeProp(name) {
  43349. return this.each(function () {
  43350. delete this[jQuery.propFix[name] || name];
  43351. });
  43352. }
  43353. });
  43354. jQuery.extend({
  43355. prop: function prop(elem, name, value) {
  43356. var ret,
  43357. hooks,
  43358. nType = elem.nodeType;
  43359. // Don't get/set properties on text, comment and attribute nodes
  43360. if (nType === 3 || nType === 8 || nType === 2) {
  43361. return;
  43362. }
  43363. if (nType !== 1 || !jQuery.isXMLDoc(elem)) {
  43364. // Fix name and attach hooks
  43365. name = jQuery.propFix[name] || name;
  43366. hooks = jQuery.propHooks[name];
  43367. }
  43368. if (value !== undefined) {
  43369. if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) {
  43370. return ret;
  43371. }
  43372. return elem[name] = value;
  43373. }
  43374. if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) {
  43375. return ret;
  43376. }
  43377. return elem[name];
  43378. },
  43379. propHooks: {
  43380. tabIndex: {
  43381. get: function get(elem) {
  43382. // Support: IE <=9 - 11 only
  43383. // elem.tabIndex doesn't always return the
  43384. // correct value when it hasn't been explicitly set
  43385. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  43386. // Use proper attribute retrieval(#12072)
  43387. var tabindex = jQuery.find.attr(elem, "tabindex");
  43388. if (tabindex) {
  43389. return parseInt(tabindex, 10);
  43390. }
  43391. if (rfocusable.test(elem.nodeName) || rclickable.test(elem.nodeName) && elem.href) {
  43392. return 0;
  43393. }
  43394. return -1;
  43395. }
  43396. }
  43397. },
  43398. propFix: {
  43399. "for": "htmlFor",
  43400. "class": "className"
  43401. }
  43402. });
  43403. // Support: IE <=11 only
  43404. // Accessing the selectedIndex property
  43405. // forces the browser to respect setting selected
  43406. // on the option
  43407. // The getter ensures a default option is selected
  43408. // when in an optgroup
  43409. // eslint rule "no-unused-expressions" is disabled for this code
  43410. // since it considers such accessions noop
  43411. if (!support.optSelected) {
  43412. jQuery.propHooks.selected = {
  43413. get: function get(elem) {
  43414. /* eslint no-unused-expressions: "off" */
  43415. var parent = elem.parentNode;
  43416. if (parent && parent.parentNode) {
  43417. parent.parentNode.selectedIndex;
  43418. }
  43419. return null;
  43420. },
  43421. set: function set(elem) {
  43422. /* eslint no-unused-expressions: "off" */
  43423. var parent = elem.parentNode;
  43424. if (parent) {
  43425. parent.selectedIndex;
  43426. if (parent.parentNode) {
  43427. parent.parentNode.selectedIndex;
  43428. }
  43429. }
  43430. }
  43431. };
  43432. }
  43433. jQuery.each(["tabIndex", "readOnly", "maxLength", "cellSpacing", "cellPadding", "rowSpan", "colSpan", "useMap", "frameBorder", "contentEditable"], function () {
  43434. jQuery.propFix[this.toLowerCase()] = this;
  43435. });
  43436. // Strip and collapse whitespace according to HTML spec
  43437. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  43438. function stripAndCollapse(value) {
  43439. var tokens = value.match(rnothtmlwhite) || [];
  43440. return tokens.join(" ");
  43441. }
  43442. function getClass(elem) {
  43443. return elem.getAttribute && elem.getAttribute("class") || "";
  43444. }
  43445. function classesToArray(value) {
  43446. if (Array.isArray(value)) {
  43447. return value;
  43448. }
  43449. if (typeof value === "string") {
  43450. return value.match(rnothtmlwhite) || [];
  43451. }
  43452. return [];
  43453. }
  43454. jQuery.fn.extend({
  43455. addClass: function addClass(value) {
  43456. var classes,
  43457. elem,
  43458. cur,
  43459. curValue,
  43460. clazz,
  43461. j,
  43462. finalValue,
  43463. i = 0;
  43464. if (isFunction(value)) {
  43465. return this.each(function (j) {
  43466. jQuery(this).addClass(value.call(this, j, getClass(this)));
  43467. });
  43468. }
  43469. classes = classesToArray(value);
  43470. if (classes.length) {
  43471. while (elem = this[i++]) {
  43472. curValue = getClass(elem);
  43473. cur = elem.nodeType === 1 && " " + stripAndCollapse(curValue) + " ";
  43474. if (cur) {
  43475. j = 0;
  43476. while (clazz = classes[j++]) {
  43477. if (cur.indexOf(" " + clazz + " ") < 0) {
  43478. cur += clazz + " ";
  43479. }
  43480. }
  43481. // Only assign if different to avoid unneeded rendering.
  43482. finalValue = stripAndCollapse(cur);
  43483. if (curValue !== finalValue) {
  43484. elem.setAttribute("class", finalValue);
  43485. }
  43486. }
  43487. }
  43488. }
  43489. return this;
  43490. },
  43491. removeClass: function removeClass(value) {
  43492. var classes,
  43493. elem,
  43494. cur,
  43495. curValue,
  43496. clazz,
  43497. j,
  43498. finalValue,
  43499. i = 0;
  43500. if (isFunction(value)) {
  43501. return this.each(function (j) {
  43502. jQuery(this).removeClass(value.call(this, j, getClass(this)));
  43503. });
  43504. }
  43505. if (!arguments.length) {
  43506. return this.attr("class", "");
  43507. }
  43508. classes = classesToArray(value);
  43509. if (classes.length) {
  43510. while (elem = this[i++]) {
  43511. curValue = getClass(elem);
  43512. // This expression is here for better compressibility (see addClass)
  43513. cur = elem.nodeType === 1 && " " + stripAndCollapse(curValue) + " ";
  43514. if (cur) {
  43515. j = 0;
  43516. while (clazz = classes[j++]) {
  43517. // Remove *all* instances
  43518. while (cur.indexOf(" " + clazz + " ") > -1) {
  43519. cur = cur.replace(" " + clazz + " ", " ");
  43520. }
  43521. }
  43522. // Only assign if different to avoid unneeded rendering.
  43523. finalValue = stripAndCollapse(cur);
  43524. if (curValue !== finalValue) {
  43525. elem.setAttribute("class", finalValue);
  43526. }
  43527. }
  43528. }
  43529. }
  43530. return this;
  43531. },
  43532. toggleClass: function toggleClass(value, stateVal) {
  43533. var type = typeof value === "undefined" ? "undefined" : _typeof(value),
  43534. isValidValue = type === "string" || Array.isArray(value);
  43535. if (typeof stateVal === "boolean" && isValidValue) {
  43536. return stateVal ? this.addClass(value) : this.removeClass(value);
  43537. }
  43538. if (isFunction(value)) {
  43539. return this.each(function (i) {
  43540. jQuery(this).toggleClass(value.call(this, i, getClass(this), stateVal), stateVal);
  43541. });
  43542. }
  43543. return this.each(function () {
  43544. var className, i, self, classNames;
  43545. if (isValidValue) {
  43546. // Toggle individual class names
  43547. i = 0;
  43548. self = jQuery(this);
  43549. classNames = classesToArray(value);
  43550. while (className = classNames[i++]) {
  43551. // Check each className given, space separated list
  43552. if (self.hasClass(className)) {
  43553. self.removeClass(className);
  43554. } else {
  43555. self.addClass(className);
  43556. }
  43557. }
  43558. // Toggle whole class name
  43559. } else if (value === undefined || type === "boolean") {
  43560. className = getClass(this);
  43561. if (className) {
  43562. // Store className if set
  43563. dataPriv.set(this, "__className__", className);
  43564. }
  43565. // If the element has a class name or if we're passed `false`,
  43566. // then remove the whole classname (if there was one, the above saved it).
  43567. // Otherwise bring back whatever was previously saved (if anything),
  43568. // falling back to the empty string if nothing was stored.
  43569. if (this.setAttribute) {
  43570. this.setAttribute("class", className || value === false ? "" : dataPriv.get(this, "__className__") || "");
  43571. }
  43572. }
  43573. });
  43574. },
  43575. hasClass: function hasClass(selector) {
  43576. var className,
  43577. elem,
  43578. i = 0;
  43579. className = " " + selector + " ";
  43580. while (elem = this[i++]) {
  43581. if (elem.nodeType === 1 && (" " + stripAndCollapse(getClass(elem)) + " ").indexOf(className) > -1) {
  43582. return true;
  43583. }
  43584. }
  43585. return false;
  43586. }
  43587. });
  43588. var rreturn = /\r/g;
  43589. jQuery.fn.extend({
  43590. val: function val(value) {
  43591. var hooks,
  43592. ret,
  43593. valueIsFunction,
  43594. elem = this[0];
  43595. if (!arguments.length) {
  43596. if (elem) {
  43597. hooks = jQuery.valHooks[elem.type] || jQuery.valHooks[elem.nodeName.toLowerCase()];
  43598. if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) {
  43599. return ret;
  43600. }
  43601. ret = elem.value;
  43602. // Handle most common string cases
  43603. if (typeof ret === "string") {
  43604. return ret.replace(rreturn, "");
  43605. }
  43606. // Handle cases where value is null/undef or number
  43607. return ret == null ? "" : ret;
  43608. }
  43609. return;
  43610. }
  43611. valueIsFunction = isFunction(value);
  43612. return this.each(function (i) {
  43613. var val;
  43614. if (this.nodeType !== 1) {
  43615. return;
  43616. }
  43617. if (valueIsFunction) {
  43618. val = value.call(this, i, jQuery(this).val());
  43619. } else {
  43620. val = value;
  43621. }
  43622. // Treat null/undefined as ""; convert numbers to string
  43623. if (val == null) {
  43624. val = "";
  43625. } else if (typeof val === "number") {
  43626. val += "";
  43627. } else if (Array.isArray(val)) {
  43628. val = jQuery.map(val, function (value) {
  43629. return value == null ? "" : value + "";
  43630. });
  43631. }
  43632. hooks = jQuery.valHooks[this.type] || jQuery.valHooks[this.nodeName.toLowerCase()];
  43633. // If set returns undefined, fall back to normal setting
  43634. if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) {
  43635. this.value = val;
  43636. }
  43637. });
  43638. }
  43639. });
  43640. jQuery.extend({
  43641. valHooks: {
  43642. option: {
  43643. get: function get(elem) {
  43644. var val = jQuery.find.attr(elem, "value");
  43645. return val != null ? val :
  43646. // Support: IE <=10 - 11 only
  43647. // option.text throws exceptions (#14686, #14858)
  43648. // Strip and collapse whitespace
  43649. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  43650. stripAndCollapse(jQuery.text(elem));
  43651. }
  43652. },
  43653. select: {
  43654. get: function get(elem) {
  43655. var value,
  43656. option,
  43657. i,
  43658. options = elem.options,
  43659. index = elem.selectedIndex,
  43660. one = elem.type === "select-one",
  43661. values = one ? null : [],
  43662. max = one ? index + 1 : options.length;
  43663. if (index < 0) {
  43664. i = max;
  43665. } else {
  43666. i = one ? index : 0;
  43667. }
  43668. // Loop through all the selected options
  43669. for (; i < max; i++) {
  43670. option = options[i];
  43671. // Support: IE <=9 only
  43672. // IE8-9 doesn't update selected after form reset (#2551)
  43673. if ((option.selected || i === index) &&
  43674. // Don't return options that are disabled or in a disabled optgroup
  43675. !option.disabled && (!option.parentNode.disabled || !nodeName(option.parentNode, "optgroup"))) {
  43676. // Get the specific value for the option
  43677. value = jQuery(option).val();
  43678. // We don't need an array for one selects
  43679. if (one) {
  43680. return value;
  43681. }
  43682. // Multi-Selects return an array
  43683. values.push(value);
  43684. }
  43685. }
  43686. return values;
  43687. },
  43688. set: function set(elem, value) {
  43689. var optionSet,
  43690. option,
  43691. options = elem.options,
  43692. values = jQuery.makeArray(value),
  43693. i = options.length;
  43694. while (i--) {
  43695. option = options[i];
  43696. /* eslint-disable no-cond-assign */
  43697. if (option.selected = jQuery.inArray(jQuery.valHooks.option.get(option), values) > -1) {
  43698. optionSet = true;
  43699. }
  43700. /* eslint-enable no-cond-assign */
  43701. }
  43702. // Force browsers to behave consistently when non-matching value is set
  43703. if (!optionSet) {
  43704. elem.selectedIndex = -1;
  43705. }
  43706. return values;
  43707. }
  43708. }
  43709. }
  43710. });
  43711. // Radios and checkboxes getter/setter
  43712. jQuery.each(["radio", "checkbox"], function () {
  43713. jQuery.valHooks[this] = {
  43714. set: function set(elem, value) {
  43715. if (Array.isArray(value)) {
  43716. return elem.checked = jQuery.inArray(jQuery(elem).val(), value) > -1;
  43717. }
  43718. }
  43719. };
  43720. if (!support.checkOn) {
  43721. jQuery.valHooks[this].get = function (elem) {
  43722. return elem.getAttribute("value") === null ? "on" : elem.value;
  43723. };
  43724. }
  43725. });
  43726. // Return jQuery for attributes-only inclusion
  43727. support.focusin = "onfocusin" in window;
  43728. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  43729. stopPropagationCallback = function stopPropagationCallback(e) {
  43730. e.stopPropagation();
  43731. };
  43732. jQuery.extend(jQuery.event, {
  43733. trigger: function trigger(event, data, elem, onlyHandlers) {
  43734. var i,
  43735. cur,
  43736. tmp,
  43737. bubbleType,
  43738. ontype,
  43739. handle,
  43740. special,
  43741. lastElement,
  43742. eventPath = [elem || document],
  43743. type = hasOwn.call(event, "type") ? event.type : event,
  43744. namespaces = hasOwn.call(event, "namespace") ? event.namespace.split(".") : [];
  43745. cur = lastElement = tmp = elem = elem || document;
  43746. // Don't do events on text and comment nodes
  43747. if (elem.nodeType === 3 || elem.nodeType === 8) {
  43748. return;
  43749. }
  43750. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  43751. if (rfocusMorph.test(type + jQuery.event.triggered)) {
  43752. return;
  43753. }
  43754. if (type.indexOf(".") > -1) {
  43755. // Namespaced trigger; create a regexp to match event type in handle()
  43756. namespaces = type.split(".");
  43757. type = namespaces.shift();
  43758. namespaces.sort();
  43759. }
  43760. ontype = type.indexOf(":") < 0 && "on" + type;
  43761. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  43762. event = event[jQuery.expando] ? event : new jQuery.Event(type, (typeof event === "undefined" ? "undefined" : _typeof(event)) === "object" && event);
  43763. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  43764. event.isTrigger = onlyHandlers ? 2 : 3;
  43765. event.namespace = namespaces.join(".");
  43766. event.rnamespace = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
  43767. // Clean up the event in case it is being reused
  43768. event.result = undefined;
  43769. if (!event.target) {
  43770. event.target = elem;
  43771. }
  43772. // Clone any incoming data and prepend the event, creating the handler arg list
  43773. data = data == null ? [event] : jQuery.makeArray(data, [event]);
  43774. // Allow special events to draw outside the lines
  43775. special = jQuery.event.special[type] || {};
  43776. if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) {
  43777. return;
  43778. }
  43779. // Determine event propagation path in advance, per W3C events spec (#9951)
  43780. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  43781. if (!onlyHandlers && !special.noBubble && !isWindow(elem)) {
  43782. bubbleType = special.delegateType || type;
  43783. if (!rfocusMorph.test(bubbleType + type)) {
  43784. cur = cur.parentNode;
  43785. }
  43786. for (; cur; cur = cur.parentNode) {
  43787. eventPath.push(cur);
  43788. tmp = cur;
  43789. }
  43790. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  43791. if (tmp === (elem.ownerDocument || document)) {
  43792. eventPath.push(tmp.defaultView || tmp.parentWindow || window);
  43793. }
  43794. }
  43795. // Fire handlers on the event path
  43796. i = 0;
  43797. while ((cur = eventPath[i++]) && !event.isPropagationStopped()) {
  43798. lastElement = cur;
  43799. event.type = i > 1 ? bubbleType : special.bindType || type;
  43800. // jQuery handler
  43801. handle = (dataPriv.get(cur, "events") || {})[event.type] && dataPriv.get(cur, "handle");
  43802. if (handle) {
  43803. handle.apply(cur, data);
  43804. }
  43805. // Native handler
  43806. handle = ontype && cur[ontype];
  43807. if (handle && handle.apply && acceptData(cur)) {
  43808. event.result = handle.apply(cur, data);
  43809. if (event.result === false) {
  43810. event.preventDefault();
  43811. }
  43812. }
  43813. }
  43814. event.type = type;
  43815. // If nobody prevented the default action, do it now
  43816. if (!onlyHandlers && !event.isDefaultPrevented()) {
  43817. if ((!special._default || special._default.apply(eventPath.pop(), data) === false) && acceptData(elem)) {
  43818. // Call a native DOM method on the target with the same name as the event.
  43819. // Don't do default actions on window, that's where global variables be (#6170)
  43820. if (ontype && isFunction(elem[type]) && !isWindow(elem)) {
  43821. // Don't re-trigger an onFOO event when we call its FOO() method
  43822. tmp = elem[ontype];
  43823. if (tmp) {
  43824. elem[ontype] = null;
  43825. }
  43826. // Prevent re-triggering of the same event, since we already bubbled it above
  43827. jQuery.event.triggered = type;
  43828. if (event.isPropagationStopped()) {
  43829. lastElement.addEventListener(type, stopPropagationCallback);
  43830. }
  43831. elem[type]();
  43832. if (event.isPropagationStopped()) {
  43833. lastElement.removeEventListener(type, stopPropagationCallback);
  43834. }
  43835. jQuery.event.triggered = undefined;
  43836. if (tmp) {
  43837. elem[ontype] = tmp;
  43838. }
  43839. }
  43840. }
  43841. }
  43842. return event.result;
  43843. },
  43844. // Piggyback on a donor event to simulate a different one
  43845. // Used only for `focus(in | out)` events
  43846. simulate: function simulate(type, elem, event) {
  43847. var e = jQuery.extend(new jQuery.Event(), event, {
  43848. type: type,
  43849. isSimulated: true
  43850. });
  43851. jQuery.event.trigger(e, null, elem);
  43852. }
  43853. });
  43854. jQuery.fn.extend({
  43855. trigger: function trigger(type, data) {
  43856. return this.each(function () {
  43857. jQuery.event.trigger(type, data, this);
  43858. });
  43859. },
  43860. triggerHandler: function triggerHandler(type, data) {
  43861. var elem = this[0];
  43862. if (elem) {
  43863. return jQuery.event.trigger(type, data, elem, true);
  43864. }
  43865. }
  43866. });
  43867. // Support: Firefox <=44
  43868. // Firefox doesn't have focus(in | out) events
  43869. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  43870. //
  43871. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  43872. // focus(in | out) events fire after focus & blur events,
  43873. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  43874. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  43875. if (!support.focusin) {
  43876. jQuery.each({ focus: "focusin", blur: "focusout" }, function (orig, fix) {
  43877. // Attach a single capturing handler on the document while someone wants focusin/focusout
  43878. var handler = function handler(event) {
  43879. jQuery.event.simulate(fix, event.target, jQuery.event.fix(event));
  43880. };
  43881. jQuery.event.special[fix] = {
  43882. setup: function setup() {
  43883. var doc = this.ownerDocument || this,
  43884. attaches = dataPriv.access(doc, fix);
  43885. if (!attaches) {
  43886. doc.addEventListener(orig, handler, true);
  43887. }
  43888. dataPriv.access(doc, fix, (attaches || 0) + 1);
  43889. },
  43890. teardown: function teardown() {
  43891. var doc = this.ownerDocument || this,
  43892. attaches = dataPriv.access(doc, fix) - 1;
  43893. if (!attaches) {
  43894. doc.removeEventListener(orig, handler, true);
  43895. dataPriv.remove(doc, fix);
  43896. } else {
  43897. dataPriv.access(doc, fix, attaches);
  43898. }
  43899. }
  43900. };
  43901. });
  43902. }
  43903. var location = window.location;
  43904. var nonce = Date.now();
  43905. var rquery = /\?/;
  43906. // Cross-browser xml parsing
  43907. jQuery.parseXML = function (data) {
  43908. var xml;
  43909. if (!data || typeof data !== "string") {
  43910. return null;
  43911. }
  43912. // Support: IE 9 - 11 only
  43913. // IE throws on parseFromString with invalid input.
  43914. try {
  43915. xml = new window.DOMParser().parseFromString(data, "text/xml");
  43916. } catch (e) {
  43917. xml = undefined;
  43918. }
  43919. if (!xml || xml.getElementsByTagName("parsererror").length) {
  43920. jQuery.error("Invalid XML: " + data);
  43921. }
  43922. return xml;
  43923. };
  43924. var rbracket = /\[\]$/,
  43925. rCRLF = /\r?\n/g,
  43926. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  43927. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  43928. function buildParams(prefix, obj, traditional, add) {
  43929. var name;
  43930. if (Array.isArray(obj)) {
  43931. // Serialize array item.
  43932. jQuery.each(obj, function (i, v) {
  43933. if (traditional || rbracket.test(prefix)) {
  43934. // Treat each array item as a scalar.
  43935. add(prefix, v);
  43936. } else {
  43937. // Item is non-scalar (array or object), encode its numeric index.
  43938. buildParams(prefix + "[" + ((typeof v === "undefined" ? "undefined" : _typeof(v)) === "object" && v != null ? i : "") + "]", v, traditional, add);
  43939. }
  43940. });
  43941. } else if (!traditional && toType(obj) === "object") {
  43942. // Serialize object item.
  43943. for (name in obj) {
  43944. buildParams(prefix + "[" + name + "]", obj[name], traditional, add);
  43945. }
  43946. } else {
  43947. // Serialize scalar item.
  43948. add(prefix, obj);
  43949. }
  43950. }
  43951. // Serialize an array of form elements or a set of
  43952. // key/values into a query string
  43953. jQuery.param = function (a, traditional) {
  43954. var prefix,
  43955. s = [],
  43956. add = function add(key, valueOrFunction) {
  43957. // If value is a function, invoke it and use its return value
  43958. var value = isFunction(valueOrFunction) ? valueOrFunction() : valueOrFunction;
  43959. s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value == null ? "" : value);
  43960. };
  43961. // If an array was passed in, assume that it is an array of form elements.
  43962. if (Array.isArray(a) || a.jquery && !jQuery.isPlainObject(a)) {
  43963. // Serialize the form elements
  43964. jQuery.each(a, function () {
  43965. add(this.name, this.value);
  43966. });
  43967. } else {
  43968. // If traditional, encode the "old" way (the way 1.3.2 or older
  43969. // did it), otherwise encode params recursively.
  43970. for (prefix in a) {
  43971. buildParams(prefix, a[prefix], traditional, add);
  43972. }
  43973. }
  43974. // Return the resulting serialization
  43975. return s.join("&");
  43976. };
  43977. jQuery.fn.extend({
  43978. serialize: function serialize() {
  43979. return jQuery.param(this.serializeArray());
  43980. },
  43981. serializeArray: function serializeArray() {
  43982. return this.map(function () {
  43983. // Can add propHook for "elements" to filter or add form elements
  43984. var elements = jQuery.prop(this, "elements");
  43985. return elements ? jQuery.makeArray(elements) : this;
  43986. }).filter(function () {
  43987. var type = this.type;
  43988. // Use .is( ":disabled" ) so that fieldset[disabled] works
  43989. return this.name && !jQuery(this).is(":disabled") && rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) && (this.checked || !rcheckableType.test(type));
  43990. }).map(function (i, elem) {
  43991. var val = jQuery(this).val();
  43992. if (val == null) {
  43993. return null;
  43994. }
  43995. if (Array.isArray(val)) {
  43996. return jQuery.map(val, function (val) {
  43997. return { name: elem.name, value: val.replace(rCRLF, "\r\n") };
  43998. });
  43999. }
  44000. return { name: elem.name, value: val.replace(rCRLF, "\r\n") };
  44001. }).get();
  44002. }
  44003. });
  44004. var r20 = /%20/g,
  44005. rhash = /#.*$/,
  44006. rantiCache = /([?&])_=[^&]*/,
  44007. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  44008. // #7653, #8125, #8152: local protocol detection
  44009. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  44010. rnoContent = /^(?:GET|HEAD)$/,
  44011. rprotocol = /^\/\//,
  44012. /* Prefilters
  44013. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  44014. * 2) These are called:
  44015. * - BEFORE asking for a transport
  44016. * - AFTER param serialization (s.data is a string if s.processData is true)
  44017. * 3) key is the dataType
  44018. * 4) the catchall symbol "*" can be used
  44019. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  44020. */
  44021. prefilters = {},
  44022. /* Transports bindings
  44023. * 1) key is the dataType
  44024. * 2) the catchall symbol "*" can be used
  44025. * 3) selection will start with transport dataType and THEN go to "*" if needed
  44026. */
  44027. transports = {},
  44028. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  44029. allTypes = "*/".concat("*"),
  44030. // Anchor tag for parsing the document origin
  44031. originAnchor = document.createElement("a");
  44032. originAnchor.href = location.href;
  44033. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  44034. function addToPrefiltersOrTransports(structure) {
  44035. // dataTypeExpression is optional and defaults to "*"
  44036. return function (dataTypeExpression, func) {
  44037. if (typeof dataTypeExpression !== "string") {
  44038. func = dataTypeExpression;
  44039. dataTypeExpression = "*";
  44040. }
  44041. var dataType,
  44042. i = 0,
  44043. dataTypes = dataTypeExpression.toLowerCase().match(rnothtmlwhite) || [];
  44044. if (isFunction(func)) {
  44045. // For each dataType in the dataTypeExpression
  44046. while (dataType = dataTypes[i++]) {
  44047. // Prepend if requested
  44048. if (dataType[0] === "+") {
  44049. dataType = dataType.slice(1) || "*";
  44050. (structure[dataType] = structure[dataType] || []).unshift(func);
  44051. // Otherwise append
  44052. } else {
  44053. (structure[dataType] = structure[dataType] || []).push(func);
  44054. }
  44055. }
  44056. }
  44057. };
  44058. }
  44059. // Base inspection function for prefilters and transports
  44060. function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) {
  44061. var inspected = {},
  44062. seekingTransport = structure === transports;
  44063. function inspect(dataType) {
  44064. var selected;
  44065. inspected[dataType] = true;
  44066. jQuery.each(structure[dataType] || [], function (_, prefilterOrFactory) {
  44067. var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR);
  44068. if (typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[dataTypeOrTransport]) {
  44069. options.dataTypes.unshift(dataTypeOrTransport);
  44070. inspect(dataTypeOrTransport);
  44071. return false;
  44072. } else if (seekingTransport) {
  44073. return !(selected = dataTypeOrTransport);
  44074. }
  44075. });
  44076. return selected;
  44077. }
  44078. return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*");
  44079. }
  44080. // A special extend for ajax options
  44081. // that takes "flat" options (not to be deep extended)
  44082. // Fixes #9887
  44083. function ajaxExtend(target, src) {
  44084. var key,
  44085. deep,
  44086. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  44087. for (key in src) {
  44088. if (src[key] !== undefined) {
  44089. (flatOptions[key] ? target : deep || (deep = {}))[key] = src[key];
  44090. }
  44091. }
  44092. if (deep) {
  44093. jQuery.extend(true, target, deep);
  44094. }
  44095. return target;
  44096. }
  44097. /* Handles responses to an ajax request:
  44098. * - finds the right dataType (mediates between content-type and expected dataType)
  44099. * - returns the corresponding response
  44100. */
  44101. function ajaxHandleResponses(s, jqXHR, responses) {
  44102. var ct,
  44103. type,
  44104. finalDataType,
  44105. firstDataType,
  44106. contents = s.contents,
  44107. dataTypes = s.dataTypes;
  44108. // Remove auto dataType and get content-type in the process
  44109. while (dataTypes[0] === "*") {
  44110. dataTypes.shift();
  44111. if (ct === undefined) {
  44112. ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
  44113. }
  44114. }
  44115. // Check if we're dealing with a known content-type
  44116. if (ct) {
  44117. for (type in contents) {
  44118. if (contents[type] && contents[type].test(ct)) {
  44119. dataTypes.unshift(type);
  44120. break;
  44121. }
  44122. }
  44123. }
  44124. // Check to see if we have a response for the expected dataType
  44125. if (dataTypes[0] in responses) {
  44126. finalDataType = dataTypes[0];
  44127. } else {
  44128. // Try convertible dataTypes
  44129. for (type in responses) {
  44130. if (!dataTypes[0] || s.converters[type + " " + dataTypes[0]]) {
  44131. finalDataType = type;
  44132. break;
  44133. }
  44134. if (!firstDataType) {
  44135. firstDataType = type;
  44136. }
  44137. }
  44138. // Or just use first one
  44139. finalDataType = finalDataType || firstDataType;
  44140. }
  44141. // If we found a dataType
  44142. // We add the dataType to the list if needed
  44143. // and return the corresponding response
  44144. if (finalDataType) {
  44145. if (finalDataType !== dataTypes[0]) {
  44146. dataTypes.unshift(finalDataType);
  44147. }
  44148. return responses[finalDataType];
  44149. }
  44150. }
  44151. /* Chain conversions given the request and the original response
  44152. * Also sets the responseXXX fields on the jqXHR instance
  44153. */
  44154. function ajaxConvert(s, response, jqXHR, isSuccess) {
  44155. var conv2,
  44156. current,
  44157. conv,
  44158. tmp,
  44159. prev,
  44160. converters = {},
  44161. // Work with a copy of dataTypes in case we need to modify it for conversion
  44162. dataTypes = s.dataTypes.slice();
  44163. // Create converters map with lowercased keys
  44164. if (dataTypes[1]) {
  44165. for (conv in s.converters) {
  44166. converters[conv.toLowerCase()] = s.converters[conv];
  44167. }
  44168. }
  44169. current = dataTypes.shift();
  44170. // Convert to each sequential dataType
  44171. while (current) {
  44172. if (s.responseFields[current]) {
  44173. jqXHR[s.responseFields[current]] = response;
  44174. }
  44175. // Apply the dataFilter if provided
  44176. if (!prev && isSuccess && s.dataFilter) {
  44177. response = s.dataFilter(response, s.dataType);
  44178. }
  44179. prev = current;
  44180. current = dataTypes.shift();
  44181. if (current) {
  44182. // There's only work to do if current dataType is non-auto
  44183. if (current === "*") {
  44184. current = prev;
  44185. // Convert response if prev dataType is non-auto and differs from current
  44186. } else if (prev !== "*" && prev !== current) {
  44187. // Seek a direct converter
  44188. conv = converters[prev + " " + current] || converters["* " + current];
  44189. // If none found, seek a pair
  44190. if (!conv) {
  44191. for (conv2 in converters) {
  44192. // If conv2 outputs current
  44193. tmp = conv2.split(" ");
  44194. if (tmp[1] === current) {
  44195. // If prev can be converted to accepted input
  44196. conv = converters[prev + " " + tmp[0]] || converters["* " + tmp[0]];
  44197. if (conv) {
  44198. // Condense equivalence converters
  44199. if (conv === true) {
  44200. conv = converters[conv2];
  44201. // Otherwise, insert the intermediate dataType
  44202. } else if (converters[conv2] !== true) {
  44203. current = tmp[0];
  44204. dataTypes.unshift(tmp[1]);
  44205. }
  44206. break;
  44207. }
  44208. }
  44209. }
  44210. }
  44211. // Apply converter (if not an equivalence)
  44212. if (conv !== true) {
  44213. // Unless errors are allowed to bubble, catch and return them
  44214. if (conv && s.throws) {
  44215. response = conv(response);
  44216. } else {
  44217. try {
  44218. response = conv(response);
  44219. } catch (e) {
  44220. return {
  44221. state: "parsererror",
  44222. error: conv ? e : "No conversion from " + prev + " to " + current
  44223. };
  44224. }
  44225. }
  44226. }
  44227. }
  44228. }
  44229. }
  44230. return { state: "success", data: response };
  44231. }
  44232. jQuery.extend({
  44233. // Counter for holding the number of active queries
  44234. active: 0,
  44235. // Last-Modified header cache for next request
  44236. lastModified: {},
  44237. etag: {},
  44238. ajaxSettings: {
  44239. url: location.href,
  44240. type: "GET",
  44241. isLocal: rlocalProtocol.test(location.protocol),
  44242. global: true,
  44243. processData: true,
  44244. async: true,
  44245. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  44246. /*
  44247. timeout: 0,
  44248. data: null,
  44249. dataType: null,
  44250. username: null,
  44251. password: null,
  44252. cache: null,
  44253. throws: false,
  44254. traditional: false,
  44255. headers: {},
  44256. */
  44257. accepts: {
  44258. "*": allTypes,
  44259. text: "text/plain",
  44260. html: "text/html",
  44261. xml: "application/xml, text/xml",
  44262. json: "application/json, text/javascript"
  44263. },
  44264. contents: {
  44265. xml: /\bxml\b/,
  44266. html: /\bhtml/,
  44267. json: /\bjson\b/
  44268. },
  44269. responseFields: {
  44270. xml: "responseXML",
  44271. text: "responseText",
  44272. json: "responseJSON"
  44273. },
  44274. // Data converters
  44275. // Keys separate source (or catchall "*") and destination types with a single space
  44276. converters: {
  44277. // Convert anything to text
  44278. "* text": String,
  44279. // Text to html (true = no transformation)
  44280. "text html": true,
  44281. // Evaluate text as a json expression
  44282. "text json": JSON.parse,
  44283. // Parse text as xml
  44284. "text xml": jQuery.parseXML
  44285. },
  44286. // For options that shouldn't be deep extended:
  44287. // you can add your own custom options here if
  44288. // and when you create one that shouldn't be
  44289. // deep extended (see ajaxExtend)
  44290. flatOptions: {
  44291. url: true,
  44292. context: true
  44293. }
  44294. },
  44295. // Creates a full fledged settings object into target
  44296. // with both ajaxSettings and settings fields.
  44297. // If target is omitted, writes into ajaxSettings.
  44298. ajaxSetup: function ajaxSetup(target, settings) {
  44299. return settings ?
  44300. // Building a settings object
  44301. ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) :
  44302. // Extending ajaxSettings
  44303. ajaxExtend(jQuery.ajaxSettings, target);
  44304. },
  44305. ajaxPrefilter: addToPrefiltersOrTransports(prefilters),
  44306. ajaxTransport: addToPrefiltersOrTransports(transports),
  44307. // Main method
  44308. ajax: function ajax(url, options) {
  44309. // If url is an object, simulate pre-1.5 signature
  44310. if ((typeof url === "undefined" ? "undefined" : _typeof(url)) === "object") {
  44311. options = url;
  44312. url = undefined;
  44313. }
  44314. // Force options to be an object
  44315. options = options || {};
  44316. var transport,
  44317. // URL without anti-cache param
  44318. cacheURL,
  44319. // Response headers
  44320. responseHeadersString,
  44321. responseHeaders,
  44322. // timeout handle
  44323. timeoutTimer,
  44324. // Url cleanup var
  44325. urlAnchor,
  44326. // Request state (becomes false upon send and true upon completion)
  44327. completed,
  44328. // To know if global events are to be dispatched
  44329. fireGlobals,
  44330. // Loop variable
  44331. i,
  44332. // uncached part of the url
  44333. uncached,
  44334. // Create the final options object
  44335. s = jQuery.ajaxSetup({}, options),
  44336. // Callbacks context
  44337. callbackContext = s.context || s,
  44338. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  44339. globalEventContext = s.context && (callbackContext.nodeType || callbackContext.jquery) ? jQuery(callbackContext) : jQuery.event,
  44340. // Deferreds
  44341. deferred = jQuery.Deferred(),
  44342. completeDeferred = jQuery.Callbacks("once memory"),
  44343. // Status-dependent callbacks
  44344. _statusCode = s.statusCode || {},
  44345. // Headers (they are sent all at once)
  44346. requestHeaders = {},
  44347. requestHeadersNames = {},
  44348. // Default abort message
  44349. strAbort = "canceled",
  44350. // Fake xhr
  44351. jqXHR = {
  44352. readyState: 0,
  44353. // Builds headers hashtable if needed
  44354. getResponseHeader: function getResponseHeader(key) {
  44355. var match;
  44356. if (completed) {
  44357. if (!responseHeaders) {
  44358. responseHeaders = {};
  44359. while (match = rheaders.exec(responseHeadersString)) {
  44360. responseHeaders[match[1].toLowerCase()] = match[2];
  44361. }
  44362. }
  44363. match = responseHeaders[key.toLowerCase()];
  44364. }
  44365. return match == null ? null : match;
  44366. },
  44367. // Raw string
  44368. getAllResponseHeaders: function getAllResponseHeaders() {
  44369. return completed ? responseHeadersString : null;
  44370. },
  44371. // Caches the header
  44372. setRequestHeader: function setRequestHeader(name, value) {
  44373. if (completed == null) {
  44374. name = requestHeadersNames[name.toLowerCase()] = requestHeadersNames[name.toLowerCase()] || name;
  44375. requestHeaders[name] = value;
  44376. }
  44377. return this;
  44378. },
  44379. // Overrides response content-type header
  44380. overrideMimeType: function overrideMimeType(type) {
  44381. if (completed == null) {
  44382. s.mimeType = type;
  44383. }
  44384. return this;
  44385. },
  44386. // Status-dependent callbacks
  44387. statusCode: function statusCode(map) {
  44388. var code;
  44389. if (map) {
  44390. if (completed) {
  44391. // Execute the appropriate callbacks
  44392. jqXHR.always(map[jqXHR.status]);
  44393. } else {
  44394. // Lazy-add the new callbacks in a way that preserves old ones
  44395. for (code in map) {
  44396. _statusCode[code] = [_statusCode[code], map[code]];
  44397. }
  44398. }
  44399. }
  44400. return this;
  44401. },
  44402. // Cancel the request
  44403. abort: function abort(statusText) {
  44404. var finalText = statusText || strAbort;
  44405. if (transport) {
  44406. transport.abort(finalText);
  44407. }
  44408. done(0, finalText);
  44409. return this;
  44410. }
  44411. };
  44412. // Attach deferreds
  44413. deferred.promise(jqXHR);
  44414. // Add protocol if not provided (prefilters might expect it)
  44415. // Handle falsy url in the settings object (#10093: consistency with old signature)
  44416. // We also use the url parameter if available
  44417. s.url = ((url || s.url || location.href) + "").replace(rprotocol, location.protocol + "//");
  44418. // Alias method option to type as per ticket #12004
  44419. s.type = options.method || options.type || s.method || s.type;
  44420. // Extract dataTypes list
  44421. s.dataTypes = (s.dataType || "*").toLowerCase().match(rnothtmlwhite) || [""];
  44422. // A cross-domain request is in order when the origin doesn't match the current origin.
  44423. if (s.crossDomain == null) {
  44424. urlAnchor = document.createElement("a");
  44425. // Support: IE <=8 - 11, Edge 12 - 15
  44426. // IE throws exception on accessing the href property if url is malformed,
  44427. // e.g. http://example.com:80x/
  44428. try {
  44429. urlAnchor.href = s.url;
  44430. // Support: IE <=8 - 11 only
  44431. // Anchor's host property isn't correctly set when s.url is relative
  44432. urlAnchor.href = urlAnchor.href;
  44433. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== urlAnchor.protocol + "//" + urlAnchor.host;
  44434. } catch (e) {
  44435. // If there is an error parsing the URL, assume it is crossDomain,
  44436. // it can be rejected by the transport if it is invalid
  44437. s.crossDomain = true;
  44438. }
  44439. }
  44440. // Convert data if not already a string
  44441. if (s.data && s.processData && typeof s.data !== "string") {
  44442. s.data = jQuery.param(s.data, s.traditional);
  44443. }
  44444. // Apply prefilters
  44445. inspectPrefiltersOrTransports(prefilters, s, options, jqXHR);
  44446. // If request was aborted inside a prefilter, stop there
  44447. if (completed) {
  44448. return jqXHR;
  44449. }
  44450. // We can fire global events as of now if asked to
  44451. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  44452. fireGlobals = jQuery.event && s.global;
  44453. // Watch for a new set of requests
  44454. if (fireGlobals && jQuery.active++ === 0) {
  44455. jQuery.event.trigger("ajaxStart");
  44456. }
  44457. // Uppercase the type
  44458. s.type = s.type.toUpperCase();
  44459. // Determine if request has content
  44460. s.hasContent = !rnoContent.test(s.type);
  44461. // Save the URL in case we're toying with the If-Modified-Since
  44462. // and/or If-None-Match header later on
  44463. // Remove hash to simplify url manipulation
  44464. cacheURL = s.url.replace(rhash, "");
  44465. // More options handling for requests with no content
  44466. if (!s.hasContent) {
  44467. // Remember the hash so we can put it back
  44468. uncached = s.url.slice(cacheURL.length);
  44469. // If data is available and should be processed, append data to url
  44470. if (s.data && (s.processData || typeof s.data === "string")) {
  44471. cacheURL += (rquery.test(cacheURL) ? "&" : "?") + s.data;
  44472. // #9682: remove data so that it's not used in an eventual retry
  44473. delete s.data;
  44474. }
  44475. // Add or update anti-cache param if needed
  44476. if (s.cache === false) {
  44477. cacheURL = cacheURL.replace(rantiCache, "$1");
  44478. uncached = (rquery.test(cacheURL) ? "&" : "?") + "_=" + nonce++ + uncached;
  44479. }
  44480. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  44481. s.url = cacheURL + uncached;
  44482. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  44483. } else if (s.data && s.processData && (s.contentType || "").indexOf("application/x-www-form-urlencoded") === 0) {
  44484. s.data = s.data.replace(r20, "+");
  44485. }
  44486. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  44487. if (s.ifModified) {
  44488. if (jQuery.lastModified[cacheURL]) {
  44489. jqXHR.setRequestHeader("If-Modified-Since", jQuery.lastModified[cacheURL]);
  44490. }
  44491. if (jQuery.etag[cacheURL]) {
  44492. jqXHR.setRequestHeader("If-None-Match", jQuery.etag[cacheURL]);
  44493. }
  44494. }
  44495. // Set the correct header, if data is being sent
  44496. if (s.data && s.hasContent && s.contentType !== false || options.contentType) {
  44497. jqXHR.setRequestHeader("Content-Type", s.contentType);
  44498. }
  44499. // Set the Accepts header for the server, depending on the dataType
  44500. jqXHR.setRequestHeader("Accept", s.dataTypes[0] && s.accepts[s.dataTypes[0]] ? s.accepts[s.dataTypes[0]] + (s.dataTypes[0] !== "*" ? ", " + allTypes + "; q=0.01" : "") : s.accepts["*"]);
  44501. // Check for headers option
  44502. for (i in s.headers) {
  44503. jqXHR.setRequestHeader(i, s.headers[i]);
  44504. }
  44505. // Allow custom headers/mimetypes and early abort
  44506. if (s.beforeSend && (s.beforeSend.call(callbackContext, jqXHR, s) === false || completed)) {
  44507. // Abort if not done already and return
  44508. return jqXHR.abort();
  44509. }
  44510. // Aborting is no longer a cancellation
  44511. strAbort = "abort";
  44512. // Install callbacks on deferreds
  44513. completeDeferred.add(s.complete);
  44514. jqXHR.done(s.success);
  44515. jqXHR.fail(s.error);
  44516. // Get transport
  44517. transport = inspectPrefiltersOrTransports(transports, s, options, jqXHR);
  44518. // If no transport, we auto-abort
  44519. if (!transport) {
  44520. done(-1, "No Transport");
  44521. } else {
  44522. jqXHR.readyState = 1;
  44523. // Send global event
  44524. if (fireGlobals) {
  44525. globalEventContext.trigger("ajaxSend", [jqXHR, s]);
  44526. }
  44527. // If request was aborted inside ajaxSend, stop there
  44528. if (completed) {
  44529. return jqXHR;
  44530. }
  44531. // Timeout
  44532. if (s.async && s.timeout > 0) {
  44533. timeoutTimer = window.setTimeout(function () {
  44534. jqXHR.abort("timeout");
  44535. }, s.timeout);
  44536. }
  44537. try {
  44538. completed = false;
  44539. transport.send(requestHeaders, done);
  44540. } catch (e) {
  44541. // Rethrow post-completion exceptions
  44542. if (completed) {
  44543. throw e;
  44544. }
  44545. // Propagate others as results
  44546. done(-1, e);
  44547. }
  44548. }
  44549. // Callback for when everything is done
  44550. function done(status, nativeStatusText, responses, headers) {
  44551. var isSuccess,
  44552. success,
  44553. error,
  44554. response,
  44555. modified,
  44556. statusText = nativeStatusText;
  44557. // Ignore repeat invocations
  44558. if (completed) {
  44559. return;
  44560. }
  44561. completed = true;
  44562. // Clear timeout if it exists
  44563. if (timeoutTimer) {
  44564. window.clearTimeout(timeoutTimer);
  44565. }
  44566. // Dereference transport for early garbage collection
  44567. // (no matter how long the jqXHR object will be used)
  44568. transport = undefined;
  44569. // Cache response headers
  44570. responseHeadersString = headers || "";
  44571. // Set readyState
  44572. jqXHR.readyState = status > 0 ? 4 : 0;
  44573. // Determine if successful
  44574. isSuccess = status >= 200 && status < 300 || status === 304;
  44575. // Get response data
  44576. if (responses) {
  44577. response = ajaxHandleResponses(s, jqXHR, responses);
  44578. }
  44579. // Convert no matter what (that way responseXXX fields are always set)
  44580. response = ajaxConvert(s, response, jqXHR, isSuccess);
  44581. // If successful, handle type chaining
  44582. if (isSuccess) {
  44583. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  44584. if (s.ifModified) {
  44585. modified = jqXHR.getResponseHeader("Last-Modified");
  44586. if (modified) {
  44587. jQuery.lastModified[cacheURL] = modified;
  44588. }
  44589. modified = jqXHR.getResponseHeader("etag");
  44590. if (modified) {
  44591. jQuery.etag[cacheURL] = modified;
  44592. }
  44593. }
  44594. // if no content
  44595. if (status === 204 || s.type === "HEAD") {
  44596. statusText = "nocontent";
  44597. // if not modified
  44598. } else if (status === 304) {
  44599. statusText = "notmodified";
  44600. // If we have data, let's convert it
  44601. } else {
  44602. statusText = response.state;
  44603. success = response.data;
  44604. error = response.error;
  44605. isSuccess = !error;
  44606. }
  44607. } else {
  44608. // Extract error from statusText and normalize for non-aborts
  44609. error = statusText;
  44610. if (status || !statusText) {
  44611. statusText = "error";
  44612. if (status < 0) {
  44613. status = 0;
  44614. }
  44615. }
  44616. }
  44617. // Set data for the fake xhr object
  44618. jqXHR.status = status;
  44619. jqXHR.statusText = (nativeStatusText || statusText) + "";
  44620. // Success/Error
  44621. if (isSuccess) {
  44622. deferred.resolveWith(callbackContext, [success, statusText, jqXHR]);
  44623. } else {
  44624. deferred.rejectWith(callbackContext, [jqXHR, statusText, error]);
  44625. }
  44626. // Status-dependent callbacks
  44627. jqXHR.statusCode(_statusCode);
  44628. _statusCode = undefined;
  44629. if (fireGlobals) {
  44630. globalEventContext.trigger(isSuccess ? "ajaxSuccess" : "ajaxError", [jqXHR, s, isSuccess ? success : error]);
  44631. }
  44632. // Complete
  44633. completeDeferred.fireWith(callbackContext, [jqXHR, statusText]);
  44634. if (fireGlobals) {
  44635. globalEventContext.trigger("ajaxComplete", [jqXHR, s]);
  44636. // Handle the global AJAX counter
  44637. if (! --jQuery.active) {
  44638. jQuery.event.trigger("ajaxStop");
  44639. }
  44640. }
  44641. }
  44642. return jqXHR;
  44643. },
  44644. getJSON: function getJSON(url, data, callback) {
  44645. return jQuery.get(url, data, callback, "json");
  44646. },
  44647. getScript: function getScript(url, callback) {
  44648. return jQuery.get(url, undefined, callback, "script");
  44649. }
  44650. });
  44651. jQuery.each(["get", "post"], function (i, method) {
  44652. jQuery[method] = function (url, data, callback, type) {
  44653. // Shift arguments if data argument was omitted
  44654. if (isFunction(data)) {
  44655. type = type || callback;
  44656. callback = data;
  44657. data = undefined;
  44658. }
  44659. // The url can be an options object (which then must have .url)
  44660. return jQuery.ajax(jQuery.extend({
  44661. url: url,
  44662. type: method,
  44663. dataType: type,
  44664. data: data,
  44665. success: callback
  44666. }, jQuery.isPlainObject(url) && url));
  44667. };
  44668. });
  44669. jQuery._evalUrl = function (url) {
  44670. return jQuery.ajax({
  44671. url: url,
  44672. // Make this explicit, since user can override this through ajaxSetup (#11264)
  44673. type: "GET",
  44674. dataType: "script",
  44675. cache: true,
  44676. async: false,
  44677. global: false,
  44678. "throws": true
  44679. });
  44680. };
  44681. jQuery.fn.extend({
  44682. wrapAll: function wrapAll(html) {
  44683. var wrap;
  44684. if (this[0]) {
  44685. if (isFunction(html)) {
  44686. html = html.call(this[0]);
  44687. }
  44688. // The elements to wrap the target around
  44689. wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true);
  44690. if (this[0].parentNode) {
  44691. wrap.insertBefore(this[0]);
  44692. }
  44693. wrap.map(function () {
  44694. var elem = this;
  44695. while (elem.firstElementChild) {
  44696. elem = elem.firstElementChild;
  44697. }
  44698. return elem;
  44699. }).append(this);
  44700. }
  44701. return this;
  44702. },
  44703. wrapInner: function wrapInner(html) {
  44704. if (isFunction(html)) {
  44705. return this.each(function (i) {
  44706. jQuery(this).wrapInner(html.call(this, i));
  44707. });
  44708. }
  44709. return this.each(function () {
  44710. var self = jQuery(this),
  44711. contents = self.contents();
  44712. if (contents.length) {
  44713. contents.wrapAll(html);
  44714. } else {
  44715. self.append(html);
  44716. }
  44717. });
  44718. },
  44719. wrap: function wrap(html) {
  44720. var htmlIsFunction = isFunction(html);
  44721. return this.each(function (i) {
  44722. jQuery(this).wrapAll(htmlIsFunction ? html.call(this, i) : html);
  44723. });
  44724. },
  44725. unwrap: function unwrap(selector) {
  44726. this.parent(selector).not("body").each(function () {
  44727. jQuery(this).replaceWith(this.childNodes);
  44728. });
  44729. return this;
  44730. }
  44731. });
  44732. jQuery.expr.pseudos.hidden = function (elem) {
  44733. return !jQuery.expr.pseudos.visible(elem);
  44734. };
  44735. jQuery.expr.pseudos.visible = function (elem) {
  44736. return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
  44737. };
  44738. jQuery.ajaxSettings.xhr = function () {
  44739. try {
  44740. return new window.XMLHttpRequest();
  44741. } catch (e) {}
  44742. };
  44743. var xhrSuccessStatus = {
  44744. // File protocol always yields status code 0, assume 200
  44745. 0: 200,
  44746. // Support: IE <=9 only
  44747. // #1450: sometimes IE returns 1223 when it should be 204
  44748. 1223: 204
  44749. },
  44750. xhrSupported = jQuery.ajaxSettings.xhr();
  44751. support.cors = !!xhrSupported && "withCredentials" in xhrSupported;
  44752. support.ajax = xhrSupported = !!xhrSupported;
  44753. jQuery.ajaxTransport(function (options) {
  44754. var _callback, errorCallback;
  44755. // Cross domain only allowed if supported through XMLHttpRequest
  44756. if (support.cors || xhrSupported && !options.crossDomain) {
  44757. return {
  44758. send: function send(headers, complete) {
  44759. var i,
  44760. xhr = options.xhr();
  44761. xhr.open(options.type, options.url, options.async, options.username, options.password);
  44762. // Apply custom fields if provided
  44763. if (options.xhrFields) {
  44764. for (i in options.xhrFields) {
  44765. xhr[i] = options.xhrFields[i];
  44766. }
  44767. }
  44768. // Override mime type if needed
  44769. if (options.mimeType && xhr.overrideMimeType) {
  44770. xhr.overrideMimeType(options.mimeType);
  44771. }
  44772. // X-Requested-With header
  44773. // For cross-domain requests, seeing as conditions for a preflight are
  44774. // akin to a jigsaw puzzle, we simply never set it to be sure.
  44775. // (it can always be set on a per-request basis or even using ajaxSetup)
  44776. // For same-domain requests, won't change header if already provided.
  44777. if (!options.crossDomain && !headers["X-Requested-With"]) {
  44778. headers["X-Requested-With"] = "XMLHttpRequest";
  44779. }
  44780. // Set headers
  44781. for (i in headers) {
  44782. xhr.setRequestHeader(i, headers[i]);
  44783. }
  44784. // Callback
  44785. _callback = function callback(type) {
  44786. return function () {
  44787. if (_callback) {
  44788. _callback = errorCallback = xhr.onload = xhr.onerror = xhr.onabort = xhr.ontimeout = xhr.onreadystatechange = null;
  44789. if (type === "abort") {
  44790. xhr.abort();
  44791. } else if (type === "error") {
  44792. // Support: IE <=9 only
  44793. // On a manual native abort, IE9 throws
  44794. // errors on any property access that is not readyState
  44795. if (typeof xhr.status !== "number") {
  44796. complete(0, "error");
  44797. } else {
  44798. complete(
  44799. // File: protocol always yields status 0; see #8605, #14207
  44800. xhr.status, xhr.statusText);
  44801. }
  44802. } else {
  44803. complete(xhrSuccessStatus[xhr.status] || xhr.status, xhr.statusText,
  44804. // Support: IE <=9 only
  44805. // IE9 has no XHR2 but throws on binary (trac-11426)
  44806. // For XHR2 non-text, let the caller handle it (gh-2498)
  44807. (xhr.responseType || "text") !== "text" || typeof xhr.responseText !== "string" ? { binary: xhr.response } : { text: xhr.responseText }, xhr.getAllResponseHeaders());
  44808. }
  44809. }
  44810. };
  44811. };
  44812. // Listen to events
  44813. xhr.onload = _callback();
  44814. errorCallback = xhr.onerror = xhr.ontimeout = _callback("error");
  44815. // Support: IE 9 only
  44816. // Use onreadystatechange to replace onabort
  44817. // to handle uncaught aborts
  44818. if (xhr.onabort !== undefined) {
  44819. xhr.onabort = errorCallback;
  44820. } else {
  44821. xhr.onreadystatechange = function () {
  44822. // Check readyState before timeout as it changes
  44823. if (xhr.readyState === 4) {
  44824. // Allow onerror to be called first,
  44825. // but that will not handle a native abort
  44826. // Also, save errorCallback to a variable
  44827. // as xhr.onerror cannot be accessed
  44828. window.setTimeout(function () {
  44829. if (_callback) {
  44830. errorCallback();
  44831. }
  44832. });
  44833. }
  44834. };
  44835. }
  44836. // Create the abort callback
  44837. _callback = _callback("abort");
  44838. try {
  44839. // Do send the request (this may raise an exception)
  44840. xhr.send(options.hasContent && options.data || null);
  44841. } catch (e) {
  44842. // #14683: Only rethrow if this hasn't been notified as an error yet
  44843. if (_callback) {
  44844. throw e;
  44845. }
  44846. }
  44847. },
  44848. abort: function abort() {
  44849. if (_callback) {
  44850. _callback();
  44851. }
  44852. }
  44853. };
  44854. }
  44855. });
  44856. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  44857. jQuery.ajaxPrefilter(function (s) {
  44858. if (s.crossDomain) {
  44859. s.contents.script = false;
  44860. }
  44861. });
  44862. // Install script dataType
  44863. jQuery.ajaxSetup({
  44864. accepts: {
  44865. script: "text/javascript, application/javascript, " + "application/ecmascript, application/x-ecmascript"
  44866. },
  44867. contents: {
  44868. script: /\b(?:java|ecma)script\b/
  44869. },
  44870. converters: {
  44871. "text script": function textScript(text) {
  44872. jQuery.globalEval(text);
  44873. return text;
  44874. }
  44875. }
  44876. });
  44877. // Handle cache's special case and crossDomain
  44878. jQuery.ajaxPrefilter("script", function (s) {
  44879. if (s.cache === undefined) {
  44880. s.cache = false;
  44881. }
  44882. if (s.crossDomain) {
  44883. s.type = "GET";
  44884. }
  44885. });
  44886. // Bind script tag hack transport
  44887. jQuery.ajaxTransport("script", function (s) {
  44888. // This transport only deals with cross domain requests
  44889. if (s.crossDomain) {
  44890. var script, _callback2;
  44891. return {
  44892. send: function send(_, complete) {
  44893. script = jQuery("<script>").prop({
  44894. charset: s.scriptCharset,
  44895. src: s.url
  44896. }).on("load error", _callback2 = function callback(evt) {
  44897. script.remove();
  44898. _callback2 = null;
  44899. if (evt) {
  44900. complete(evt.type === "error" ? 404 : 200, evt.type);
  44901. }
  44902. });
  44903. // Use native DOM manipulation to avoid our domManip AJAX trickery
  44904. document.head.appendChild(script[0]);
  44905. },
  44906. abort: function abort() {
  44907. if (_callback2) {
  44908. _callback2();
  44909. }
  44910. }
  44911. };
  44912. }
  44913. });
  44914. var oldCallbacks = [],
  44915. rjsonp = /(=)\?(?=&|$)|\?\?/;
  44916. // Default jsonp settings
  44917. jQuery.ajaxSetup({
  44918. jsonp: "callback",
  44919. jsonpCallback: function jsonpCallback() {
  44920. var callback = oldCallbacks.pop() || jQuery.expando + "_" + nonce++;
  44921. this[callback] = true;
  44922. return callback;
  44923. }
  44924. });
  44925. // Detect, normalize options and install callbacks for jsonp requests
  44926. jQuery.ajaxPrefilter("json jsonp", function (s, originalSettings, jqXHR) {
  44927. var callbackName,
  44928. overwritten,
  44929. responseContainer,
  44930. jsonProp = s.jsonp !== false && (rjsonp.test(s.url) ? "url" : typeof s.data === "string" && (s.contentType || "").indexOf("application/x-www-form-urlencoded") === 0 && rjsonp.test(s.data) && "data");
  44931. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  44932. if (jsonProp || s.dataTypes[0] === "jsonp") {
  44933. // Get callback name, remembering preexisting value associated with it
  44934. callbackName = s.jsonpCallback = isFunction(s.jsonpCallback) ? s.jsonpCallback() : s.jsonpCallback;
  44935. // Insert callback into url or form data
  44936. if (jsonProp) {
  44937. s[jsonProp] = s[jsonProp].replace(rjsonp, "$1" + callbackName);
  44938. } else if (s.jsonp !== false) {
  44939. s.url += (rquery.test(s.url) ? "&" : "?") + s.jsonp + "=" + callbackName;
  44940. }
  44941. // Use data converter to retrieve json after script execution
  44942. s.converters["script json"] = function () {
  44943. if (!responseContainer) {
  44944. jQuery.error(callbackName + " was not called");
  44945. }
  44946. return responseContainer[0];
  44947. };
  44948. // Force json dataType
  44949. s.dataTypes[0] = "json";
  44950. // Install callback
  44951. overwritten = window[callbackName];
  44952. window[callbackName] = function () {
  44953. responseContainer = arguments;
  44954. };
  44955. // Clean-up function (fires after converters)
  44956. jqXHR.always(function () {
  44957. // If previous value didn't exist - remove it
  44958. if (overwritten === undefined) {
  44959. jQuery(window).removeProp(callbackName);
  44960. // Otherwise restore preexisting value
  44961. } else {
  44962. window[callbackName] = overwritten;
  44963. }
  44964. // Save back as free
  44965. if (s[callbackName]) {
  44966. // Make sure that re-using the options doesn't screw things around
  44967. s.jsonpCallback = originalSettings.jsonpCallback;
  44968. // Save the callback name for future use
  44969. oldCallbacks.push(callbackName);
  44970. }
  44971. // Call if it was a function and we have a response
  44972. if (responseContainer && isFunction(overwritten)) {
  44973. overwritten(responseContainer[0]);
  44974. }
  44975. responseContainer = overwritten = undefined;
  44976. });
  44977. // Delegate to script
  44978. return "script";
  44979. }
  44980. });
  44981. // Support: Safari 8 only
  44982. // In Safari 8 documents created via document.implementation.createHTMLDocument
  44983. // collapse sibling forms: the second one becomes a child of the first one.
  44984. // Because of that, this security measure has to be disabled in Safari 8.
  44985. // https://bugs.webkit.org/show_bug.cgi?id=137337
  44986. support.createHTMLDocument = function () {
  44987. var body = document.implementation.createHTMLDocument("").body;
  44988. body.innerHTML = "<form></form><form></form>";
  44989. return body.childNodes.length === 2;
  44990. }();
  44991. // Argument "data" should be string of html
  44992. // context (optional): If specified, the fragment will be created in this context,
  44993. // defaults to document
  44994. // keepScripts (optional): If true, will include scripts passed in the html string
  44995. jQuery.parseHTML = function (data, context, keepScripts) {
  44996. if (typeof data !== "string") {
  44997. return [];
  44998. }
  44999. if (typeof context === "boolean") {
  45000. keepScripts = context;
  45001. context = false;
  45002. }
  45003. var base, parsed, scripts;
  45004. if (!context) {
  45005. // Stop scripts or inline event handlers from being executed immediately
  45006. // by using document.implementation
  45007. if (support.createHTMLDocument) {
  45008. context = document.implementation.createHTMLDocument("");
  45009. // Set the base href for the created document
  45010. // so any parsed elements with URLs
  45011. // are based on the document's URL (gh-2965)
  45012. base = context.createElement("base");
  45013. base.href = document.location.href;
  45014. context.head.appendChild(base);
  45015. } else {
  45016. context = document;
  45017. }
  45018. }
  45019. parsed = rsingleTag.exec(data);
  45020. scripts = !keepScripts && [];
  45021. // Single tag
  45022. if (parsed) {
  45023. return [context.createElement(parsed[1])];
  45024. }
  45025. parsed = buildFragment([data], context, scripts);
  45026. if (scripts && scripts.length) {
  45027. jQuery(scripts).remove();
  45028. }
  45029. return jQuery.merge([], parsed.childNodes);
  45030. };
  45031. /**
  45032. * Load a url into a page
  45033. */
  45034. jQuery.fn.load = function (url, params, callback) {
  45035. var selector,
  45036. type,
  45037. response,
  45038. self = this,
  45039. off = url.indexOf(" ");
  45040. if (off > -1) {
  45041. selector = stripAndCollapse(url.slice(off));
  45042. url = url.slice(0, off);
  45043. }
  45044. // If it's a function
  45045. if (isFunction(params)) {
  45046. // We assume that it's the callback
  45047. callback = params;
  45048. params = undefined;
  45049. // Otherwise, build a param string
  45050. } else if (params && (typeof params === "undefined" ? "undefined" : _typeof(params)) === "object") {
  45051. type = "POST";
  45052. }
  45053. // If we have elements to modify, make the request
  45054. if (self.length > 0) {
  45055. jQuery.ajax({
  45056. url: url,
  45057. // If "type" variable is undefined, then "GET" method will be used.
  45058. // Make value of this field explicit since
  45059. // user can override it through ajaxSetup method
  45060. type: type || "GET",
  45061. dataType: "html",
  45062. data: params
  45063. }).done(function (responseText) {
  45064. // Save response for use in complete callback
  45065. response = arguments;
  45066. self.html(selector ?
  45067. // If a selector was specified, locate the right elements in a dummy div
  45068. // Exclude scripts to avoid IE 'Permission Denied' errors
  45069. jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector) :
  45070. // Otherwise use the full result
  45071. responseText);
  45072. // If the request succeeds, this function gets "data", "status", "jqXHR"
  45073. // but they are ignored because response was set above.
  45074. // If it fails, this function gets "jqXHR", "status", "error"
  45075. }).always(callback && function (jqXHR, status) {
  45076. self.each(function () {
  45077. callback.apply(this, response || [jqXHR.responseText, status, jqXHR]);
  45078. });
  45079. });
  45080. }
  45081. return this;
  45082. };
  45083. // Attach a bunch of functions for handling common AJAX events
  45084. jQuery.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function (i, type) {
  45085. jQuery.fn[type] = function (fn) {
  45086. return this.on(type, fn);
  45087. };
  45088. });
  45089. jQuery.expr.pseudos.animated = function (elem) {
  45090. return jQuery.grep(jQuery.timers, function (fn) {
  45091. return elem === fn.elem;
  45092. }).length;
  45093. };
  45094. jQuery.offset = {
  45095. setOffset: function setOffset(elem, options, i) {
  45096. var curPosition,
  45097. curLeft,
  45098. curCSSTop,
  45099. curTop,
  45100. curOffset,
  45101. curCSSLeft,
  45102. calculatePosition,
  45103. position = jQuery.css(elem, "position"),
  45104. curElem = jQuery(elem),
  45105. props = {};
  45106. // Set position first, in-case top/left are set even on static elem
  45107. if (position === "static") {
  45108. elem.style.position = "relative";
  45109. }
  45110. curOffset = curElem.offset();
  45111. curCSSTop = jQuery.css(elem, "top");
  45112. curCSSLeft = jQuery.css(elem, "left");
  45113. calculatePosition = (position === "absolute" || position === "fixed") && (curCSSTop + curCSSLeft).indexOf("auto") > -1;
  45114. // Need to be able to calculate position if either
  45115. // top or left is auto and position is either absolute or fixed
  45116. if (calculatePosition) {
  45117. curPosition = curElem.position();
  45118. curTop = curPosition.top;
  45119. curLeft = curPosition.left;
  45120. } else {
  45121. curTop = parseFloat(curCSSTop) || 0;
  45122. curLeft = parseFloat(curCSSLeft) || 0;
  45123. }
  45124. if (isFunction(options)) {
  45125. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  45126. options = options.call(elem, i, jQuery.extend({}, curOffset));
  45127. }
  45128. if (options.top != null) {
  45129. props.top = options.top - curOffset.top + curTop;
  45130. }
  45131. if (options.left != null) {
  45132. props.left = options.left - curOffset.left + curLeft;
  45133. }
  45134. if ("using" in options) {
  45135. options.using.call(elem, props);
  45136. } else {
  45137. curElem.css(props);
  45138. }
  45139. }
  45140. };
  45141. jQuery.fn.extend({
  45142. // offset() relates an element's border box to the document origin
  45143. offset: function offset(options) {
  45144. // Preserve chaining for setter
  45145. if (arguments.length) {
  45146. return options === undefined ? this : this.each(function (i) {
  45147. jQuery.offset.setOffset(this, options, i);
  45148. });
  45149. }
  45150. var rect,
  45151. win,
  45152. elem = this[0];
  45153. if (!elem) {
  45154. return;
  45155. }
  45156. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  45157. // Support: IE <=11 only
  45158. // Running getBoundingClientRect on a
  45159. // disconnected node in IE throws an error
  45160. if (!elem.getClientRects().length) {
  45161. return { top: 0, left: 0 };
  45162. }
  45163. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  45164. rect = elem.getBoundingClientRect();
  45165. win = elem.ownerDocument.defaultView;
  45166. return {
  45167. top: rect.top + win.pageYOffset,
  45168. left: rect.left + win.pageXOffset
  45169. };
  45170. },
  45171. // position() relates an element's margin box to its offset parent's padding box
  45172. // This corresponds to the behavior of CSS absolute positioning
  45173. position: function position() {
  45174. if (!this[0]) {
  45175. return;
  45176. }
  45177. var offsetParent,
  45178. offset,
  45179. doc,
  45180. elem = this[0],
  45181. parentOffset = { top: 0, left: 0 };
  45182. // position:fixed elements are offset from the viewport, which itself always has zero offset
  45183. if (jQuery.css(elem, "position") === "fixed") {
  45184. // Assume position:fixed implies availability of getBoundingClientRect
  45185. offset = elem.getBoundingClientRect();
  45186. } else {
  45187. offset = this.offset();
  45188. // Account for the *real* offset parent, which can be the document or its root element
  45189. // when a statically positioned element is identified
  45190. doc = elem.ownerDocument;
  45191. offsetParent = elem.offsetParent || doc.documentElement;
  45192. while (offsetParent && (offsetParent === doc.body || offsetParent === doc.documentElement) && jQuery.css(offsetParent, "position") === "static") {
  45193. offsetParent = offsetParent.parentNode;
  45194. }
  45195. if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
  45196. // Incorporate borders into its offset, since they are outside its content origin
  45197. parentOffset = jQuery(offsetParent).offset();
  45198. parentOffset.top += jQuery.css(offsetParent, "borderTopWidth", true);
  45199. parentOffset.left += jQuery.css(offsetParent, "borderLeftWidth", true);
  45200. }
  45201. }
  45202. // Subtract parent offsets and element margins
  45203. return {
  45204. top: offset.top - parentOffset.top - jQuery.css(elem, "marginTop", true),
  45205. left: offset.left - parentOffset.left - jQuery.css(elem, "marginLeft", true)
  45206. };
  45207. },
  45208. // This method will return documentElement in the following cases:
  45209. // 1) For the element inside the iframe without offsetParent, this method will return
  45210. // documentElement of the parent window
  45211. // 2) For the hidden or detached element
  45212. // 3) For body or html element, i.e. in case of the html node - it will return itself
  45213. //
  45214. // but those exceptions were never presented as a real life use-cases
  45215. // and might be considered as more preferable results.
  45216. //
  45217. // This logic, however, is not guaranteed and can change at any point in the future
  45218. offsetParent: function offsetParent() {
  45219. return this.map(function () {
  45220. var offsetParent = this.offsetParent;
  45221. while (offsetParent && jQuery.css(offsetParent, "position") === "static") {
  45222. offsetParent = offsetParent.offsetParent;
  45223. }
  45224. return offsetParent || documentElement;
  45225. });
  45226. }
  45227. });
  45228. // Create scrollLeft and scrollTop methods
  45229. jQuery.each({ scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function (method, prop) {
  45230. var top = "pageYOffset" === prop;
  45231. jQuery.fn[method] = function (val) {
  45232. return access(this, function (elem, method, val) {
  45233. // Coalesce documents and windows
  45234. var win;
  45235. if (isWindow(elem)) {
  45236. win = elem;
  45237. } else if (elem.nodeType === 9) {
  45238. win = elem.defaultView;
  45239. }
  45240. if (val === undefined) {
  45241. return win ? win[prop] : elem[method];
  45242. }
  45243. if (win) {
  45244. win.scrollTo(!top ? val : win.pageXOffset, top ? val : win.pageYOffset);
  45245. } else {
  45246. elem[method] = val;
  45247. }
  45248. }, method, val, arguments.length);
  45249. };
  45250. });
  45251. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  45252. // Add the top/left cssHooks using jQuery.fn.position
  45253. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  45254. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  45255. // getComputedStyle returns percent when specified for top/left/bottom/right;
  45256. // rather than make the css module depend on the offset module, just check for it here
  45257. jQuery.each(["top", "left"], function (i, prop) {
  45258. jQuery.cssHooks[prop] = addGetHookIf(support.pixelPosition, function (elem, computed) {
  45259. if (computed) {
  45260. computed = curCSS(elem, prop);
  45261. // If curCSS returns percentage, fallback to offset
  45262. return rnumnonpx.test(computed) ? jQuery(elem).position()[prop] + "px" : computed;
  45263. }
  45264. });
  45265. });
  45266. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  45267. jQuery.each({ Height: "height", Width: "width" }, function (name, type) {
  45268. jQuery.each({ padding: "inner" + name, content: type, "": "outer" + name }, function (defaultExtra, funcName) {
  45269. // Margin is only for outerHeight, outerWidth
  45270. jQuery.fn[funcName] = function (margin, value) {
  45271. var chainable = arguments.length && (defaultExtra || typeof margin !== "boolean"),
  45272. extra = defaultExtra || (margin === true || value === true ? "margin" : "border");
  45273. return access(this, function (elem, type, value) {
  45274. var doc;
  45275. if (isWindow(elem)) {
  45276. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  45277. return funcName.indexOf("outer") === 0 ? elem["inner" + name] : elem.document.documentElement["client" + name];
  45278. }
  45279. // Get document width or height
  45280. if (elem.nodeType === 9) {
  45281. doc = elem.documentElement;
  45282. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  45283. // whichever is greatest
  45284. return Math.max(elem.body["scroll" + name], doc["scroll" + name], elem.body["offset" + name], doc["offset" + name], doc["client" + name]);
  45285. }
  45286. return value === undefined ?
  45287. // Get width or height on the element, requesting but not forcing parseFloat
  45288. jQuery.css(elem, type, extra) :
  45289. // Set width or height on the element
  45290. jQuery.style(elem, type, value, extra);
  45291. }, type, chainable ? margin : undefined, chainable);
  45292. };
  45293. });
  45294. });
  45295. jQuery.each(("blur focus focusin focusout resize scroll click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup contextmenu").split(" "), function (i, name) {
  45296. // Handle event binding
  45297. jQuery.fn[name] = function (data, fn) {
  45298. return arguments.length > 0 ? this.on(name, null, data, fn) : this.trigger(name);
  45299. };
  45300. });
  45301. jQuery.fn.extend({
  45302. hover: function hover(fnOver, fnOut) {
  45303. return this.mouseenter(fnOver).mouseleave(fnOut || fnOver);
  45304. }
  45305. });
  45306. jQuery.fn.extend({
  45307. bind: function bind(types, data, fn) {
  45308. return this.on(types, null, data, fn);
  45309. },
  45310. unbind: function unbind(types, fn) {
  45311. return this.off(types, null, fn);
  45312. },
  45313. delegate: function delegate(selector, types, data, fn) {
  45314. return this.on(types, selector, data, fn);
  45315. },
  45316. undelegate: function undelegate(selector, types, fn) {
  45317. // ( namespace ) or ( selector, types [, fn] )
  45318. return arguments.length === 1 ? this.off(selector, "**") : this.off(types, selector || "**", fn);
  45319. }
  45320. });
  45321. // Bind a function to a context, optionally partially applying any
  45322. // arguments.
  45323. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  45324. // However, it is not slated for removal any time soon
  45325. jQuery.proxy = function (fn, context) {
  45326. var tmp, args, proxy;
  45327. if (typeof context === "string") {
  45328. tmp = fn[context];
  45329. context = fn;
  45330. fn = tmp;
  45331. }
  45332. // Quick check to determine if target is callable, in the spec
  45333. // this throws a TypeError, but we will just return undefined.
  45334. if (!isFunction(fn)) {
  45335. return undefined;
  45336. }
  45337. // Simulated bind
  45338. args = _slice.call(arguments, 2);
  45339. proxy = function proxy() {
  45340. return fn.apply(context || this, args.concat(_slice.call(arguments)));
  45341. };
  45342. // Set the guid of unique handler to the same of original handler, so it can be removed
  45343. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  45344. return proxy;
  45345. };
  45346. jQuery.holdReady = function (hold) {
  45347. if (hold) {
  45348. jQuery.readyWait++;
  45349. } else {
  45350. jQuery.ready(true);
  45351. }
  45352. };
  45353. jQuery.isArray = Array.isArray;
  45354. jQuery.parseJSON = JSON.parse;
  45355. jQuery.nodeName = nodeName;
  45356. jQuery.isFunction = isFunction;
  45357. jQuery.isWindow = isWindow;
  45358. jQuery.camelCase = camelCase;
  45359. jQuery.type = toType;
  45360. jQuery.now = Date.now;
  45361. jQuery.isNumeric = function (obj) {
  45362. // As of jQuery 3.0, isNumeric is limited to
  45363. // strings and numbers (primitives or objects)
  45364. // that can be coerced to finite numbers (gh-2662)
  45365. var type = jQuery.type(obj);
  45366. return (type === "number" || type === "string") &&
  45367. // parseFloat NaNs numeric-cast false positives ("")
  45368. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  45369. // subtraction forces infinities to NaN
  45370. !isNaN(obj - parseFloat(obj));
  45371. };
  45372. // Register as a named AMD module, since jQuery can be concatenated with other
  45373. // files that may use define, but not via a proper concatenation script that
  45374. // understands anonymous AMD modules. A named AMD is safest and most robust
  45375. // way to register. Lowercase jquery is used because AMD module names are
  45376. // derived from file names, and jQuery is normally delivered in a lowercase
  45377. // file name. Do this after creating the global so that if an AMD module wants
  45378. // to call noConflict to hide this version of jQuery, it will work.
  45379. // Note that for maximum portability, libraries that are not jQuery should
  45380. // declare themselves as anonymous modules, and avoid setting a global if an
  45381. // AMD loader is present. jQuery is a special case. For more information, see
  45382. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  45383. if (true) {
  45384. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  45385. return jQuery;
  45386. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  45387. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  45388. }
  45389. var
  45390. // Map over jQuery in case of overwrite
  45391. _jQuery = window.jQuery,
  45392. // Map over the $ in case of overwrite
  45393. _$ = window.$;
  45394. jQuery.noConflict = function (deep) {
  45395. if (window.$ === jQuery) {
  45396. window.$ = _$;
  45397. }
  45398. if (deep && window.jQuery === jQuery) {
  45399. window.jQuery = _jQuery;
  45400. }
  45401. return jQuery;
  45402. };
  45403. // Expose jQuery and $ identifiers, even in AMD
  45404. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  45405. // and CommonJS for browser emulators (#13566)
  45406. if (!noGlobal) {
  45407. window.jQuery = window.$ = jQuery;
  45408. }
  45409. return jQuery;
  45410. });
  45411. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
  45412. /***/ }),
  45413. /***/ "./node_modules/line-i18n/dist/LanguageService.js":
  45414. /*!********************************************************!*\
  45415. !*** ./node_modules/line-i18n/dist/LanguageService.js ***!
  45416. \********************************************************/
  45417. /*! no static exports found */
  45418. /***/ (function(module, exports, __webpack_require__) {
  45419. "use strict";
  45420. Object.defineProperty(exports, "__esModule", {
  45421. value: true
  45422. });
  45423. var LanguageService = /** @class */function () {
  45424. function LanguageService(lsKey, defaultLang) {
  45425. if (defaultLang === void 0) {
  45426. defaultLang = 'pt';
  45427. }
  45428. this.lsKey = lsKey;
  45429. this.defaultLang = defaultLang;
  45430. this.listeners = [];
  45431. this.document = document;
  45432. this.setupListener();
  45433. }
  45434. LanguageService.prototype.setupListener = function () {
  45435. var _this = this;
  45436. if (this.document !== null) {
  45437. this.document.addEventListener("storage", function (event) {
  45438. var e = event;
  45439. if (e.key === _this.lsKey) {
  45440. _this.listeners.forEach(function (l) {
  45441. return l();
  45442. });
  45443. }
  45444. });
  45445. }
  45446. };
  45447. LanguageService.prototype.getLang = function () {
  45448. var lang = localStorage.getItem(this.lsKey);
  45449. if (lang === null || lang === undefined) {
  45450. console.warn("Internal Error: User language information has not been set. Returning default...");
  45451. return this.getDefaultLang();
  45452. }
  45453. return lang;
  45454. };
  45455. LanguageService.prototype.getDefaultLang = function () {
  45456. return this.defaultLang;
  45457. };
  45458. LanguageService.prototype.registerLanguageChangeListener = function (listener) {
  45459. this.listeners.push(listener);
  45460. };
  45461. return LanguageService;
  45462. }();
  45463. exports.LanguageService = LanguageService;
  45464. /***/ }),
  45465. /***/ "./node_modules/line-i18n/dist/LanguageServiceNoLS.js":
  45466. /*!************************************************************!*\
  45467. !*** ./node_modules/line-i18n/dist/LanguageServiceNoLS.js ***!
  45468. \************************************************************/
  45469. /*! no static exports found */
  45470. /***/ (function(module, exports, __webpack_require__) {
  45471. "use strict";
  45472. Object.defineProperty(exports, "__esModule", {
  45473. value: true
  45474. });
  45475. var LanguageServiceNoLS = /** @class */function () {
  45476. function LanguageServiceNoLS(lang) {
  45477. this.lang = lang;
  45478. this.listeners = [];
  45479. }
  45480. LanguageServiceNoLS.prototype.setupListener = function () {};
  45481. LanguageServiceNoLS.prototype.notifyChange = function () {
  45482. this.listeners.forEach(function (l) {
  45483. return l();
  45484. });
  45485. };
  45486. LanguageServiceNoLS.prototype.setLang = function (lang) {
  45487. this.lang = lang;
  45488. this.notifyChange();
  45489. };
  45490. LanguageServiceNoLS.prototype.getLang = function () {
  45491. return this.lang;
  45492. };
  45493. LanguageServiceNoLS.prototype.getDefaultLang = function () {
  45494. return this.lang;
  45495. };
  45496. LanguageServiceNoLS.prototype.registerLanguageChangeListener = function (listener) {
  45497. this.listeners.push(listener);
  45498. };
  45499. return LanguageServiceNoLS;
  45500. }();
  45501. exports.LanguageServiceNoLS = LanguageServiceNoLS;
  45502. /***/ }),
  45503. /***/ "./node_modules/line-i18n/dist/LocalizedStrings.js":
  45504. /*!*********************************************************!*\
  45505. !*** ./node_modules/line-i18n/dist/LocalizedStrings.js ***!
  45506. \*********************************************************/
  45507. /*! no static exports found */
  45508. /***/ (function(module, exports, __webpack_require__) {
  45509. "use strict";
  45510. Object.defineProperty(exports, "__esModule", {
  45511. value: true
  45512. });
  45513. exports.LocalizedStrings = undefined;
  45514. var _StringTypes = __webpack_require__(/*! ./StringTypes */ "./node_modules/line-i18n/dist/StringTypes.js");
  45515. var LocalizedStrings = /** @class */function () {
  45516. function LocalizedStrings(service, i18nData, listenToChange) {
  45517. if (listenToChange === void 0) {
  45518. listenToChange = false;
  45519. }
  45520. var _this = this;
  45521. this.service = service;
  45522. this.i18nData = i18nData;
  45523. this.listenToChange = listenToChange;
  45524. this.document = document;
  45525. if (this.listenToChange) {
  45526. service.registerLanguageChangeListener(function () {
  45527. _this.updateTagText();
  45528. });
  45529. }
  45530. }
  45531. LocalizedStrings.prototype.getString = function (id, type) {
  45532. var i18nObj = this.i18nData[this.service.getLang()];
  45533. if (!!!i18nObj) {
  45534. console.warn("Internal Error. The language set at ivprog.lang is not valid: " + this.service.getLang());
  45535. i18nObj = this.i18nData[this.service.getDefaultLang()];
  45536. }
  45537. if (!!!i18nObj[type]) {
  45538. return "{MISSING_I18N_TYPE_IDENTIFIER}";
  45539. } else if (!!!i18nObj[type][id]) {
  45540. return "{MISSING_I18N_IDENTIFIER}";
  45541. } else {
  45542. return i18nObj[type][id];
  45543. }
  45544. };
  45545. LocalizedStrings.prototype.getOR = function () {
  45546. return this.getUI('join_or');
  45547. };
  45548. LocalizedStrings.prototype.getError = function (id, context) {
  45549. if (context === void 0) {
  45550. context = [];
  45551. }
  45552. var text = this.getString(id, _StringTypes.StringTypes.ERROR);
  45553. return this.processString(text, context);
  45554. };
  45555. LocalizedStrings.prototype.getMessage = function (id, context) {
  45556. if (context === void 0) {
  45557. context = [];
  45558. }
  45559. var text = this.getString(id, _StringTypes.StringTypes.MESSAGE);
  45560. return this.processString(text, context);
  45561. };
  45562. LocalizedStrings.prototype.getUI = function (id, context) {
  45563. if (context === void 0) {
  45564. context = [];
  45565. }
  45566. var text = this.getString(id, _StringTypes.StringTypes.UI);
  45567. return this.processString(text, context);
  45568. };
  45569. LocalizedStrings.prototype.processString = function (text, context) {
  45570. for (var i = 0; i < context.length; i++) {
  45571. var v = context[i];
  45572. text = text.replace('\$' + i, v);
  45573. }
  45574. return text;
  45575. };
  45576. LocalizedStrings.prototype.updateTagText = function (func) {
  45577. var _this = this;
  45578. if (func === void 0) {
  45579. func = null;
  45580. }
  45581. if (this.document !== null) {
  45582. var list = this.document.querySelectorAll("data.i18n");
  45583. list.forEach(function (node) {
  45584. if (func === null) {
  45585. node.innerHTML = _this.processTagTex(node.getAttribute("value"));
  45586. } else {
  45587. node.innerHTML = func(node.getAttribute("value"));
  45588. }
  45589. });
  45590. }
  45591. };
  45592. LocalizedStrings.prototype.processTagTex = function (text) {
  45593. if (text === null) {
  45594. return "<Invalid i18n identifier>";
  45595. }
  45596. var opts = text.split(':');
  45597. var type = opts[0].toLowerCase();
  45598. var id = opts[1];
  45599. if (_StringTypes.StringTypes.ERROR === type) {
  45600. return this.getError(id);
  45601. } else if (_StringTypes.StringTypes.MESSAGE === type) {
  45602. return this.getMessage(id);
  45603. } else if (_StringTypes.StringTypes.UI === type) {
  45604. return this.getUI(id);
  45605. } else {
  45606. console.warn(" A string has been passed to the i18n helper function that was not in the form type:id -> " + text);
  45607. return this.getString(id, type);
  45608. }
  45609. };
  45610. return LocalizedStrings;
  45611. }();
  45612. exports.LocalizedStrings = LocalizedStrings;
  45613. /***/ }),
  45614. /***/ "./node_modules/line-i18n/dist/StringTypes.js":
  45615. /*!****************************************************!*\
  45616. !*** ./node_modules/line-i18n/dist/StringTypes.js ***!
  45617. \****************************************************/
  45618. /*! no static exports found */
  45619. /***/ (function(module, exports, __webpack_require__) {
  45620. "use strict";
  45621. Object.defineProperty(exports, "__esModule", {
  45622. value: true
  45623. });
  45624. var StringTypes = exports.StringTypes = undefined;
  45625. (function (StringTypes) {
  45626. StringTypes["ERROR"] = "error";
  45627. StringTypes["MESSAGE"] = "message";
  45628. StringTypes["UI"] = "ui";
  45629. })(StringTypes || (exports.StringTypes = StringTypes = {}));
  45630. /***/ }),
  45631. /***/ "./node_modules/line-i18n/dist/index.js":
  45632. /*!**********************************************!*\
  45633. !*** ./node_modules/line-i18n/dist/index.js ***!
  45634. \**********************************************/
  45635. /*! no static exports found */
  45636. /***/ (function(module, exports, __webpack_require__) {
  45637. "use strict";
  45638. Object.defineProperty(exports, "__esModule", {
  45639. value: true
  45640. });
  45641. var _LanguageService = __webpack_require__(/*! ./LanguageService */ "./node_modules/line-i18n/dist/LanguageService.js");
  45642. var _LocalizedStrings = __webpack_require__(/*! ./LocalizedStrings */ "./node_modules/line-i18n/dist/LocalizedStrings.js");
  45643. var _StringTypes = __webpack_require__(/*! ./StringTypes */ "./node_modules/line-i18n/dist/StringTypes.js");
  45644. var _LanguageServiceNoLS = __webpack_require__(/*! ./LanguageServiceNoLS */ "./node_modules/line-i18n/dist/LanguageServiceNoLS.js");
  45645. exports.default = {
  45646. LanguageService: _LanguageService.LanguageService,
  45647. LanguageServiceNoLS: _LanguageServiceNoLS.LanguageServiceNoLS,
  45648. LocalizedStrings: _LocalizedStrings.LocalizedStrings,
  45649. StringTypes: _StringTypes.StringTypes
  45650. };
  45651. /***/ }),
  45652. /***/ "./node_modules/melanke-watchjs/src/watch.js":
  45653. /*!***************************************************!*\
  45654. !*** ./node_modules/melanke-watchjs/src/watch.js ***!
  45655. \***************************************************/
  45656. /*! no static exports found */
  45657. /***/ (function(module, exports, __webpack_require__) {
  45658. "use strict";
  45659. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
  45660. * DEVELOPED BY
  45661. * GIL LOPES BUENO
  45662. * gilbueno.mail@gmail.com
  45663. *
  45664. * WORKS WITH:
  45665. * IE8*, IE 9+, FF 4+, SF 5+, WebKit, CH 7+, OP 12+, BESEN, Rhino 1.7+
  45666. * For IE8 (and other legacy browsers) WatchJS will use dirty checking
  45667. *
  45668. * FORK:
  45669. * https://github.com/melanke/Watch.JS
  45670. *
  45671. * LICENSE: MIT
  45672. */
  45673. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  45674. (function (factory) {
  45675. if (( false ? undefined : _typeof(exports)) === 'object') {
  45676. // Node. Does not work with strict CommonJS, but
  45677. // only CommonJS-like enviroments that support module.exports,
  45678. // like Node.
  45679. module.exports = factory();
  45680. } else if (true) {
  45681. // AMD. Register as an anonymous module.
  45682. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  45683. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  45684. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
  45685. __WEBPACK_AMD_DEFINE_FACTORY__),
  45686. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  45687. } else {}
  45688. })(function () {
  45689. var WatchJS = {
  45690. noMore: false, // use WatchJS.suspend(obj) instead
  45691. useDirtyCheck: false, // use only dirty checking to track changes.
  45692. preserveExistingSetters: false
  45693. },
  45694. lengthsubjects = [];
  45695. var dirtyChecklist = [];
  45696. var pendingChanges = []; // used coalesce changes from defineProperty and __defineSetter__
  45697. var supportDefineProperty = false;
  45698. try {
  45699. supportDefineProperty = Object.defineProperty && Object.defineProperty({}, 'x', {});
  45700. } catch (ex) {/* not supported */}
  45701. var isFunction = function isFunction(functionToCheck) {
  45702. var getType = {};
  45703. return functionToCheck && getType.toString.call(functionToCheck) == '[object Function]';
  45704. };
  45705. var isInt = function isInt(x) {
  45706. return x % 1 === 0;
  45707. };
  45708. var isArray = function isArray(obj) {
  45709. return Object.prototype.toString.call(obj) === '[object Array]';
  45710. };
  45711. var isObject = function isObject(obj) {
  45712. return {}.toString.apply(obj) === '[object Object]';
  45713. };
  45714. var getObjDiff = function getObjDiff(a, b) {
  45715. var aplus = [],
  45716. bplus = [];
  45717. if (!(typeof a == "string") && !(typeof b == "string")) {
  45718. if (isArray(a) && b) {
  45719. for (var i = 0; i < a.length; i++) {
  45720. if (b[i] === undefined) aplus.push(i);
  45721. }
  45722. } else {
  45723. for (var i in a) {
  45724. if (a.hasOwnProperty(i)) {
  45725. if (b && !b.hasOwnProperty(i)) {
  45726. aplus.push(i);
  45727. }
  45728. }
  45729. }
  45730. }
  45731. if (isArray(b) && a) {
  45732. for (var j = 0; j < b.length; j++) {
  45733. if (a[j] === undefined) bplus.push(j);
  45734. }
  45735. } else {
  45736. for (var j in b) {
  45737. if (b.hasOwnProperty(j)) {
  45738. if (a && !a.hasOwnProperty(j)) {
  45739. bplus.push(j);
  45740. }
  45741. }
  45742. }
  45743. }
  45744. }
  45745. return {
  45746. added: aplus,
  45747. removed: bplus
  45748. };
  45749. };
  45750. var clone = function clone(obj) {
  45751. if (null == obj || "object" != (typeof obj === 'undefined' ? 'undefined' : _typeof(obj))) {
  45752. return obj;
  45753. }
  45754. var copy = obj.constructor();
  45755. for (var attr in obj) {
  45756. copy[attr] = obj[attr];
  45757. }
  45758. return copy;
  45759. };
  45760. var getExistingSetter = function getExistingSetter(obj, propName) {
  45761. if (WatchJS.preserveExistingSetters) {
  45762. var existing = Object.getOwnPropertyDescriptor(obj, propName);
  45763. return existing.set;
  45764. }
  45765. return undefined;
  45766. };
  45767. var defineGetAndSet = function defineGetAndSet(obj, propName, getter, setter) {
  45768. try {
  45769. var existingSetter = getExistingSetter(obj, propName);
  45770. Object.defineProperty(obj, propName, {
  45771. get: getter,
  45772. set: function set(value) {
  45773. setter.call(this, value, true); // coalesce changes
  45774. if (existingSetter) {
  45775. existingSetter(value);
  45776. }
  45777. },
  45778. enumerable: true,
  45779. configurable: true
  45780. });
  45781. } catch (e1) {
  45782. try {
  45783. Object.prototype.__defineGetter__.call(obj, propName, getter);
  45784. Object.prototype.__defineSetter__.call(obj, propName, function (value) {
  45785. setter.call(this, value, true); // coalesce changes
  45786. });
  45787. } catch (e2) {
  45788. observeDirtyChanges(obj, propName, setter);
  45789. //throw new Error("watchJS error: browser not supported :/")
  45790. }
  45791. }
  45792. };
  45793. var defineProp = function defineProp(obj, propName, value) {
  45794. try {
  45795. Object.defineProperty(obj, propName, {
  45796. enumerable: false,
  45797. configurable: true,
  45798. writable: false,
  45799. value: value
  45800. });
  45801. } catch (error) {
  45802. obj[propName] = value;
  45803. }
  45804. };
  45805. var observeDirtyChanges = function observeDirtyChanges(obj, propName, setter) {
  45806. dirtyChecklist[dirtyChecklist.length] = {
  45807. prop: propName,
  45808. object: obj,
  45809. orig: clone(obj[propName]),
  45810. callback: setter
  45811. };
  45812. };
  45813. var watch = function watch() {
  45814. if (isFunction(arguments[1])) {
  45815. watchAll.apply(this, arguments);
  45816. } else if (isArray(arguments[1])) {
  45817. watchMany.apply(this, arguments);
  45818. } else {
  45819. watchOne.apply(this, arguments);
  45820. }
  45821. };
  45822. var watchAll = function watchAll(obj, watcher, level, addNRemove) {
  45823. if (typeof obj == "string" || !(obj instanceof Object) && !isArray(obj)) {
  45824. //accepts only objects and array (not string)
  45825. return;
  45826. }
  45827. if (isArray(obj)) {
  45828. defineWatcher(obj, "__watchall__", watcher, level); // watch all changes on the array
  45829. if (level === undefined || level > 0) {
  45830. for (var prop = 0; prop < obj.length; prop++) {
  45831. // watch objects in array
  45832. watchAll(obj[prop], watcher, level, addNRemove);
  45833. }
  45834. }
  45835. } else {
  45836. var prop,
  45837. props = [];
  45838. for (prop in obj) {
  45839. //for each attribute if obj is an object
  45840. if (prop == "$val" || !supportDefineProperty && prop === 'watchers') {
  45841. continue;
  45842. }
  45843. if (Object.prototype.hasOwnProperty.call(obj, prop)) {
  45844. props.push(prop); //put in the props
  45845. }
  45846. }
  45847. watchMany(obj, props, watcher, level, addNRemove); //watch all items of the props
  45848. }
  45849. if (addNRemove) {
  45850. pushToLengthSubjects(obj, "$$watchlengthsubjectroot", watcher, level);
  45851. }
  45852. };
  45853. var watchMany = function watchMany(obj, props, watcher, level, addNRemove) {
  45854. if (typeof obj == "string" || !(obj instanceof Object) && !isArray(obj)) {
  45855. //accepts only objects and array (not string)
  45856. return;
  45857. }
  45858. for (var i = 0; i < props.length; i++) {
  45859. //watch each property
  45860. var prop = props[i];
  45861. watchOne(obj, prop, watcher, level, addNRemove);
  45862. }
  45863. };
  45864. var watchOne = function watchOne(obj, prop, watcher, level, addNRemove) {
  45865. if (typeof obj == "string" || !(obj instanceof Object) && !isArray(obj)) {
  45866. //accepts only objects and array (not string)
  45867. return;
  45868. }
  45869. if (isFunction(obj[prop])) {
  45870. //dont watch if it is a function
  45871. return;
  45872. }
  45873. if (obj[prop] != null && (level === undefined || level > 0)) {
  45874. watchAll(obj[prop], watcher, level !== undefined ? level - 1 : level); //recursively watch all attributes of this
  45875. }
  45876. defineWatcher(obj, prop, watcher, level);
  45877. if (addNRemove && (level === undefined || level > 0)) {
  45878. pushToLengthSubjects(obj, prop, watcher, level);
  45879. }
  45880. };
  45881. var unwatch = function unwatch() {
  45882. if (isFunction(arguments[1])) {
  45883. unwatchAll.apply(this, arguments);
  45884. } else if (isArray(arguments[1])) {
  45885. unwatchMany.apply(this, arguments);
  45886. } else {
  45887. unwatchOne.apply(this, arguments);
  45888. }
  45889. };
  45890. var unwatchAll = function unwatchAll(obj, watcher) {
  45891. if (obj instanceof String || !(obj instanceof Object) && !isArray(obj)) {
  45892. //accepts only objects and array (not string)
  45893. return;
  45894. }
  45895. if (isArray(obj)) {
  45896. var props = ['__watchall__'];
  45897. for (var prop = 0; prop < obj.length; prop++) {
  45898. //for each item if obj is an array
  45899. props.push(prop); //put in the props
  45900. }
  45901. unwatchMany(obj, props, watcher); //watch all itens of the props
  45902. } else {
  45903. var unwatchPropsInObject = function unwatchPropsInObject(obj2) {
  45904. var props = [];
  45905. for (var prop2 in obj2) {
  45906. //for each attribute if obj is an object
  45907. if (obj2.hasOwnProperty(prop2)) {
  45908. if (obj2[prop2] instanceof Object) {
  45909. unwatchPropsInObject(obj2[prop2]); //recurs into object props
  45910. } else {
  45911. props.push(prop2); //put in the props
  45912. }
  45913. }
  45914. }
  45915. unwatchMany(obj2, props, watcher); //unwatch all of the props
  45916. };
  45917. unwatchPropsInObject(obj);
  45918. }
  45919. };
  45920. var unwatchMany = function unwatchMany(obj, props, watcher) {
  45921. for (var prop2 in props) {
  45922. //watch each attribute of "props" if is an object
  45923. if (props.hasOwnProperty(prop2)) {
  45924. unwatchOne(obj, props[prop2], watcher);
  45925. }
  45926. }
  45927. };
  45928. var timeouts = [],
  45929. timerID = null;
  45930. function clearTimerID() {
  45931. timerID = null;
  45932. for (var i = 0; i < timeouts.length; i++) {
  45933. timeouts[i]();
  45934. }
  45935. timeouts.length = 0;
  45936. }
  45937. var getTimerID = function getTimerID() {
  45938. if (!timerID) {
  45939. timerID = setTimeout(clearTimerID);
  45940. }
  45941. return timerID;
  45942. };
  45943. var registerTimeout = function registerTimeout(fn) {
  45944. // register function to be called on timeout
  45945. if (timerID == null) getTimerID();
  45946. timeouts[timeouts.length] = fn;
  45947. };
  45948. // Track changes made to an array, object or an object's property
  45949. // and invoke callback with a single change object containing type, value, oldvalue and array splices
  45950. // Syntax:
  45951. // trackChange(obj, callback, recursive, addNRemove)
  45952. // trackChange(obj, prop, callback, recursive, addNRemove)
  45953. var trackChange = function trackChange() {
  45954. var fn = isFunction(arguments[2]) ? trackProperty : trackObject;
  45955. fn.apply(this, arguments);
  45956. };
  45957. // track changes made to an object and invoke callback with a single change object containing type, value and array splices
  45958. var trackObject = function trackObject(obj, callback, recursive, addNRemove) {
  45959. var change = null,
  45960. lastTimerID = -1;
  45961. var isArr = isArray(obj);
  45962. var level,
  45963. fn = function fn(prop, action, newValue, oldValue) {
  45964. var timerID = getTimerID();
  45965. if (lastTimerID !== timerID) {
  45966. // check if timer has changed since last update
  45967. lastTimerID = timerID;
  45968. change = {
  45969. type: 'update'
  45970. };
  45971. change['value'] = obj;
  45972. change['splices'] = null;
  45973. registerTimeout(function () {
  45974. callback.call(this, change);
  45975. change = null;
  45976. });
  45977. }
  45978. // create splices for array changes
  45979. if (isArr && obj === this && change !== null) {
  45980. if (action === 'pop' || action === 'shift') {
  45981. newValue = [];
  45982. oldValue = [oldValue];
  45983. } else if (action === 'push' || action === 'unshift') {
  45984. newValue = [newValue];
  45985. oldValue = [];
  45986. } else if (action !== 'splice') {
  45987. return; // return here - for reverse and sort operations we don't need to return splices. a simple update will do
  45988. }
  45989. if (!change.splices) change.splices = [];
  45990. change.splices[change.splices.length] = {
  45991. index: prop,
  45992. deleteCount: oldValue ? oldValue.length : 0,
  45993. addedCount: newValue ? newValue.length : 0,
  45994. added: newValue,
  45995. deleted: oldValue
  45996. };
  45997. }
  45998. };
  45999. level = recursive == true ? undefined : 0;
  46000. watchAll(obj, fn, level, addNRemove);
  46001. };
  46002. // track changes made to the property of an object and invoke callback with a single change object containing type, value, oldvalue and splices
  46003. var trackProperty = function trackProperty(obj, prop, callback, recursive, addNRemove) {
  46004. if (obj && prop) {
  46005. watchOne(obj, prop, function (prop, action, newvalue, oldvalue) {
  46006. var change = {
  46007. type: 'update'
  46008. };
  46009. change['value'] = newvalue;
  46010. change['oldvalue'] = oldvalue;
  46011. if (recursive && isObject(newvalue) || isArray(newvalue)) {
  46012. trackObject(newvalue, callback, recursive, addNRemove);
  46013. }
  46014. callback.call(this, change);
  46015. }, 0);
  46016. if (recursive && isObject(obj[prop]) || isArray(obj[prop])) {
  46017. trackObject(obj[prop], callback, recursive, addNRemove);
  46018. }
  46019. }
  46020. };
  46021. var defineWatcher = function defineWatcher(obj, prop, watcher, level) {
  46022. var newWatcher = false;
  46023. var isArr = isArray(obj);
  46024. if (!obj.watchers) {
  46025. defineProp(obj, "watchers", {});
  46026. if (isArr) {
  46027. // watch array functions
  46028. watchFunctions(obj, function (index, action, newValue, oldValue) {
  46029. addPendingChange(obj, index, action, newValue, oldValue);
  46030. if (level !== 0 && newValue && (isObject(newValue) || isArray(newValue))) {
  46031. var i,
  46032. n,
  46033. ln,
  46034. wAll,
  46035. watchList = obj.watchers[prop];
  46036. if (wAll = obj.watchers['__watchall__']) {
  46037. watchList = watchList ? watchList.concat(wAll) : wAll;
  46038. }
  46039. ln = watchList ? watchList.length : 0;
  46040. for (i = 0; i < ln; i++) {
  46041. if (action !== 'splice') {
  46042. watchAll(newValue, watchList[i], level === undefined ? level : level - 1);
  46043. } else {
  46044. // watch spliced values
  46045. for (n = 0; n < newValue.length; n++) {
  46046. watchAll(newValue[n], watchList[i], level === undefined ? level : level - 1);
  46047. }
  46048. }
  46049. }
  46050. }
  46051. });
  46052. }
  46053. }
  46054. if (!obj.watchers[prop]) {
  46055. obj.watchers[prop] = [];
  46056. if (!isArr) newWatcher = true;
  46057. }
  46058. for (var i = 0; i < obj.watchers[prop].length; i++) {
  46059. if (obj.watchers[prop][i] === watcher) {
  46060. return;
  46061. }
  46062. }
  46063. obj.watchers[prop].push(watcher); //add the new watcher to the watchers array
  46064. if (newWatcher) {
  46065. var val = obj[prop];
  46066. var getter = function getter() {
  46067. return val;
  46068. };
  46069. var setter = function setter(newval, delayWatcher) {
  46070. var oldval = val;
  46071. val = newval;
  46072. if (level !== 0 && obj[prop] && (isObject(obj[prop]) || isArray(obj[prop])) && !obj[prop].watchers) {
  46073. // watch sub properties
  46074. var i,
  46075. ln = obj.watchers[prop].length;
  46076. for (i = 0; i < ln; i++) {
  46077. watchAll(obj[prop], obj.watchers[prop][i], level === undefined ? level : level - 1);
  46078. }
  46079. }
  46080. //watchFunctions(obj, prop);
  46081. if (isSuspended(obj, prop)) {
  46082. resume(obj, prop);
  46083. return;
  46084. }
  46085. if (!WatchJS.noMore) {
  46086. // this does not work with Object.observe
  46087. //if (JSON.stringify(oldval) !== JSON.stringify(newval)) {
  46088. if (oldval !== newval) {
  46089. if (!delayWatcher) {
  46090. callWatchers(obj, prop, "set", newval, oldval);
  46091. } else {
  46092. addPendingChange(obj, prop, "set", newval, oldval);
  46093. }
  46094. WatchJS.noMore = false;
  46095. }
  46096. }
  46097. };
  46098. if (WatchJS.useDirtyCheck) {
  46099. observeDirtyChanges(obj, prop, setter);
  46100. } else {
  46101. defineGetAndSet(obj, prop, getter, setter);
  46102. }
  46103. }
  46104. };
  46105. var callWatchers = function callWatchers(obj, prop, action, newval, oldval) {
  46106. if (prop !== undefined) {
  46107. var ln,
  46108. wl,
  46109. watchList = obj.watchers[prop];
  46110. if (wl = obj.watchers['__watchall__']) {
  46111. watchList = watchList ? watchList.concat(wl) : wl;
  46112. }
  46113. ln = watchList ? watchList.length : 0;
  46114. for (var wr = 0; wr < ln; wr++) {
  46115. watchList[wr].call(obj, prop, action, newval, oldval);
  46116. }
  46117. } else {
  46118. for (var prop in obj) {
  46119. //call all
  46120. if (obj.hasOwnProperty(prop)) {
  46121. callWatchers(obj, prop, action, newval, oldval);
  46122. }
  46123. }
  46124. }
  46125. };
  46126. var methodNames = ['pop', 'push', 'reverse', 'shift', 'sort', 'slice', 'unshift', 'splice'];
  46127. var defineArrayMethodWatcher = function defineArrayMethodWatcher(obj, original, methodName, callback) {
  46128. defineProp(obj, methodName, function () {
  46129. var index = 0;
  46130. var i, newValue, oldValue, response;
  46131. // get values before splicing array
  46132. if (methodName === 'splice') {
  46133. var start = arguments[0];
  46134. var end = start + arguments[1];
  46135. oldValue = obj.slice(start, end);
  46136. newValue = [];
  46137. for (i = 2; i < arguments.length; i++) {
  46138. newValue[i - 2] = arguments[i];
  46139. }
  46140. index = start;
  46141. } else {
  46142. newValue = arguments.length > 0 ? arguments[0] : undefined;
  46143. }
  46144. response = original.apply(obj, arguments);
  46145. if (methodName !== 'slice') {
  46146. if (methodName === 'pop') {
  46147. oldValue = response;
  46148. index = obj.length;
  46149. } else if (methodName === 'push') {
  46150. index = obj.length - 1;
  46151. } else if (methodName === 'shift') {
  46152. oldValue = response;
  46153. } else if (methodName !== 'unshift' && newValue === undefined) {
  46154. newValue = response;
  46155. }
  46156. callback.call(obj, index, methodName, newValue, oldValue);
  46157. }
  46158. return response;
  46159. });
  46160. };
  46161. var watchFunctions = function watchFunctions(obj, callback) {
  46162. if (!isFunction(callback) || !obj || obj instanceof String || !isArray(obj)) {
  46163. return;
  46164. }
  46165. for (var i = methodNames.length, methodName; i--;) {
  46166. methodName = methodNames[i];
  46167. defineArrayMethodWatcher(obj, obj[methodName], methodName, callback);
  46168. }
  46169. };
  46170. var unwatchOne = function unwatchOne(obj, prop, watcher) {
  46171. if (prop) {
  46172. if (obj.watchers && obj.watchers[prop]) {
  46173. if (watcher === undefined) {
  46174. delete obj.watchers[prop]; // remove all property watchers
  46175. } else {
  46176. for (var i = 0; i < obj.watchers[prop].length; i++) {
  46177. var w = obj.watchers[prop][i];
  46178. if (w == watcher) {
  46179. obj.watchers[prop].splice(i, 1);
  46180. }
  46181. }
  46182. }
  46183. }
  46184. } else {
  46185. delete obj.watchers;
  46186. }
  46187. removeFromLengthSubjects(obj, prop, watcher);
  46188. removeFromDirtyChecklist(obj, prop);
  46189. };
  46190. // suspend watchers until next update cycle
  46191. var suspend = function suspend(obj, prop) {
  46192. if (obj.watchers) {
  46193. var name = '__wjs_suspend__' + (prop !== undefined ? prop : '');
  46194. obj.watchers[name] = true;
  46195. }
  46196. };
  46197. var isSuspended = function isSuspended(obj, prop) {
  46198. return obj.watchers && (obj.watchers['__wjs_suspend__'] || obj.watchers['__wjs_suspend__' + prop]);
  46199. };
  46200. // resumes preivously suspended watchers
  46201. var resume = function resume(obj, prop) {
  46202. registerTimeout(function () {
  46203. delete obj.watchers['__wjs_suspend__'];
  46204. delete obj.watchers['__wjs_suspend__' + prop];
  46205. });
  46206. };
  46207. var pendingTimerID = null;
  46208. var addPendingChange = function addPendingChange(obj, prop, mode, newval, oldval) {
  46209. pendingChanges[pendingChanges.length] = {
  46210. obj: obj,
  46211. prop: prop,
  46212. mode: mode,
  46213. newval: newval,
  46214. oldval: oldval
  46215. };
  46216. if (pendingTimerID === null) {
  46217. pendingTimerID = setTimeout(applyPendingChanges);
  46218. }
  46219. };
  46220. var applyPendingChanges = function applyPendingChanges() {
  46221. // apply pending changes
  46222. var change = null;
  46223. pendingTimerID = null;
  46224. for (var i = 0; i < pendingChanges.length; i++) {
  46225. change = pendingChanges[i];
  46226. callWatchers(change.obj, change.prop, change.mode, change.newval, change.oldval);
  46227. }
  46228. if (change) {
  46229. pendingChanges = [];
  46230. change = null;
  46231. }
  46232. };
  46233. var loop = function loop() {
  46234. // check for new or deleted props
  46235. for (var i = 0; i < lengthsubjects.length; i++) {
  46236. var subj = lengthsubjects[i];
  46237. if (subj.prop === "$$watchlengthsubjectroot") {
  46238. var difference = getObjDiff(subj.obj, subj.actual);
  46239. if (difference.added.length || difference.removed.length) {
  46240. if (difference.added.length) {
  46241. watchMany(subj.obj, difference.added, subj.watcher, subj.level - 1, true);
  46242. }
  46243. subj.watcher.call(subj.obj, "root", "differentattr", difference, subj.actual);
  46244. }
  46245. subj.actual = clone(subj.obj);
  46246. } else {
  46247. var difference = getObjDiff(subj.obj[subj.prop], subj.actual);
  46248. if (difference.added.length || difference.removed.length) {
  46249. if (difference.added.length) {
  46250. for (var j = 0; j < subj.obj.watchers[subj.prop].length; j++) {
  46251. watchMany(subj.obj[subj.prop], difference.added, subj.obj.watchers[subj.prop][j], subj.level - 1, true);
  46252. }
  46253. }
  46254. callWatchers(subj.obj, subj.prop, "differentattr", difference, subj.actual);
  46255. }
  46256. subj.actual = clone(subj.obj[subj.prop]);
  46257. }
  46258. }
  46259. // start dirty check
  46260. var n, value;
  46261. if (dirtyChecklist.length > 0) {
  46262. for (var i = 0; i < dirtyChecklist.length; i++) {
  46263. n = dirtyChecklist[i];
  46264. value = n.object[n.prop];
  46265. if (!compareValues(n.orig, value)) {
  46266. n.orig = clone(value);
  46267. n.callback(value);
  46268. }
  46269. }
  46270. }
  46271. };
  46272. var compareValues = function compareValues(a, b) {
  46273. var i,
  46274. state = true;
  46275. if (a !== b) {
  46276. if (isObject(a)) {
  46277. for (i in a) {
  46278. if (!supportDefineProperty && i === 'watchers') continue;
  46279. if (a[i] !== b[i]) {
  46280. state = false;
  46281. break;
  46282. };
  46283. }
  46284. } else {
  46285. state = false;
  46286. }
  46287. }
  46288. return state;
  46289. };
  46290. var pushToLengthSubjects = function pushToLengthSubjects(obj, prop, watcher, level) {
  46291. var actual;
  46292. if (prop === "$$watchlengthsubjectroot") {
  46293. actual = clone(obj);
  46294. } else {
  46295. actual = clone(obj[prop]);
  46296. }
  46297. lengthsubjects.push({
  46298. obj: obj,
  46299. prop: prop,
  46300. actual: actual,
  46301. watcher: watcher,
  46302. level: level
  46303. });
  46304. };
  46305. var removeFromLengthSubjects = function removeFromLengthSubjects(obj, prop, watcher) {
  46306. for (var i = 0; i < lengthsubjects.length; i++) {
  46307. var subj = lengthsubjects[i];
  46308. if (subj.obj == obj) {
  46309. if (!prop || subj.prop == prop) {
  46310. if (!watcher || subj.watcher == watcher) {
  46311. // if we splice off one item at position i
  46312. // we need to decrement i as the array is one item shorter
  46313. // so when we increment i in the loop statement we
  46314. // will land at the correct index.
  46315. // if it's not decremented, you won't delete all length subjects
  46316. lengthsubjects.splice(i--, 1);
  46317. }
  46318. }
  46319. }
  46320. }
  46321. };
  46322. var removeFromDirtyChecklist = function removeFromDirtyChecklist(obj, prop) {
  46323. var notInUse;
  46324. for (var i = 0; i < dirtyChecklist.length; i++) {
  46325. var n = dirtyChecklist[i];
  46326. var watchers = n.object.watchers;
  46327. notInUse = n.object == obj && (!prop || n.prop == prop) && watchers && (!prop || !watchers[prop] || watchers[prop].length == 0);
  46328. if (notInUse) {
  46329. // we use the same syntax as in removeFromLengthSubjects
  46330. dirtyChecklist.splice(i--, 1);
  46331. }
  46332. }
  46333. };
  46334. setInterval(loop, 50);
  46335. WatchJS.watch = watch;
  46336. WatchJS.unwatch = unwatch;
  46337. WatchJS.callWatchers = callWatchers;
  46338. WatchJS.suspend = suspend; // suspend watchers
  46339. WatchJS.onChange = trackChange; // track changes made to object or it's property and return a single change object
  46340. return WatchJS;
  46341. });
  46342. /***/ }),
  46343. /***/ "./node_modules/node-libs-browser/mock/empty.js":
  46344. /*!******************************************************!*\
  46345. !*** ./node_modules/node-libs-browser/mock/empty.js ***!
  46346. \******************************************************/
  46347. /*! no static exports found */
  46348. /***/ (function(module, exports, __webpack_require__) {
  46349. "use strict";
  46350. /***/ }),
  46351. /***/ "./node_modules/webpack/buildin/module.js":
  46352. /*!***********************************!*\
  46353. !*** (webpack)/buildin/module.js ***!
  46354. \***********************************/
  46355. /*! no static exports found */
  46356. /***/ (function(module, exports, __webpack_require__) {
  46357. "use strict";
  46358. module.exports = function (module) {
  46359. if (!module.webpackPolyfill) {
  46360. module.deprecate = function () {};
  46361. module.paths = [];
  46362. // module.parent = undefined by default
  46363. if (!module.children) module.children = [];
  46364. Object.defineProperty(module, "loaded", {
  46365. enumerable: true,
  46366. get: function get() {
  46367. return module.l;
  46368. }
  46369. });
  46370. Object.defineProperty(module, "id", {
  46371. enumerable: true,
  46372. get: function get() {
  46373. return module.i;
  46374. }
  46375. });
  46376. module.webpackPolyfill = 1;
  46377. }
  46378. return module;
  46379. };
  46380. /***/ })
  46381. /******/ });
  46382. });
  46383. //# sourceMappingURL=ivprog.bundle.js.map